@me1a/ui 1.2.3 → 1.2.5
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/dist/components/components/iconify/iconify.d.ts +7 -0
- package/dist/components/components/iconify/index.d.ts +2 -0
- package/dist/components/components/iconify/types.d.ts +2 -0
- package/dist/components/components/index.d.ts +2 -0
- package/dist/components/components/snackbar/index.d.ts +2 -0
- package/dist/components/components/snackbar/snackbar-provider.d.ts +5 -0
- package/dist/components/components/snackbar/styles.d.ts +6 -0
- package/dist/components/hooks/index.d.ts +1 -0
- package/dist/components/hooks/use-boolean.d.ts +9 -0
- package/dist/components/iconify/iconify.d.ts +7 -0
- package/dist/components/iconify/index.d.ts +2 -0
- package/dist/components/iconify/types.d.ts +2 -0
- package/dist/components/index.cjs.js +12760 -0
- package/dist/components/index.cjs.js.map +1 -0
- package/dist/{mui → components}/index.d.ts +1 -1
- package/dist/components/index.es.js +12736 -0
- package/dist/components/index.es.js.map +1 -0
- package/dist/components/redux/index.d.ts +1 -0
- package/dist/components/snackbar/index.d.ts +2 -0
- package/dist/components/snackbar/snackbar-provider.d.ts +5 -0
- package/dist/components/snackbar/styles.d.ts +6 -0
- package/dist/hook-forms/components/iconify/iconify.d.ts +7 -0
- package/dist/hook-forms/components/iconify/index.d.ts +2 -0
- package/dist/hook-forms/components/iconify/types.d.ts +2 -0
- package/dist/hook-forms/components/index.d.ts +2 -0
- package/dist/hook-forms/components/snackbar/index.d.ts +2 -0
- package/dist/hook-forms/components/snackbar/snackbar-provider.d.ts +5 -0
- package/dist/hook-forms/components/snackbar/styles.d.ts +6 -0
- package/dist/hook-forms/hooks/index.d.ts +1 -0
- package/dist/hook-forms/hooks/use-boolean.d.ts +9 -0
- package/dist/hook-forms/index.cjs.js +155 -2361
- package/dist/hook-forms/index.cjs.js.map +1 -1
- package/dist/hook-forms/index.d.ts +1 -1
- package/dist/hook-forms/index.es.js +151 -2357
- package/dist/hook-forms/index.es.js.map +1 -1
- package/dist/hook-forms/redux/index.d.ts +1 -0
- package/dist/hooks/components/iconify/iconify.d.ts +7 -0
- package/dist/hooks/components/iconify/index.d.ts +2 -0
- package/dist/hooks/components/iconify/types.d.ts +2 -0
- package/dist/hooks/components/index.d.ts +2 -0
- package/dist/hooks/components/snackbar/index.d.ts +2 -0
- package/dist/hooks/components/snackbar/snackbar-provider.d.ts +5 -0
- package/dist/hooks/components/snackbar/styles.d.ts +6 -0
- package/dist/hooks/hooks/index.d.ts +1 -0
- package/dist/hooks/hooks/use-boolean.d.ts +9 -0
- package/dist/hooks/index.cjs.js +27 -0
- package/dist/hooks/index.cjs.js.map +1 -0
- package/dist/{example → hooks}/index.d.ts +1 -1
- package/dist/hooks/index.es.js +25 -0
- package/dist/hooks/index.es.js.map +1 -0
- package/dist/hooks/redux/index.d.ts +1 -0
- package/dist/hooks/use-boolean.d.ts +9 -0
- package/dist/index.cjs.js +6204 -8407
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +6284 -8487
- package/dist/index.es.js.map +1 -1
- package/dist/redux/components/iconify/iconify.d.ts +7 -0
- package/dist/redux/components/iconify/index.d.ts +2 -0
- package/dist/redux/components/iconify/types.d.ts +2 -0
- package/dist/redux/components/index.d.ts +2 -0
- package/dist/redux/components/snackbar/index.d.ts +2 -0
- package/dist/redux/components/snackbar/snackbar-provider.d.ts +5 -0
- package/dist/redux/components/snackbar/styles.d.ts +6 -0
- package/dist/redux/hook-forms/form-provider.d.ts +8 -0
- package/dist/redux/hook-forms/index.d.ts +11 -0
- package/dist/redux/hook-forms/rhf-autocomplete.d.ts +11 -0
- package/dist/redux/hook-forms/rhf-checkbox.d.ts +19 -0
- package/dist/redux/hook-forms/rhf-radio-group.d.ts +13 -0
- package/dist/redux/hook-forms/rhf-select.d.ts +11 -0
- package/dist/redux/hook-forms/rhf-slider.d.ts +7 -0
- package/dist/redux/hook-forms/rhf-switch.d.ts +7 -0
- package/dist/redux/hook-forms/rhf-text-field.d.ts +6 -0
- package/dist/redux/hooks/index.d.ts +1 -0
- package/dist/redux/hooks/use-boolean.d.ts +9 -0
- package/dist/redux/index.cjs.js +1347 -0
- package/dist/redux/index.cjs.js.map +1 -0
- package/dist/redux/index.d.ts +2 -0
- package/dist/redux/index.es.js +1317 -0
- package/dist/redux/index.es.js.map +1 -0
- package/dist/redux/redux/index.d.ts +1 -0
- package/dist/redux-toolkit/components/iconify/iconify.d.ts +7 -0
- package/dist/redux-toolkit/components/iconify/index.d.ts +2 -0
- package/dist/redux-toolkit/components/iconify/types.d.ts +2 -0
- package/dist/redux-toolkit/components/index.d.ts +2 -0
- package/dist/redux-toolkit/components/snackbar/index.d.ts +2 -0
- package/dist/redux-toolkit/components/snackbar/snackbar-provider.d.ts +5 -0
- package/dist/redux-toolkit/components/snackbar/styles.d.ts +6 -0
- package/dist/redux-toolkit/hook-forms/form-provider.d.ts +8 -0
- package/dist/redux-toolkit/hook-forms/index.d.ts +11 -0
- package/dist/redux-toolkit/hook-forms/rhf-autocomplete.d.ts +11 -0
- package/dist/redux-toolkit/hook-forms/rhf-checkbox.d.ts +19 -0
- package/dist/redux-toolkit/hook-forms/rhf-radio-group.d.ts +13 -0
- package/dist/redux-toolkit/hook-forms/rhf-select.d.ts +11 -0
- package/dist/redux-toolkit/hook-forms/rhf-slider.d.ts +7 -0
- package/dist/redux-toolkit/hook-forms/rhf-switch.d.ts +7 -0
- package/dist/redux-toolkit/hook-forms/rhf-text-field.d.ts +6 -0
- package/dist/redux-toolkit/hooks/index.d.ts +1 -0
- package/dist/redux-toolkit/hooks/use-boolean.d.ts +9 -0
- package/dist/redux-toolkit/index.cjs.js +3 -0
- package/dist/redux-toolkit/index.cjs.js.map +1 -0
- package/dist/redux-toolkit/index.d.ts +2 -0
- package/dist/redux-toolkit/index.es.js +2 -0
- package/dist/redux-toolkit/index.es.js.map +1 -0
- package/dist/redux-toolkit/redux/index.d.ts +1 -0
- package/package.json +27 -13
- package/dist/example/example/index.d.ts +0 -1
- package/dist/example/example/simple.d.ts +0 -4
- package/dist/example/index.cjs.js +0 -1381
- package/dist/example/index.cjs.js.map +0 -1
- package/dist/example/index.es.js +0 -1379
- package/dist/example/index.es.js.map +0 -1
- package/dist/example/mui/index.d.ts +0 -1
- package/dist/example/simple.d.ts +0 -4
- package/dist/hook-forms/example/index.d.ts +0 -1
- package/dist/hook-forms/example/simple.d.ts +0 -4
- package/dist/hook-forms/mui/index.d.ts +0 -1
- package/dist/mui/example/index.d.ts +0 -1
- package/dist/mui/example/simple.d.ts +0 -4
- package/dist/mui/index.cjs.js +0 -54943
- package/dist/mui/index.cjs.js.map +0 -1
- package/dist/mui/index.es.js +0 -54463
- package/dist/mui/index.es.js.map +0 -1
- package/dist/mui/mui/index.d.ts +0 -1
- /package/dist/{example → components}/hook-forms/form-provider.d.ts +0 -0
- /package/dist/{example → components}/hook-forms/index.d.ts +0 -0
- /package/dist/{example → components}/hook-forms/rhf-autocomplete.d.ts +0 -0
- /package/dist/{example → components}/hook-forms/rhf-checkbox.d.ts +0 -0
- /package/dist/{example → components}/hook-forms/rhf-radio-group.d.ts +0 -0
- /package/dist/{example → components}/hook-forms/rhf-select.d.ts +0 -0
- /package/dist/{example → components}/hook-forms/rhf-slider.d.ts +0 -0
- /package/dist/{example → components}/hook-forms/rhf-switch.d.ts +0 -0
- /package/dist/{example → components}/hook-forms/rhf-text-field.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/form-provider.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/index.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/rhf-autocomplete.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/rhf-checkbox.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/rhf-radio-group.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/rhf-select.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/rhf-slider.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/rhf-switch.d.ts +0 -0
- /package/dist/{mui → hooks}/hook-forms/rhf-text-field.d.ts +0 -0
|
@@ -0,0 +1,1347 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ReactOriginal = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var ReactOriginal__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactOriginal);
|
|
23
|
+
|
|
24
|
+
var withSelector = {exports: {}};
|
|
25
|
+
|
|
26
|
+
var useSyncExternalStoreWithSelector_production_min = {};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @license React
|
|
30
|
+
* use-sync-external-store-with-selector.production.min.js
|
|
31
|
+
*
|
|
32
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the MIT license found in the
|
|
35
|
+
* LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
var hasRequiredUseSyncExternalStoreWithSelector_production_min;
|
|
39
|
+
|
|
40
|
+
function requireUseSyncExternalStoreWithSelector_production_min () {
|
|
41
|
+
if (hasRequiredUseSyncExternalStoreWithSelector_production_min) return useSyncExternalStoreWithSelector_production_min;
|
|
42
|
+
hasRequiredUseSyncExternalStoreWithSelector_production_min = 1;
|
|
43
|
+
var g=ReactOriginal;function n(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var p="function"===typeof Object.is?Object.is:n,q=g.useSyncExternalStore,r=g.useRef,t=g.useEffect,u=g.useMemo,v=g.useDebugValue;
|
|
44
|
+
useSyncExternalStoreWithSelector_production_min.useSyncExternalStoreWithSelector=function(a,b,e,l,h){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f;}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==h&&f.hasValue){var b=f.value;if(h(b,a))return k=b}return k=a}b=k;if(p(d,a))return b;var e=l(a);if(void 0!==h&&h(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return [function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,h]);var d=q(a,c[0],c[1]);
|
|
45
|
+
t(function(){f.hasValue=!0;f.value=d;},[d]);v(d);return d};
|
|
46
|
+
return useSyncExternalStoreWithSelector_production_min;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var useSyncExternalStoreWithSelector_development = {};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @license React
|
|
53
|
+
* use-sync-external-store-with-selector.development.js
|
|
54
|
+
*
|
|
55
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
56
|
+
*
|
|
57
|
+
* This source code is licensed under the MIT license found in the
|
|
58
|
+
* LICENSE file in the root directory of this source tree.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
var hasRequiredUseSyncExternalStoreWithSelector_development;
|
|
62
|
+
|
|
63
|
+
function requireUseSyncExternalStoreWithSelector_development () {
|
|
64
|
+
if (hasRequiredUseSyncExternalStoreWithSelector_development) return useSyncExternalStoreWithSelector_development;
|
|
65
|
+
hasRequiredUseSyncExternalStoreWithSelector_development = 1;
|
|
66
|
+
|
|
67
|
+
if (process.env.NODE_ENV !== "production") {
|
|
68
|
+
(function() {
|
|
69
|
+
|
|
70
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
71
|
+
if (
|
|
72
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
73
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
74
|
+
'function'
|
|
75
|
+
) {
|
|
76
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
77
|
+
}
|
|
78
|
+
var React = ReactOriginal;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
82
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
83
|
+
*/
|
|
84
|
+
function is(x, y) {
|
|
85
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
86
|
+
;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
90
|
+
|
|
91
|
+
var useSyncExternalStore = React.useSyncExternalStore;
|
|
92
|
+
|
|
93
|
+
// for CommonJS interop.
|
|
94
|
+
|
|
95
|
+
var useRef = React.useRef,
|
|
96
|
+
useEffect = React.useEffect,
|
|
97
|
+
useMemo = React.useMemo,
|
|
98
|
+
useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
|
|
99
|
+
|
|
100
|
+
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
101
|
+
// Use this to track the rendered snapshot.
|
|
102
|
+
var instRef = useRef(null);
|
|
103
|
+
var inst;
|
|
104
|
+
|
|
105
|
+
if (instRef.current === null) {
|
|
106
|
+
inst = {
|
|
107
|
+
hasValue: false,
|
|
108
|
+
value: null
|
|
109
|
+
};
|
|
110
|
+
instRef.current = inst;
|
|
111
|
+
} else {
|
|
112
|
+
inst = instRef.current;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
var _useMemo = useMemo(function () {
|
|
116
|
+
// Track the memoized state using closure variables that are local to this
|
|
117
|
+
// memoized instance of a getSnapshot function. Intentionally not using a
|
|
118
|
+
// useRef hook, because that state would be shared across all concurrent
|
|
119
|
+
// copies of the hook/component.
|
|
120
|
+
var hasMemo = false;
|
|
121
|
+
var memoizedSnapshot;
|
|
122
|
+
var memoizedSelection;
|
|
123
|
+
|
|
124
|
+
var memoizedSelector = function (nextSnapshot) {
|
|
125
|
+
if (!hasMemo) {
|
|
126
|
+
// The first time the hook is called, there is no memoized result.
|
|
127
|
+
hasMemo = true;
|
|
128
|
+
memoizedSnapshot = nextSnapshot;
|
|
129
|
+
|
|
130
|
+
var _nextSelection = selector(nextSnapshot);
|
|
131
|
+
|
|
132
|
+
if (isEqual !== undefined) {
|
|
133
|
+
// Even if the selector has changed, the currently rendered selection
|
|
134
|
+
// may be equal to the new selection. We should attempt to reuse the
|
|
135
|
+
// current value if possible, to preserve downstream memoizations.
|
|
136
|
+
if (inst.hasValue) {
|
|
137
|
+
var currentSelection = inst.value;
|
|
138
|
+
|
|
139
|
+
if (isEqual(currentSelection, _nextSelection)) {
|
|
140
|
+
memoizedSelection = currentSelection;
|
|
141
|
+
return currentSelection;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
memoizedSelection = _nextSelection;
|
|
147
|
+
return _nextSelection;
|
|
148
|
+
} // We may be able to reuse the previous invocation's result.
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
// We may be able to reuse the previous invocation's result.
|
|
152
|
+
var prevSnapshot = memoizedSnapshot;
|
|
153
|
+
var prevSelection = memoizedSelection;
|
|
154
|
+
|
|
155
|
+
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
156
|
+
// The snapshot is the same as last time. Reuse the previous selection.
|
|
157
|
+
return prevSelection;
|
|
158
|
+
} // The snapshot has changed, so we need to compute a new selection.
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
// The snapshot has changed, so we need to compute a new selection.
|
|
162
|
+
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
|
|
163
|
+
// has changed. If it hasn't, return the previous selection. That signals
|
|
164
|
+
// to React that the selections are conceptually equal, and we can bail
|
|
165
|
+
// out of rendering.
|
|
166
|
+
|
|
167
|
+
// If a custom isEqual function is provided, use that to check if the data
|
|
168
|
+
// has changed. If it hasn't, return the previous selection. That signals
|
|
169
|
+
// to React that the selections are conceptually equal, and we can bail
|
|
170
|
+
// out of rendering.
|
|
171
|
+
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
|
|
172
|
+
return prevSelection;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
memoizedSnapshot = nextSnapshot;
|
|
176
|
+
memoizedSelection = nextSelection;
|
|
177
|
+
return nextSelection;
|
|
178
|
+
}; // Assigning this to a constant so that Flow knows it can't change.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
// Assigning this to a constant so that Flow knows it can't change.
|
|
182
|
+
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
|
|
183
|
+
|
|
184
|
+
var getSnapshotWithSelector = function () {
|
|
185
|
+
return memoizedSelector(getSnapshot());
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
|
|
189
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
190
|
+
};
|
|
191
|
+
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
192
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]),
|
|
193
|
+
getSelection = _useMemo[0],
|
|
194
|
+
getServerSelection = _useMemo[1];
|
|
195
|
+
|
|
196
|
+
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
197
|
+
useEffect(function () {
|
|
198
|
+
inst.hasValue = true;
|
|
199
|
+
inst.value = value;
|
|
200
|
+
}, [value]);
|
|
201
|
+
useDebugValue(value);
|
|
202
|
+
return value;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
|
|
206
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
207
|
+
if (
|
|
208
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
209
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
210
|
+
'function'
|
|
211
|
+
) {
|
|
212
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
})();
|
|
216
|
+
}
|
|
217
|
+
return useSyncExternalStoreWithSelector_development;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
var hasRequiredWithSelector;
|
|
221
|
+
|
|
222
|
+
function requireWithSelector () {
|
|
223
|
+
if (hasRequiredWithSelector) return withSelector.exports;
|
|
224
|
+
hasRequiredWithSelector = 1;
|
|
225
|
+
|
|
226
|
+
if (process.env.NODE_ENV === 'production') {
|
|
227
|
+
withSelector.exports = requireUseSyncExternalStoreWithSelector_production_min();
|
|
228
|
+
} else {
|
|
229
|
+
withSelector.exports = requireUseSyncExternalStoreWithSelector_development();
|
|
230
|
+
}
|
|
231
|
+
return withSelector.exports;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var withSelectorExports = requireWithSelector();
|
|
235
|
+
|
|
236
|
+
// src/index.ts
|
|
237
|
+
var React = (
|
|
238
|
+
// prettier-ignore
|
|
239
|
+
// @ts-ignore
|
|
240
|
+
"default" in ReactOriginal__namespace ? ReactOriginal__namespace["default"] : ReactOriginal__namespace
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
// src/components/Context.ts
|
|
244
|
+
var ContextKey = Symbol.for(`react-redux-context`);
|
|
245
|
+
var gT = typeof globalThis !== "undefined" ? globalThis : (
|
|
246
|
+
/* fall back to a per-module scope (pre-8.1 behaviour) if `globalThis` is not available */
|
|
247
|
+
{}
|
|
248
|
+
);
|
|
249
|
+
function getContext() {
|
|
250
|
+
if (!React.createContext)
|
|
251
|
+
return {};
|
|
252
|
+
const contextMap = gT[ContextKey] ?? (gT[ContextKey] = /* @__PURE__ */ new Map());
|
|
253
|
+
let realContext = contextMap.get(React.createContext);
|
|
254
|
+
if (!realContext) {
|
|
255
|
+
realContext = React.createContext(
|
|
256
|
+
null
|
|
257
|
+
);
|
|
258
|
+
if (process.env.NODE_ENV !== "production") {
|
|
259
|
+
realContext.displayName = "ReactRedux";
|
|
260
|
+
}
|
|
261
|
+
contextMap.set(React.createContext, realContext);
|
|
262
|
+
}
|
|
263
|
+
return realContext;
|
|
264
|
+
}
|
|
265
|
+
var ReactReduxContext = /* @__PURE__ */ getContext();
|
|
266
|
+
|
|
267
|
+
// src/utils/useSyncExternalStore.ts
|
|
268
|
+
var notInitialized = () => {
|
|
269
|
+
throw new Error("uSES not initialized!");
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// src/hooks/useReduxContext.ts
|
|
273
|
+
function createReduxContextHook(context = ReactReduxContext) {
|
|
274
|
+
return function useReduxContext2() {
|
|
275
|
+
const contextValue = React.useContext(context);
|
|
276
|
+
if (process.env.NODE_ENV !== "production" && !contextValue) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
"could not find react-redux context value; please ensure the component is wrapped in a <Provider>"
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
return contextValue;
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
var useReduxContext = /* @__PURE__ */ createReduxContextHook();
|
|
285
|
+
|
|
286
|
+
// src/hooks/useSelector.ts
|
|
287
|
+
var useSyncExternalStoreWithSelector = notInitialized;
|
|
288
|
+
var initializeUseSelector = (fn) => {
|
|
289
|
+
useSyncExternalStoreWithSelector = fn;
|
|
290
|
+
};
|
|
291
|
+
var refEquality = (a, b) => a === b;
|
|
292
|
+
function createSelectorHook(context = ReactReduxContext) {
|
|
293
|
+
const useReduxContext2 = context === ReactReduxContext ? useReduxContext : createReduxContextHook(context);
|
|
294
|
+
const useSelector2 = (selector, equalityFnOrOptions = {}) => {
|
|
295
|
+
const { equalityFn = refEquality, devModeChecks = {} } = typeof equalityFnOrOptions === "function" ? { equalityFn: equalityFnOrOptions } : equalityFnOrOptions;
|
|
296
|
+
if (process.env.NODE_ENV !== "production") {
|
|
297
|
+
if (!selector) {
|
|
298
|
+
throw new Error(`You must pass a selector to useSelector`);
|
|
299
|
+
}
|
|
300
|
+
if (typeof selector !== "function") {
|
|
301
|
+
throw new Error(`You must pass a function as a selector to useSelector`);
|
|
302
|
+
}
|
|
303
|
+
if (typeof equalityFn !== "function") {
|
|
304
|
+
throw new Error(
|
|
305
|
+
`You must pass a function as an equality function to useSelector`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const {
|
|
310
|
+
store,
|
|
311
|
+
subscription,
|
|
312
|
+
getServerState,
|
|
313
|
+
stabilityCheck,
|
|
314
|
+
identityFunctionCheck
|
|
315
|
+
} = useReduxContext2();
|
|
316
|
+
const firstRun = React.useRef(true);
|
|
317
|
+
const wrappedSelector = React.useCallback(
|
|
318
|
+
{
|
|
319
|
+
[selector.name](state) {
|
|
320
|
+
const selected = selector(state);
|
|
321
|
+
if (process.env.NODE_ENV !== "production") {
|
|
322
|
+
const {
|
|
323
|
+
identityFunctionCheck: finalIdentityFunctionCheck,
|
|
324
|
+
stabilityCheck: finalStabilityCheck
|
|
325
|
+
} = {
|
|
326
|
+
stabilityCheck,
|
|
327
|
+
identityFunctionCheck,
|
|
328
|
+
...devModeChecks
|
|
329
|
+
};
|
|
330
|
+
if (finalStabilityCheck === "always" || finalStabilityCheck === "once" && firstRun.current) {
|
|
331
|
+
const toCompare = selector(state);
|
|
332
|
+
if (!equalityFn(selected, toCompare)) {
|
|
333
|
+
let stack = void 0;
|
|
334
|
+
try {
|
|
335
|
+
throw new Error();
|
|
336
|
+
} catch (e) {
|
|
337
|
+
({ stack } = e);
|
|
338
|
+
}
|
|
339
|
+
console.warn(
|
|
340
|
+
"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",
|
|
341
|
+
{
|
|
342
|
+
state,
|
|
343
|
+
selected,
|
|
344
|
+
selected2: toCompare,
|
|
345
|
+
stack
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (finalIdentityFunctionCheck === "always" || finalIdentityFunctionCheck === "once" && firstRun.current) {
|
|
351
|
+
if (selected === state) {
|
|
352
|
+
let stack = void 0;
|
|
353
|
+
try {
|
|
354
|
+
throw new Error();
|
|
355
|
+
} catch (e) {
|
|
356
|
+
({ stack } = e);
|
|
357
|
+
}
|
|
358
|
+
console.warn(
|
|
359
|
+
"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.",
|
|
360
|
+
{ stack }
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (firstRun.current)
|
|
365
|
+
firstRun.current = false;
|
|
366
|
+
}
|
|
367
|
+
return selected;
|
|
368
|
+
}
|
|
369
|
+
}[selector.name],
|
|
370
|
+
[selector, stabilityCheck, devModeChecks.stabilityCheck]
|
|
371
|
+
);
|
|
372
|
+
const selectedState = useSyncExternalStoreWithSelector(
|
|
373
|
+
subscription.addNestedSub,
|
|
374
|
+
store.getState,
|
|
375
|
+
getServerState || store.getState,
|
|
376
|
+
wrappedSelector,
|
|
377
|
+
equalityFn
|
|
378
|
+
);
|
|
379
|
+
React.useDebugValue(selectedState);
|
|
380
|
+
return selectedState;
|
|
381
|
+
};
|
|
382
|
+
Object.assign(useSelector2, {
|
|
383
|
+
withTypes: () => useSelector2
|
|
384
|
+
});
|
|
385
|
+
return useSelector2;
|
|
386
|
+
}
|
|
387
|
+
var useSelector = /* @__PURE__ */ createSelectorHook();
|
|
388
|
+
|
|
389
|
+
// src/utils/react-is.ts
|
|
390
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.element");
|
|
391
|
+
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
|
392
|
+
var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
393
|
+
var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
|
|
394
|
+
var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
395
|
+
var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
|
|
396
|
+
var REACT_CONTEXT_TYPE = Symbol.for("react.context");
|
|
397
|
+
var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
|
|
398
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
|
|
399
|
+
var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
|
|
400
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
|
|
401
|
+
var REACT_MEMO_TYPE = Symbol.for("react.memo");
|
|
402
|
+
var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
403
|
+
var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
|
|
404
|
+
var REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference");
|
|
405
|
+
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
406
|
+
var Memo = REACT_MEMO_TYPE;
|
|
407
|
+
function isValidElementType(type) {
|
|
408
|
+
if (typeof type === "string" || typeof type === "function") {
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
if (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) {
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
if (typeof type === "object" && type !== null) {
|
|
415
|
+
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
|
|
416
|
+
// types supported by any Flight configuration anywhere since
|
|
417
|
+
// we don't know which Flight build this will end up being used
|
|
418
|
+
// with.
|
|
419
|
+
type.$$typeof === REACT_CLIENT_REFERENCE || type.getModuleId !== void 0) {
|
|
420
|
+
return true;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
function typeOf(object) {
|
|
426
|
+
if (typeof object === "object" && object !== null) {
|
|
427
|
+
const $$typeof = object.$$typeof;
|
|
428
|
+
switch ($$typeof) {
|
|
429
|
+
case REACT_ELEMENT_TYPE: {
|
|
430
|
+
const type = object.type;
|
|
431
|
+
switch (type) {
|
|
432
|
+
case REACT_FRAGMENT_TYPE:
|
|
433
|
+
case REACT_PROFILER_TYPE:
|
|
434
|
+
case REACT_STRICT_MODE_TYPE:
|
|
435
|
+
case REACT_SUSPENSE_TYPE:
|
|
436
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
437
|
+
return type;
|
|
438
|
+
default: {
|
|
439
|
+
const $$typeofType = type && type.$$typeof;
|
|
440
|
+
switch ($$typeofType) {
|
|
441
|
+
case REACT_SERVER_CONTEXT_TYPE:
|
|
442
|
+
case REACT_CONTEXT_TYPE:
|
|
443
|
+
case REACT_FORWARD_REF_TYPE:
|
|
444
|
+
case REACT_LAZY_TYPE:
|
|
445
|
+
case REACT_MEMO_TYPE:
|
|
446
|
+
case REACT_PROVIDER_TYPE:
|
|
447
|
+
return $$typeofType;
|
|
448
|
+
default:
|
|
449
|
+
return $$typeof;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
case REACT_PORTAL_TYPE: {
|
|
455
|
+
return $$typeof;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return void 0;
|
|
460
|
+
}
|
|
461
|
+
function isContextConsumer(object) {
|
|
462
|
+
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
463
|
+
}
|
|
464
|
+
function isMemo(object) {
|
|
465
|
+
return typeOf(object) === REACT_MEMO_TYPE;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// src/utils/warning.ts
|
|
469
|
+
function warning(message) {
|
|
470
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
471
|
+
console.error(message);
|
|
472
|
+
}
|
|
473
|
+
try {
|
|
474
|
+
throw new Error(message);
|
|
475
|
+
} catch (e) {
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/connect/verifySubselectors.ts
|
|
480
|
+
function verify(selector, methodName) {
|
|
481
|
+
if (!selector) {
|
|
482
|
+
throw new Error(`Unexpected value for ${methodName} in connect.`);
|
|
483
|
+
} else if (methodName === "mapStateToProps" || methodName === "mapDispatchToProps") {
|
|
484
|
+
if (!Object.prototype.hasOwnProperty.call(selector, "dependsOnOwnProps")) {
|
|
485
|
+
warning(
|
|
486
|
+
`The selector for ${methodName} of connect did not specify a value for dependsOnOwnProps.`
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps) {
|
|
492
|
+
verify(mapStateToProps, "mapStateToProps");
|
|
493
|
+
verify(mapDispatchToProps, "mapDispatchToProps");
|
|
494
|
+
verify(mergeProps, "mergeProps");
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/connect/selectorFactory.ts
|
|
498
|
+
function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, {
|
|
499
|
+
areStatesEqual,
|
|
500
|
+
areOwnPropsEqual,
|
|
501
|
+
areStatePropsEqual
|
|
502
|
+
}) {
|
|
503
|
+
let hasRunAtLeastOnce = false;
|
|
504
|
+
let state;
|
|
505
|
+
let ownProps;
|
|
506
|
+
let stateProps;
|
|
507
|
+
let dispatchProps;
|
|
508
|
+
let mergedProps;
|
|
509
|
+
function handleFirstCall(firstState, firstOwnProps) {
|
|
510
|
+
state = firstState;
|
|
511
|
+
ownProps = firstOwnProps;
|
|
512
|
+
stateProps = mapStateToProps(state, ownProps);
|
|
513
|
+
dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
|
514
|
+
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
|
515
|
+
hasRunAtLeastOnce = true;
|
|
516
|
+
return mergedProps;
|
|
517
|
+
}
|
|
518
|
+
function handleNewPropsAndNewState() {
|
|
519
|
+
stateProps = mapStateToProps(state, ownProps);
|
|
520
|
+
if (mapDispatchToProps.dependsOnOwnProps)
|
|
521
|
+
dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
|
522
|
+
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
|
523
|
+
return mergedProps;
|
|
524
|
+
}
|
|
525
|
+
function handleNewProps() {
|
|
526
|
+
if (mapStateToProps.dependsOnOwnProps)
|
|
527
|
+
stateProps = mapStateToProps(state, ownProps);
|
|
528
|
+
if (mapDispatchToProps.dependsOnOwnProps)
|
|
529
|
+
dispatchProps = mapDispatchToProps(dispatch, ownProps);
|
|
530
|
+
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
|
531
|
+
return mergedProps;
|
|
532
|
+
}
|
|
533
|
+
function handleNewState() {
|
|
534
|
+
const nextStateProps = mapStateToProps(state, ownProps);
|
|
535
|
+
const statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
|
|
536
|
+
stateProps = nextStateProps;
|
|
537
|
+
if (statePropsChanged)
|
|
538
|
+
mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
|
539
|
+
return mergedProps;
|
|
540
|
+
}
|
|
541
|
+
function handleSubsequentCalls(nextState, nextOwnProps) {
|
|
542
|
+
const propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
|
|
543
|
+
const stateChanged = !areStatesEqual(
|
|
544
|
+
nextState,
|
|
545
|
+
state,
|
|
546
|
+
nextOwnProps,
|
|
547
|
+
ownProps
|
|
548
|
+
);
|
|
549
|
+
state = nextState;
|
|
550
|
+
ownProps = nextOwnProps;
|
|
551
|
+
if (propsChanged && stateChanged)
|
|
552
|
+
return handleNewPropsAndNewState();
|
|
553
|
+
if (propsChanged)
|
|
554
|
+
return handleNewProps();
|
|
555
|
+
if (stateChanged)
|
|
556
|
+
return handleNewState();
|
|
557
|
+
return mergedProps;
|
|
558
|
+
}
|
|
559
|
+
return function pureFinalPropsSelector(nextState, nextOwnProps) {
|
|
560
|
+
return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
function finalPropsSelectorFactory(dispatch, {
|
|
564
|
+
initMapStateToProps,
|
|
565
|
+
initMapDispatchToProps,
|
|
566
|
+
initMergeProps,
|
|
567
|
+
...options
|
|
568
|
+
}) {
|
|
569
|
+
const mapStateToProps = initMapStateToProps(dispatch, options);
|
|
570
|
+
const mapDispatchToProps = initMapDispatchToProps(dispatch, options);
|
|
571
|
+
const mergeProps = initMergeProps(dispatch, options);
|
|
572
|
+
if (process.env.NODE_ENV !== "production") {
|
|
573
|
+
verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps);
|
|
574
|
+
}
|
|
575
|
+
return pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// src/utils/bindActionCreators.ts
|
|
579
|
+
function bindActionCreators(actionCreators, dispatch) {
|
|
580
|
+
const boundActionCreators = {};
|
|
581
|
+
for (const key in actionCreators) {
|
|
582
|
+
const actionCreator = actionCreators[key];
|
|
583
|
+
if (typeof actionCreator === "function") {
|
|
584
|
+
boundActionCreators[key] = (...args) => dispatch(actionCreator(...args));
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return boundActionCreators;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// src/utils/isPlainObject.ts
|
|
591
|
+
function isPlainObject(obj) {
|
|
592
|
+
if (typeof obj !== "object" || obj === null)
|
|
593
|
+
return false;
|
|
594
|
+
const proto = Object.getPrototypeOf(obj);
|
|
595
|
+
if (proto === null)
|
|
596
|
+
return true;
|
|
597
|
+
let baseProto = proto;
|
|
598
|
+
while (Object.getPrototypeOf(baseProto) !== null) {
|
|
599
|
+
baseProto = Object.getPrototypeOf(baseProto);
|
|
600
|
+
}
|
|
601
|
+
return proto === baseProto;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// src/utils/verifyPlainObject.ts
|
|
605
|
+
function verifyPlainObject(value, displayName, methodName) {
|
|
606
|
+
if (!isPlainObject(value)) {
|
|
607
|
+
warning(
|
|
608
|
+
`${methodName}() in ${displayName} must return a plain object. Instead received ${value}.`
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// src/connect/wrapMapToProps.ts
|
|
614
|
+
function wrapMapToPropsConstant(getConstant) {
|
|
615
|
+
return function initConstantSelector(dispatch) {
|
|
616
|
+
const constant = getConstant(dispatch);
|
|
617
|
+
function constantSelector() {
|
|
618
|
+
return constant;
|
|
619
|
+
}
|
|
620
|
+
constantSelector.dependsOnOwnProps = false;
|
|
621
|
+
return constantSelector;
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
function getDependsOnOwnProps(mapToProps) {
|
|
625
|
+
return mapToProps.dependsOnOwnProps ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
|
|
626
|
+
}
|
|
627
|
+
function wrapMapToPropsFunc(mapToProps, methodName) {
|
|
628
|
+
return function initProxySelector(dispatch, { displayName }) {
|
|
629
|
+
const proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
|
|
630
|
+
return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch, void 0);
|
|
631
|
+
};
|
|
632
|
+
proxy.dependsOnOwnProps = true;
|
|
633
|
+
proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
|
|
634
|
+
proxy.mapToProps = mapToProps;
|
|
635
|
+
proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
|
|
636
|
+
let props = proxy(stateOrDispatch, ownProps);
|
|
637
|
+
if (typeof props === "function") {
|
|
638
|
+
proxy.mapToProps = props;
|
|
639
|
+
proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
|
|
640
|
+
props = proxy(stateOrDispatch, ownProps);
|
|
641
|
+
}
|
|
642
|
+
if (process.env.NODE_ENV !== "production")
|
|
643
|
+
verifyPlainObject(props, displayName, methodName);
|
|
644
|
+
return props;
|
|
645
|
+
};
|
|
646
|
+
return proxy;
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// src/connect/invalidArgFactory.ts
|
|
651
|
+
function createInvalidArgFactory(arg, name) {
|
|
652
|
+
return (dispatch, options) => {
|
|
653
|
+
throw new Error(
|
|
654
|
+
`Invalid value of type ${typeof arg} for ${name} argument when connecting component ${options.wrappedComponentName}.`
|
|
655
|
+
);
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// src/connect/mapDispatchToProps.ts
|
|
660
|
+
function mapDispatchToPropsFactory(mapDispatchToProps) {
|
|
661
|
+
return mapDispatchToProps && typeof mapDispatchToProps === "object" ? wrapMapToPropsConstant(
|
|
662
|
+
(dispatch) => (
|
|
663
|
+
// @ts-ignore
|
|
664
|
+
bindActionCreators(mapDispatchToProps, dispatch)
|
|
665
|
+
)
|
|
666
|
+
) : !mapDispatchToProps ? wrapMapToPropsConstant((dispatch) => ({
|
|
667
|
+
dispatch
|
|
668
|
+
})) : typeof mapDispatchToProps === "function" ? (
|
|
669
|
+
// @ts-ignore
|
|
670
|
+
wrapMapToPropsFunc(mapDispatchToProps, "mapDispatchToProps")
|
|
671
|
+
) : createInvalidArgFactory(mapDispatchToProps, "mapDispatchToProps");
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// src/connect/mapStateToProps.ts
|
|
675
|
+
function mapStateToPropsFactory(mapStateToProps) {
|
|
676
|
+
return !mapStateToProps ? wrapMapToPropsConstant(() => ({})) : typeof mapStateToProps === "function" ? (
|
|
677
|
+
// @ts-ignore
|
|
678
|
+
wrapMapToPropsFunc(mapStateToProps, "mapStateToProps")
|
|
679
|
+
) : createInvalidArgFactory(mapStateToProps, "mapStateToProps");
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// src/connect/mergeProps.ts
|
|
683
|
+
function defaultMergeProps(stateProps, dispatchProps, ownProps) {
|
|
684
|
+
return { ...ownProps, ...stateProps, ...dispatchProps };
|
|
685
|
+
}
|
|
686
|
+
function wrapMergePropsFunc(mergeProps) {
|
|
687
|
+
return function initMergePropsProxy(dispatch, { displayName, areMergedPropsEqual }) {
|
|
688
|
+
let hasRunOnce = false;
|
|
689
|
+
let mergedProps;
|
|
690
|
+
return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
|
|
691
|
+
const nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
|
|
692
|
+
if (hasRunOnce) {
|
|
693
|
+
if (!areMergedPropsEqual(nextMergedProps, mergedProps))
|
|
694
|
+
mergedProps = nextMergedProps;
|
|
695
|
+
} else {
|
|
696
|
+
hasRunOnce = true;
|
|
697
|
+
mergedProps = nextMergedProps;
|
|
698
|
+
if (process.env.NODE_ENV !== "production")
|
|
699
|
+
verifyPlainObject(mergedProps, displayName, "mergeProps");
|
|
700
|
+
}
|
|
701
|
+
return mergedProps;
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
function mergePropsFactory(mergeProps) {
|
|
706
|
+
return !mergeProps ? () => defaultMergeProps : typeof mergeProps === "function" ? wrapMergePropsFunc(mergeProps) : createInvalidArgFactory(mergeProps, "mergeProps");
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/utils/batch.ts
|
|
710
|
+
function defaultNoopBatch(callback) {
|
|
711
|
+
callback();
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// src/utils/Subscription.ts
|
|
715
|
+
function createListenerCollection() {
|
|
716
|
+
let first = null;
|
|
717
|
+
let last = null;
|
|
718
|
+
return {
|
|
719
|
+
clear() {
|
|
720
|
+
first = null;
|
|
721
|
+
last = null;
|
|
722
|
+
},
|
|
723
|
+
notify() {
|
|
724
|
+
defaultNoopBatch(() => {
|
|
725
|
+
let listener = first;
|
|
726
|
+
while (listener) {
|
|
727
|
+
listener.callback();
|
|
728
|
+
listener = listener.next;
|
|
729
|
+
}
|
|
730
|
+
});
|
|
731
|
+
},
|
|
732
|
+
get() {
|
|
733
|
+
const listeners = [];
|
|
734
|
+
let listener = first;
|
|
735
|
+
while (listener) {
|
|
736
|
+
listeners.push(listener);
|
|
737
|
+
listener = listener.next;
|
|
738
|
+
}
|
|
739
|
+
return listeners;
|
|
740
|
+
},
|
|
741
|
+
subscribe(callback) {
|
|
742
|
+
let isSubscribed = true;
|
|
743
|
+
const listener = last = {
|
|
744
|
+
callback,
|
|
745
|
+
next: null,
|
|
746
|
+
prev: last
|
|
747
|
+
};
|
|
748
|
+
if (listener.prev) {
|
|
749
|
+
listener.prev.next = listener;
|
|
750
|
+
} else {
|
|
751
|
+
first = listener;
|
|
752
|
+
}
|
|
753
|
+
return function unsubscribe() {
|
|
754
|
+
if (!isSubscribed || first === null)
|
|
755
|
+
return;
|
|
756
|
+
isSubscribed = false;
|
|
757
|
+
if (listener.next) {
|
|
758
|
+
listener.next.prev = listener.prev;
|
|
759
|
+
} else {
|
|
760
|
+
last = listener.prev;
|
|
761
|
+
}
|
|
762
|
+
if (listener.prev) {
|
|
763
|
+
listener.prev.next = listener.next;
|
|
764
|
+
} else {
|
|
765
|
+
first = listener.next;
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
var nullListeners = {
|
|
772
|
+
notify() {
|
|
773
|
+
},
|
|
774
|
+
get: () => []
|
|
775
|
+
};
|
|
776
|
+
function createSubscription(store, parentSub) {
|
|
777
|
+
let unsubscribe;
|
|
778
|
+
let listeners = nullListeners;
|
|
779
|
+
let subscriptionsAmount = 0;
|
|
780
|
+
let selfSubscribed = false;
|
|
781
|
+
function addNestedSub(listener) {
|
|
782
|
+
trySubscribe();
|
|
783
|
+
const cleanupListener = listeners.subscribe(listener);
|
|
784
|
+
let removed = false;
|
|
785
|
+
return () => {
|
|
786
|
+
if (!removed) {
|
|
787
|
+
removed = true;
|
|
788
|
+
cleanupListener();
|
|
789
|
+
tryUnsubscribe();
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function notifyNestedSubs() {
|
|
794
|
+
listeners.notify();
|
|
795
|
+
}
|
|
796
|
+
function handleChangeWrapper() {
|
|
797
|
+
if (subscription.onStateChange) {
|
|
798
|
+
subscription.onStateChange();
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
function isSubscribed() {
|
|
802
|
+
return selfSubscribed;
|
|
803
|
+
}
|
|
804
|
+
function trySubscribe() {
|
|
805
|
+
subscriptionsAmount++;
|
|
806
|
+
if (!unsubscribe) {
|
|
807
|
+
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
|
|
808
|
+
listeners = createListenerCollection();
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function tryUnsubscribe() {
|
|
812
|
+
subscriptionsAmount--;
|
|
813
|
+
if (unsubscribe && subscriptionsAmount === 0) {
|
|
814
|
+
unsubscribe();
|
|
815
|
+
unsubscribe = void 0;
|
|
816
|
+
listeners.clear();
|
|
817
|
+
listeners = nullListeners;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
function trySubscribeSelf() {
|
|
821
|
+
if (!selfSubscribed) {
|
|
822
|
+
selfSubscribed = true;
|
|
823
|
+
trySubscribe();
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
function tryUnsubscribeSelf() {
|
|
827
|
+
if (selfSubscribed) {
|
|
828
|
+
selfSubscribed = false;
|
|
829
|
+
tryUnsubscribe();
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
const subscription = {
|
|
833
|
+
addNestedSub,
|
|
834
|
+
notifyNestedSubs,
|
|
835
|
+
handleChangeWrapper,
|
|
836
|
+
isSubscribed,
|
|
837
|
+
trySubscribe: trySubscribeSelf,
|
|
838
|
+
tryUnsubscribe: tryUnsubscribeSelf,
|
|
839
|
+
getListeners: () => listeners
|
|
840
|
+
};
|
|
841
|
+
return subscription;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// src/utils/useIsomorphicLayoutEffect.ts
|
|
845
|
+
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
846
|
+
var isReactNative = typeof navigator !== "undefined" && navigator.product === "ReactNative";
|
|
847
|
+
var useIsomorphicLayoutEffect = canUseDOM || isReactNative ? React.useLayoutEffect : React.useEffect;
|
|
848
|
+
|
|
849
|
+
// src/utils/shallowEqual.ts
|
|
850
|
+
function is(x, y) {
|
|
851
|
+
if (x === y) {
|
|
852
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
853
|
+
} else {
|
|
854
|
+
return x !== x && y !== y;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function shallowEqual(objA, objB) {
|
|
858
|
+
if (is(objA, objB))
|
|
859
|
+
return true;
|
|
860
|
+
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
const keysA = Object.keys(objA);
|
|
864
|
+
const keysB = Object.keys(objB);
|
|
865
|
+
if (keysA.length !== keysB.length)
|
|
866
|
+
return false;
|
|
867
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
868
|
+
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return true;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// src/utils/hoistStatics.ts
|
|
876
|
+
var REACT_STATICS = {
|
|
877
|
+
childContextTypes: true,
|
|
878
|
+
contextType: true,
|
|
879
|
+
contextTypes: true,
|
|
880
|
+
defaultProps: true,
|
|
881
|
+
displayName: true,
|
|
882
|
+
getDefaultProps: true,
|
|
883
|
+
getDerivedStateFromError: true,
|
|
884
|
+
getDerivedStateFromProps: true,
|
|
885
|
+
mixins: true,
|
|
886
|
+
propTypes: true,
|
|
887
|
+
type: true
|
|
888
|
+
};
|
|
889
|
+
var KNOWN_STATICS = {
|
|
890
|
+
name: true,
|
|
891
|
+
length: true,
|
|
892
|
+
prototype: true,
|
|
893
|
+
caller: true,
|
|
894
|
+
callee: true,
|
|
895
|
+
arguments: true,
|
|
896
|
+
arity: true
|
|
897
|
+
};
|
|
898
|
+
var FORWARD_REF_STATICS = {
|
|
899
|
+
$$typeof: true,
|
|
900
|
+
render: true,
|
|
901
|
+
defaultProps: true,
|
|
902
|
+
displayName: true,
|
|
903
|
+
propTypes: true
|
|
904
|
+
};
|
|
905
|
+
var MEMO_STATICS = {
|
|
906
|
+
$$typeof: true,
|
|
907
|
+
compare: true,
|
|
908
|
+
defaultProps: true,
|
|
909
|
+
displayName: true,
|
|
910
|
+
propTypes: true,
|
|
911
|
+
type: true
|
|
912
|
+
};
|
|
913
|
+
var TYPE_STATICS = {
|
|
914
|
+
[ForwardRef]: FORWARD_REF_STATICS,
|
|
915
|
+
[Memo]: MEMO_STATICS
|
|
916
|
+
};
|
|
917
|
+
function getStatics(component) {
|
|
918
|
+
if (isMemo(component)) {
|
|
919
|
+
return MEMO_STATICS;
|
|
920
|
+
}
|
|
921
|
+
return TYPE_STATICS[component["$$typeof"]] || REACT_STATICS;
|
|
922
|
+
}
|
|
923
|
+
var defineProperty = Object.defineProperty;
|
|
924
|
+
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
925
|
+
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
926
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
927
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
|
928
|
+
var objectPrototype = Object.prototype;
|
|
929
|
+
function hoistNonReactStatics(targetComponent, sourceComponent) {
|
|
930
|
+
if (typeof sourceComponent !== "string") {
|
|
931
|
+
if (objectPrototype) {
|
|
932
|
+
const inheritedComponent = getPrototypeOf(sourceComponent);
|
|
933
|
+
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
|
934
|
+
hoistNonReactStatics(targetComponent, inheritedComponent);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
let keys = getOwnPropertyNames(sourceComponent);
|
|
938
|
+
if (getOwnPropertySymbols) {
|
|
939
|
+
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
|
940
|
+
}
|
|
941
|
+
const targetStatics = getStatics(targetComponent);
|
|
942
|
+
const sourceStatics = getStatics(sourceComponent);
|
|
943
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
944
|
+
const key = keys[i];
|
|
945
|
+
if (!KNOWN_STATICS[key] && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
|
946
|
+
const descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
|
947
|
+
try {
|
|
948
|
+
defineProperty(targetComponent, key, descriptor);
|
|
949
|
+
} catch (e) {
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
return targetComponent;
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// src/components/connect.tsx
|
|
958
|
+
var useSyncExternalStore = notInitialized;
|
|
959
|
+
var initializeConnect = (fn) => {
|
|
960
|
+
useSyncExternalStore = fn;
|
|
961
|
+
};
|
|
962
|
+
var NO_SUBSCRIPTION_ARRAY = [null, null];
|
|
963
|
+
var stringifyComponent = (Comp) => {
|
|
964
|
+
try {
|
|
965
|
+
return JSON.stringify(Comp);
|
|
966
|
+
} catch (err) {
|
|
967
|
+
return String(Comp);
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
function useIsomorphicLayoutEffectWithArgs(effectFunc, effectArgs, dependencies) {
|
|
971
|
+
useIsomorphicLayoutEffect(() => effectFunc(...effectArgs), dependencies);
|
|
972
|
+
}
|
|
973
|
+
function captureWrapperProps(lastWrapperProps, lastChildProps, renderIsScheduled, wrapperProps, childPropsFromStoreUpdate, notifyNestedSubs) {
|
|
974
|
+
lastWrapperProps.current = wrapperProps;
|
|
975
|
+
renderIsScheduled.current = false;
|
|
976
|
+
if (childPropsFromStoreUpdate.current) {
|
|
977
|
+
childPropsFromStoreUpdate.current = null;
|
|
978
|
+
notifyNestedSubs();
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
function subscribeUpdates(shouldHandleStateChanges, store, subscription, childPropsSelector, lastWrapperProps, lastChildProps, renderIsScheduled, isMounted, childPropsFromStoreUpdate, notifyNestedSubs, additionalSubscribeListener) {
|
|
982
|
+
if (!shouldHandleStateChanges)
|
|
983
|
+
return () => {
|
|
984
|
+
};
|
|
985
|
+
let didUnsubscribe = false;
|
|
986
|
+
let lastThrownError = null;
|
|
987
|
+
const checkForUpdates = () => {
|
|
988
|
+
if (didUnsubscribe || !isMounted.current) {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
const latestStoreState = store.getState();
|
|
992
|
+
let newChildProps, error;
|
|
993
|
+
try {
|
|
994
|
+
newChildProps = childPropsSelector(
|
|
995
|
+
latestStoreState,
|
|
996
|
+
lastWrapperProps.current
|
|
997
|
+
);
|
|
998
|
+
} catch (e) {
|
|
999
|
+
error = e;
|
|
1000
|
+
lastThrownError = e;
|
|
1001
|
+
}
|
|
1002
|
+
if (!error) {
|
|
1003
|
+
lastThrownError = null;
|
|
1004
|
+
}
|
|
1005
|
+
if (newChildProps === lastChildProps.current) {
|
|
1006
|
+
if (!renderIsScheduled.current) {
|
|
1007
|
+
notifyNestedSubs();
|
|
1008
|
+
}
|
|
1009
|
+
} else {
|
|
1010
|
+
lastChildProps.current = newChildProps;
|
|
1011
|
+
childPropsFromStoreUpdate.current = newChildProps;
|
|
1012
|
+
renderIsScheduled.current = true;
|
|
1013
|
+
additionalSubscribeListener();
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
subscription.onStateChange = checkForUpdates;
|
|
1017
|
+
subscription.trySubscribe();
|
|
1018
|
+
checkForUpdates();
|
|
1019
|
+
const unsubscribeWrapper = () => {
|
|
1020
|
+
didUnsubscribe = true;
|
|
1021
|
+
subscription.tryUnsubscribe();
|
|
1022
|
+
subscription.onStateChange = null;
|
|
1023
|
+
if (lastThrownError) {
|
|
1024
|
+
throw lastThrownError;
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
return unsubscribeWrapper;
|
|
1028
|
+
}
|
|
1029
|
+
function strictEqual(a, b) {
|
|
1030
|
+
return a === b;
|
|
1031
|
+
}
|
|
1032
|
+
var hasWarnedAboutDeprecatedPureOption = false;
|
|
1033
|
+
function connect(mapStateToProps, mapDispatchToProps, mergeProps, {
|
|
1034
|
+
// The `pure` option has been removed, so TS doesn't like us destructuring this to check its existence.
|
|
1035
|
+
// @ts-ignore
|
|
1036
|
+
pure,
|
|
1037
|
+
areStatesEqual = strictEqual,
|
|
1038
|
+
areOwnPropsEqual = shallowEqual,
|
|
1039
|
+
areStatePropsEqual = shallowEqual,
|
|
1040
|
+
areMergedPropsEqual = shallowEqual,
|
|
1041
|
+
// use React's forwardRef to expose a ref of the wrapped component
|
|
1042
|
+
forwardRef = false,
|
|
1043
|
+
// the context consumer to use
|
|
1044
|
+
context = ReactReduxContext
|
|
1045
|
+
} = {}) {
|
|
1046
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1047
|
+
if (pure !== void 0 && !hasWarnedAboutDeprecatedPureOption) {
|
|
1048
|
+
hasWarnedAboutDeprecatedPureOption = true;
|
|
1049
|
+
warning(
|
|
1050
|
+
'The `pure` option has been removed. `connect` is now always a "pure/memoized" component'
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
const Context = context;
|
|
1055
|
+
const initMapStateToProps = mapStateToPropsFactory(mapStateToProps);
|
|
1056
|
+
const initMapDispatchToProps = mapDispatchToPropsFactory(mapDispatchToProps);
|
|
1057
|
+
const initMergeProps = mergePropsFactory(mergeProps);
|
|
1058
|
+
const shouldHandleStateChanges = Boolean(mapStateToProps);
|
|
1059
|
+
const wrapWithConnect = (WrappedComponent) => {
|
|
1060
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1061
|
+
const isValid = /* @__PURE__ */ isValidElementType(WrappedComponent);
|
|
1062
|
+
if (!isValid)
|
|
1063
|
+
throw new Error(
|
|
1064
|
+
`You must pass a component to the function returned by connect. Instead received ${stringifyComponent(
|
|
1065
|
+
WrappedComponent
|
|
1066
|
+
)}`
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1069
|
+
const wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || "Component";
|
|
1070
|
+
const displayName = `Connect(${wrappedComponentName})`;
|
|
1071
|
+
const selectorFactoryOptions = {
|
|
1072
|
+
shouldHandleStateChanges,
|
|
1073
|
+
displayName,
|
|
1074
|
+
wrappedComponentName,
|
|
1075
|
+
WrappedComponent,
|
|
1076
|
+
// @ts-ignore
|
|
1077
|
+
initMapStateToProps,
|
|
1078
|
+
// @ts-ignore
|
|
1079
|
+
initMapDispatchToProps,
|
|
1080
|
+
initMergeProps,
|
|
1081
|
+
areStatesEqual,
|
|
1082
|
+
areStatePropsEqual,
|
|
1083
|
+
areOwnPropsEqual,
|
|
1084
|
+
areMergedPropsEqual
|
|
1085
|
+
};
|
|
1086
|
+
function ConnectFunction(props) {
|
|
1087
|
+
const [propsContext, reactReduxForwardedRef, wrapperProps] = React.useMemo(() => {
|
|
1088
|
+
const { reactReduxForwardedRef: reactReduxForwardedRef2, ...wrapperProps2 } = props;
|
|
1089
|
+
return [props.context, reactReduxForwardedRef2, wrapperProps2];
|
|
1090
|
+
}, [props]);
|
|
1091
|
+
const ContextToUse = React.useMemo(() => {
|
|
1092
|
+
let ResultContext = Context;
|
|
1093
|
+
if (propsContext?.Consumer) {
|
|
1094
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1095
|
+
const isValid = /* @__PURE__ */ isContextConsumer(
|
|
1096
|
+
// @ts-ignore
|
|
1097
|
+
/* @__PURE__ */ React.createElement(propsContext.Consumer, null)
|
|
1098
|
+
);
|
|
1099
|
+
if (!isValid) {
|
|
1100
|
+
throw new Error(
|
|
1101
|
+
"You must pass a valid React context consumer as `props.context`"
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
ResultContext = propsContext;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
return ResultContext;
|
|
1108
|
+
}, [propsContext, Context]);
|
|
1109
|
+
const contextValue = React.useContext(ContextToUse);
|
|
1110
|
+
const didStoreComeFromProps = Boolean(props.store) && Boolean(props.store.getState) && Boolean(props.store.dispatch);
|
|
1111
|
+
const didStoreComeFromContext = Boolean(contextValue) && Boolean(contextValue.store);
|
|
1112
|
+
if (process.env.NODE_ENV !== "production" && !didStoreComeFromProps && !didStoreComeFromContext) {
|
|
1113
|
+
throw new Error(
|
|
1114
|
+
`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.`
|
|
1115
|
+
);
|
|
1116
|
+
}
|
|
1117
|
+
const store = didStoreComeFromProps ? props.store : contextValue.store;
|
|
1118
|
+
const getServerState = didStoreComeFromContext ? contextValue.getServerState : store.getState;
|
|
1119
|
+
const childPropsSelector = React.useMemo(() => {
|
|
1120
|
+
return finalPropsSelectorFactory(store.dispatch, selectorFactoryOptions);
|
|
1121
|
+
}, [store]);
|
|
1122
|
+
const [subscription, notifyNestedSubs] = React.useMemo(() => {
|
|
1123
|
+
if (!shouldHandleStateChanges)
|
|
1124
|
+
return NO_SUBSCRIPTION_ARRAY;
|
|
1125
|
+
const subscription2 = createSubscription(
|
|
1126
|
+
store,
|
|
1127
|
+
didStoreComeFromProps ? void 0 : contextValue.subscription
|
|
1128
|
+
);
|
|
1129
|
+
const notifyNestedSubs2 = subscription2.notifyNestedSubs.bind(subscription2);
|
|
1130
|
+
return [subscription2, notifyNestedSubs2];
|
|
1131
|
+
}, [store, didStoreComeFromProps, contextValue]);
|
|
1132
|
+
const overriddenContextValue = React.useMemo(() => {
|
|
1133
|
+
if (didStoreComeFromProps) {
|
|
1134
|
+
return contextValue;
|
|
1135
|
+
}
|
|
1136
|
+
return {
|
|
1137
|
+
...contextValue,
|
|
1138
|
+
subscription
|
|
1139
|
+
};
|
|
1140
|
+
}, [didStoreComeFromProps, contextValue, subscription]);
|
|
1141
|
+
const lastChildProps = React.useRef(void 0);
|
|
1142
|
+
const lastWrapperProps = React.useRef(wrapperProps);
|
|
1143
|
+
const childPropsFromStoreUpdate = React.useRef(void 0);
|
|
1144
|
+
const renderIsScheduled = React.useRef(false);
|
|
1145
|
+
const isMounted = React.useRef(false);
|
|
1146
|
+
const latestSubscriptionCallbackError = React.useRef(
|
|
1147
|
+
void 0
|
|
1148
|
+
);
|
|
1149
|
+
useIsomorphicLayoutEffect(() => {
|
|
1150
|
+
isMounted.current = true;
|
|
1151
|
+
return () => {
|
|
1152
|
+
isMounted.current = false;
|
|
1153
|
+
};
|
|
1154
|
+
}, []);
|
|
1155
|
+
const actualChildPropsSelector = React.useMemo(() => {
|
|
1156
|
+
const selector = () => {
|
|
1157
|
+
if (childPropsFromStoreUpdate.current && wrapperProps === lastWrapperProps.current) {
|
|
1158
|
+
return childPropsFromStoreUpdate.current;
|
|
1159
|
+
}
|
|
1160
|
+
return childPropsSelector(store.getState(), wrapperProps);
|
|
1161
|
+
};
|
|
1162
|
+
return selector;
|
|
1163
|
+
}, [store, wrapperProps]);
|
|
1164
|
+
const subscribeForReact = React.useMemo(() => {
|
|
1165
|
+
const subscribe = (reactListener) => {
|
|
1166
|
+
if (!subscription) {
|
|
1167
|
+
return () => {
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
return subscribeUpdates(
|
|
1171
|
+
shouldHandleStateChanges,
|
|
1172
|
+
store,
|
|
1173
|
+
subscription,
|
|
1174
|
+
// @ts-ignore
|
|
1175
|
+
childPropsSelector,
|
|
1176
|
+
lastWrapperProps,
|
|
1177
|
+
lastChildProps,
|
|
1178
|
+
renderIsScheduled,
|
|
1179
|
+
isMounted,
|
|
1180
|
+
childPropsFromStoreUpdate,
|
|
1181
|
+
notifyNestedSubs,
|
|
1182
|
+
reactListener
|
|
1183
|
+
);
|
|
1184
|
+
};
|
|
1185
|
+
return subscribe;
|
|
1186
|
+
}, [subscription]);
|
|
1187
|
+
useIsomorphicLayoutEffectWithArgs(captureWrapperProps, [
|
|
1188
|
+
lastWrapperProps,
|
|
1189
|
+
lastChildProps,
|
|
1190
|
+
renderIsScheduled,
|
|
1191
|
+
wrapperProps,
|
|
1192
|
+
childPropsFromStoreUpdate,
|
|
1193
|
+
notifyNestedSubs
|
|
1194
|
+
]);
|
|
1195
|
+
let actualChildProps;
|
|
1196
|
+
try {
|
|
1197
|
+
actualChildProps = useSyncExternalStore(
|
|
1198
|
+
// TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
|
|
1199
|
+
subscribeForReact,
|
|
1200
|
+
// TODO This is incredibly hacky. We've already processed the store update and calculated new child props,
|
|
1201
|
+
// TODO and we're just passing that through so it triggers a re-render for us rather than relying on `uSES`.
|
|
1202
|
+
actualChildPropsSelector,
|
|
1203
|
+
getServerState ? () => childPropsSelector(getServerState(), wrapperProps) : actualChildPropsSelector
|
|
1204
|
+
);
|
|
1205
|
+
} catch (err) {
|
|
1206
|
+
if (latestSubscriptionCallbackError.current) {
|
|
1207
|
+
err.message += `
|
|
1208
|
+
The error may be correlated with this previous error:
|
|
1209
|
+
${latestSubscriptionCallbackError.current.stack}
|
|
1210
|
+
|
|
1211
|
+
`;
|
|
1212
|
+
}
|
|
1213
|
+
throw err;
|
|
1214
|
+
}
|
|
1215
|
+
useIsomorphicLayoutEffect(() => {
|
|
1216
|
+
latestSubscriptionCallbackError.current = void 0;
|
|
1217
|
+
childPropsFromStoreUpdate.current = void 0;
|
|
1218
|
+
lastChildProps.current = actualChildProps;
|
|
1219
|
+
});
|
|
1220
|
+
const renderedWrappedComponent = React.useMemo(() => {
|
|
1221
|
+
return (
|
|
1222
|
+
// @ts-ignore
|
|
1223
|
+
/* @__PURE__ */ React.createElement(
|
|
1224
|
+
WrappedComponent,
|
|
1225
|
+
{
|
|
1226
|
+
...actualChildProps,
|
|
1227
|
+
ref: reactReduxForwardedRef
|
|
1228
|
+
}
|
|
1229
|
+
)
|
|
1230
|
+
);
|
|
1231
|
+
}, [reactReduxForwardedRef, WrappedComponent, actualChildProps]);
|
|
1232
|
+
const renderedChild = React.useMemo(() => {
|
|
1233
|
+
if (shouldHandleStateChanges) {
|
|
1234
|
+
return /* @__PURE__ */ React.createElement(ContextToUse.Provider, { value: overriddenContextValue }, renderedWrappedComponent);
|
|
1235
|
+
}
|
|
1236
|
+
return renderedWrappedComponent;
|
|
1237
|
+
}, [ContextToUse, renderedWrappedComponent, overriddenContextValue]);
|
|
1238
|
+
return renderedChild;
|
|
1239
|
+
}
|
|
1240
|
+
const _Connect = React.memo(ConnectFunction);
|
|
1241
|
+
const Connect = _Connect;
|
|
1242
|
+
Connect.WrappedComponent = WrappedComponent;
|
|
1243
|
+
Connect.displayName = ConnectFunction.displayName = displayName;
|
|
1244
|
+
if (forwardRef) {
|
|
1245
|
+
const _forwarded = React.forwardRef(
|
|
1246
|
+
function forwardConnectRef(props, ref) {
|
|
1247
|
+
return /* @__PURE__ */ React.createElement(Connect, { ...props, reactReduxForwardedRef: ref });
|
|
1248
|
+
}
|
|
1249
|
+
);
|
|
1250
|
+
const forwarded = _forwarded;
|
|
1251
|
+
forwarded.displayName = displayName;
|
|
1252
|
+
forwarded.WrappedComponent = WrappedComponent;
|
|
1253
|
+
return /* @__PURE__ */ hoistNonReactStatics(forwarded, WrappedComponent);
|
|
1254
|
+
}
|
|
1255
|
+
return /* @__PURE__ */ hoistNonReactStatics(Connect, WrappedComponent);
|
|
1256
|
+
};
|
|
1257
|
+
return wrapWithConnect;
|
|
1258
|
+
}
|
|
1259
|
+
var connect_default = connect;
|
|
1260
|
+
|
|
1261
|
+
// src/components/Provider.tsx
|
|
1262
|
+
function Provider({
|
|
1263
|
+
store,
|
|
1264
|
+
context,
|
|
1265
|
+
children,
|
|
1266
|
+
serverState,
|
|
1267
|
+
stabilityCheck = "once",
|
|
1268
|
+
identityFunctionCheck = "once"
|
|
1269
|
+
}) {
|
|
1270
|
+
const contextValue = React.useMemo(() => {
|
|
1271
|
+
const subscription = createSubscription(store);
|
|
1272
|
+
return {
|
|
1273
|
+
store,
|
|
1274
|
+
subscription,
|
|
1275
|
+
getServerState: serverState ? () => serverState : void 0,
|
|
1276
|
+
stabilityCheck,
|
|
1277
|
+
identityFunctionCheck
|
|
1278
|
+
};
|
|
1279
|
+
}, [store, serverState, stabilityCheck, identityFunctionCheck]);
|
|
1280
|
+
const previousState = React.useMemo(() => store.getState(), [store]);
|
|
1281
|
+
useIsomorphicLayoutEffect(() => {
|
|
1282
|
+
const { subscription } = contextValue;
|
|
1283
|
+
subscription.onStateChange = subscription.notifyNestedSubs;
|
|
1284
|
+
subscription.trySubscribe();
|
|
1285
|
+
if (previousState !== store.getState()) {
|
|
1286
|
+
subscription.notifyNestedSubs();
|
|
1287
|
+
}
|
|
1288
|
+
return () => {
|
|
1289
|
+
subscription.tryUnsubscribe();
|
|
1290
|
+
subscription.onStateChange = void 0;
|
|
1291
|
+
};
|
|
1292
|
+
}, [contextValue, previousState]);
|
|
1293
|
+
const Context = context || ReactReduxContext;
|
|
1294
|
+
return /* @__PURE__ */ React.createElement(Context.Provider, { value: contextValue }, children);
|
|
1295
|
+
}
|
|
1296
|
+
var Provider_default = Provider;
|
|
1297
|
+
|
|
1298
|
+
// src/hooks/useStore.ts
|
|
1299
|
+
function createStoreHook(context = ReactReduxContext) {
|
|
1300
|
+
const useReduxContext2 = context === ReactReduxContext ? useReduxContext : (
|
|
1301
|
+
// @ts-ignore
|
|
1302
|
+
createReduxContextHook(context)
|
|
1303
|
+
);
|
|
1304
|
+
const useStore2 = () => {
|
|
1305
|
+
const { store } = useReduxContext2();
|
|
1306
|
+
return store;
|
|
1307
|
+
};
|
|
1308
|
+
Object.assign(useStore2, {
|
|
1309
|
+
withTypes: () => useStore2
|
|
1310
|
+
});
|
|
1311
|
+
return useStore2;
|
|
1312
|
+
}
|
|
1313
|
+
var useStore = /* @__PURE__ */ createStoreHook();
|
|
1314
|
+
|
|
1315
|
+
// src/hooks/useDispatch.ts
|
|
1316
|
+
function createDispatchHook(context = ReactReduxContext) {
|
|
1317
|
+
const useStore2 = context === ReactReduxContext ? useStore : createStoreHook(context);
|
|
1318
|
+
const useDispatch2 = () => {
|
|
1319
|
+
const store = useStore2();
|
|
1320
|
+
return store.dispatch;
|
|
1321
|
+
};
|
|
1322
|
+
Object.assign(useDispatch2, {
|
|
1323
|
+
withTypes: () => useDispatch2
|
|
1324
|
+
});
|
|
1325
|
+
return useDispatch2;
|
|
1326
|
+
}
|
|
1327
|
+
var useDispatch = /* @__PURE__ */ createDispatchHook();
|
|
1328
|
+
|
|
1329
|
+
// src/exports.ts
|
|
1330
|
+
var batch = defaultNoopBatch;
|
|
1331
|
+
|
|
1332
|
+
// src/index.ts
|
|
1333
|
+
initializeUseSelector(withSelectorExports.useSyncExternalStoreWithSelector);
|
|
1334
|
+
initializeConnect(ReactOriginal__namespace.useSyncExternalStore);
|
|
1335
|
+
|
|
1336
|
+
exports.Provider = Provider_default;
|
|
1337
|
+
exports.ReactReduxContext = ReactReduxContext;
|
|
1338
|
+
exports.batch = batch;
|
|
1339
|
+
exports.connect = connect_default;
|
|
1340
|
+
exports.createDispatchHook = createDispatchHook;
|
|
1341
|
+
exports.createSelectorHook = createSelectorHook;
|
|
1342
|
+
exports.createStoreHook = createStoreHook;
|
|
1343
|
+
exports.shallowEqual = shallowEqual;
|
|
1344
|
+
exports.useDispatch = useDispatch;
|
|
1345
|
+
exports.useSelector = useSelector;
|
|
1346
|
+
exports.useStore = useStore;
|
|
1347
|
+
//# sourceMappingURL=index.cjs.js.map
|