@depup/react-redux 9.3.0-depup.53

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.
Files changed (48) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +32 -0
  3. package/changes.json +14 -0
  4. package/dist/cjs/index.js +6 -0
  5. package/dist/cjs/react-redux.development.cjs +1119 -0
  6. package/dist/cjs/react-redux.development.cjs.map +1 -0
  7. package/dist/cjs/react-redux.production.min.cjs +6 -0
  8. package/dist/cjs/react-redux.production.min.cjs.map +1 -0
  9. package/dist/react-redux.browser.mjs +6 -0
  10. package/dist/react-redux.browser.mjs.map +1 -0
  11. package/dist/react-redux.d.ts +587 -0
  12. package/dist/react-redux.legacy-esm.js +1105 -0
  13. package/dist/react-redux.legacy-esm.js.map +1 -0
  14. package/dist/react-redux.mjs +1071 -0
  15. package/dist/react-redux.mjs.map +1 -0
  16. package/dist/rsc.mjs +46 -0
  17. package/dist/rsc.mjs.map +1 -0
  18. package/package.json +124 -0
  19. package/src/components/Context.ts +50 -0
  20. package/src/components/Provider.tsx +105 -0
  21. package/src/components/connect.tsx +845 -0
  22. package/src/connect/invalidArgFactory.ts +14 -0
  23. package/src/connect/mapDispatchToProps.ts +25 -0
  24. package/src/connect/mapStateToProps.ts +14 -0
  25. package/src/connect/mergeProps.ts +78 -0
  26. package/src/connect/selectorFactory.ts +242 -0
  27. package/src/connect/verifySubselectors.ts +26 -0
  28. package/src/connect/wrapMapToProps.ts +110 -0
  29. package/src/exports.ts +51 -0
  30. package/src/hooks/useDispatch.ts +104 -0
  31. package/src/hooks/useReduxContext.ts +42 -0
  32. package/src/hooks/useSelector.ts +286 -0
  33. package/src/hooks/useStore.ts +123 -0
  34. package/src/index-rsc.ts +35 -0
  35. package/src/index.ts +1 -0
  36. package/src/types.ts +180 -0
  37. package/src/utils/Subscription.ts +183 -0
  38. package/src/utils/batch.ts +4 -0
  39. package/src/utils/bindActionCreators.ts +16 -0
  40. package/src/utils/hoistStatics.ts +139 -0
  41. package/src/utils/isPlainObject.ts +17 -0
  42. package/src/utils/react-is.ts +97 -0
  43. package/src/utils/react.ts +3 -0
  44. package/src/utils/shallowEqual.ts +36 -0
  45. package/src/utils/useIsomorphicLayoutEffect.ts +40 -0
  46. package/src/utils/useSyncExternalStore.ts +9 -0
  47. package/src/utils/verifyPlainObject.ts +14 -0
  48. package/src/utils/warning.ts +21 -0
@@ -0,0 +1,1105 @@
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/utils/react.ts
34
+ import * as React from "react";
35
+
36
+ // src/utils/react-is.ts
37
+ var IS_REACT_19 = /* @__PURE__ */ React.version.startsWith("19");
38
+ var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for(
39
+ IS_REACT_19 ? "react.transitional.element" : "react.element"
40
+ );
41
+ var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
42
+ var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
43
+ var REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode");
44
+ var REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler");
45
+ var REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer");
46
+ var REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context");
47
+ var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
48
+ var REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
49
+ var REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for(
50
+ "react.suspense_list"
51
+ );
52
+ var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
53
+ var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
54
+ var REACT_OFFSCREEN_TYPE = /* @__PURE__ */ Symbol.for("react.offscreen");
55
+ var REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for(
56
+ "react.client.reference"
57
+ );
58
+ var ForwardRef = REACT_FORWARD_REF_TYPE;
59
+ var Memo = REACT_MEMO_TYPE;
60
+ function isValidElementType(type) {
61
+ return typeof type === "string" || typeof type === "function" || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_OFFSCREEN_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || type.getModuleId !== void 0) ? true : false;
62
+ }
63
+ function typeOf(object) {
64
+ if (typeof object === "object" && object !== null) {
65
+ const { $$typeof } = object;
66
+ switch ($$typeof) {
67
+ case REACT_ELEMENT_TYPE:
68
+ switch (object = object.type, object) {
69
+ case REACT_FRAGMENT_TYPE:
70
+ case REACT_PROFILER_TYPE:
71
+ case REACT_STRICT_MODE_TYPE:
72
+ case REACT_SUSPENSE_TYPE:
73
+ case REACT_SUSPENSE_LIST_TYPE:
74
+ return object;
75
+ default:
76
+ switch (object = object && object.$$typeof, object) {
77
+ case REACT_CONTEXT_TYPE:
78
+ case REACT_FORWARD_REF_TYPE:
79
+ case REACT_LAZY_TYPE:
80
+ case REACT_MEMO_TYPE:
81
+ return object;
82
+ case REACT_CONSUMER_TYPE:
83
+ return object;
84
+ default:
85
+ return $$typeof;
86
+ }
87
+ }
88
+ case REACT_PORTAL_TYPE:
89
+ return $$typeof;
90
+ }
91
+ }
92
+ }
93
+ function isContextConsumer(object) {
94
+ return IS_REACT_19 ? typeOf(object) === REACT_CONSUMER_TYPE : typeOf(object) === REACT_CONTEXT_TYPE;
95
+ }
96
+ function isMemo(object) {
97
+ return typeOf(object) === REACT_MEMO_TYPE;
98
+ }
99
+
100
+ // src/utils/warning.ts
101
+ function warning(message) {
102
+ if (typeof console !== "undefined" && typeof console.error === "function") {
103
+ console.error(message);
104
+ }
105
+ try {
106
+ throw new Error(message);
107
+ } catch (e) {
108
+ }
109
+ }
110
+
111
+ // src/connect/verifySubselectors.ts
112
+ function verify(selector, methodName) {
113
+ if (!selector) {
114
+ throw new Error(`Unexpected value for ${methodName} in connect.`);
115
+ } else if (methodName === "mapStateToProps" || methodName === "mapDispatchToProps") {
116
+ if (!Object.prototype.hasOwnProperty.call(selector, "dependsOnOwnProps")) {
117
+ warning(
118
+ `The selector for ${methodName} of connect did not specify a value for dependsOnOwnProps.`
119
+ );
120
+ }
121
+ }
122
+ }
123
+ function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps) {
124
+ verify(mapStateToProps, "mapStateToProps");
125
+ verify(mapDispatchToProps, "mapDispatchToProps");
126
+ verify(mergeProps, "mergeProps");
127
+ }
128
+
129
+ // src/connect/selectorFactory.ts
130
+ function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, {
131
+ areStatesEqual,
132
+ areOwnPropsEqual,
133
+ areStatePropsEqual
134
+ }) {
135
+ let hasRunAtLeastOnce = false;
136
+ let state;
137
+ let ownProps;
138
+ let stateProps;
139
+ let dispatchProps;
140
+ let mergedProps;
141
+ function handleFirstCall(firstState, firstOwnProps) {
142
+ state = firstState;
143
+ ownProps = firstOwnProps;
144
+ stateProps = mapStateToProps(state, ownProps);
145
+ dispatchProps = mapDispatchToProps(dispatch, ownProps);
146
+ mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
147
+ hasRunAtLeastOnce = true;
148
+ return mergedProps;
149
+ }
150
+ function handleNewPropsAndNewState() {
151
+ stateProps = mapStateToProps(state, ownProps);
152
+ if (mapDispatchToProps.dependsOnOwnProps)
153
+ dispatchProps = mapDispatchToProps(dispatch, ownProps);
154
+ mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
155
+ return mergedProps;
156
+ }
157
+ function handleNewProps() {
158
+ if (mapStateToProps.dependsOnOwnProps)
159
+ stateProps = mapStateToProps(state, ownProps);
160
+ if (mapDispatchToProps.dependsOnOwnProps)
161
+ dispatchProps = mapDispatchToProps(dispatch, ownProps);
162
+ mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
163
+ return mergedProps;
164
+ }
165
+ function handleNewState() {
166
+ const nextStateProps = mapStateToProps(state, ownProps);
167
+ const statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
168
+ stateProps = nextStateProps;
169
+ if (statePropsChanged)
170
+ mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
171
+ return mergedProps;
172
+ }
173
+ function handleSubsequentCalls(nextState, nextOwnProps) {
174
+ const propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
175
+ const stateChanged = !areStatesEqual(
176
+ nextState,
177
+ state,
178
+ nextOwnProps,
179
+ ownProps
180
+ );
181
+ state = nextState;
182
+ ownProps = nextOwnProps;
183
+ if (propsChanged && stateChanged) return handleNewPropsAndNewState();
184
+ if (propsChanged) return handleNewProps();
185
+ if (stateChanged) return handleNewState();
186
+ return mergedProps;
187
+ }
188
+ return function pureFinalPropsSelector(nextState, nextOwnProps) {
189
+ return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
190
+ };
191
+ }
192
+ function finalPropsSelectorFactory(dispatch, _a) {
193
+ var _b = _a, {
194
+ initMapStateToProps,
195
+ initMapDispatchToProps,
196
+ initMergeProps
197
+ } = _b, options = __objRest(_b, [
198
+ "initMapStateToProps",
199
+ "initMapDispatchToProps",
200
+ "initMergeProps"
201
+ ]);
202
+ const mapStateToProps = initMapStateToProps(dispatch, options);
203
+ const mapDispatchToProps = initMapDispatchToProps(dispatch, options);
204
+ const mergeProps = initMergeProps(dispatch, options);
205
+ if (process.env.NODE_ENV !== "production") {
206
+ verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps);
207
+ }
208
+ return pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
209
+ }
210
+
211
+ // src/utils/bindActionCreators.ts
212
+ function bindActionCreators(actionCreators, dispatch) {
213
+ const boundActionCreators = {};
214
+ for (const key in actionCreators) {
215
+ const actionCreator = actionCreators[key];
216
+ if (typeof actionCreator === "function") {
217
+ boundActionCreators[key] = (...args) => dispatch(actionCreator(...args));
218
+ }
219
+ }
220
+ return boundActionCreators;
221
+ }
222
+
223
+ // src/utils/isPlainObject.ts
224
+ function isPlainObject(obj) {
225
+ if (typeof obj !== "object" || obj === null) return false;
226
+ const proto = Object.getPrototypeOf(obj);
227
+ if (proto === null) return true;
228
+ let baseProto = proto;
229
+ while (Object.getPrototypeOf(baseProto) !== null) {
230
+ baseProto = Object.getPrototypeOf(baseProto);
231
+ }
232
+ return proto === baseProto;
233
+ }
234
+
235
+ // src/utils/verifyPlainObject.ts
236
+ function verifyPlainObject(value, displayName, methodName) {
237
+ if (!isPlainObject(value)) {
238
+ warning(
239
+ `${methodName}() in ${displayName} must return a plain object. Instead received ${value}.`
240
+ );
241
+ }
242
+ }
243
+
244
+ // src/connect/wrapMapToProps.ts
245
+ function wrapMapToPropsConstant(getConstant) {
246
+ return function initConstantSelector(dispatch) {
247
+ const constant = getConstant(dispatch);
248
+ function constantSelector() {
249
+ return constant;
250
+ }
251
+ constantSelector.dependsOnOwnProps = false;
252
+ return constantSelector;
253
+ };
254
+ }
255
+ function getDependsOnOwnProps(mapToProps) {
256
+ return mapToProps.dependsOnOwnProps ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
257
+ }
258
+ function wrapMapToPropsFunc(mapToProps, methodName) {
259
+ return function initProxySelector(dispatch, { displayName }) {
260
+ const proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
261
+ return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch, void 0);
262
+ };
263
+ proxy.dependsOnOwnProps = true;
264
+ proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
265
+ proxy.mapToProps = mapToProps;
266
+ proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
267
+ let props = proxy(stateOrDispatch, ownProps);
268
+ if (typeof props === "function") {
269
+ proxy.mapToProps = props;
270
+ proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
271
+ props = proxy(stateOrDispatch, ownProps);
272
+ }
273
+ if (process.env.NODE_ENV !== "production")
274
+ verifyPlainObject(props, displayName, methodName);
275
+ return props;
276
+ };
277
+ return proxy;
278
+ };
279
+ }
280
+
281
+ // src/connect/invalidArgFactory.ts
282
+ function createInvalidArgFactory(arg, name) {
283
+ return (dispatch, options) => {
284
+ throw new Error(
285
+ `Invalid value of type ${typeof arg} for ${name} argument when connecting component ${options.wrappedComponentName}.`
286
+ );
287
+ };
288
+ }
289
+
290
+ // src/connect/mapDispatchToProps.ts
291
+ function mapDispatchToPropsFactory(mapDispatchToProps) {
292
+ return mapDispatchToProps && typeof mapDispatchToProps === "object" ? wrapMapToPropsConstant(
293
+ (dispatch) => (
294
+ // @ts-ignore
295
+ bindActionCreators(mapDispatchToProps, dispatch)
296
+ )
297
+ ) : !mapDispatchToProps ? wrapMapToPropsConstant((dispatch) => ({
298
+ dispatch
299
+ })) : typeof mapDispatchToProps === "function" ? (
300
+ // @ts-ignore
301
+ wrapMapToPropsFunc(mapDispatchToProps, "mapDispatchToProps")
302
+ ) : createInvalidArgFactory(mapDispatchToProps, "mapDispatchToProps");
303
+ }
304
+
305
+ // src/connect/mapStateToProps.ts
306
+ function mapStateToPropsFactory(mapStateToProps) {
307
+ return !mapStateToProps ? wrapMapToPropsConstant(() => ({})) : typeof mapStateToProps === "function" ? (
308
+ // @ts-ignore
309
+ wrapMapToPropsFunc(mapStateToProps, "mapStateToProps")
310
+ ) : createInvalidArgFactory(mapStateToProps, "mapStateToProps");
311
+ }
312
+
313
+ // src/connect/mergeProps.ts
314
+ function defaultMergeProps(stateProps, dispatchProps, ownProps) {
315
+ return __spreadValues(__spreadValues(__spreadValues({}, ownProps), stateProps), dispatchProps);
316
+ }
317
+ function wrapMergePropsFunc(mergeProps) {
318
+ return function initMergePropsProxy(dispatch, { displayName, areMergedPropsEqual }) {
319
+ let hasRunOnce = false;
320
+ let mergedProps;
321
+ return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
322
+ const nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
323
+ if (hasRunOnce) {
324
+ if (!areMergedPropsEqual(nextMergedProps, mergedProps))
325
+ mergedProps = nextMergedProps;
326
+ } else {
327
+ hasRunOnce = true;
328
+ mergedProps = nextMergedProps;
329
+ if (process.env.NODE_ENV !== "production")
330
+ verifyPlainObject(mergedProps, displayName, "mergeProps");
331
+ }
332
+ return mergedProps;
333
+ };
334
+ };
335
+ }
336
+ function mergePropsFactory(mergeProps) {
337
+ return !mergeProps ? () => defaultMergeProps : typeof mergeProps === "function" ? wrapMergePropsFunc(mergeProps) : createInvalidArgFactory(mergeProps, "mergeProps");
338
+ }
339
+
340
+ // src/utils/batch.ts
341
+ function defaultNoopBatch(callback) {
342
+ callback();
343
+ }
344
+
345
+ // src/utils/Subscription.ts
346
+ function createListenerCollection() {
347
+ let first = null;
348
+ let last = null;
349
+ return {
350
+ clear() {
351
+ first = null;
352
+ last = null;
353
+ },
354
+ notify() {
355
+ defaultNoopBatch(() => {
356
+ let listener = first;
357
+ while (listener) {
358
+ listener.callback();
359
+ listener = listener.next;
360
+ }
361
+ });
362
+ },
363
+ get() {
364
+ const listeners = [];
365
+ let listener = first;
366
+ while (listener) {
367
+ listeners.push(listener);
368
+ listener = listener.next;
369
+ }
370
+ return listeners;
371
+ },
372
+ subscribe(callback) {
373
+ let isSubscribed = true;
374
+ const listener = last = {
375
+ callback,
376
+ next: null,
377
+ prev: last
378
+ };
379
+ if (listener.prev) {
380
+ listener.prev.next = listener;
381
+ } else {
382
+ first = listener;
383
+ }
384
+ return function unsubscribe() {
385
+ if (!isSubscribed || first === null) return;
386
+ isSubscribed = false;
387
+ if (listener.next) {
388
+ listener.next.prev = listener.prev;
389
+ } else {
390
+ last = listener.prev;
391
+ }
392
+ if (listener.prev) {
393
+ listener.prev.next = listener.next;
394
+ } else {
395
+ first = listener.next;
396
+ }
397
+ };
398
+ }
399
+ };
400
+ }
401
+ var nullListeners = {
402
+ notify() {
403
+ },
404
+ get: () => []
405
+ };
406
+ function createSubscription(store, parentSub) {
407
+ let unsubscribe;
408
+ let listeners = nullListeners;
409
+ let subscriptionsAmount = 0;
410
+ let selfSubscribed = false;
411
+ function addNestedSub(listener) {
412
+ trySubscribe();
413
+ const cleanupListener = listeners.subscribe(listener);
414
+ let removed = false;
415
+ return () => {
416
+ if (!removed) {
417
+ removed = true;
418
+ cleanupListener();
419
+ tryUnsubscribe();
420
+ }
421
+ };
422
+ }
423
+ function notifyNestedSubs() {
424
+ listeners.notify();
425
+ }
426
+ function handleChangeWrapper() {
427
+ if (subscription.onStateChange) {
428
+ subscription.onStateChange();
429
+ }
430
+ }
431
+ function isSubscribed() {
432
+ return selfSubscribed;
433
+ }
434
+ function trySubscribe() {
435
+ subscriptionsAmount++;
436
+ if (!unsubscribe) {
437
+ unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
438
+ listeners = createListenerCollection();
439
+ }
440
+ }
441
+ function tryUnsubscribe() {
442
+ subscriptionsAmount--;
443
+ if (unsubscribe && subscriptionsAmount === 0) {
444
+ unsubscribe();
445
+ unsubscribe = void 0;
446
+ listeners.clear();
447
+ listeners = nullListeners;
448
+ }
449
+ }
450
+ function trySubscribeSelf() {
451
+ if (!selfSubscribed) {
452
+ selfSubscribed = true;
453
+ trySubscribe();
454
+ }
455
+ }
456
+ function tryUnsubscribeSelf() {
457
+ if (selfSubscribed) {
458
+ selfSubscribed = false;
459
+ tryUnsubscribe();
460
+ }
461
+ }
462
+ const subscription = {
463
+ addNestedSub,
464
+ notifyNestedSubs,
465
+ handleChangeWrapper,
466
+ isSubscribed,
467
+ trySubscribe: trySubscribeSelf,
468
+ tryUnsubscribe: tryUnsubscribeSelf,
469
+ getListeners: () => listeners
470
+ };
471
+ return subscription;
472
+ }
473
+
474
+ // src/utils/useIsomorphicLayoutEffect.ts
475
+ var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
476
+ var isDOM = /* @__PURE__ */ canUseDOM();
477
+ var isRunningInReactNative = () => typeof navigator !== "undefined" && navigator.product === "ReactNative";
478
+ var isReactNative = /* @__PURE__ */ isRunningInReactNative();
479
+ var getUseIsomorphicLayoutEffect = () => isDOM || isReactNative ? React.useLayoutEffect : React.useEffect;
480
+ var useIsomorphicLayoutEffect = /* @__PURE__ */ getUseIsomorphicLayoutEffect();
481
+
482
+ // src/utils/shallowEqual.ts
483
+ function is(x, y) {
484
+ if (x === y) {
485
+ return x !== 0 || y !== 0 || 1 / x === 1 / y;
486
+ } else {
487
+ return x !== x && y !== y;
488
+ }
489
+ }
490
+ function shallowEqual(objA, objB) {
491
+ if (is(objA, objB)) return true;
492
+ if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
493
+ return false;
494
+ }
495
+ const keysA = Object.keys(objA);
496
+ const keysB = Object.keys(objB);
497
+ if (keysA.length !== keysB.length) return false;
498
+ for (let i = 0; i < keysA.length; i++) {
499
+ if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
500
+ return false;
501
+ }
502
+ }
503
+ return true;
504
+ }
505
+
506
+ // src/utils/hoistStatics.ts
507
+ var REACT_STATICS = {
508
+ childContextTypes: true,
509
+ contextType: true,
510
+ contextTypes: true,
511
+ defaultProps: true,
512
+ displayName: true,
513
+ getDefaultProps: true,
514
+ getDerivedStateFromError: true,
515
+ getDerivedStateFromProps: true,
516
+ mixins: true,
517
+ propTypes: true,
518
+ type: true
519
+ };
520
+ var KNOWN_STATICS = {
521
+ name: true,
522
+ length: true,
523
+ prototype: true,
524
+ caller: true,
525
+ callee: true,
526
+ arguments: true,
527
+ arity: true
528
+ };
529
+ var FORWARD_REF_STATICS = {
530
+ $$typeof: true,
531
+ render: true,
532
+ defaultProps: true,
533
+ displayName: true,
534
+ propTypes: true
535
+ };
536
+ var MEMO_STATICS = {
537
+ $$typeof: true,
538
+ compare: true,
539
+ defaultProps: true,
540
+ displayName: true,
541
+ propTypes: true,
542
+ type: true
543
+ };
544
+ var TYPE_STATICS = {
545
+ [ForwardRef]: FORWARD_REF_STATICS,
546
+ [Memo]: MEMO_STATICS
547
+ };
548
+ function getStatics(component) {
549
+ if (isMemo(component)) {
550
+ return MEMO_STATICS;
551
+ }
552
+ return TYPE_STATICS[component["$$typeof"]] || REACT_STATICS;
553
+ }
554
+ var defineProperty = Object.defineProperty;
555
+ var getOwnPropertyNames = Object.getOwnPropertyNames;
556
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
557
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
558
+ var getPrototypeOf = Object.getPrototypeOf;
559
+ var objectPrototype = Object.prototype;
560
+ function hoistNonReactStatics(targetComponent, sourceComponent) {
561
+ if (typeof sourceComponent !== "string") {
562
+ if (objectPrototype) {
563
+ const inheritedComponent = getPrototypeOf(sourceComponent);
564
+ if (inheritedComponent && inheritedComponent !== objectPrototype) {
565
+ hoistNonReactStatics(targetComponent, inheritedComponent);
566
+ }
567
+ }
568
+ let keys = getOwnPropertyNames(sourceComponent);
569
+ if (getOwnPropertySymbols) {
570
+ keys = keys.concat(getOwnPropertySymbols(sourceComponent));
571
+ }
572
+ const targetStatics = getStatics(targetComponent);
573
+ const sourceStatics = getStatics(sourceComponent);
574
+ for (let i = 0; i < keys.length; ++i) {
575
+ const key = keys[i];
576
+ if (!KNOWN_STATICS[key] && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
577
+ const descriptor = getOwnPropertyDescriptor(sourceComponent, key);
578
+ try {
579
+ defineProperty(targetComponent, key, descriptor);
580
+ } catch (e) {
581
+ }
582
+ }
583
+ }
584
+ }
585
+ return targetComponent;
586
+ }
587
+
588
+ // src/components/Context.ts
589
+ var ContextKey = /* @__PURE__ */ Symbol.for(`react-redux-context`);
590
+ var gT = typeof globalThis !== "undefined" ? globalThis : (
591
+ /* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
592
+ {}
593
+ );
594
+ function getContext() {
595
+ var _a;
596
+ if (!React.createContext) return {};
597
+ const contextMap = (_a = gT[ContextKey]) != null ? _a : gT[ContextKey] = /* @__PURE__ */ new Map();
598
+ let realContext = contextMap.get(React.createContext);
599
+ if (!realContext) {
600
+ realContext = React.createContext(
601
+ null
602
+ );
603
+ if (process.env.NODE_ENV !== "production") {
604
+ realContext.displayName = "ReactRedux";
605
+ }
606
+ contextMap.set(React.createContext, realContext);
607
+ }
608
+ return realContext;
609
+ }
610
+ var ReactReduxContext = /* @__PURE__ */ getContext();
611
+
612
+ // src/components/connect.tsx
613
+ var NO_SUBSCRIPTION_ARRAY = [null, null];
614
+ var stringifyComponent = (Comp) => {
615
+ try {
616
+ return JSON.stringify(Comp);
617
+ } catch (err) {
618
+ return String(Comp);
619
+ }
620
+ };
621
+ function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
622
+ useIsomorphicLayoutEffect(() => effectFunc(...effectArgs), dependencies);
623
+ }
624
+ function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, childPropsFromStoreUpdate, notifyNestedSubs) {
625
+ lastWrapperProps.current = wrapperProps;
626
+ renderIsScheduled.current = false;
627
+ if (childPropsFromStoreUpdate.current) {
628
+ childPropsFromStoreUpdate.current = null;
629
+ notifyNestedSubs();
630
+ }
631
+ }
632
+ function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, isMounted, childPropsFromStoreUpdate, notifyNestedSubs, additionalSubscribeListener) {
633
+ if (!shouldHandleStateChanges) return () => {
634
+ };
635
+ let didUnsubscribe = false;
636
+ let lastThrownError = null;
637
+ const checkForUpdates = () => {
638
+ if (didUnsubscribe || !isMounted.current) {
639
+ return;
640
+ }
641
+ const latestStoreState = store.getState();
642
+ let newChildProps, error;
643
+ try {
644
+ newChildProps = childPropsSelector(
645
+ latestStoreState,
646
+ lastWrapperProps.current
647
+ );
648
+ } catch (e) {
649
+ error = e;
650
+ lastThrownError = e;
651
+ }
652
+ if (!error) {
653
+ lastThrownError = null;
654
+ }
655
+ if (newChildProps === lastChildProps.current) {
656
+ if (!renderIsScheduled.current) {
657
+ notifyNestedSubs();
658
+ }
659
+ } else {
660
+ lastChildProps.current = newChildProps;
661
+ childPropsFromStoreUpdate.current = newChildProps;
662
+ renderIsScheduled.current = true;
663
+ additionalSubscribeListener();
664
+ }
665
+ };
666
+ subscription.onStateChange = checkForUpdates;
667
+ subscription.trySubscribe();
668
+ checkForUpdates();
669
+ const unsubscribeWrapper = () => {
670
+ didUnsubscribe = true;
671
+ subscription.tryUnsubscribe();
672
+ subscription.onStateChange = null;
673
+ if (lastThrownError) {
674
+ throw lastThrownError;
675
+ }
676
+ };
677
+ return unsubscribeWrapper;
678
+ }
679
+ function strictEqual(a, b) {
680
+ return a === b;
681
+ }
682
+ var hasWarnedAboutDeprecatedPureOption = false;
683
+ function _connect(mapStateToProps, mapDispatchToProps, mergeProps, {
684
+ // The `pure` option has been removed, so TS doesn't like us destructuring this to check its existence.
685
+ // @ts-ignore
686
+ pure,
687
+ areStatesEqual = strictEqual,
688
+ areOwnPropsEqual = shallowEqual,
689
+ areStatePropsEqual = shallowEqual,
690
+ areMergedPropsEqual = shallowEqual,
691
+ // use React's forwardRef to expose a ref of the wrapped component
692
+ forwardRef = false,
693
+ // the context consumer to use
694
+ context = ReactReduxContext
695
+ } = {}) {
696
+ if (process.env.NODE_ENV !== "production") {
697
+ if (pure !== void 0 && !hasWarnedAboutDeprecatedPureOption) {
698
+ hasWarnedAboutDeprecatedPureOption = true;
699
+ warning(
700
+ 'The `pure` option has been removed. `connect` is now always a "pure/memoized" component'
701
+ );
702
+ }
703
+ }
704
+ const Context = context;
705
+ const initMapStateToProps = mapStateToPropsFactory(mapStateToProps);
706
+ const initMapDispatchToProps = mapDispatchToPropsFactory(mapDispatchToProps);
707
+ const initMergeProps = mergePropsFactory(mergeProps);
708
+ const shouldHandleStateChanges = Boolean(mapStateToProps);
709
+ const wrapWithConnect = (WrappedComponent) => {
710
+ if (process.env.NODE_ENV !== "production") {
711
+ const isValid = /* @__PURE__ */ isValidElementType(WrappedComponent);
712
+ if (!isValid)
713
+ throw new Error(
714
+ `You must pass a component to the function returned by connect. Instead received ${stringifyComponent(
715
+ WrappedComponent
716
+ )}`
717
+ );
718
+ }
719
+ const wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
720
+ const displayName = `Connect(${wrappedComponentName})`;
721
+ const selectorFactoryOptions = {
722
+ shouldHandleStateChanges,
723
+ displayName,
724
+ wrappedComponentName,
725
+ WrappedComponent,
726
+ // @ts-ignore
727
+ initMapStateToProps,
728
+ initMapDispatchToProps,
729
+ initMergeProps,
730
+ areStatesEqual,
731
+ areStatePropsEqual,
732
+ areOwnPropsEqual,
733
+ areMergedPropsEqual
734
+ };
735
+ function ConnectFunction(props) {
736
+ const [propsContext, reactReduxForwardedRef, wrapperProps] = React.useMemo(() => {
737
+ const _a = props, { reactReduxForwardedRef: reactReduxForwardedRef2 } = _a, wrapperProps2 = __objRest(_a, ["reactReduxForwardedRef"]);
738
+ return [props.context, reactReduxForwardedRef2, wrapperProps2];
739
+ }, [props]);
740
+ const ContextToUse = React.useMemo(() => {
741
+ let ResultContext = Context;
742
+ if (propsContext == null ? void 0 : propsContext.Consumer) {
743
+ if (process.env.NODE_ENV !== "production") {
744
+ const isValid = /* @__PURE__ */ isContextConsumer(
745
+ // @ts-ignore
746
+ /* @__PURE__ */ React.createElement(propsContext.Consumer, null)
747
+ );
748
+ if (!isValid) {
749
+ throw new Error(
750
+ "You must pass a valid React context consumer as `props.context`"
751
+ );
752
+ }
753
+ ResultContext = propsContext;
754
+ }
755
+ }
756
+ return ResultContext;
757
+ }, [propsContext, Context]);
758
+ const contextValue = React.useContext(ContextToUse);
759
+ const didStoreComeFromProps = Boolean(props.store) && Boolean(props.store.getState) && Boolean(props.store.dispatch);
760
+ const didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store);
761
+ if (process.env.NODE_ENV !== "production" && !didStoreComeFromProps && !didStoreComeFromContext) {
762
+ throw new Error(
763
+ `Could not find "store" in the context of "${displayName}". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to ${displayName} in connect options.`
764
+ );
765
+ }
766
+ const store = didStoreComeFromProps ? props.store : contextValue.store;
767
+ const getServerState = didStoreComeFromContext ? contextValue.getServerState : store.getState;
768
+ const childPropsSelector = React.useMemo(() => {
769
+ return finalPropsSelectorFactory(store.dispatch, selectorFactoryOptions);
770
+ }, [store]);
771
+ const [subscription, notifyNestedSubs] = React.useMemo(() => {
772
+ if (!shouldHandleStateChanges) return NO_SUBSCRIPTION_ARRAY;
773
+ const subscription2 = createSubscription(
774
+ store,
775
+ didStoreComeFromProps ? void 0 : contextValue.subscription
776
+ );
777
+ const notifyNestedSubs2 = subscription2.notifyNestedSubs.bind(subscription2);
778
+ return [subscription2, notifyNestedSubs2];
779
+ }, [store, didStoreComeFromProps, contextValue]);
780
+ const overriddenContextValue = React.useMemo(() => {
781
+ if (didStoreComeFromProps) {
782
+ return contextValue;
783
+ }
784
+ return __spreadProps(__spreadValues({}, contextValue), {
785
+ subscription
786
+ });
787
+ }, [didStoreComeFromProps, contextValue, subscription]);
788
+ const lastChildProps = React.useRef(void 0);
789
+ const lastWrapperProps = React.useRef(wrapperProps);
790
+ const childPropsFromStoreUpdate = React.useRef(void 0);
791
+ const renderIsScheduled = React.useRef(false);
792
+ const isMounted = React.useRef(false);
793
+ const latestSubscriptionCallbackError = React.useRef(
794
+ void 0
795
+ );
796
+ useIsomorphicLayoutEffect(() => {
797
+ isMounted.current = true;
798
+ return () => {
799
+ isMounted.current = false;
800
+ };
801
+ }, []);
802
+ const actualChildPropsSelector = React.useMemo(() => {
803
+ const selector = () => {
804
+ if (childPropsFromStoreUpdate.current && wrapperProps === lastWrapperProps.current) {
805
+ return childPropsFromStoreUpdate.current;
806
+ }
807
+ return childPropsSelector(store.getState(), wrapperProps);
808
+ };
809
+ return selector;
810
+ }, [store, wrapperProps]);
811
+ const subscribeForReact = React.useMemo(() => {
812
+ const subscribe = (reactListener) => {
813
+ if (!subscription) {
814
+ return () => {
815
+ };
816
+ }
817
+ return subscribeUpdates(
818
+ shouldHandleStateChanges,
819
+ store,
820
+ subscription,
821
+ // @ts-ignore
822
+ childPropsSelector,
823
+ lastWrapperProps,
824
+ lastChildProps,
825
+ renderIsScheduled,
826
+ isMounted,
827
+ childPropsFromStoreUpdate,
828
+ notifyNestedSubs,
829
+ reactListener
830
+ );
831
+ };
832
+ return subscribe;
833
+ }, [subscription]);
834
+ useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [
835
+ lastWrapperProps,
836
+ lastChildProps,
837
+ renderIsScheduled,
838
+ wrapperProps,
839
+ childPropsFromStoreUpdate,
840
+ notifyNestedSubs
841
+ ]);
842
+ let actualChildProps;
843
+ try {
844
+ actualChildProps = React.useSyncExternalStore(
845
+ // TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
846
+ subscribeForReact,
847
+ // TODO This is incredibly hacky. We've already processed the store update and calculated new child props,
848
+ // TODO and we're just passing that through so it triggers a re-render for us rather than relying on `uSES`.
849
+ actualChildPropsSelector,
850
+ getServerState ? () => childPropsSelector(getServerState(), wrapperProps) : actualChildPropsSelector
851
+ );
852
+ } catch (err) {
853
+ if (latestSubscriptionCallbackError.current) {
854
+ ;
855
+ err.message += `
856
+ The error may be correlated with this previous error:
857
+ ${latestSubscriptionCallbackError.current.stack}
858
+
859
+ `;
860
+ }
861
+ throw err;
862
+ }
863
+ useIsomorphicLayoutEffect(() => {
864
+ latestSubscriptionCallbackError.current = void 0;
865
+ childPropsFromStoreUpdate.current = void 0;
866
+ lastChildProps.current = actualChildProps;
867
+ });
868
+ const renderedWrappedComponent = React.useMemo(() => {
869
+ return (
870
+ // @ts-ignore
871
+ /* @__PURE__ */ React.createElement(
872
+ WrappedComponent,
873
+ __spreadProps(__spreadValues({}, actualChildProps), {
874
+ ref: reactReduxForwardedRef
875
+ })
876
+ )
877
+ );
878
+ }, [reactReduxForwardedRef, WrappedComponent, actualChildProps]);
879
+ const renderedChild = React.useMemo(() => {
880
+ if (shouldHandleStateChanges) {
881
+ return /* @__PURE__ */ React.createElement(ContextToUse.Provider, { value: overriddenContextValue }, renderedWrappedComponent);
882
+ }
883
+ return renderedWrappedComponent;
884
+ }, [ContextToUse, renderedWrappedComponent, overriddenContextValue]);
885
+ return renderedChild;
886
+ }
887
+ const _Connect = React.memo(ConnectFunction);
888
+ const Connect = _Connect;
889
+ Connect.WrappedComponent = WrappedComponent;
890
+ Connect.displayName = ConnectFunction.displayName = displayName;
891
+ if (forwardRef) {
892
+ const _forwarded = React.forwardRef(
893
+ function forwardConnectRef(props, ref) {
894
+ return /* @__PURE__ */ React.createElement(Connect, __spreadProps(__spreadValues({}, props), { reactReduxForwardedRef: ref }));
895
+ }
896
+ );
897
+ const forwarded = _forwarded;
898
+ forwarded.displayName = displayName;
899
+ forwarded.WrappedComponent = WrappedComponent;
900
+ return /* @__PURE__ */ hoistNonReactStatics(forwarded, WrappedComponent);
901
+ }
902
+ return /* @__PURE__ */ hoistNonReactStatics(Connect, WrappedComponent);
903
+ };
904
+ return wrapWithConnect;
905
+ }
906
+ var connect = _connect;
907
+ var legacy_connect = _connect;
908
+
909
+ // src/components/Provider.tsx
910
+ function Provider(providerProps) {
911
+ const { children, context, serverState, store } = providerProps;
912
+ const contextValue = React.useMemo(() => {
913
+ const subscription = createSubscription(store);
914
+ const baseContextValue = {
915
+ store,
916
+ subscription,
917
+ getServerState: serverState ? () => serverState : void 0
918
+ };
919
+ if (process.env.NODE_ENV === "production") {
920
+ return baseContextValue;
921
+ } else {
922
+ const { identityFunctionCheck = "once", stabilityCheck = "once" } = providerProps;
923
+ return /* @__PURE__ */ Object.assign(baseContextValue, {
924
+ stabilityCheck,
925
+ identityFunctionCheck
926
+ });
927
+ }
928
+ }, [store, serverState]);
929
+ const previousState = React.useMemo(() => store.getState(), [store]);
930
+ useIsomorphicLayoutEffect(() => {
931
+ const { subscription } = contextValue;
932
+ subscription.onStateChange = subscription.notifyNestedSubs;
933
+ subscription.trySubscribe();
934
+ if (previousState !== store.getState()) {
935
+ subscription.notifyNestedSubs();
936
+ }
937
+ return () => {
938
+ subscription.tryUnsubscribe();
939
+ subscription.onStateChange = void 0;
940
+ };
941
+ }, [contextValue, previousState]);
942
+ const Context = context || ReactReduxContext;
943
+ return /* @__PURE__ */ React.createElement(Context.Provider, { value: contextValue }, children);
944
+ }
945
+ var Provider_default = Provider;
946
+
947
+ // src/hooks/useReduxContext.ts
948
+ function createReduxContextHook(context = ReactReduxContext) {
949
+ return function useReduxContext2() {
950
+ const contextValue = React.useContext(context);
951
+ if (process.env.NODE_ENV !== "production" && !contextValue) {
952
+ throw new Error(
953
+ "could not find react-redux context value; please ensure the component is wrapped in a <Provider>"
954
+ );
955
+ }
956
+ return contextValue;
957
+ };
958
+ }
959
+ var useReduxContext = /* @__PURE__ */ createReduxContextHook();
960
+
961
+ // src/hooks/useStore.ts
962
+ function createStoreHook(context = ReactReduxContext) {
963
+ const useReduxContext2 = context === ReactReduxContext ? useReduxContext : (
964
+ // @ts-ignore
965
+ createReduxContextHook(context)
966
+ );
967
+ const useStore2 = () => {
968
+ const { store } = useReduxContext2();
969
+ return store;
970
+ };
971
+ Object.assign(useStore2, {
972
+ withTypes: () => useStore2
973
+ });
974
+ return useStore2;
975
+ }
976
+ var useStore = /* @__PURE__ */ createStoreHook();
977
+
978
+ // src/hooks/useDispatch.ts
979
+ function createDispatchHook(context = ReactReduxContext) {
980
+ const useStore2 = context === ReactReduxContext ? useStore : createStoreHook(context);
981
+ const useDispatch2 = () => {
982
+ const store = useStore2();
983
+ return store.dispatch;
984
+ };
985
+ Object.assign(useDispatch2, {
986
+ withTypes: () => useDispatch2
987
+ });
988
+ return useDispatch2;
989
+ }
990
+ var useDispatch = /* @__PURE__ */ createDispatchHook();
991
+
992
+ // src/hooks/useSelector.ts
993
+ import { useSyncExternalStoreWithSelector } from "use-sync-external-store/with-selector.js";
994
+ var refEquality = (a, b) => a === b;
995
+ function createSelectorHook(context = ReactReduxContext) {
996
+ const useReduxContext2 = context === ReactReduxContext ? useReduxContext : createReduxContextHook(context);
997
+ const useSelector2 = (selector, equalityFnOrOptions = {}) => {
998
+ const { equalityFn = refEquality } = typeof equalityFnOrOptions === "function" ? { equalityFn: equalityFnOrOptions } : equalityFnOrOptions;
999
+ if (process.env.NODE_ENV !== "production") {
1000
+ if (!selector) {
1001
+ throw new Error(`You must pass a selector to useSelector`);
1002
+ }
1003
+ if (typeof selector !== "function") {
1004
+ throw new Error(`You must pass a function as a selector to useSelector`);
1005
+ }
1006
+ if (typeof equalityFn !== "function") {
1007
+ throw new Error(
1008
+ `You must pass a function as an equality function to useSelector`
1009
+ );
1010
+ }
1011
+ }
1012
+ const reduxContext = useReduxContext2();
1013
+ const { store, subscription, getServerState } = reduxContext;
1014
+ const firstRun = React.useRef(true);
1015
+ const wrappedSelector = React.useCallback(
1016
+ {
1017
+ [selector.name](state) {
1018
+ const selected = selector(state);
1019
+ if (process.env.NODE_ENV !== "production") {
1020
+ const { devModeChecks = {} } = typeof equalityFnOrOptions === "function" ? {} : equalityFnOrOptions;
1021
+ const { identityFunctionCheck, stabilityCheck } = reduxContext;
1022
+ const {
1023
+ identityFunctionCheck: finalIdentityFunctionCheck,
1024
+ stabilityCheck: finalStabilityCheck
1025
+ } = __spreadValues({
1026
+ stabilityCheck,
1027
+ identityFunctionCheck
1028
+ }, devModeChecks);
1029
+ if (finalStabilityCheck === "always" || finalStabilityCheck === "once" && firstRun.current) {
1030
+ const toCompare = selector(state);
1031
+ if (!equalityFn(selected, toCompare)) {
1032
+ let stack = void 0;
1033
+ try {
1034
+ throw new Error();
1035
+ } catch (e) {
1036
+ ;
1037
+ ({ stack } = e);
1038
+ }
1039
+ console.warn(
1040
+ "Selector " + (selector.name || "unknown") + " returned a different result when called with the same parameters. This can lead to unnecessary rerenders.\nSelectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization",
1041
+ {
1042
+ state,
1043
+ selected,
1044
+ selected2: toCompare,
1045
+ stack
1046
+ }
1047
+ );
1048
+ }
1049
+ }
1050
+ if (finalIdentityFunctionCheck === "always" || finalIdentityFunctionCheck === "once" && firstRun.current) {
1051
+ if (selected === state) {
1052
+ let stack = void 0;
1053
+ try {
1054
+ throw new Error();
1055
+ } catch (e) {
1056
+ ;
1057
+ ({ stack } = e);
1058
+ }
1059
+ console.warn(
1060
+ "Selector " + (selector.name || "unknown") + " returned the root state when called. This can lead to unnecessary rerenders.\nSelectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.",
1061
+ { stack }
1062
+ );
1063
+ }
1064
+ }
1065
+ if (firstRun.current) firstRun.current = false;
1066
+ }
1067
+ return selected;
1068
+ }
1069
+ }[selector.name],
1070
+ [selector]
1071
+ );
1072
+ const selectedState = useSyncExternalStoreWithSelector(
1073
+ subscription.addNestedSub,
1074
+ store.getState,
1075
+ getServerState || store.getState,
1076
+ wrappedSelector,
1077
+ equalityFn
1078
+ );
1079
+ React.useDebugValue(selectedState);
1080
+ return selectedState;
1081
+ };
1082
+ Object.assign(useSelector2, {
1083
+ withTypes: () => useSelector2
1084
+ });
1085
+ return useSelector2;
1086
+ }
1087
+ var useSelector = /* @__PURE__ */ createSelectorHook();
1088
+
1089
+ // src/exports.ts
1090
+ var batch = defaultNoopBatch;
1091
+ export {
1092
+ Provider_default as Provider,
1093
+ ReactReduxContext,
1094
+ batch,
1095
+ connect,
1096
+ createDispatchHook,
1097
+ createSelectorHook,
1098
+ createStoreHook,
1099
+ legacy_connect,
1100
+ shallowEqual,
1101
+ useDispatch,
1102
+ useSelector,
1103
+ useStore
1104
+ };
1105
+ //# sourceMappingURL=react-redux.legacy-esm.js.map