pocketbase-react 0.1.0 → 0.1.2
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/CHANGELOG.md +4 -1
- package/README.md +15 -0
- package/dist/pocketbase-react.js +492 -0
- package/dist/pocketbase-react.min.js +1 -0
- package/{dist/esm → es}/context/Pocketbase.d.ts +1 -3
- package/es/context/Pocketbase.js +28 -0
- package/{dist/cjs → es}/context/client.d.ts +1 -1
- package/es/context/client.js +8 -0
- package/{dist/cjs → es}/context/content.d.ts +0 -0
- package/es/context/content.js +67 -0
- package/{dist/cjs → es}/context/index.d.ts +0 -0
- package/es/context/index.js +3 -0
- package/{dist/cjs → es}/hooks/index.d.ts +0 -0
- package/es/hooks/index.js +2 -0
- package/{dist/cjs → es}/hooks/useAppContent.d.ts +1 -1
- package/es/hooks/useAppContent.js +26 -0
- package/es/hooks/useClientContext.d.ts +2 -0
- package/es/hooks/useClientContext.js +9 -0
- package/{dist/cjs → es}/index.d.ts +0 -0
- package/{dist/esm/index.d.ts → es/index.js} +1 -1
- package/{dist/cjs → es}/interfaces/Record.d.ts +1 -1
- package/es/interfaces/Record.js +1 -0
- package/{dist/cjs → es}/interfaces/index.d.ts +0 -0
- package/es/interfaces/index.js +1 -0
- package/es/store/actions/index.d.ts +2 -0
- package/es/store/actions/index.js +2 -0
- package/es/store/actions/records.d.ts +9 -0
- package/es/store/actions/records.js +39 -0
- package/{dist/cjs → es}/store/index.d.ts +0 -0
- package/{dist/esm/store/index.d.ts → es/store/index.js} +1 -1
- package/{dist/cjs → es}/store/reducers/index.d.ts +2 -2
- package/es/store/reducers/index.js +5 -0
- package/{dist/cjs → es}/store/reducers/records.d.ts +2 -3
- package/es/store/reducers/records.js +71 -0
- package/{dist/cjs → es}/store/store.d.ts +1 -1
- package/es/store/store.js +46 -0
- package/{dist/cjs → es}/store/types/index.d.ts +0 -0
- package/es/store/types/index.js +6 -0
- package/lib/context/Pocketbase.js +49 -0
- package/lib/context/client.js +21 -0
- package/lib/context/content.js +83 -0
- package/lib/context/index.js +42 -0
- package/lib/hooks/index.js +29 -0
- package/lib/hooks/useAppContent.js +38 -0
- package/lib/hooks/useClientContext.js +15 -0
- package/lib/index.js +55 -0
- package/lib/interfaces/Record.js +1 -0
- package/lib/interfaces/index.js +16 -0
- package/lib/store/actions/index.js +12 -0
- package/lib/store/actions/records.js +58 -0
- package/lib/store/index.js +55 -0
- package/lib/store/reducers/index.js +13 -0
- package/lib/store/reducers/records.js +85 -0
- package/lib/store/store.js +63 -0
- package/lib/store/types/index.js +16 -0
- package/package.json +94 -35
- package/src/context/Pocketbase.tsx +43 -0
- package/src/context/client.tsx +14 -0
- package/src/context/content.tsx +88 -0
- package/{dist/esm/context/index.d.ts → src/context/index.ts} +0 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useAppContent.ts +28 -0
- package/src/hooks/useClientContext.ts +11 -0
- package/src/index.ts +4 -0
- package/src/interfaces/Record.ts +10 -0
- package/src/interfaces/index.ts +1 -0
- package/src/store/actions/index.tsx +3 -0
- package/src/store/actions/records.tsx +54 -0
- package/src/store/index.ts +4 -0
- package/src/store/reducers/index.tsx +12 -0
- package/src/store/reducers/records.tsx +78 -0
- package/src/store/store.tsx +67 -0
- package/src/store/types/index.ts +14 -0
- package/dist/cjs/EventSource.d.ts +0 -1
- package/dist/cjs/context/Pocketbase.d.ts +0 -15
- package/dist/cjs/hooks/useClientContext.d.ts +0 -2
- package/dist/cjs/index.js +0 -3477
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/store/actions/index.d.ts +0 -2
- package/dist/cjs/store/actions/records.d.ts +0 -11
- package/dist/esm/EventSource.d.ts +0 -1
- package/dist/esm/context/client.d.ts +0 -8
- package/dist/esm/context/content.d.ts +0 -16
- package/dist/esm/hooks/index.d.ts +0 -2
- package/dist/esm/hooks/useAppContent.d.ts +0 -12
- package/dist/esm/hooks/useClientContext.d.ts +0 -2
- package/dist/esm/index.js +0 -3432
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/interfaces/Record.d.ts +0 -10
- package/dist/esm/interfaces/index.d.ts +0 -1
- package/dist/esm/store/actions/index.d.ts +0 -2
- package/dist/esm/store/actions/records.d.ts +0 -11
- package/dist/esm/store/reducers/index.d.ts +0 -8
- package/dist/esm/store/reducers/records.d.ts +0 -12
- package/dist/esm/store/store.d.ts +0 -27
- package/dist/esm/store/types/index.d.ts +0 -7
- package/dist/index.d.ts +0 -128
package/dist/esm/index.js
DELETED
|
@@ -1,3432 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import React__default, { createContext, useContext, useDebugValue, useLayoutEffect, useEffect, useMemo } from 'react';
|
|
3
|
-
import { unstable_batchedUpdates } from 'react-dom';
|
|
4
|
-
import PocketBase from 'pocketbase/dist/pocketbase.cjs';
|
|
5
|
-
|
|
6
|
-
/******************************************************************************
|
|
7
|
-
Copyright (c) Microsoft Corporation.
|
|
8
|
-
|
|
9
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
purpose with or without fee is hereby granted.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
-
***************************************************************************** */
|
|
20
|
-
|
|
21
|
-
var __assign = function() {
|
|
22
|
-
__assign = Object.assign || function __assign(t) {
|
|
23
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
24
|
-
s = arguments[i];
|
|
25
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
26
|
-
}
|
|
27
|
-
return t;
|
|
28
|
-
};
|
|
29
|
-
return __assign.apply(this, arguments);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
33
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
34
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
35
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
36
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
37
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
38
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function __generator(thisArg, body) {
|
|
43
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
44
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
45
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
46
|
-
function step(op) {
|
|
47
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
48
|
-
while (_) try {
|
|
49
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
50
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
51
|
-
switch (op[0]) {
|
|
52
|
-
case 0: case 1: t = op; break;
|
|
53
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
54
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
55
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
56
|
-
default:
|
|
57
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
58
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
59
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
60
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
61
|
-
if (t[2]) _.ops.pop();
|
|
62
|
-
_.trys.pop(); continue;
|
|
63
|
-
}
|
|
64
|
-
op = body.call(thisArg, _);
|
|
65
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
66
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function __spreadArray$1(to, from, pack) {
|
|
71
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
72
|
-
if (ar || !(i in from)) {
|
|
73
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
74
|
-
ar[i] = from[i];
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
var SET_RECORDS = 'SET_RECORDS';
|
|
81
|
-
var ADD_RECORD = 'ADD_RECORD';
|
|
82
|
-
var ADD_RECORDS = 'ADD_RECORDS';
|
|
83
|
-
var UPDATE_RECORD = 'UPDATE_RECORD';
|
|
84
|
-
var DELETE_RECORD = 'DELETE_RECORD';
|
|
85
|
-
var DELETE_RECORDS = 'DELETE_RECORDS';
|
|
86
|
-
|
|
87
|
-
var setRecords = function (key, payload) {
|
|
88
|
-
return ({
|
|
89
|
-
type: SET_RECORDS,
|
|
90
|
-
key: key,
|
|
91
|
-
payload: payload,
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
var addRecord = function (key, payload) {
|
|
95
|
-
return ({
|
|
96
|
-
type: ADD_RECORD,
|
|
97
|
-
key: key,
|
|
98
|
-
payload: payload,
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
var addRecords = function (key, payload) {
|
|
102
|
-
return ({
|
|
103
|
-
type: ADD_RECORDS,
|
|
104
|
-
key: key,
|
|
105
|
-
payload: payload,
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
var deleteRecord$1 = function (key, payload) {
|
|
109
|
-
return ({
|
|
110
|
-
type: DELETE_RECORD,
|
|
111
|
-
key: key,
|
|
112
|
-
payload: payload,
|
|
113
|
-
});
|
|
114
|
-
};
|
|
115
|
-
var deleteRecords$1 = function (key, payload) {
|
|
116
|
-
return ({
|
|
117
|
-
type: DELETE_RECORDS,
|
|
118
|
-
key: key,
|
|
119
|
-
payload: payload,
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
var updateRecord$1 = function (key, payload) {
|
|
123
|
-
return ({
|
|
124
|
-
type: UPDATE_RECORD,
|
|
125
|
-
key: key,
|
|
126
|
-
payload: payload,
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
var recordsAction = {
|
|
130
|
-
setRecords: setRecords,
|
|
131
|
-
addRecord: addRecord,
|
|
132
|
-
addRecords: addRecords,
|
|
133
|
-
deleteRecord: deleteRecord$1,
|
|
134
|
-
deleteRecords: deleteRecords$1,
|
|
135
|
-
updateRecord: updateRecord$1,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
function _defineProperty$4(obj, key, value) {
|
|
139
|
-
if (key in obj) {
|
|
140
|
-
Object.defineProperty(obj, key, {
|
|
141
|
-
value: value,
|
|
142
|
-
enumerable: true,
|
|
143
|
-
configurable: true,
|
|
144
|
-
writable: true
|
|
145
|
-
});
|
|
146
|
-
} else {
|
|
147
|
-
obj[key] = value;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return obj;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function ownKeys$3(object, enumerableOnly) {
|
|
154
|
-
var keys = Object.keys(object);
|
|
155
|
-
|
|
156
|
-
if (Object.getOwnPropertySymbols) {
|
|
157
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
158
|
-
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
159
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
160
|
-
})), keys.push.apply(keys, symbols);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return keys;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function _objectSpread2(target) {
|
|
167
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
168
|
-
var source = null != arguments[i] ? arguments[i] : {};
|
|
169
|
-
i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) {
|
|
170
|
-
_defineProperty$4(target, key, source[key]);
|
|
171
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) {
|
|
172
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return target;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
|
|
181
|
-
*
|
|
182
|
-
* Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
|
|
183
|
-
* during build.
|
|
184
|
-
* @param {number} code
|
|
185
|
-
*/
|
|
186
|
-
function formatProdErrorMessage(code) {
|
|
187
|
-
return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Inlined version of the `symbol-observable` polyfill
|
|
191
|
-
var $$observable = (function () {
|
|
192
|
-
return typeof Symbol === 'function' && Symbol.observable || '@@observable';
|
|
193
|
-
})();
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* These are private action types reserved by Redux.
|
|
197
|
-
* For any unknown actions, you must return the current state.
|
|
198
|
-
* If the current state is undefined, you must return the initial state.
|
|
199
|
-
* Do not reference these action types directly in your code.
|
|
200
|
-
*/
|
|
201
|
-
var randomString = function randomString() {
|
|
202
|
-
return Math.random().toString(36).substring(7).split('').join('.');
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
var ActionTypes = {
|
|
206
|
-
INIT: "@@redux/INIT" + randomString(),
|
|
207
|
-
REPLACE: "@@redux/REPLACE" + randomString(),
|
|
208
|
-
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
|
209
|
-
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* @param {any} obj The object to inspect.
|
|
215
|
-
* @returns {boolean} True if the argument appears to be a plain object.
|
|
216
|
-
*/
|
|
217
|
-
function isPlainObject$1(obj) {
|
|
218
|
-
if (typeof obj !== 'object' || obj === null) return false;
|
|
219
|
-
var proto = obj;
|
|
220
|
-
|
|
221
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
222
|
-
proto = Object.getPrototypeOf(proto);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return Object.getPrototypeOf(obj) === proto;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
|
|
229
|
-
function miniKindOf(val) {
|
|
230
|
-
if (val === void 0) return 'undefined';
|
|
231
|
-
if (val === null) return 'null';
|
|
232
|
-
var type = typeof val;
|
|
233
|
-
|
|
234
|
-
switch (type) {
|
|
235
|
-
case 'boolean':
|
|
236
|
-
case 'string':
|
|
237
|
-
case 'number':
|
|
238
|
-
case 'symbol':
|
|
239
|
-
case 'function':
|
|
240
|
-
{
|
|
241
|
-
return type;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (Array.isArray(val)) return 'array';
|
|
246
|
-
if (isDate(val)) return 'date';
|
|
247
|
-
if (isError(val)) return 'error';
|
|
248
|
-
var constructorName = ctorName(val);
|
|
249
|
-
|
|
250
|
-
switch (constructorName) {
|
|
251
|
-
case 'Symbol':
|
|
252
|
-
case 'Promise':
|
|
253
|
-
case 'WeakMap':
|
|
254
|
-
case 'WeakSet':
|
|
255
|
-
case 'Map':
|
|
256
|
-
case 'Set':
|
|
257
|
-
return constructorName;
|
|
258
|
-
} // other
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function ctorName(val) {
|
|
265
|
-
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
function isError(val) {
|
|
269
|
-
return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function isDate(val) {
|
|
273
|
-
if (val instanceof Date) return true;
|
|
274
|
-
return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function kindOf(val) {
|
|
278
|
-
var typeOfVal = typeof val;
|
|
279
|
-
|
|
280
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
281
|
-
typeOfVal = miniKindOf(val);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return typeOfVal;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* @deprecated
|
|
289
|
-
*
|
|
290
|
-
* **We recommend using the `configureStore` method
|
|
291
|
-
* of the `@reduxjs/toolkit` package**, which replaces `createStore`.
|
|
292
|
-
*
|
|
293
|
-
* Redux Toolkit is our recommended approach for writing Redux logic today,
|
|
294
|
-
* including store setup, reducers, data fetching, and more.
|
|
295
|
-
*
|
|
296
|
-
* **For more details, please read this Redux docs page:**
|
|
297
|
-
* **https://redux.js.org/introduction/why-rtk-is-redux-today**
|
|
298
|
-
*
|
|
299
|
-
* `configureStore` from Redux Toolkit is an improved version of `createStore` that
|
|
300
|
-
* simplifies setup and helps avoid common bugs.
|
|
301
|
-
*
|
|
302
|
-
* You should not be using the `redux` core package by itself today, except for learning purposes.
|
|
303
|
-
* The `createStore` method from the core `redux` package will not be removed, but we encourage
|
|
304
|
-
* all users to migrate to using Redux Toolkit for all Redux code.
|
|
305
|
-
*
|
|
306
|
-
* If you want to use `createStore` without this visual deprecation warning, use
|
|
307
|
-
* the `legacy_createStore` import instead:
|
|
308
|
-
*
|
|
309
|
-
* `import { legacy_createStore as createStore} from 'redux'`
|
|
310
|
-
*
|
|
311
|
-
*/
|
|
312
|
-
|
|
313
|
-
function createStore(reducer, preloadedState, enhancer) {
|
|
314
|
-
var _ref2;
|
|
315
|
-
|
|
316
|
-
if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
|
|
317
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(0) : 'It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.');
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
|
|
321
|
-
enhancer = preloadedState;
|
|
322
|
-
preloadedState = undefined;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (typeof enhancer !== 'undefined') {
|
|
326
|
-
if (typeof enhancer !== 'function') {
|
|
327
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
return enhancer(createStore)(reducer, preloadedState);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (typeof reducer !== 'function') {
|
|
334
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
var currentReducer = reducer;
|
|
338
|
-
var currentState = preloadedState;
|
|
339
|
-
var currentListeners = [];
|
|
340
|
-
var nextListeners = currentListeners;
|
|
341
|
-
var isDispatching = false;
|
|
342
|
-
/**
|
|
343
|
-
* This makes a shallow copy of currentListeners so we can use
|
|
344
|
-
* nextListeners as a temporary list while dispatching.
|
|
345
|
-
*
|
|
346
|
-
* This prevents any bugs around consumers calling
|
|
347
|
-
* subscribe/unsubscribe in the middle of a dispatch.
|
|
348
|
-
*/
|
|
349
|
-
|
|
350
|
-
function ensureCanMutateNextListeners() {
|
|
351
|
-
if (nextListeners === currentListeners) {
|
|
352
|
-
nextListeners = currentListeners.slice();
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Reads the state tree managed by the store.
|
|
357
|
-
*
|
|
358
|
-
* @returns {any} The current state tree of your application.
|
|
359
|
-
*/
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
function getState() {
|
|
363
|
-
if (isDispatching) {
|
|
364
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(3) : 'You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return currentState;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Adds a change listener. It will be called any time an action is dispatched,
|
|
371
|
-
* and some part of the state tree may potentially have changed. You may then
|
|
372
|
-
* call `getState()` to read the current state tree inside the callback.
|
|
373
|
-
*
|
|
374
|
-
* You may call `dispatch()` from a change listener, with the following
|
|
375
|
-
* caveats:
|
|
376
|
-
*
|
|
377
|
-
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
|
|
378
|
-
* If you subscribe or unsubscribe while the listeners are being invoked, this
|
|
379
|
-
* will not have any effect on the `dispatch()` that is currently in progress.
|
|
380
|
-
* However, the next `dispatch()` call, whether nested or not, will use a more
|
|
381
|
-
* recent snapshot of the subscription list.
|
|
382
|
-
*
|
|
383
|
-
* 2. The listener should not expect to see all state changes, as the state
|
|
384
|
-
* might have been updated multiple times during a nested `dispatch()` before
|
|
385
|
-
* the listener is called. It is, however, guaranteed that all subscribers
|
|
386
|
-
* registered before the `dispatch()` started will be called with the latest
|
|
387
|
-
* state by the time it exits.
|
|
388
|
-
*
|
|
389
|
-
* @param {Function} listener A callback to be invoked on every dispatch.
|
|
390
|
-
* @returns {Function} A function to remove this change listener.
|
|
391
|
-
*/
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
function subscribe(listener) {
|
|
395
|
-
if (typeof listener !== 'function') {
|
|
396
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener) + "'");
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if (isDispatching) {
|
|
400
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(5) : 'You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
var isSubscribed = true;
|
|
404
|
-
ensureCanMutateNextListeners();
|
|
405
|
-
nextListeners.push(listener);
|
|
406
|
-
return function unsubscribe() {
|
|
407
|
-
if (!isSubscribed) {
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (isDispatching) {
|
|
412
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(6) : 'You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api/store#subscribelistener for more details.');
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
isSubscribed = false;
|
|
416
|
-
ensureCanMutateNextListeners();
|
|
417
|
-
var index = nextListeners.indexOf(listener);
|
|
418
|
-
nextListeners.splice(index, 1);
|
|
419
|
-
currentListeners = null;
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Dispatches an action. It is the only way to trigger a state change.
|
|
424
|
-
*
|
|
425
|
-
* The `reducer` function, used to create the store, will be called with the
|
|
426
|
-
* current state tree and the given `action`. Its return value will
|
|
427
|
-
* be considered the **next** state of the tree, and the change listeners
|
|
428
|
-
* will be notified.
|
|
429
|
-
*
|
|
430
|
-
* The base implementation only supports plain object actions. If you want to
|
|
431
|
-
* dispatch a Promise, an Observable, a thunk, or something else, you need to
|
|
432
|
-
* wrap your store creating function into the corresponding middleware. For
|
|
433
|
-
* example, see the documentation for the `redux-thunk` package. Even the
|
|
434
|
-
* middleware will eventually dispatch plain object actions using this method.
|
|
435
|
-
*
|
|
436
|
-
* @param {Object} action A plain object representing “what changed”. It is
|
|
437
|
-
* a good idea to keep actions serializable so you can record and replay user
|
|
438
|
-
* sessions, or use the time travelling `redux-devtools`. An action must have
|
|
439
|
-
* a `type` property which may not be `undefined`. It is a good idea to use
|
|
440
|
-
* string constants for action types.
|
|
441
|
-
*
|
|
442
|
-
* @returns {Object} For convenience, the same action object you dispatched.
|
|
443
|
-
*
|
|
444
|
-
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
|
|
445
|
-
* return something else (for example, a Promise you can await).
|
|
446
|
-
*/
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
function dispatch(action) {
|
|
450
|
-
if (!isPlainObject$1(action)) {
|
|
451
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
if (typeof action.type === 'undefined') {
|
|
455
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
if (isDispatching) {
|
|
459
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(9) : 'Reducers may not dispatch actions.');
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
try {
|
|
463
|
-
isDispatching = true;
|
|
464
|
-
currentState = currentReducer(currentState, action);
|
|
465
|
-
} finally {
|
|
466
|
-
isDispatching = false;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
var listeners = currentListeners = nextListeners;
|
|
470
|
-
|
|
471
|
-
for (var i = 0; i < listeners.length; i++) {
|
|
472
|
-
var listener = listeners[i];
|
|
473
|
-
listener();
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
return action;
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Replaces the reducer currently used by the store to calculate the state.
|
|
480
|
-
*
|
|
481
|
-
* You might need this if your app implements code splitting and you want to
|
|
482
|
-
* load some of the reducers dynamically. You might also need this if you
|
|
483
|
-
* implement a hot reloading mechanism for Redux.
|
|
484
|
-
*
|
|
485
|
-
* @param {Function} nextReducer The reducer for the store to use instead.
|
|
486
|
-
* @returns {void}
|
|
487
|
-
*/
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
function replaceReducer(nextReducer) {
|
|
491
|
-
if (typeof nextReducer !== 'function') {
|
|
492
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
|
|
496
|
-
// Any reducers that existed in both the new and old rootReducer
|
|
497
|
-
// will receive the previous state. This effectively populates
|
|
498
|
-
// the new state tree with any relevant data from the old one.
|
|
499
|
-
|
|
500
|
-
dispatch({
|
|
501
|
-
type: ActionTypes.REPLACE
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Interoperability point for observable/reactive libraries.
|
|
506
|
-
* @returns {observable} A minimal observable of state changes.
|
|
507
|
-
* For more information, see the observable proposal:
|
|
508
|
-
* https://github.com/tc39/proposal-observable
|
|
509
|
-
*/
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
function observable() {
|
|
513
|
-
var _ref;
|
|
514
|
-
|
|
515
|
-
var outerSubscribe = subscribe;
|
|
516
|
-
return _ref = {
|
|
517
|
-
/**
|
|
518
|
-
* The minimal observable subscription method.
|
|
519
|
-
* @param {Object} observer Any object that can be used as an observer.
|
|
520
|
-
* The observer object should have a `next` method.
|
|
521
|
-
* @returns {subscription} An object with an `unsubscribe` method that can
|
|
522
|
-
* be used to unsubscribe the observable from the store, and prevent further
|
|
523
|
-
* emission of values from the observable.
|
|
524
|
-
*/
|
|
525
|
-
subscribe: function subscribe(observer) {
|
|
526
|
-
if (typeof observer !== 'object' || observer === null) {
|
|
527
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
function observeState() {
|
|
531
|
-
if (observer.next) {
|
|
532
|
-
observer.next(getState());
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
observeState();
|
|
537
|
-
var unsubscribe = outerSubscribe(observeState);
|
|
538
|
-
return {
|
|
539
|
-
unsubscribe: unsubscribe
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
}, _ref[$$observable] = function () {
|
|
543
|
-
return this;
|
|
544
|
-
}, _ref;
|
|
545
|
-
} // When a store is created, an "INIT" action is dispatched so that every
|
|
546
|
-
// reducer returns their initial state. This effectively populates
|
|
547
|
-
// the initial state tree.
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
dispatch({
|
|
551
|
-
type: ActionTypes.INIT
|
|
552
|
-
});
|
|
553
|
-
return _ref2 = {
|
|
554
|
-
dispatch: dispatch,
|
|
555
|
-
subscribe: subscribe,
|
|
556
|
-
getState: getState,
|
|
557
|
-
replaceReducer: replaceReducer
|
|
558
|
-
}, _ref2[$$observable] = observable, _ref2;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Prints a warning in the console if it exists.
|
|
563
|
-
*
|
|
564
|
-
* @param {String} message The warning message.
|
|
565
|
-
* @returns {void}
|
|
566
|
-
*/
|
|
567
|
-
function warning(message) {
|
|
568
|
-
/* eslint-disable no-console */
|
|
569
|
-
if (typeof console !== 'undefined' && typeof console.error === 'function') {
|
|
570
|
-
console.error(message);
|
|
571
|
-
}
|
|
572
|
-
/* eslint-enable no-console */
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
try {
|
|
576
|
-
// This error was thrown as a convenience so that if you enable
|
|
577
|
-
// "break on all exceptions" in your console,
|
|
578
|
-
// it would pause the execution at this line.
|
|
579
|
-
throw new Error(message);
|
|
580
|
-
} catch (e) {} // eslint-disable-line no-empty
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
|
585
|
-
var reducerKeys = Object.keys(reducers);
|
|
586
|
-
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
|
|
587
|
-
|
|
588
|
-
if (reducerKeys.length === 0) {
|
|
589
|
-
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
if (!isPlainObject$1(inputState)) {
|
|
593
|
-
return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
|
|
597
|
-
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
|
598
|
-
});
|
|
599
|
-
unexpectedKeys.forEach(function (key) {
|
|
600
|
-
unexpectedKeyCache[key] = true;
|
|
601
|
-
});
|
|
602
|
-
if (action && action.type === ActionTypes.REPLACE) return;
|
|
603
|
-
|
|
604
|
-
if (unexpectedKeys.length > 0) {
|
|
605
|
-
return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function assertReducerShape(reducers) {
|
|
610
|
-
Object.keys(reducers).forEach(function (key) {
|
|
611
|
-
var reducer = reducers[key];
|
|
612
|
-
var initialState = reducer(undefined, {
|
|
613
|
-
type: ActionTypes.INIT
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
if (typeof initialState === 'undefined') {
|
|
617
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : "The slice reducer for key \"" + key + "\" returned undefined during initialization. " + "If the state passed to the reducer is undefined, you must " + "explicitly return the initial state. The initial state may " + "not be undefined. If you don't want to set a value for this reducer, " + "you can use null instead of undefined.");
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
if (typeof reducer(undefined, {
|
|
621
|
-
type: ActionTypes.PROBE_UNKNOWN_ACTION()
|
|
622
|
-
}) === 'undefined') {
|
|
623
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : "The slice reducer for key \"" + key + "\" returned undefined when probed with a random type. " + ("Don't try to handle '" + ActionTypes.INIT + "' or other actions in \"redux/*\" ") + "namespace. They are considered private. Instead, you must return the " + "current state for any unknown actions, unless it is undefined, " + "in which case you must return the initial state, regardless of the " + "action type. The initial state may not be undefined, but can be null.");
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Turns an object whose values are different reducer functions, into a single
|
|
629
|
-
* reducer function. It will call every child reducer, and gather their results
|
|
630
|
-
* into a single state object, whose keys correspond to the keys of the passed
|
|
631
|
-
* reducer functions.
|
|
632
|
-
*
|
|
633
|
-
* @param {Object} reducers An object whose values correspond to different
|
|
634
|
-
* reducer functions that need to be combined into one. One handy way to obtain
|
|
635
|
-
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
|
|
636
|
-
* undefined for any action. Instead, they should return their initial state
|
|
637
|
-
* if the state passed to them was undefined, and the current state for any
|
|
638
|
-
* unrecognized action.
|
|
639
|
-
*
|
|
640
|
-
* @returns {Function} A reducer function that invokes every reducer inside the
|
|
641
|
-
* passed object, and builds a state object with the same shape.
|
|
642
|
-
*/
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
function combineReducers(reducers) {
|
|
646
|
-
var reducerKeys = Object.keys(reducers);
|
|
647
|
-
var finalReducers = {};
|
|
648
|
-
|
|
649
|
-
for (var i = 0; i < reducerKeys.length; i++) {
|
|
650
|
-
var key = reducerKeys[i];
|
|
651
|
-
|
|
652
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
653
|
-
if (typeof reducers[key] === 'undefined') {
|
|
654
|
-
warning("No reducer provided for key \"" + key + "\"");
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
if (typeof reducers[key] === 'function') {
|
|
659
|
-
finalReducers[key] = reducers[key];
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
|
|
664
|
-
// keys multiple times.
|
|
665
|
-
|
|
666
|
-
var unexpectedKeyCache;
|
|
667
|
-
|
|
668
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
669
|
-
unexpectedKeyCache = {};
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
var shapeAssertionError;
|
|
673
|
-
|
|
674
|
-
try {
|
|
675
|
-
assertReducerShape(finalReducers);
|
|
676
|
-
} catch (e) {
|
|
677
|
-
shapeAssertionError = e;
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
return function combination(state, action) {
|
|
681
|
-
if (state === void 0) {
|
|
682
|
-
state = {};
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
if (shapeAssertionError) {
|
|
686
|
-
throw shapeAssertionError;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
690
|
-
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
|
691
|
-
|
|
692
|
-
if (warningMessage) {
|
|
693
|
-
warning(warningMessage);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
var hasChanged = false;
|
|
698
|
-
var nextState = {};
|
|
699
|
-
|
|
700
|
-
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
|
701
|
-
var _key = finalReducerKeys[_i];
|
|
702
|
-
var reducer = finalReducers[_key];
|
|
703
|
-
var previousStateForKey = state[_key];
|
|
704
|
-
var nextStateForKey = reducer(previousStateForKey, action);
|
|
705
|
-
|
|
706
|
-
if (typeof nextStateForKey === 'undefined') {
|
|
707
|
-
var actionType = action && action.type;
|
|
708
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : "When called with an action of type " + (actionType ? "\"" + String(actionType) + "\"" : '(unknown type)') + ", the slice reducer for key \"" + _key + "\" returned undefined. " + "To ignore an action, you must explicitly return the previous state. " + "If you want this reducer to hold no value, you can return null instead of undefined.");
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
nextState[_key] = nextStateForKey;
|
|
712
|
-
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
716
|
-
return hasChanged ? nextState : state;
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
/**
|
|
721
|
-
* Composes single-argument functions from right to left. The rightmost
|
|
722
|
-
* function can take multiple arguments as it provides the signature for
|
|
723
|
-
* the resulting composite function.
|
|
724
|
-
*
|
|
725
|
-
* @param {...Function} funcs The functions to compose.
|
|
726
|
-
* @returns {Function} A function obtained by composing the argument functions
|
|
727
|
-
* from right to left. For example, compose(f, g, h) is identical to doing
|
|
728
|
-
* (...args) => f(g(h(...args))).
|
|
729
|
-
*/
|
|
730
|
-
function compose() {
|
|
731
|
-
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
732
|
-
funcs[_key] = arguments[_key];
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
if (funcs.length === 0) {
|
|
736
|
-
return function (arg) {
|
|
737
|
-
return arg;
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
if (funcs.length === 1) {
|
|
742
|
-
return funcs[0];
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
return funcs.reduce(function (a, b) {
|
|
746
|
-
return function () {
|
|
747
|
-
return a(b.apply(void 0, arguments));
|
|
748
|
-
};
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
* Creates a store enhancer that applies middleware to the dispatch method
|
|
754
|
-
* of the Redux store. This is handy for a variety of tasks, such as expressing
|
|
755
|
-
* asynchronous actions in a concise manner, or logging every action payload.
|
|
756
|
-
*
|
|
757
|
-
* See `redux-thunk` package as an example of the Redux middleware.
|
|
758
|
-
*
|
|
759
|
-
* Because middleware is potentially asynchronous, this should be the first
|
|
760
|
-
* store enhancer in the composition chain.
|
|
761
|
-
*
|
|
762
|
-
* Note that each middleware will be given the `dispatch` and `getState` functions
|
|
763
|
-
* as named arguments.
|
|
764
|
-
*
|
|
765
|
-
* @param {...Function} middlewares The middleware chain to be applied.
|
|
766
|
-
* @returns {Function} A store enhancer applying the middleware.
|
|
767
|
-
*/
|
|
768
|
-
|
|
769
|
-
function applyMiddleware() {
|
|
770
|
-
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
771
|
-
middlewares[_key] = arguments[_key];
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
return function (createStore) {
|
|
775
|
-
return function () {
|
|
776
|
-
var store = createStore.apply(void 0, arguments);
|
|
777
|
-
|
|
778
|
-
var _dispatch = function dispatch() {
|
|
779
|
-
throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(15) : 'Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
var middlewareAPI = {
|
|
783
|
-
getState: store.getState,
|
|
784
|
-
dispatch: function dispatch() {
|
|
785
|
-
return _dispatch.apply(void 0, arguments);
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
var chain = middlewares.map(function (middleware) {
|
|
789
|
-
return middleware(middlewareAPI);
|
|
790
|
-
});
|
|
791
|
-
_dispatch = compose.apply(void 0, chain)(store.dispatch);
|
|
792
|
-
return _objectSpread2(_objectSpread2({}, store), {}, {
|
|
793
|
-
dispatch: _dispatch
|
|
794
|
-
});
|
|
795
|
-
};
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
/*
|
|
800
|
-
* This is a dummy function to check if the function name has been altered by minification.
|
|
801
|
-
* If the function has been minified and NODE_ENV !== 'production', warn the user.
|
|
802
|
-
*/
|
|
803
|
-
|
|
804
|
-
function isCrushed() {}
|
|
805
|
-
|
|
806
|
-
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
|
|
807
|
-
warning('You are currently using minified code outside of NODE_ENV === "production". ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
function appendRecord(record, records) {
|
|
811
|
-
return __spreadArray$1(__spreadArray$1([], records, true), [record], false);
|
|
812
|
-
}
|
|
813
|
-
function appendRecords(recordsToAppend, records) {
|
|
814
|
-
return __spreadArray$1(__spreadArray$1([], records, true), recordsToAppend, true);
|
|
815
|
-
}
|
|
816
|
-
function updateRecord(record, records) {
|
|
817
|
-
return records.map(function (r) {
|
|
818
|
-
if (r.id === record.id) {
|
|
819
|
-
return record;
|
|
820
|
-
}
|
|
821
|
-
return r;
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
function deleteRecord(record, records) {
|
|
825
|
-
return records.filter(function (r) { return r.id !== record.id; });
|
|
826
|
-
}
|
|
827
|
-
function deleteRecords(recordsToDelete, records) {
|
|
828
|
-
return records.filter(function (r) { return !recordsToDelete.includes(r); });
|
|
829
|
-
}
|
|
830
|
-
var records = (function (state, action) {
|
|
831
|
-
var _a, _b, _c, _d, _e, _f;
|
|
832
|
-
var _g;
|
|
833
|
-
if (state === void 0) { state = {}; }
|
|
834
|
-
var list = (_g = state[action.key]) !== null && _g !== void 0 ? _g : [];
|
|
835
|
-
switch (action.type) {
|
|
836
|
-
case SET_RECORDS:
|
|
837
|
-
if (Array.isArray(action.payload)) {
|
|
838
|
-
return __assign(__assign({}, state), (_a = {}, _a[action.key] = action.payload, _a));
|
|
839
|
-
}
|
|
840
|
-
case ADD_RECORD:
|
|
841
|
-
return __assign(__assign({}, state), (_b = {}, _b[action.key] = appendRecord(action.payload, list), _b));
|
|
842
|
-
case ADD_RECORDS:
|
|
843
|
-
return __assign(__assign({}, state), (_c = {}, _c[action.key] = appendRecords(action.payload, list), _c));
|
|
844
|
-
case DELETE_RECORD:
|
|
845
|
-
return __assign(__assign({}, state), (_d = {}, _d[action.key] = deleteRecord(action.payload, list), _d));
|
|
846
|
-
case DELETE_RECORDS:
|
|
847
|
-
return __assign(__assign({}, state), (_e = {}, _e[action.key] = deleteRecords(action.payload, list), _e));
|
|
848
|
-
case UPDATE_RECORD:
|
|
849
|
-
return __assign(__assign({}, state), (_f = {}, _f[action.key] = updateRecord(action.payload, list), _f));
|
|
850
|
-
default:
|
|
851
|
-
return state;
|
|
852
|
-
}
|
|
853
|
-
});
|
|
854
|
-
|
|
855
|
-
var appReducer = combineReducers({
|
|
856
|
-
records: records,
|
|
857
|
-
});
|
|
858
|
-
|
|
859
|
-
function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){return !!n&&(function(n){if(!n||"object"!=typeof n)return !1;var r=Object.getPrototypeOf(n);if(null===r)return !0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!n.constructor[L]||s(n)||v(n))}function i(n,r,t){void 0===t&&(t=!1),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?(n.delete(r),n.add(t)):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=!1),y(n)||r(n)||!t(n)?n:(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,!0)}),!0),n)}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function m(n,r){tn[n]||(tn[n]=r);}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function O(n){g(n),n.p.forEach(S),n.p=null;}function g(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:!0,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.O=!0;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.g||b("ES5").S(e,r,o),o?(i[Q].P&&(O(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),O(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),!0),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o;i(3===e.i?new Set(o):o,(function(r,i){return A(n,e,o,r,i,t)})),x(n,o,!1),t&&n.u&&b("Patches").R(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var v=M(e,c,s&&i&&3!==i.i&&!u(i.D,a)?s.concat(a):void 0);if(f(o,a,v),!r(v))return;e.m=!1;}if(t(c)&&!y(c)){if(!e.h.F&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){void 0===t&&(t=!1),n.h.F&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=!0,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function R(n,r,t){var e=s(r)?b("MapSet").N(r,t):v(r)?b("MapSet").T(r,t):n.g?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:!1,I:!1,D:{},l:r,t:n,k:null,o:null,j:null,C:!1},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function D(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=!0,e=F(r,c),u.I=!1;}else e=F(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function F(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}function N(){function t(n,r){var t=s[n];return t?t.enumerable=r:s[n]=t={configurable:!0,enumerable:r,get:function(){var r=this[Q];return "production"!==process.env.NODE_ENV&&f(r),en.get(r,n)},set:function(r){var t=this[Q];"production"!==process.env.NODE_ENV&&f(t),en.set(t,n,r);}},t}function e(n){for(var r=n.length-1;r>=0;r--){var t=n[r][Q];if(!t.P)switch(t.i){case 5:a(t)&&k(t);break;case 4:o(t)&&k(t);}}}function o(n){for(var r=n.t,t=n.k,e=nn(t),i=e.length-1;i>=0;i--){var o=e[i];if(o!==Q){var a=r[o];if(void 0===a&&!u(r,o))return !0;var f=t[o],s=f&&f[Q];if(s?s.t!==a:!c(f,a))return !0}}var v=!!r[Q];return e.length!==nn(r).length+(v?0:1)}function a(n){var r=n.k;if(r.length!==n.t.length)return !0;var t=Object.getOwnPropertyDescriptor(r,r.length-1);if(t&&!t.get)return !0;for(var e=0;e<r.length;e++)if(!r.hasOwnProperty(e))return !0;return !1}function f(r){r.O&&n(3,JSON.stringify(p(r)));}var s={};m("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,!0));return e}var o=rn(r);delete o[Q];for(var u=nn(o),a=0;a<u.length;a++){var f=u[a];o[f]=t(f,n||!!o[f].enumerable);}return Object.create(Object.getPrototypeOf(r),o)}(e,n),o={i:e?5:4,A:r?r.A:_(),P:!1,I:!1,D:{},l:r,t:n,k:i,o:null,O:!1,C:!1};return Object.defineProperty(i,Q,{value:o,writable:!0}),i},S:function(n,t,o){o?r(t)&&t[Q].A===n&&e(n.p):(n.u&&function n(r){if(r&&"object"==typeof r){var t=r[Q];if(t){var e=t.t,o=t.k,f=t.D,c=t.i;if(4===c)i(o,(function(r){r!==Q&&(void 0!==e[r]||u(e,r)?f[r]||n(o[r]):(f[r]=!0,k(t)));})),i(e,(function(n){void 0!==o[n]||u(o,n)||(f[n]=!1,k(t));}));else if(5===c){if(a(t)&&(k(t),f.length=!0),o.length<e.length)for(var s=o.length;s<e.length;s++)f[s]=!1;else for(var v=e.length;v<o.length;v++)f[v]=!0;for(var p=Math.min(o.length,e.length),l=0;l<p;l++)o.hasOwnProperty(l)||(f[l]=!0),void 0===f[l]&&n(o[l]);}}}}(n.p[0]),e(n.p));},K:function(n){return 4===n.i?o(n):a(n)}});}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=!0,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=R(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),!0;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.D[r]=!1,!0;if(c(t,i)&&(void 0!==t||u(n.t,r)))return !0;E(n),k(n);}return n.o[r]===t&&"number"!=typeof t&&(void 0!==t||r in n.o)||(n.o[r]=t,n.D[r]=!0,!0)},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.D[r]=!1,E(n),k(n)):delete n.D[r],n.o&&delete n.o[r],!0},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:!0,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.g=B,this.F=!0,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=R(e,r,void 0),v=!0;try{f=i(s),v=!1;}finally{v?O(c):g(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw O(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.F&&d(f,!0),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=D(e));var i=w(this),o=R(this,e,void 0);return o[Q].C=!0,g(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.F=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.g=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un;an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);
|
|
860
|
-
|
|
861
|
-
/** A function that accepts a potential "extra argument" value to be injected later,
|
|
862
|
-
* and returns an instance of the thunk middleware that uses that value
|
|
863
|
-
*/
|
|
864
|
-
function createThunkMiddleware(extraArgument) {
|
|
865
|
-
// Standard Redux middleware definition pattern:
|
|
866
|
-
// See: https://redux.js.org/tutorials/fundamentals/part-4-store#writing-custom-middleware
|
|
867
|
-
var middleware = function middleware(_ref) {
|
|
868
|
-
var dispatch = _ref.dispatch,
|
|
869
|
-
getState = _ref.getState;
|
|
870
|
-
return function (next) {
|
|
871
|
-
return function (action) {
|
|
872
|
-
// The thunk middleware looks for any functions that were passed to `store.dispatch`.
|
|
873
|
-
// If this "action" is really a function, call it and return the result.
|
|
874
|
-
if (typeof action === 'function') {
|
|
875
|
-
// Inject the store's `dispatch` and `getState` methods, as well as any "extra arg"
|
|
876
|
-
return action(dispatch, getState, extraArgument);
|
|
877
|
-
} // Otherwise, pass the action down the middleware chain as usual
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
return next(action);
|
|
881
|
-
};
|
|
882
|
-
};
|
|
883
|
-
};
|
|
884
|
-
|
|
885
|
-
return middleware;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
var thunk = createThunkMiddleware(); // Attach the factory function so users can create a customized version
|
|
889
|
-
// with whatever "extra arg" they want to inject into their thunks
|
|
890
|
-
|
|
891
|
-
thunk.withExtraArgument = createThunkMiddleware;
|
|
892
|
-
var thunk$1 = thunk;
|
|
893
|
-
|
|
894
|
-
var __extends = (undefined && undefined.__extends) || (function () {
|
|
895
|
-
var extendStatics = function (d, b) {
|
|
896
|
-
extendStatics = Object.setPrototypeOf ||
|
|
897
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
898
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
899
|
-
return extendStatics(d, b);
|
|
900
|
-
};
|
|
901
|
-
return function (d, b) {
|
|
902
|
-
if (typeof b !== "function" && b !== null)
|
|
903
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
904
|
-
extendStatics(d, b);
|
|
905
|
-
function __() { this.constructor = d; }
|
|
906
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
907
|
-
};
|
|
908
|
-
})();
|
|
909
|
-
(undefined && undefined.__generator) || function (thisArg, body) {
|
|
910
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
911
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
912
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
913
|
-
function step(op) {
|
|
914
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
915
|
-
while (_) try {
|
|
916
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
917
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
918
|
-
switch (op[0]) {
|
|
919
|
-
case 0: case 1: t = op; break;
|
|
920
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
921
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
922
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
923
|
-
default:
|
|
924
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
925
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
926
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
927
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
928
|
-
if (t[2]) _.ops.pop();
|
|
929
|
-
_.trys.pop(); continue;
|
|
930
|
-
}
|
|
931
|
-
op = body.call(thisArg, _);
|
|
932
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
933
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
934
|
-
}
|
|
935
|
-
};
|
|
936
|
-
var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from) {
|
|
937
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
938
|
-
to[j] = from[i];
|
|
939
|
-
return to;
|
|
940
|
-
};
|
|
941
|
-
var __defProp = Object.defineProperty;
|
|
942
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
943
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
944
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
945
|
-
var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
|
|
946
|
-
var __spreadValues = function (a, b) {
|
|
947
|
-
for (var prop in b || (b = {}))
|
|
948
|
-
if (__hasOwnProp.call(b, prop))
|
|
949
|
-
__defNormalProp(a, prop, b[prop]);
|
|
950
|
-
if (__getOwnPropSymbols)
|
|
951
|
-
for (var _i = 0, _c = __getOwnPropSymbols(b); _i < _c.length; _i++) {
|
|
952
|
-
var prop = _c[_i];
|
|
953
|
-
if (__propIsEnum.call(b, prop))
|
|
954
|
-
__defNormalProp(a, prop, b[prop]);
|
|
955
|
-
}
|
|
956
|
-
return a;
|
|
957
|
-
};
|
|
958
|
-
var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function () {
|
|
959
|
-
if (arguments.length === 0)
|
|
960
|
-
return void 0;
|
|
961
|
-
if (typeof arguments[0] === "object")
|
|
962
|
-
return compose;
|
|
963
|
-
return compose.apply(null, arguments);
|
|
964
|
-
};
|
|
965
|
-
// src/isPlainObject.ts
|
|
966
|
-
function isPlainObject(value) {
|
|
967
|
-
if (typeof value !== "object" || value === null)
|
|
968
|
-
return false;
|
|
969
|
-
var proto = Object.getPrototypeOf(value);
|
|
970
|
-
if (proto === null)
|
|
971
|
-
return true;
|
|
972
|
-
var baseProto = proto;
|
|
973
|
-
while (Object.getPrototypeOf(baseProto) !== null) {
|
|
974
|
-
baseProto = Object.getPrototypeOf(baseProto);
|
|
975
|
-
}
|
|
976
|
-
return proto === baseProto;
|
|
977
|
-
}
|
|
978
|
-
function getTimeMeasureUtils(maxDelay, fnName) {
|
|
979
|
-
var elapsed = 0;
|
|
980
|
-
return {
|
|
981
|
-
measureTime: function (fn) {
|
|
982
|
-
var started = Date.now();
|
|
983
|
-
try {
|
|
984
|
-
return fn();
|
|
985
|
-
}
|
|
986
|
-
finally {
|
|
987
|
-
var finished = Date.now();
|
|
988
|
-
elapsed += finished - started;
|
|
989
|
-
}
|
|
990
|
-
},
|
|
991
|
-
warnIfExceeded: function () {
|
|
992
|
-
if (elapsed > maxDelay) {
|
|
993
|
-
console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
}
|
|
998
|
-
var MiddlewareArray = /** @class */ (function (_super) {
|
|
999
|
-
__extends(MiddlewareArray, _super);
|
|
1000
|
-
function MiddlewareArray() {
|
|
1001
|
-
var args = [];
|
|
1002
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1003
|
-
args[_i] = arguments[_i];
|
|
1004
|
-
}
|
|
1005
|
-
var _this = _super.apply(this, args) || this;
|
|
1006
|
-
Object.setPrototypeOf(_this, MiddlewareArray.prototype);
|
|
1007
|
-
return _this;
|
|
1008
|
-
}
|
|
1009
|
-
Object.defineProperty(MiddlewareArray, Symbol.species, {
|
|
1010
|
-
get: function () {
|
|
1011
|
-
return MiddlewareArray;
|
|
1012
|
-
},
|
|
1013
|
-
enumerable: false,
|
|
1014
|
-
configurable: true
|
|
1015
|
-
});
|
|
1016
|
-
MiddlewareArray.prototype.concat = function () {
|
|
1017
|
-
var arr = [];
|
|
1018
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1019
|
-
arr[_i] = arguments[_i];
|
|
1020
|
-
}
|
|
1021
|
-
return _super.prototype.concat.apply(this, arr);
|
|
1022
|
-
};
|
|
1023
|
-
MiddlewareArray.prototype.prepend = function () {
|
|
1024
|
-
var arr = [];
|
|
1025
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1026
|
-
arr[_i] = arguments[_i];
|
|
1027
|
-
}
|
|
1028
|
-
if (arr.length === 1 && Array.isArray(arr[0])) {
|
|
1029
|
-
return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr[0].concat(this))))();
|
|
1030
|
-
}
|
|
1031
|
-
return new (MiddlewareArray.bind.apply(MiddlewareArray, __spreadArray([void 0], arr.concat(this))))();
|
|
1032
|
-
};
|
|
1033
|
-
return MiddlewareArray;
|
|
1034
|
-
}(Array));
|
|
1035
|
-
// src/immutableStateInvariantMiddleware.ts
|
|
1036
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
1037
|
-
var prefix = "Invariant failed";
|
|
1038
|
-
function invariant(condition, message) {
|
|
1039
|
-
if (condition) {
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
if (isProduction) {
|
|
1043
|
-
throw new Error(prefix);
|
|
1044
|
-
}
|
|
1045
|
-
throw new Error(prefix + ": " + (message || ""));
|
|
1046
|
-
}
|
|
1047
|
-
function stringify(obj, serializer, indent, decycler) {
|
|
1048
|
-
return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
|
|
1049
|
-
}
|
|
1050
|
-
function getSerialize(serializer, decycler) {
|
|
1051
|
-
var stack = [], keys = [];
|
|
1052
|
-
if (!decycler)
|
|
1053
|
-
decycler = function (_, value) {
|
|
1054
|
-
if (stack[0] === value)
|
|
1055
|
-
return "[Circular ~]";
|
|
1056
|
-
return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
|
|
1057
|
-
};
|
|
1058
|
-
return function (key, value) {
|
|
1059
|
-
if (stack.length > 0) {
|
|
1060
|
-
var thisPos = stack.indexOf(this);
|
|
1061
|
-
~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
|
|
1062
|
-
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
|
|
1063
|
-
if (~stack.indexOf(value))
|
|
1064
|
-
value = decycler.call(this, key, value);
|
|
1065
|
-
}
|
|
1066
|
-
else
|
|
1067
|
-
stack.push(value);
|
|
1068
|
-
return serializer == null ? value : serializer.call(this, key, value);
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
function isImmutableDefault(value) {
|
|
1072
|
-
return typeof value !== "object" || value == null || Object.isFrozen(value);
|
|
1073
|
-
}
|
|
1074
|
-
function trackForMutations(isImmutable, ignorePaths, obj) {
|
|
1075
|
-
var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
|
|
1076
|
-
return {
|
|
1077
|
-
detectMutations: function () {
|
|
1078
|
-
return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
|
|
1079
|
-
}
|
|
1080
|
-
};
|
|
1081
|
-
}
|
|
1082
|
-
function trackProperties(isImmutable, ignorePaths, obj, path) {
|
|
1083
|
-
if (ignorePaths === void 0) { ignorePaths = []; }
|
|
1084
|
-
if (path === void 0) { path = ""; }
|
|
1085
|
-
var tracked = { value: obj };
|
|
1086
|
-
if (!isImmutable(obj)) {
|
|
1087
|
-
tracked.children = {};
|
|
1088
|
-
for (var key in obj) {
|
|
1089
|
-
var childPath = path ? path + "." + key : key;
|
|
1090
|
-
if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
|
|
1091
|
-
continue;
|
|
1092
|
-
}
|
|
1093
|
-
tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
return tracked;
|
|
1097
|
-
}
|
|
1098
|
-
function detectMutations(isImmutable, ignorePaths, trackedProperty, obj, sameParentRef, path) {
|
|
1099
|
-
if (ignorePaths === void 0) { ignorePaths = []; }
|
|
1100
|
-
if (sameParentRef === void 0) { sameParentRef = false; }
|
|
1101
|
-
if (path === void 0) { path = ""; }
|
|
1102
|
-
var prevObj = trackedProperty ? trackedProperty.value : void 0;
|
|
1103
|
-
var sameRef = prevObj === obj;
|
|
1104
|
-
if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
|
|
1105
|
-
return { wasMutated: true, path: path };
|
|
1106
|
-
}
|
|
1107
|
-
if (isImmutable(prevObj) || isImmutable(obj)) {
|
|
1108
|
-
return { wasMutated: false };
|
|
1109
|
-
}
|
|
1110
|
-
var keysToDetect = {};
|
|
1111
|
-
for (var key in trackedProperty.children) {
|
|
1112
|
-
keysToDetect[key] = true;
|
|
1113
|
-
}
|
|
1114
|
-
for (var key in obj) {
|
|
1115
|
-
keysToDetect[key] = true;
|
|
1116
|
-
}
|
|
1117
|
-
for (var key in keysToDetect) {
|
|
1118
|
-
var childPath = path ? path + "." + key : key;
|
|
1119
|
-
if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
|
|
1120
|
-
continue;
|
|
1121
|
-
}
|
|
1122
|
-
var result = detectMutations(isImmutable, ignorePaths, trackedProperty.children[key], obj[key], sameRef, childPath);
|
|
1123
|
-
if (result.wasMutated) {
|
|
1124
|
-
return result;
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
return { wasMutated: false };
|
|
1128
|
-
}
|
|
1129
|
-
function createImmutableStateInvariantMiddleware(options) {
|
|
1130
|
-
if (options === void 0) { options = {}; }
|
|
1131
|
-
if (process.env.NODE_ENV === "production") {
|
|
1132
|
-
return function () { return function (next) { return function (action) { return next(action); }; }; };
|
|
1133
|
-
}
|
|
1134
|
-
var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
|
|
1135
|
-
ignoredPaths = ignoredPaths || ignore;
|
|
1136
|
-
var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
|
|
1137
|
-
return function (_c) {
|
|
1138
|
-
var getState = _c.getState;
|
|
1139
|
-
var state = getState();
|
|
1140
|
-
var tracker = track(state);
|
|
1141
|
-
var result;
|
|
1142
|
-
return function (next) { return function (action) {
|
|
1143
|
-
var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
|
|
1144
|
-
measureUtils.measureTime(function () {
|
|
1145
|
-
state = getState();
|
|
1146
|
-
result = tracker.detectMutations();
|
|
1147
|
-
tracker = track(state);
|
|
1148
|
-
invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
|
|
1149
|
-
});
|
|
1150
|
-
var dispatchedAction = next(action);
|
|
1151
|
-
measureUtils.measureTime(function () {
|
|
1152
|
-
state = getState();
|
|
1153
|
-
result = tracker.detectMutations();
|
|
1154
|
-
tracker = track(state);
|
|
1155
|
-
result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
|
|
1156
|
-
});
|
|
1157
|
-
measureUtils.warnIfExceeded();
|
|
1158
|
-
return dispatchedAction;
|
|
1159
|
-
}; };
|
|
1160
|
-
};
|
|
1161
|
-
}
|
|
1162
|
-
// src/serializableStateInvariantMiddleware.ts
|
|
1163
|
-
function isPlain(val) {
|
|
1164
|
-
var type = typeof val;
|
|
1165
|
-
return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
|
|
1166
|
-
}
|
|
1167
|
-
function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths) {
|
|
1168
|
-
if (path === void 0) { path = ""; }
|
|
1169
|
-
if (isSerializable === void 0) { isSerializable = isPlain; }
|
|
1170
|
-
if (ignoredPaths === void 0) { ignoredPaths = []; }
|
|
1171
|
-
var foundNestedSerializable;
|
|
1172
|
-
if (!isSerializable(value)) {
|
|
1173
|
-
return {
|
|
1174
|
-
keyPath: path || "<root>",
|
|
1175
|
-
value: value
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
if (typeof value !== "object" || value === null) {
|
|
1179
|
-
return false;
|
|
1180
|
-
}
|
|
1181
|
-
var entries = getEntries != null ? getEntries(value) : Object.entries(value);
|
|
1182
|
-
var hasIgnoredPaths = ignoredPaths.length > 0;
|
|
1183
|
-
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
1184
|
-
var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
|
|
1185
|
-
var nestedPath = path ? path + "." + key : key;
|
|
1186
|
-
if (hasIgnoredPaths && ignoredPaths.indexOf(nestedPath) >= 0) {
|
|
1187
|
-
continue;
|
|
1188
|
-
}
|
|
1189
|
-
if (!isSerializable(nestedValue)) {
|
|
1190
|
-
return {
|
|
1191
|
-
keyPath: nestedPath,
|
|
1192
|
-
value: nestedValue
|
|
1193
|
-
};
|
|
1194
|
-
}
|
|
1195
|
-
if (typeof nestedValue === "object") {
|
|
1196
|
-
foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths);
|
|
1197
|
-
if (foundNestedSerializable) {
|
|
1198
|
-
return foundNestedSerializable;
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
return false;
|
|
1203
|
-
}
|
|
1204
|
-
function createSerializableStateInvariantMiddleware(options) {
|
|
1205
|
-
if (options === void 0) { options = {}; }
|
|
1206
|
-
if (process.env.NODE_ENV === "production") {
|
|
1207
|
-
return function () { return function (next) { return function (action) { return next(action); }; }; };
|
|
1208
|
-
}
|
|
1209
|
-
var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j;
|
|
1210
|
-
return function (storeAPI) { return function (next) { return function (action) {
|
|
1211
|
-
var result = next(action);
|
|
1212
|
-
var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
|
|
1213
|
-
if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
|
|
1214
|
-
measureUtils.measureTime(function () {
|
|
1215
|
-
var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths);
|
|
1216
|
-
if (foundActionNonSerializableValue) {
|
|
1217
|
-
var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
|
|
1218
|
-
console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
|
|
1219
|
-
}
|
|
1220
|
-
});
|
|
1221
|
-
}
|
|
1222
|
-
if (!ignoreState) {
|
|
1223
|
-
measureUtils.measureTime(function () {
|
|
1224
|
-
var state = storeAPI.getState();
|
|
1225
|
-
var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths);
|
|
1226
|
-
if (foundStateNonSerializableValue) {
|
|
1227
|
-
var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
|
|
1228
|
-
console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
|
|
1229
|
-
}
|
|
1230
|
-
});
|
|
1231
|
-
measureUtils.warnIfExceeded();
|
|
1232
|
-
}
|
|
1233
|
-
return result;
|
|
1234
|
-
}; }; };
|
|
1235
|
-
}
|
|
1236
|
-
// src/getDefaultMiddleware.ts
|
|
1237
|
-
function isBoolean(x) {
|
|
1238
|
-
return typeof x === "boolean";
|
|
1239
|
-
}
|
|
1240
|
-
function curryGetDefaultMiddleware() {
|
|
1241
|
-
return function curriedGetDefaultMiddleware(options) {
|
|
1242
|
-
return getDefaultMiddleware(options);
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
|
-
function getDefaultMiddleware(options) {
|
|
1246
|
-
if (options === void 0) { options = {}; }
|
|
1247
|
-
var _c = options.thunk, thunk = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e;
|
|
1248
|
-
var middlewareArray = new MiddlewareArray();
|
|
1249
|
-
if (thunk) {
|
|
1250
|
-
if (isBoolean(thunk)) {
|
|
1251
|
-
middlewareArray.push(thunk$1);
|
|
1252
|
-
}
|
|
1253
|
-
else {
|
|
1254
|
-
middlewareArray.push(thunk$1.withExtraArgument(thunk.extraArgument));
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1258
|
-
if (immutableCheck) {
|
|
1259
|
-
var immutableOptions = {};
|
|
1260
|
-
if (!isBoolean(immutableCheck)) {
|
|
1261
|
-
immutableOptions = immutableCheck;
|
|
1262
|
-
}
|
|
1263
|
-
middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
|
|
1264
|
-
}
|
|
1265
|
-
if (serializableCheck) {
|
|
1266
|
-
var serializableOptions = {};
|
|
1267
|
-
if (!isBoolean(serializableCheck)) {
|
|
1268
|
-
serializableOptions = serializableCheck;
|
|
1269
|
-
}
|
|
1270
|
-
middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
return middlewareArray;
|
|
1274
|
-
}
|
|
1275
|
-
// src/configureStore.ts
|
|
1276
|
-
var IS_PRODUCTION = process.env.NODE_ENV === "production";
|
|
1277
|
-
function configureStore(options) {
|
|
1278
|
-
var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
|
|
1279
|
-
var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
|
|
1280
|
-
var rootReducer;
|
|
1281
|
-
if (typeof reducer === "function") {
|
|
1282
|
-
rootReducer = reducer;
|
|
1283
|
-
}
|
|
1284
|
-
else if (isPlainObject(reducer)) {
|
|
1285
|
-
rootReducer = combineReducers(reducer);
|
|
1286
|
-
}
|
|
1287
|
-
else {
|
|
1288
|
-
throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
|
|
1289
|
-
}
|
|
1290
|
-
var finalMiddleware = middleware;
|
|
1291
|
-
if (typeof finalMiddleware === "function") {
|
|
1292
|
-
finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
|
|
1293
|
-
if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
|
|
1294
|
-
throw new Error("when using a middleware builder function, an array of middleware must be returned");
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
if (!IS_PRODUCTION && finalMiddleware.some(function (item) { return typeof item !== "function"; })) {
|
|
1298
|
-
throw new Error("each middleware provided to configureStore must be a function");
|
|
1299
|
-
}
|
|
1300
|
-
var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
|
|
1301
|
-
var finalCompose = compose;
|
|
1302
|
-
if (devTools) {
|
|
1303
|
-
finalCompose = composeWithDevTools(__spreadValues({
|
|
1304
|
-
trace: !IS_PRODUCTION
|
|
1305
|
-
}, typeof devTools === "object" && devTools));
|
|
1306
|
-
}
|
|
1307
|
-
var storeEnhancers = [middlewareEnhancer];
|
|
1308
|
-
if (Array.isArray(enhancers)) {
|
|
1309
|
-
storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
|
|
1310
|
-
}
|
|
1311
|
-
else if (typeof enhancers === "function") {
|
|
1312
|
-
storeEnhancers = enhancers(storeEnhancers);
|
|
1313
|
-
}
|
|
1314
|
-
var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
|
|
1315
|
-
return createStore(rootReducer, preloadedState, composedEnhancer);
|
|
1316
|
-
}
|
|
1317
|
-
// src/index.ts
|
|
1318
|
-
N();
|
|
1319
|
-
|
|
1320
|
-
var KEY_PREFIX = 'persist:';
|
|
1321
|
-
var FLUSH = 'persist/FLUSH';
|
|
1322
|
-
var REHYDRATE = 'persist/REHYDRATE';
|
|
1323
|
-
var PAUSE = 'persist/PAUSE';
|
|
1324
|
-
var PERSIST = 'persist/PERSIST';
|
|
1325
|
-
var PURGE = 'persist/PURGE';
|
|
1326
|
-
var REGISTER = 'persist/REGISTER';
|
|
1327
|
-
var DEFAULT_VERSION = -1;
|
|
1328
|
-
|
|
1329
|
-
function _typeof$1(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
|
|
1330
|
-
|
|
1331
|
-
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
1332
|
-
|
|
1333
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(source, true).forEach(function (key) { _defineProperty$3(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1334
|
-
|
|
1335
|
-
function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1336
|
-
|
|
1337
|
-
/*
|
|
1338
|
-
autoMergeLevel1:
|
|
1339
|
-
- merges 1 level of substate
|
|
1340
|
-
- skips substate if already modified
|
|
1341
|
-
*/
|
|
1342
|
-
function autoMergeLevel1(inboundState, originalState, reducedState, _ref) {
|
|
1343
|
-
var debug = _ref.debug;
|
|
1344
|
-
|
|
1345
|
-
var newState = _objectSpread$2({}, reducedState); // only rehydrate if inboundState exists and is an object
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
if (inboundState && _typeof$1(inboundState) === 'object') {
|
|
1349
|
-
Object.keys(inboundState).forEach(function (key) {
|
|
1350
|
-
// ignore _persist data
|
|
1351
|
-
if (key === '_persist') return; // if reducer modifies substate, skip auto rehydration
|
|
1352
|
-
|
|
1353
|
-
if (originalState[key] !== reducedState[key]) {
|
|
1354
|
-
if (process.env.NODE_ENV !== 'production' && debug) console.log('redux-persist/stateReconciler: sub state for key `%s` modified, skipping.', key);
|
|
1355
|
-
return;
|
|
1356
|
-
} // otherwise hard set the new value
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
newState[key] = inboundState[key];
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
if (process.env.NODE_ENV !== 'production' && debug && inboundState && _typeof$1(inboundState) === 'object') console.log("redux-persist/stateReconciler: rehydrated keys '".concat(Object.keys(inboundState).join(', '), "'"));
|
|
1364
|
-
return newState;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
// @TODO remove once flow < 0.63 support is no longer required.
|
|
1368
|
-
function createPersistoid(config) {
|
|
1369
|
-
// defaults
|
|
1370
|
-
var blacklist = config.blacklist || null;
|
|
1371
|
-
var whitelist = config.whitelist || null;
|
|
1372
|
-
var transforms = config.transforms || [];
|
|
1373
|
-
var throttle = config.throttle || 0;
|
|
1374
|
-
var storageKey = "".concat(config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX).concat(config.key);
|
|
1375
|
-
var storage = config.storage;
|
|
1376
|
-
var serialize;
|
|
1377
|
-
|
|
1378
|
-
if (config.serialize === false) {
|
|
1379
|
-
serialize = function serialize(x) {
|
|
1380
|
-
return x;
|
|
1381
|
-
};
|
|
1382
|
-
} else if (typeof config.serialize === 'function') {
|
|
1383
|
-
serialize = config.serialize;
|
|
1384
|
-
} else {
|
|
1385
|
-
serialize = defaultSerialize;
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
var writeFailHandler = config.writeFailHandler || null; // initialize stateful values
|
|
1389
|
-
|
|
1390
|
-
var lastState = {};
|
|
1391
|
-
var stagedState = {};
|
|
1392
|
-
var keysToProcess = [];
|
|
1393
|
-
var timeIterator = null;
|
|
1394
|
-
var writePromise = null;
|
|
1395
|
-
|
|
1396
|
-
var update = function update(state) {
|
|
1397
|
-
// add any changed keys to the queue
|
|
1398
|
-
Object.keys(state).forEach(function (key) {
|
|
1399
|
-
if (!passWhitelistBlacklist(key)) return; // is keyspace ignored? noop
|
|
1400
|
-
|
|
1401
|
-
if (lastState[key] === state[key]) return; // value unchanged? noop
|
|
1402
|
-
|
|
1403
|
-
if (keysToProcess.indexOf(key) !== -1) return; // is key already queued? noop
|
|
1404
|
-
|
|
1405
|
-
keysToProcess.push(key); // add key to queue
|
|
1406
|
-
}); //if any key is missing in the new state which was present in the lastState,
|
|
1407
|
-
//add it for processing too
|
|
1408
|
-
|
|
1409
|
-
Object.keys(lastState).forEach(function (key) {
|
|
1410
|
-
if (state[key] === undefined && passWhitelistBlacklist(key) && keysToProcess.indexOf(key) === -1 && lastState[key] !== undefined) {
|
|
1411
|
-
keysToProcess.push(key);
|
|
1412
|
-
}
|
|
1413
|
-
}); // start the time iterator if not running (read: throttle)
|
|
1414
|
-
|
|
1415
|
-
if (timeIterator === null) {
|
|
1416
|
-
timeIterator = setInterval(processNextKey, throttle);
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
lastState = state;
|
|
1420
|
-
};
|
|
1421
|
-
|
|
1422
|
-
function processNextKey() {
|
|
1423
|
-
if (keysToProcess.length === 0) {
|
|
1424
|
-
if (timeIterator) clearInterval(timeIterator);
|
|
1425
|
-
timeIterator = null;
|
|
1426
|
-
return;
|
|
1427
|
-
}
|
|
1428
|
-
|
|
1429
|
-
var key = keysToProcess.shift();
|
|
1430
|
-
var endState = transforms.reduce(function (subState, transformer) {
|
|
1431
|
-
return transformer.in(subState, key, lastState);
|
|
1432
|
-
}, lastState[key]);
|
|
1433
|
-
|
|
1434
|
-
if (endState !== undefined) {
|
|
1435
|
-
try {
|
|
1436
|
-
stagedState[key] = serialize(endState);
|
|
1437
|
-
} catch (err) {
|
|
1438
|
-
console.error('redux-persist/createPersistoid: error serializing state', err);
|
|
1439
|
-
}
|
|
1440
|
-
} else {
|
|
1441
|
-
//if the endState is undefined, no need to persist the existing serialized content
|
|
1442
|
-
delete stagedState[key];
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
if (keysToProcess.length === 0) {
|
|
1446
|
-
writeStagedState();
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
function writeStagedState() {
|
|
1451
|
-
// cleanup any removed keys just before write.
|
|
1452
|
-
Object.keys(stagedState).forEach(function (key) {
|
|
1453
|
-
if (lastState[key] === undefined) {
|
|
1454
|
-
delete stagedState[key];
|
|
1455
|
-
}
|
|
1456
|
-
});
|
|
1457
|
-
writePromise = storage.setItem(storageKey, serialize(stagedState)).catch(onWriteFail);
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
function passWhitelistBlacklist(key) {
|
|
1461
|
-
if (whitelist && whitelist.indexOf(key) === -1 && key !== '_persist') return false;
|
|
1462
|
-
if (blacklist && blacklist.indexOf(key) !== -1) return false;
|
|
1463
|
-
return true;
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
function onWriteFail(err) {
|
|
1467
|
-
// @TODO add fail handlers (typically storage full)
|
|
1468
|
-
if (writeFailHandler) writeFailHandler(err);
|
|
1469
|
-
|
|
1470
|
-
if (err && process.env.NODE_ENV !== 'production') {
|
|
1471
|
-
console.error('Error storing data', err);
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
var flush = function flush() {
|
|
1476
|
-
while (keysToProcess.length !== 0) {
|
|
1477
|
-
processNextKey();
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
return writePromise || Promise.resolve();
|
|
1481
|
-
}; // return `persistoid`
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
return {
|
|
1485
|
-
update: update,
|
|
1486
|
-
flush: flush
|
|
1487
|
-
};
|
|
1488
|
-
} // @NOTE in the future this may be exposed via config
|
|
1489
|
-
|
|
1490
|
-
function defaultSerialize(data) {
|
|
1491
|
-
return JSON.stringify(data);
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
function getStoredState(config) {
|
|
1495
|
-
var transforms = config.transforms || [];
|
|
1496
|
-
var storageKey = "".concat(config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX).concat(config.key);
|
|
1497
|
-
var storage = config.storage;
|
|
1498
|
-
var debug = config.debug;
|
|
1499
|
-
var deserialize;
|
|
1500
|
-
|
|
1501
|
-
if (config.deserialize === false) {
|
|
1502
|
-
deserialize = function deserialize(x) {
|
|
1503
|
-
return x;
|
|
1504
|
-
};
|
|
1505
|
-
} else if (typeof config.deserialize === 'function') {
|
|
1506
|
-
deserialize = config.deserialize;
|
|
1507
|
-
} else {
|
|
1508
|
-
deserialize = defaultDeserialize;
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
return storage.getItem(storageKey).then(function (serialized) {
|
|
1512
|
-
if (!serialized) return undefined;else {
|
|
1513
|
-
try {
|
|
1514
|
-
var state = {};
|
|
1515
|
-
var rawState = deserialize(serialized);
|
|
1516
|
-
Object.keys(rawState).forEach(function (key) {
|
|
1517
|
-
state[key] = transforms.reduceRight(function (subState, transformer) {
|
|
1518
|
-
return transformer.out(subState, key, rawState);
|
|
1519
|
-
}, deserialize(rawState[key]));
|
|
1520
|
-
});
|
|
1521
|
-
return state;
|
|
1522
|
-
} catch (err) {
|
|
1523
|
-
if (process.env.NODE_ENV !== 'production' && debug) console.log("redux-persist/getStoredState: Error restoring data ".concat(serialized), err);
|
|
1524
|
-
throw err;
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
});
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
function defaultDeserialize(serial) {
|
|
1531
|
-
return JSON.parse(serial);
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
function purgeStoredState(config) {
|
|
1535
|
-
var storage = config.storage;
|
|
1536
|
-
var storageKey = "".concat(config.keyPrefix !== undefined ? config.keyPrefix : KEY_PREFIX).concat(config.key);
|
|
1537
|
-
return storage.removeItem(storageKey, warnIfRemoveError);
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
function warnIfRemoveError(err) {
|
|
1541
|
-
if (err && process.env.NODE_ENV !== 'production') {
|
|
1542
|
-
console.error('redux-persist/purgeStoredState: Error purging data stored state', err);
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
1547
|
-
|
|
1548
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1549
|
-
|
|
1550
|
-
function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1551
|
-
|
|
1552
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
1553
|
-
|
|
1554
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1555
|
-
var DEFAULT_TIMEOUT = 5000;
|
|
1556
|
-
/*
|
|
1557
|
-
@TODO add validation / handling for:
|
|
1558
|
-
- persisting a reducer which has nested _persist
|
|
1559
|
-
- handling actions that fire before reydrate is called
|
|
1560
|
-
*/
|
|
1561
|
-
|
|
1562
|
-
function persistReducer(config, baseReducer) {
|
|
1563
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1564
|
-
if (!config) throw new Error('config is required for persistReducer');
|
|
1565
|
-
if (!config.key) throw new Error('key is required in persistor config');
|
|
1566
|
-
if (!config.storage) throw new Error("redux-persist: config.storage is required. Try using one of the provided storage engines `import storage from 'redux-persist/lib/storage'`");
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
var version = config.version !== undefined ? config.version : DEFAULT_VERSION;
|
|
1570
|
-
config.debug || false;
|
|
1571
|
-
var stateReconciler = config.stateReconciler === undefined ? autoMergeLevel1 : config.stateReconciler;
|
|
1572
|
-
var getStoredState$1 = config.getStoredState || getStoredState;
|
|
1573
|
-
var timeout = config.timeout !== undefined ? config.timeout : DEFAULT_TIMEOUT;
|
|
1574
|
-
var _persistoid = null;
|
|
1575
|
-
var _purge = false;
|
|
1576
|
-
var _paused = true;
|
|
1577
|
-
|
|
1578
|
-
var conditionalUpdate = function conditionalUpdate(state) {
|
|
1579
|
-
// update the persistoid only if we are rehydrated and not paused
|
|
1580
|
-
state._persist.rehydrated && _persistoid && !_paused && _persistoid.update(state);
|
|
1581
|
-
return state;
|
|
1582
|
-
};
|
|
1583
|
-
|
|
1584
|
-
return function (state, action) {
|
|
1585
|
-
var _ref = state || {},
|
|
1586
|
-
_persist = _ref._persist,
|
|
1587
|
-
rest = _objectWithoutProperties(_ref, ["_persist"]); // $FlowIgnore need to update State type
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
var restState = rest;
|
|
1591
|
-
|
|
1592
|
-
if (action.type === PERSIST) {
|
|
1593
|
-
var _sealed = false;
|
|
1594
|
-
|
|
1595
|
-
var _rehydrate = function _rehydrate(payload, err) {
|
|
1596
|
-
// dev warning if we are already sealed
|
|
1597
|
-
if (process.env.NODE_ENV !== 'production' && _sealed) console.error("redux-persist: rehydrate for \"".concat(config.key, "\" called after timeout."), payload, err); // only rehydrate if we are not already sealed
|
|
1598
|
-
|
|
1599
|
-
if (!_sealed) {
|
|
1600
|
-
action.rehydrate(config.key, payload, err);
|
|
1601
|
-
_sealed = true;
|
|
1602
|
-
}
|
|
1603
|
-
};
|
|
1604
|
-
|
|
1605
|
-
timeout && setTimeout(function () {
|
|
1606
|
-
!_sealed && _rehydrate(undefined, new Error("redux-persist: persist timed out for persist key \"".concat(config.key, "\"")));
|
|
1607
|
-
}, timeout); // @NOTE PERSIST resumes if paused.
|
|
1608
|
-
|
|
1609
|
-
_paused = false; // @NOTE only ever create persistoid once, ensure we call it at least once, even if _persist has already been set
|
|
1610
|
-
|
|
1611
|
-
if (!_persistoid) _persistoid = createPersistoid(config); // @NOTE PERSIST can be called multiple times, noop after the first
|
|
1612
|
-
|
|
1613
|
-
if (_persist) {
|
|
1614
|
-
// We still need to call the base reducer because there might be nested
|
|
1615
|
-
// uses of persistReducer which need to be aware of the PERSIST action
|
|
1616
|
-
return _objectSpread$1({}, baseReducer(restState, action), {
|
|
1617
|
-
_persist: _persist
|
|
1618
|
-
});
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
if (typeof action.rehydrate !== 'function' || typeof action.register !== 'function') throw new Error('redux-persist: either rehydrate or register is not a function on the PERSIST action. This can happen if the action is being replayed. This is an unexplored use case, please open an issue and we will figure out a resolution.');
|
|
1622
|
-
action.register(config.key);
|
|
1623
|
-
getStoredState$1(config).then(function (restoredState) {
|
|
1624
|
-
var migrate = config.migrate || function (s, v) {
|
|
1625
|
-
return Promise.resolve(s);
|
|
1626
|
-
};
|
|
1627
|
-
|
|
1628
|
-
migrate(restoredState, version).then(function (migratedState) {
|
|
1629
|
-
_rehydrate(migratedState);
|
|
1630
|
-
}, function (migrateErr) {
|
|
1631
|
-
if (process.env.NODE_ENV !== 'production' && migrateErr) console.error('redux-persist: migration error', migrateErr);
|
|
1632
|
-
|
|
1633
|
-
_rehydrate(undefined, migrateErr);
|
|
1634
|
-
});
|
|
1635
|
-
}, function (err) {
|
|
1636
|
-
_rehydrate(undefined, err);
|
|
1637
|
-
});
|
|
1638
|
-
return _objectSpread$1({}, baseReducer(restState, action), {
|
|
1639
|
-
_persist: {
|
|
1640
|
-
version: version,
|
|
1641
|
-
rehydrated: false
|
|
1642
|
-
}
|
|
1643
|
-
});
|
|
1644
|
-
} else if (action.type === PURGE) {
|
|
1645
|
-
_purge = true;
|
|
1646
|
-
action.result(purgeStoredState(config));
|
|
1647
|
-
return _objectSpread$1({}, baseReducer(restState, action), {
|
|
1648
|
-
_persist: _persist
|
|
1649
|
-
});
|
|
1650
|
-
} else if (action.type === FLUSH) {
|
|
1651
|
-
action.result(_persistoid && _persistoid.flush());
|
|
1652
|
-
return _objectSpread$1({}, baseReducer(restState, action), {
|
|
1653
|
-
_persist: _persist
|
|
1654
|
-
});
|
|
1655
|
-
} else if (action.type === PAUSE) {
|
|
1656
|
-
_paused = true;
|
|
1657
|
-
} else if (action.type === REHYDRATE) {
|
|
1658
|
-
// noop on restState if purging
|
|
1659
|
-
if (_purge) return _objectSpread$1({}, restState, {
|
|
1660
|
-
_persist: _objectSpread$1({}, _persist, {
|
|
1661
|
-
rehydrated: true
|
|
1662
|
-
}) // @NOTE if key does not match, will continue to default else below
|
|
1663
|
-
|
|
1664
|
-
});
|
|
1665
|
-
|
|
1666
|
-
if (action.key === config.key) {
|
|
1667
|
-
var reducedState = baseReducer(restState, action);
|
|
1668
|
-
var inboundState = action.payload; // only reconcile state if stateReconciler and inboundState are both defined
|
|
1669
|
-
|
|
1670
|
-
var reconciledRest = stateReconciler !== false && inboundState !== undefined ? stateReconciler(inboundState, state, reducedState, config) : reducedState;
|
|
1671
|
-
|
|
1672
|
-
var _newState = _objectSpread$1({}, reconciledRest, {
|
|
1673
|
-
_persist: _objectSpread$1({}, _persist, {
|
|
1674
|
-
rehydrated: true
|
|
1675
|
-
})
|
|
1676
|
-
});
|
|
1677
|
-
|
|
1678
|
-
return conditionalUpdate(_newState);
|
|
1679
|
-
}
|
|
1680
|
-
} // if we have not already handled PERSIST, straight passthrough
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
if (!_persist) return baseReducer(state, action); // run base reducer:
|
|
1684
|
-
// is state modified ? return original : return updated
|
|
1685
|
-
|
|
1686
|
-
var newState = baseReducer(restState, action);
|
|
1687
|
-
if (newState === restState) return state;
|
|
1688
|
-
return conditionalUpdate(_objectSpread$1({}, newState, {
|
|
1689
|
-
_persist: _persist
|
|
1690
|
-
}));
|
|
1691
|
-
};
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
1695
|
-
|
|
1696
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
1697
|
-
|
|
1698
|
-
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
|
1699
|
-
|
|
1700
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
|
1701
|
-
|
|
1702
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
1703
|
-
|
|
1704
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1705
|
-
|
|
1706
|
-
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1707
|
-
var initialState = {
|
|
1708
|
-
registry: [],
|
|
1709
|
-
bootstrapped: false
|
|
1710
|
-
};
|
|
1711
|
-
|
|
1712
|
-
var persistorReducer = function persistorReducer() {
|
|
1713
|
-
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
|
|
1714
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
1715
|
-
|
|
1716
|
-
switch (action.type) {
|
|
1717
|
-
case REGISTER:
|
|
1718
|
-
return _objectSpread({}, state, {
|
|
1719
|
-
registry: [].concat(_toConsumableArray(state.registry), [action.key])
|
|
1720
|
-
});
|
|
1721
|
-
|
|
1722
|
-
case REHYDRATE:
|
|
1723
|
-
var firstIndex = state.registry.indexOf(action.key);
|
|
1724
|
-
|
|
1725
|
-
var registry = _toConsumableArray(state.registry);
|
|
1726
|
-
|
|
1727
|
-
registry.splice(firstIndex, 1);
|
|
1728
|
-
return _objectSpread({}, state, {
|
|
1729
|
-
registry: registry,
|
|
1730
|
-
bootstrapped: registry.length === 0
|
|
1731
|
-
});
|
|
1732
|
-
|
|
1733
|
-
default:
|
|
1734
|
-
return state;
|
|
1735
|
-
}
|
|
1736
|
-
};
|
|
1737
|
-
|
|
1738
|
-
function persistStore(store, options, cb) {
|
|
1739
|
-
// help catch incorrect usage of passing PersistConfig in as PersistorOptions
|
|
1740
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1741
|
-
var optionsToTest = options || {};
|
|
1742
|
-
var bannedKeys = ['blacklist', 'whitelist', 'transforms', 'storage', 'keyPrefix', 'migrate'];
|
|
1743
|
-
bannedKeys.forEach(function (k) {
|
|
1744
|
-
if (!!optionsToTest[k]) console.error("redux-persist: invalid option passed to persistStore: \"".concat(k, "\". You may be incorrectly passing persistConfig into persistStore, whereas it should be passed into persistReducer."));
|
|
1745
|
-
});
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
var boostrappedCb = cb || false;
|
|
1749
|
-
|
|
1750
|
-
var _pStore = createStore(persistorReducer, initialState, options && options.enhancer ? options.enhancer : undefined);
|
|
1751
|
-
|
|
1752
|
-
var register = function register(key) {
|
|
1753
|
-
_pStore.dispatch({
|
|
1754
|
-
type: REGISTER,
|
|
1755
|
-
key: key
|
|
1756
|
-
});
|
|
1757
|
-
};
|
|
1758
|
-
|
|
1759
|
-
var rehydrate = function rehydrate(key, payload, err) {
|
|
1760
|
-
var rehydrateAction = {
|
|
1761
|
-
type: REHYDRATE,
|
|
1762
|
-
payload: payload,
|
|
1763
|
-
err: err,
|
|
1764
|
-
key: key // dispatch to `store` to rehydrate and `persistor` to track result
|
|
1765
|
-
|
|
1766
|
-
};
|
|
1767
|
-
store.dispatch(rehydrateAction);
|
|
1768
|
-
|
|
1769
|
-
_pStore.dispatch(rehydrateAction);
|
|
1770
|
-
|
|
1771
|
-
if (boostrappedCb && persistor.getState().bootstrapped) {
|
|
1772
|
-
boostrappedCb();
|
|
1773
|
-
boostrappedCb = false;
|
|
1774
|
-
}
|
|
1775
|
-
};
|
|
1776
|
-
|
|
1777
|
-
var persistor = _objectSpread({}, _pStore, {
|
|
1778
|
-
purge: function purge() {
|
|
1779
|
-
var results = [];
|
|
1780
|
-
store.dispatch({
|
|
1781
|
-
type: PURGE,
|
|
1782
|
-
result: function result(purgeResult) {
|
|
1783
|
-
results.push(purgeResult);
|
|
1784
|
-
}
|
|
1785
|
-
});
|
|
1786
|
-
return Promise.all(results);
|
|
1787
|
-
},
|
|
1788
|
-
flush: function flush() {
|
|
1789
|
-
var results = [];
|
|
1790
|
-
store.dispatch({
|
|
1791
|
-
type: FLUSH,
|
|
1792
|
-
result: function result(flushResult) {
|
|
1793
|
-
results.push(flushResult);
|
|
1794
|
-
}
|
|
1795
|
-
});
|
|
1796
|
-
return Promise.all(results);
|
|
1797
|
-
},
|
|
1798
|
-
pause: function pause() {
|
|
1799
|
-
store.dispatch({
|
|
1800
|
-
type: PAUSE
|
|
1801
|
-
});
|
|
1802
|
-
},
|
|
1803
|
-
persist: function persist() {
|
|
1804
|
-
store.dispatch({
|
|
1805
|
-
type: PERSIST,
|
|
1806
|
-
register: register,
|
|
1807
|
-
rehydrate: rehydrate
|
|
1808
|
-
});
|
|
1809
|
-
}
|
|
1810
|
-
});
|
|
1811
|
-
|
|
1812
|
-
if (!(options && options.manualPersist)) {
|
|
1813
|
-
persistor.persist();
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
return persistor;
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
var shim = {exports: {}};
|
|
1820
|
-
|
|
1821
|
-
var useSyncExternalStoreShim_production_min = {};
|
|
1822
|
-
|
|
1823
|
-
/**
|
|
1824
|
-
* @license React
|
|
1825
|
-
* use-sync-external-store-shim.production.min.js
|
|
1826
|
-
*
|
|
1827
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1828
|
-
*
|
|
1829
|
-
* This source code is licensed under the MIT license found in the
|
|
1830
|
-
* LICENSE file in the root directory of this source tree.
|
|
1831
|
-
*/
|
|
1832
|
-
|
|
1833
|
-
var hasRequiredUseSyncExternalStoreShim_production_min;
|
|
1834
|
-
|
|
1835
|
-
function requireUseSyncExternalStoreShim_production_min () {
|
|
1836
|
-
if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
|
|
1837
|
-
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
1838
|
-
var e=React__default;function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
|
|
1839
|
-
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
|
|
1840
|
-
return useSyncExternalStoreShim_production_min;
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
var useSyncExternalStoreShim_development = {};
|
|
1844
|
-
|
|
1845
|
-
/**
|
|
1846
|
-
* @license React
|
|
1847
|
-
* use-sync-external-store-shim.development.js
|
|
1848
|
-
*
|
|
1849
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1850
|
-
*
|
|
1851
|
-
* This source code is licensed under the MIT license found in the
|
|
1852
|
-
* LICENSE file in the root directory of this source tree.
|
|
1853
|
-
*/
|
|
1854
|
-
|
|
1855
|
-
var hasRequiredUseSyncExternalStoreShim_development;
|
|
1856
|
-
|
|
1857
|
-
function requireUseSyncExternalStoreShim_development () {
|
|
1858
|
-
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
1859
|
-
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
1860
|
-
|
|
1861
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1862
|
-
(function() {
|
|
1863
|
-
|
|
1864
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
1865
|
-
if (
|
|
1866
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
1867
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
1868
|
-
'function'
|
|
1869
|
-
) {
|
|
1870
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
1871
|
-
}
|
|
1872
|
-
var React = React__default;
|
|
1873
|
-
|
|
1874
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
1875
|
-
|
|
1876
|
-
function error(format) {
|
|
1877
|
-
{
|
|
1878
|
-
{
|
|
1879
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1880
|
-
args[_key2 - 1] = arguments[_key2];
|
|
1881
|
-
}
|
|
1882
|
-
|
|
1883
|
-
printWarning('error', format, args);
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
|
|
1888
|
-
function printWarning(level, format, args) {
|
|
1889
|
-
// When changing this logic, you might want to also
|
|
1890
|
-
// update consoleWithStackDev.www.js as well.
|
|
1891
|
-
{
|
|
1892
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
1893
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
1894
|
-
|
|
1895
|
-
if (stack !== '') {
|
|
1896
|
-
format += '%s';
|
|
1897
|
-
args = args.concat([stack]);
|
|
1898
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
var argsWithFormat = args.map(function (item) {
|
|
1902
|
-
return String(item);
|
|
1903
|
-
}); // Careful: RN currently depends on this prefix
|
|
1904
|
-
|
|
1905
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
1906
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
1907
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
|
1908
|
-
|
|
1909
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
|
|
1913
|
-
/**
|
|
1914
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
1915
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
1916
|
-
*/
|
|
1917
|
-
function is(x, y) {
|
|
1918
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
1919
|
-
;
|
|
1920
|
-
}
|
|
1921
|
-
|
|
1922
|
-
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
1923
|
-
|
|
1924
|
-
// dispatch for CommonJS interop named imports.
|
|
1925
|
-
|
|
1926
|
-
var useState = React.useState,
|
|
1927
|
-
useEffect = React.useEffect,
|
|
1928
|
-
useLayoutEffect = React.useLayoutEffect,
|
|
1929
|
-
useDebugValue = React.useDebugValue;
|
|
1930
|
-
var didWarnOld18Alpha = false;
|
|
1931
|
-
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
|
|
1932
|
-
// because of a very particular set of implementation details and assumptions
|
|
1933
|
-
// -- change any one of them and it will break. The most important assumption
|
|
1934
|
-
// is that updates are always synchronous, because concurrent rendering is
|
|
1935
|
-
// only available in versions of React that also have a built-in
|
|
1936
|
-
// useSyncExternalStore API. And we only use this shim when the built-in API
|
|
1937
|
-
// does not exist.
|
|
1938
|
-
//
|
|
1939
|
-
// Do not assume that the clever hacks used by this hook also work in general.
|
|
1940
|
-
// The point of this shim is to replace the need for hacks by other libraries.
|
|
1941
|
-
|
|
1942
|
-
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
1943
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
1944
|
-
// will need to track that themselves and return the correct value
|
|
1945
|
-
// from `getSnapshot`.
|
|
1946
|
-
getServerSnapshot) {
|
|
1947
|
-
{
|
|
1948
|
-
if (!didWarnOld18Alpha) {
|
|
1949
|
-
if (React.startTransition !== undefined) {
|
|
1950
|
-
didWarnOld18Alpha = true;
|
|
1951
|
-
|
|
1952
|
-
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
|
|
1953
|
-
}
|
|
1954
|
-
}
|
|
1955
|
-
} // Read the current snapshot from the store on every render. Again, this
|
|
1956
|
-
// breaks the rules of React, and only works here because of specific
|
|
1957
|
-
// implementation details, most importantly that updates are
|
|
1958
|
-
// always synchronous.
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
var value = getSnapshot();
|
|
1962
|
-
|
|
1963
|
-
{
|
|
1964
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
1965
|
-
var cachedValue = getSnapshot();
|
|
1966
|
-
|
|
1967
|
-
if (!objectIs(value, cachedValue)) {
|
|
1968
|
-
error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
1969
|
-
|
|
1970
|
-
didWarnUncachedGetSnapshot = true;
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
} // Because updates are synchronous, we don't queue them. Instead we force a
|
|
1974
|
-
// re-render whenever the subscribed state changes by updating an some
|
|
1975
|
-
// arbitrary useState hook. Then, during render, we call getSnapshot to read
|
|
1976
|
-
// the current value.
|
|
1977
|
-
//
|
|
1978
|
-
// Because we don't actually use the state returned by the useState hook, we
|
|
1979
|
-
// can save a bit of memory by storing other stuff in that slot.
|
|
1980
|
-
//
|
|
1981
|
-
// To implement the early bailout, we need to track some things on a mutable
|
|
1982
|
-
// object. Usually, we would put that in a useRef hook, but we can stash it in
|
|
1983
|
-
// our useState hook instead.
|
|
1984
|
-
//
|
|
1985
|
-
// To force a re-render, we call forceUpdate({inst}). That works because the
|
|
1986
|
-
// new object always fails an equality check.
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
var _useState = useState({
|
|
1990
|
-
inst: {
|
|
1991
|
-
value: value,
|
|
1992
|
-
getSnapshot: getSnapshot
|
|
1993
|
-
}
|
|
1994
|
-
}),
|
|
1995
|
-
inst = _useState[0].inst,
|
|
1996
|
-
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
|
|
1997
|
-
// in the layout phase so we can access it during the tearing check that
|
|
1998
|
-
// happens on subscribe.
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
useLayoutEffect(function () {
|
|
2002
|
-
inst.value = value;
|
|
2003
|
-
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
|
|
2004
|
-
// commit phase if there was an interleaved mutation. In concurrent mode
|
|
2005
|
-
// this can happen all the time, but even in synchronous mode, an earlier
|
|
2006
|
-
// effect may have mutated the store.
|
|
2007
|
-
|
|
2008
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
2009
|
-
// Force a re-render.
|
|
2010
|
-
forceUpdate({
|
|
2011
|
-
inst: inst
|
|
2012
|
-
});
|
|
2013
|
-
}
|
|
2014
|
-
}, [subscribe, value, getSnapshot]);
|
|
2015
|
-
useEffect(function () {
|
|
2016
|
-
// Check for changes right before subscribing. Subsequent changes will be
|
|
2017
|
-
// detected in the subscription handler.
|
|
2018
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
2019
|
-
// Force a re-render.
|
|
2020
|
-
forceUpdate({
|
|
2021
|
-
inst: inst
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
var handleStoreChange = function () {
|
|
2026
|
-
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
2027
|
-
// up to the consumer of this library to wrap their subscription event
|
|
2028
|
-
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
2029
|
-
// the case and print a warning in development?
|
|
2030
|
-
// The store changed. Check if the snapshot changed since the last time we
|
|
2031
|
-
// read from the store.
|
|
2032
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
2033
|
-
// Force a re-render.
|
|
2034
|
-
forceUpdate({
|
|
2035
|
-
inst: inst
|
|
2036
|
-
});
|
|
2037
|
-
}
|
|
2038
|
-
}; // Subscribe to the store and return a clean-up function.
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
return subscribe(handleStoreChange);
|
|
2042
|
-
}, [subscribe]);
|
|
2043
|
-
useDebugValue(value);
|
|
2044
|
-
return value;
|
|
2045
|
-
}
|
|
2046
|
-
|
|
2047
|
-
function checkIfSnapshotChanged(inst) {
|
|
2048
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
2049
|
-
var prevValue = inst.value;
|
|
2050
|
-
|
|
2051
|
-
try {
|
|
2052
|
-
var nextValue = latestGetSnapshot();
|
|
2053
|
-
return !objectIs(prevValue, nextValue);
|
|
2054
|
-
} catch (error) {
|
|
2055
|
-
return true;
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
2060
|
-
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
2061
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
2062
|
-
// will need to track that themselves and return the correct value
|
|
2063
|
-
// from `getSnapshot`.
|
|
2064
|
-
return getSnapshot();
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
2068
|
-
|
|
2069
|
-
var isServerEnvironment = !canUseDOM;
|
|
2070
|
-
|
|
2071
|
-
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
2072
|
-
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
2073
|
-
|
|
2074
|
-
useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
|
2075
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
2076
|
-
if (
|
|
2077
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
2078
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
2079
|
-
'function'
|
|
2080
|
-
) {
|
|
2081
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
})();
|
|
2085
|
-
}
|
|
2086
|
-
return useSyncExternalStoreShim_development;
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
|
-
(function (module) {
|
|
2090
|
-
|
|
2091
|
-
if (process.env.NODE_ENV === 'production') {
|
|
2092
|
-
module.exports = requireUseSyncExternalStoreShim_production_min();
|
|
2093
|
-
} else {
|
|
2094
|
-
module.exports = requireUseSyncExternalStoreShim_development();
|
|
2095
|
-
}
|
|
2096
|
-
} (shim));
|
|
2097
|
-
|
|
2098
|
-
var withSelector = {exports: {}};
|
|
2099
|
-
|
|
2100
|
-
var withSelector_production_min = {};
|
|
2101
|
-
|
|
2102
|
-
/**
|
|
2103
|
-
* @license React
|
|
2104
|
-
* use-sync-external-store-shim/with-selector.production.min.js
|
|
2105
|
-
*
|
|
2106
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2107
|
-
*
|
|
2108
|
-
* This source code is licensed under the MIT license found in the
|
|
2109
|
-
* LICENSE file in the root directory of this source tree.
|
|
2110
|
-
*/
|
|
2111
|
-
|
|
2112
|
-
var hasRequiredWithSelector_production_min;
|
|
2113
|
-
|
|
2114
|
-
function requireWithSelector_production_min () {
|
|
2115
|
-
if (hasRequiredWithSelector_production_min) return withSelector_production_min;
|
|
2116
|
-
hasRequiredWithSelector_production_min = 1;
|
|
2117
|
-
var h=React__default,n=shim.exports;function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
|
|
2118
|
-
withSelector_production_min.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f;}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(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,g]);var d=r(a,c[0],c[1]);
|
|
2119
|
-
u(function(){f.hasValue=!0;f.value=d;},[d]);w(d);return d};
|
|
2120
|
-
return withSelector_production_min;
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
var withSelector_development = {};
|
|
2124
|
-
|
|
2125
|
-
/**
|
|
2126
|
-
* @license React
|
|
2127
|
-
* use-sync-external-store-shim/with-selector.development.js
|
|
2128
|
-
*
|
|
2129
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2130
|
-
*
|
|
2131
|
-
* This source code is licensed under the MIT license found in the
|
|
2132
|
-
* LICENSE file in the root directory of this source tree.
|
|
2133
|
-
*/
|
|
2134
|
-
|
|
2135
|
-
var hasRequiredWithSelector_development;
|
|
2136
|
-
|
|
2137
|
-
function requireWithSelector_development () {
|
|
2138
|
-
if (hasRequiredWithSelector_development) return withSelector_development;
|
|
2139
|
-
hasRequiredWithSelector_development = 1;
|
|
2140
|
-
|
|
2141
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2142
|
-
(function() {
|
|
2143
|
-
|
|
2144
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
2145
|
-
if (
|
|
2146
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
2147
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
2148
|
-
'function'
|
|
2149
|
-
) {
|
|
2150
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
2151
|
-
}
|
|
2152
|
-
var React = React__default;
|
|
2153
|
-
var shim$1 = shim.exports;
|
|
2154
|
-
|
|
2155
|
-
/**
|
|
2156
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
2157
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
2158
|
-
*/
|
|
2159
|
-
function is(x, y) {
|
|
2160
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
2161
|
-
;
|
|
2162
|
-
}
|
|
2163
|
-
|
|
2164
|
-
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
2165
|
-
|
|
2166
|
-
var useSyncExternalStore = shim$1.useSyncExternalStore;
|
|
2167
|
-
|
|
2168
|
-
// for CommonJS interop.
|
|
2169
|
-
|
|
2170
|
-
var useRef = React.useRef,
|
|
2171
|
-
useEffect = React.useEffect,
|
|
2172
|
-
useMemo = React.useMemo,
|
|
2173
|
-
useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
|
|
2174
|
-
|
|
2175
|
-
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
2176
|
-
// Use this to track the rendered snapshot.
|
|
2177
|
-
var instRef = useRef(null);
|
|
2178
|
-
var inst;
|
|
2179
|
-
|
|
2180
|
-
if (instRef.current === null) {
|
|
2181
|
-
inst = {
|
|
2182
|
-
hasValue: false,
|
|
2183
|
-
value: null
|
|
2184
|
-
};
|
|
2185
|
-
instRef.current = inst;
|
|
2186
|
-
} else {
|
|
2187
|
-
inst = instRef.current;
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
var _useMemo = useMemo(function () {
|
|
2191
|
-
// Track the memoized state using closure variables that are local to this
|
|
2192
|
-
// memoized instance of a getSnapshot function. Intentionally not using a
|
|
2193
|
-
// useRef hook, because that state would be shared across all concurrent
|
|
2194
|
-
// copies of the hook/component.
|
|
2195
|
-
var hasMemo = false;
|
|
2196
|
-
var memoizedSnapshot;
|
|
2197
|
-
var memoizedSelection;
|
|
2198
|
-
|
|
2199
|
-
var memoizedSelector = function (nextSnapshot) {
|
|
2200
|
-
if (!hasMemo) {
|
|
2201
|
-
// The first time the hook is called, there is no memoized result.
|
|
2202
|
-
hasMemo = true;
|
|
2203
|
-
memoizedSnapshot = nextSnapshot;
|
|
2204
|
-
|
|
2205
|
-
var _nextSelection = selector(nextSnapshot);
|
|
2206
|
-
|
|
2207
|
-
if (isEqual !== undefined) {
|
|
2208
|
-
// Even if the selector has changed, the currently rendered selection
|
|
2209
|
-
// may be equal to the new selection. We should attempt to reuse the
|
|
2210
|
-
// current value if possible, to preserve downstream memoizations.
|
|
2211
|
-
if (inst.hasValue) {
|
|
2212
|
-
var currentSelection = inst.value;
|
|
2213
|
-
|
|
2214
|
-
if (isEqual(currentSelection, _nextSelection)) {
|
|
2215
|
-
memoizedSelection = currentSelection;
|
|
2216
|
-
return currentSelection;
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
|
|
2221
|
-
memoizedSelection = _nextSelection;
|
|
2222
|
-
return _nextSelection;
|
|
2223
|
-
} // We may be able to reuse the previous invocation's result.
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
// We may be able to reuse the previous invocation's result.
|
|
2227
|
-
var prevSnapshot = memoizedSnapshot;
|
|
2228
|
-
var prevSelection = memoizedSelection;
|
|
2229
|
-
|
|
2230
|
-
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
2231
|
-
// The snapshot is the same as last time. Reuse the previous selection.
|
|
2232
|
-
return prevSelection;
|
|
2233
|
-
} // The snapshot has changed, so we need to compute a new selection.
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
// The snapshot has changed, so we need to compute a new selection.
|
|
2237
|
-
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
|
|
2238
|
-
// has changed. If it hasn't, return the previous selection. That signals
|
|
2239
|
-
// to React that the selections are conceptually equal, and we can bail
|
|
2240
|
-
// out of rendering.
|
|
2241
|
-
|
|
2242
|
-
// If a custom isEqual function is provided, use that to check if the data
|
|
2243
|
-
// has changed. If it hasn't, return the previous selection. That signals
|
|
2244
|
-
// to React that the selections are conceptually equal, and we can bail
|
|
2245
|
-
// out of rendering.
|
|
2246
|
-
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
|
|
2247
|
-
return prevSelection;
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
memoizedSnapshot = nextSnapshot;
|
|
2251
|
-
memoizedSelection = nextSelection;
|
|
2252
|
-
return nextSelection;
|
|
2253
|
-
}; // Assigning this to a constant so that Flow knows it can't change.
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
// Assigning this to a constant so that Flow knows it can't change.
|
|
2257
|
-
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
|
|
2258
|
-
|
|
2259
|
-
var getSnapshotWithSelector = function () {
|
|
2260
|
-
return memoizedSelector(getSnapshot());
|
|
2261
|
-
};
|
|
2262
|
-
|
|
2263
|
-
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
|
|
2264
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
|
2265
|
-
};
|
|
2266
|
-
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
2267
|
-
}, [getSnapshot, getServerSnapshot, selector, isEqual]),
|
|
2268
|
-
getSelection = _useMemo[0],
|
|
2269
|
-
getServerSelection = _useMemo[1];
|
|
2270
|
-
|
|
2271
|
-
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
2272
|
-
useEffect(function () {
|
|
2273
|
-
inst.hasValue = true;
|
|
2274
|
-
inst.value = value;
|
|
2275
|
-
}, [value]);
|
|
2276
|
-
useDebugValue(value);
|
|
2277
|
-
return value;
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
|
|
2281
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
2282
|
-
if (
|
|
2283
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
2284
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
2285
|
-
'function'
|
|
2286
|
-
) {
|
|
2287
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
|
-
})();
|
|
2291
|
-
}
|
|
2292
|
-
return withSelector_development;
|
|
2293
|
-
}
|
|
2294
|
-
|
|
2295
|
-
(function (module) {
|
|
2296
|
-
|
|
2297
|
-
if (process.env.NODE_ENV === 'production') {
|
|
2298
|
-
module.exports = requireWithSelector_production_min();
|
|
2299
|
-
} else {
|
|
2300
|
-
module.exports = requireWithSelector_development();
|
|
2301
|
-
}
|
|
2302
|
-
} (withSelector));
|
|
2303
|
-
|
|
2304
|
-
// Default to a dummy "batch" implementation that just runs the callback
|
|
2305
|
-
function defaultNoopBatch(callback) {
|
|
2306
|
-
callback();
|
|
2307
|
-
}
|
|
2308
|
-
|
|
2309
|
-
let batch = defaultNoopBatch; // Allow injecting another batching function later
|
|
2310
|
-
|
|
2311
|
-
const setBatch = newBatch => batch = newBatch; // Supply a getter just to skip dealing with ESM bindings
|
|
2312
|
-
|
|
2313
|
-
const getBatch = () => batch;
|
|
2314
|
-
|
|
2315
|
-
const ReactReduxContext = /*#__PURE__*/createContext(null);
|
|
2316
|
-
|
|
2317
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2318
|
-
ReactReduxContext.displayName = 'ReactRedux';
|
|
2319
|
-
}
|
|
2320
|
-
|
|
2321
|
-
/**
|
|
2322
|
-
* A hook to access the value of the `ReactReduxContext`. This is a low-level
|
|
2323
|
-
* hook that you should usually not need to call directly.
|
|
2324
|
-
*
|
|
2325
|
-
* @returns {any} the value of the `ReactReduxContext`
|
|
2326
|
-
*
|
|
2327
|
-
* @example
|
|
2328
|
-
*
|
|
2329
|
-
* import React from 'react'
|
|
2330
|
-
* import { useReduxContext } from 'react-redux'
|
|
2331
|
-
*
|
|
2332
|
-
* export const CounterComponent = () => {
|
|
2333
|
-
* const { store } = useReduxContext()
|
|
2334
|
-
* return <div>{store.getState()}</div>
|
|
2335
|
-
* }
|
|
2336
|
-
*/
|
|
2337
|
-
function useReduxContext() {
|
|
2338
|
-
const contextValue = useContext(ReactReduxContext);
|
|
2339
|
-
|
|
2340
|
-
if (process.env.NODE_ENV !== 'production' && !contextValue) {
|
|
2341
|
-
throw new Error('could not find react-redux context value; please ensure the component is wrapped in a <Provider>');
|
|
2342
|
-
}
|
|
2343
|
-
|
|
2344
|
-
return contextValue;
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
|
-
const notInitialized = () => {
|
|
2348
|
-
throw new Error('uSES not initialized!');
|
|
2349
|
-
};
|
|
2350
|
-
|
|
2351
|
-
let useSyncExternalStoreWithSelector = notInitialized;
|
|
2352
|
-
const initializeUseSelector = fn => {
|
|
2353
|
-
useSyncExternalStoreWithSelector = fn;
|
|
2354
|
-
};
|
|
2355
|
-
|
|
2356
|
-
const refEquality = (a, b) => a === b;
|
|
2357
|
-
/**
|
|
2358
|
-
* Hook factory, which creates a `useSelector` hook bound to a given context.
|
|
2359
|
-
*
|
|
2360
|
-
* @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
|
|
2361
|
-
* @returns {Function} A `useSelector` hook bound to the specified context.
|
|
2362
|
-
*/
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
function createSelectorHook(context = ReactReduxContext) {
|
|
2366
|
-
const useReduxContext$1 = context === ReactReduxContext ? useReduxContext : () => useContext(context);
|
|
2367
|
-
return function useSelector(selector, equalityFn = refEquality) {
|
|
2368
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2369
|
-
if (!selector) {
|
|
2370
|
-
throw new Error(`You must pass a selector to useSelector`);
|
|
2371
|
-
}
|
|
2372
|
-
|
|
2373
|
-
if (typeof selector !== 'function') {
|
|
2374
|
-
throw new Error(`You must pass a function as a selector to useSelector`);
|
|
2375
|
-
}
|
|
2376
|
-
|
|
2377
|
-
if (typeof equalityFn !== 'function') {
|
|
2378
|
-
throw new Error(`You must pass a function as an equality function to useSelector`);
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
|
|
2382
|
-
const {
|
|
2383
|
-
store,
|
|
2384
|
-
subscription,
|
|
2385
|
-
getServerState
|
|
2386
|
-
} = useReduxContext$1();
|
|
2387
|
-
const selectedState = useSyncExternalStoreWithSelector(subscription.addNestedSub, store.getState, getServerState || store.getState, selector, equalityFn);
|
|
2388
|
-
useDebugValue(selectedState);
|
|
2389
|
-
return selectedState;
|
|
2390
|
-
};
|
|
2391
|
-
}
|
|
2392
|
-
/**
|
|
2393
|
-
* A hook to access the redux store's state. This hook takes a selector function
|
|
2394
|
-
* as an argument. The selector is called with the store state.
|
|
2395
|
-
*
|
|
2396
|
-
* This hook takes an optional equality comparison function as the second parameter
|
|
2397
|
-
* that allows you to customize the way the selected state is compared to determine
|
|
2398
|
-
* whether the component needs to be re-rendered.
|
|
2399
|
-
*
|
|
2400
|
-
* @param {Function} selector the selector function
|
|
2401
|
-
* @param {Function=} equalityFn the function that will be used to determine equality
|
|
2402
|
-
*
|
|
2403
|
-
* @returns {any} the selected state
|
|
2404
|
-
*
|
|
2405
|
-
* @example
|
|
2406
|
-
*
|
|
2407
|
-
* import React from 'react'
|
|
2408
|
-
* import { useSelector } from 'react-redux'
|
|
2409
|
-
*
|
|
2410
|
-
* export const CounterComponent = () => {
|
|
2411
|
-
* const counter = useSelector(state => state.counter)
|
|
2412
|
-
* return <div>{counter}</div>
|
|
2413
|
-
* }
|
|
2414
|
-
*/
|
|
2415
|
-
|
|
2416
|
-
const useSelector = /*#__PURE__*/createSelectorHook();
|
|
2417
|
-
|
|
2418
|
-
var reactIs$2 = {exports: {}};
|
|
2419
|
-
|
|
2420
|
-
var reactIs_production_min$1 = {};
|
|
2421
|
-
|
|
2422
|
-
/** @license React v16.13.1
|
|
2423
|
-
* react-is.production.min.js
|
|
2424
|
-
*
|
|
2425
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2426
|
-
*
|
|
2427
|
-
* This source code is licensed under the MIT license found in the
|
|
2428
|
-
* LICENSE file in the root directory of this source tree.
|
|
2429
|
-
*/
|
|
2430
|
-
|
|
2431
|
-
var hasRequiredReactIs_production_min$1;
|
|
2432
|
-
|
|
2433
|
-
function requireReactIs_production_min$1 () {
|
|
2434
|
-
if (hasRequiredReactIs_production_min$1) return reactIs_production_min$1;
|
|
2435
|
-
hasRequiredReactIs_production_min$1 = 1;
|
|
2436
|
-
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
|
|
2437
|
-
Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
|
|
2438
|
-
function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min$1.AsyncMode=l;reactIs_production_min$1.ConcurrentMode=m;reactIs_production_min$1.ContextConsumer=k;reactIs_production_min$1.ContextProvider=h;reactIs_production_min$1.Element=c;reactIs_production_min$1.ForwardRef=n;reactIs_production_min$1.Fragment=e;reactIs_production_min$1.Lazy=t;reactIs_production_min$1.Memo=r;reactIs_production_min$1.Portal=d;
|
|
2439
|
-
reactIs_production_min$1.Profiler=g;reactIs_production_min$1.StrictMode=f;reactIs_production_min$1.Suspense=p;reactIs_production_min$1.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min$1.isConcurrentMode=A;reactIs_production_min$1.isContextConsumer=function(a){return z(a)===k};reactIs_production_min$1.isContextProvider=function(a){return z(a)===h};reactIs_production_min$1.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min$1.isForwardRef=function(a){return z(a)===n};reactIs_production_min$1.isFragment=function(a){return z(a)===e};reactIs_production_min$1.isLazy=function(a){return z(a)===t};
|
|
2440
|
-
reactIs_production_min$1.isMemo=function(a){return z(a)===r};reactIs_production_min$1.isPortal=function(a){return z(a)===d};reactIs_production_min$1.isProfiler=function(a){return z(a)===g};reactIs_production_min$1.isStrictMode=function(a){return z(a)===f};reactIs_production_min$1.isSuspense=function(a){return z(a)===p};
|
|
2441
|
-
reactIs_production_min$1.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min$1.typeOf=z;
|
|
2442
|
-
return reactIs_production_min$1;
|
|
2443
|
-
}
|
|
2444
|
-
|
|
2445
|
-
var reactIs_development$1 = {};
|
|
2446
|
-
|
|
2447
|
-
/** @license React v16.13.1
|
|
2448
|
-
* react-is.development.js
|
|
2449
|
-
*
|
|
2450
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2451
|
-
*
|
|
2452
|
-
* This source code is licensed under the MIT license found in the
|
|
2453
|
-
* LICENSE file in the root directory of this source tree.
|
|
2454
|
-
*/
|
|
2455
|
-
|
|
2456
|
-
var hasRequiredReactIs_development$1;
|
|
2457
|
-
|
|
2458
|
-
function requireReactIs_development$1 () {
|
|
2459
|
-
if (hasRequiredReactIs_development$1) return reactIs_development$1;
|
|
2460
|
-
hasRequiredReactIs_development$1 = 1;
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2465
|
-
(function() {
|
|
2466
|
-
|
|
2467
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
2468
|
-
// nor polyfill, then a plain number is used for performance.
|
|
2469
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
2470
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
2471
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
2472
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
2473
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
2474
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
2475
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
2476
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
2477
|
-
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
2478
|
-
|
|
2479
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
2480
|
-
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
2481
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
2482
|
-
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
2483
|
-
var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
|
2484
|
-
var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
2485
|
-
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
2486
|
-
var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
|
2487
|
-
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
2488
|
-
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
2489
|
-
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
2490
|
-
|
|
2491
|
-
function isValidElementType(type) {
|
|
2492
|
-
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
2493
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (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 || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
|
|
2494
|
-
}
|
|
2495
|
-
|
|
2496
|
-
function typeOf(object) {
|
|
2497
|
-
if (typeof object === 'object' && object !== null) {
|
|
2498
|
-
var $$typeof = object.$$typeof;
|
|
2499
|
-
|
|
2500
|
-
switch ($$typeof) {
|
|
2501
|
-
case REACT_ELEMENT_TYPE:
|
|
2502
|
-
var type = object.type;
|
|
2503
|
-
|
|
2504
|
-
switch (type) {
|
|
2505
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
2506
|
-
case REACT_CONCURRENT_MODE_TYPE:
|
|
2507
|
-
case REACT_FRAGMENT_TYPE:
|
|
2508
|
-
case REACT_PROFILER_TYPE:
|
|
2509
|
-
case REACT_STRICT_MODE_TYPE:
|
|
2510
|
-
case REACT_SUSPENSE_TYPE:
|
|
2511
|
-
return type;
|
|
2512
|
-
|
|
2513
|
-
default:
|
|
2514
|
-
var $$typeofType = type && type.$$typeof;
|
|
2515
|
-
|
|
2516
|
-
switch ($$typeofType) {
|
|
2517
|
-
case REACT_CONTEXT_TYPE:
|
|
2518
|
-
case REACT_FORWARD_REF_TYPE:
|
|
2519
|
-
case REACT_LAZY_TYPE:
|
|
2520
|
-
case REACT_MEMO_TYPE:
|
|
2521
|
-
case REACT_PROVIDER_TYPE:
|
|
2522
|
-
return $$typeofType;
|
|
2523
|
-
|
|
2524
|
-
default:
|
|
2525
|
-
return $$typeof;
|
|
2526
|
-
}
|
|
2527
|
-
|
|
2528
|
-
}
|
|
2529
|
-
|
|
2530
|
-
case REACT_PORTAL_TYPE:
|
|
2531
|
-
return $$typeof;
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2534
|
-
|
|
2535
|
-
return undefined;
|
|
2536
|
-
} // AsyncMode is deprecated along with isAsyncMode
|
|
2537
|
-
|
|
2538
|
-
var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
|
2539
|
-
var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
|
2540
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
2541
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
2542
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
2543
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
2544
|
-
var Fragment = REACT_FRAGMENT_TYPE;
|
|
2545
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
2546
|
-
var Memo = REACT_MEMO_TYPE;
|
|
2547
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
2548
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
2549
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
2550
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
2551
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
|
|
2552
|
-
|
|
2553
|
-
function isAsyncMode(object) {
|
|
2554
|
-
{
|
|
2555
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
2556
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
2557
|
-
|
|
2558
|
-
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
|
|
2559
|
-
}
|
|
2560
|
-
}
|
|
2561
|
-
|
|
2562
|
-
return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
|
2563
|
-
}
|
|
2564
|
-
function isConcurrentMode(object) {
|
|
2565
|
-
return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
|
2566
|
-
}
|
|
2567
|
-
function isContextConsumer(object) {
|
|
2568
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
2569
|
-
}
|
|
2570
|
-
function isContextProvider(object) {
|
|
2571
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
2572
|
-
}
|
|
2573
|
-
function isElement(object) {
|
|
2574
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
2575
|
-
}
|
|
2576
|
-
function isForwardRef(object) {
|
|
2577
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
2578
|
-
}
|
|
2579
|
-
function isFragment(object) {
|
|
2580
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
2581
|
-
}
|
|
2582
|
-
function isLazy(object) {
|
|
2583
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
2584
|
-
}
|
|
2585
|
-
function isMemo(object) {
|
|
2586
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
2587
|
-
}
|
|
2588
|
-
function isPortal(object) {
|
|
2589
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
2590
|
-
}
|
|
2591
|
-
function isProfiler(object) {
|
|
2592
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
2593
|
-
}
|
|
2594
|
-
function isStrictMode(object) {
|
|
2595
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
2596
|
-
}
|
|
2597
|
-
function isSuspense(object) {
|
|
2598
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
2599
|
-
}
|
|
2600
|
-
|
|
2601
|
-
reactIs_development$1.AsyncMode = AsyncMode;
|
|
2602
|
-
reactIs_development$1.ConcurrentMode = ConcurrentMode;
|
|
2603
|
-
reactIs_development$1.ContextConsumer = ContextConsumer;
|
|
2604
|
-
reactIs_development$1.ContextProvider = ContextProvider;
|
|
2605
|
-
reactIs_development$1.Element = Element;
|
|
2606
|
-
reactIs_development$1.ForwardRef = ForwardRef;
|
|
2607
|
-
reactIs_development$1.Fragment = Fragment;
|
|
2608
|
-
reactIs_development$1.Lazy = Lazy;
|
|
2609
|
-
reactIs_development$1.Memo = Memo;
|
|
2610
|
-
reactIs_development$1.Portal = Portal;
|
|
2611
|
-
reactIs_development$1.Profiler = Profiler;
|
|
2612
|
-
reactIs_development$1.StrictMode = StrictMode;
|
|
2613
|
-
reactIs_development$1.Suspense = Suspense;
|
|
2614
|
-
reactIs_development$1.isAsyncMode = isAsyncMode;
|
|
2615
|
-
reactIs_development$1.isConcurrentMode = isConcurrentMode;
|
|
2616
|
-
reactIs_development$1.isContextConsumer = isContextConsumer;
|
|
2617
|
-
reactIs_development$1.isContextProvider = isContextProvider;
|
|
2618
|
-
reactIs_development$1.isElement = isElement;
|
|
2619
|
-
reactIs_development$1.isForwardRef = isForwardRef;
|
|
2620
|
-
reactIs_development$1.isFragment = isFragment;
|
|
2621
|
-
reactIs_development$1.isLazy = isLazy;
|
|
2622
|
-
reactIs_development$1.isMemo = isMemo;
|
|
2623
|
-
reactIs_development$1.isPortal = isPortal;
|
|
2624
|
-
reactIs_development$1.isProfiler = isProfiler;
|
|
2625
|
-
reactIs_development$1.isStrictMode = isStrictMode;
|
|
2626
|
-
reactIs_development$1.isSuspense = isSuspense;
|
|
2627
|
-
reactIs_development$1.isValidElementType = isValidElementType;
|
|
2628
|
-
reactIs_development$1.typeOf = typeOf;
|
|
2629
|
-
})();
|
|
2630
|
-
}
|
|
2631
|
-
return reactIs_development$1;
|
|
2632
|
-
}
|
|
2633
|
-
|
|
2634
|
-
(function (module) {
|
|
2635
|
-
|
|
2636
|
-
if (process.env.NODE_ENV === 'production') {
|
|
2637
|
-
module.exports = requireReactIs_production_min$1();
|
|
2638
|
-
} else {
|
|
2639
|
-
module.exports = requireReactIs_development$1();
|
|
2640
|
-
}
|
|
2641
|
-
} (reactIs$2));
|
|
2642
|
-
|
|
2643
|
-
var reactIs$1 = reactIs$2.exports;
|
|
2644
|
-
var FORWARD_REF_STATICS = {
|
|
2645
|
-
'$$typeof': true,
|
|
2646
|
-
render: true,
|
|
2647
|
-
defaultProps: true,
|
|
2648
|
-
displayName: true,
|
|
2649
|
-
propTypes: true
|
|
2650
|
-
};
|
|
2651
|
-
var MEMO_STATICS = {
|
|
2652
|
-
'$$typeof': true,
|
|
2653
|
-
compare: true,
|
|
2654
|
-
defaultProps: true,
|
|
2655
|
-
displayName: true,
|
|
2656
|
-
propTypes: true,
|
|
2657
|
-
type: true
|
|
2658
|
-
};
|
|
2659
|
-
var TYPE_STATICS = {};
|
|
2660
|
-
TYPE_STATICS[reactIs$1.ForwardRef] = FORWARD_REF_STATICS;
|
|
2661
|
-
TYPE_STATICS[reactIs$1.Memo] = MEMO_STATICS;
|
|
2662
|
-
|
|
2663
|
-
var reactIs = {exports: {}};
|
|
2664
|
-
|
|
2665
|
-
var reactIs_production_min = {};
|
|
2666
|
-
|
|
2667
|
-
/**
|
|
2668
|
-
* @license React
|
|
2669
|
-
* react-is.production.min.js
|
|
2670
|
-
*
|
|
2671
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2672
|
-
*
|
|
2673
|
-
* This source code is licensed under the MIT license found in the
|
|
2674
|
-
* LICENSE file in the root directory of this source tree.
|
|
2675
|
-
*/
|
|
2676
|
-
|
|
2677
|
-
var hasRequiredReactIs_production_min;
|
|
2678
|
-
|
|
2679
|
-
function requireReactIs_production_min () {
|
|
2680
|
-
if (hasRequiredReactIs_production_min) return reactIs_production_min;
|
|
2681
|
-
hasRequiredReactIs_production_min = 1;
|
|
2682
|
-
var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference");
|
|
2683
|
-
function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=g;reactIs_production_min.Element=b;reactIs_production_min.ForwardRef=l;reactIs_production_min.Fragment=d;reactIs_production_min.Lazy=q;reactIs_production_min.Memo=p;reactIs_production_min.Portal=c;reactIs_production_min.Profiler=f;reactIs_production_min.StrictMode=e;reactIs_production_min.Suspense=m;
|
|
2684
|
-
reactIs_production_min.SuspenseList=n;reactIs_production_min.isAsyncMode=function(){return !1};reactIs_production_min.isConcurrentMode=function(){return !1};reactIs_production_min.isContextConsumer=function(a){return v(a)===h};reactIs_production_min.isContextProvider=function(a){return v(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return v(a)===l};reactIs_production_min.isFragment=function(a){return v(a)===d};reactIs_production_min.isLazy=function(a){return v(a)===q};reactIs_production_min.isMemo=function(a){return v(a)===p};
|
|
2685
|
-
reactIs_production_min.isPortal=function(a){return v(a)===c};reactIs_production_min.isProfiler=function(a){return v(a)===f};reactIs_production_min.isStrictMode=function(a){return v(a)===e};reactIs_production_min.isSuspense=function(a){return v(a)===m};reactIs_production_min.isSuspenseList=function(a){return v(a)===n};
|
|
2686
|
-
reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};reactIs_production_min.typeOf=v;
|
|
2687
|
-
return reactIs_production_min;
|
|
2688
|
-
}
|
|
2689
|
-
|
|
2690
|
-
var reactIs_development = {};
|
|
2691
|
-
|
|
2692
|
-
/**
|
|
2693
|
-
* @license React
|
|
2694
|
-
* react-is.development.js
|
|
2695
|
-
*
|
|
2696
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2697
|
-
*
|
|
2698
|
-
* This source code is licensed under the MIT license found in the
|
|
2699
|
-
* LICENSE file in the root directory of this source tree.
|
|
2700
|
-
*/
|
|
2701
|
-
|
|
2702
|
-
var hasRequiredReactIs_development;
|
|
2703
|
-
|
|
2704
|
-
function requireReactIs_development () {
|
|
2705
|
-
if (hasRequiredReactIs_development) return reactIs_development;
|
|
2706
|
-
hasRequiredReactIs_development = 1;
|
|
2707
|
-
|
|
2708
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2709
|
-
(function() {
|
|
2710
|
-
|
|
2711
|
-
// ATTENTION
|
|
2712
|
-
// When adding new symbols to this file,
|
|
2713
|
-
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
|
2714
|
-
// The Symbol used to tag the ReactElement-like types.
|
|
2715
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
|
2716
|
-
var REACT_PORTAL_TYPE = Symbol.for('react.portal');
|
|
2717
|
-
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
|
2718
|
-
var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
|
|
2719
|
-
var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
|
|
2720
|
-
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
|
2721
|
-
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
|
2722
|
-
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
|
2723
|
-
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
|
2724
|
-
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
|
2725
|
-
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
|
2726
|
-
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
|
2727
|
-
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
|
2728
|
-
var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
|
|
2729
|
-
|
|
2730
|
-
// -----------------------------------------------------------------------------
|
|
2731
|
-
|
|
2732
|
-
var enableScopeAPI = false; // Experimental Create Event Handle API.
|
|
2733
|
-
var enableCacheElement = false;
|
|
2734
|
-
var enableTransitionTracing = false; // No known bugs, but needs performance testing
|
|
2735
|
-
|
|
2736
|
-
var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
|
|
2737
|
-
// stuff. Intended to enable React core members to more easily debug scheduling
|
|
2738
|
-
// issues in DEV builds.
|
|
2739
|
-
|
|
2740
|
-
var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
|
|
2741
|
-
|
|
2742
|
-
var REACT_MODULE_REFERENCE;
|
|
2743
|
-
|
|
2744
|
-
{
|
|
2745
|
-
REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
|
|
2746
|
-
}
|
|
2747
|
-
|
|
2748
|
-
function isValidElementType(type) {
|
|
2749
|
-
if (typeof type === 'string' || typeof type === 'function') {
|
|
2750
|
-
return true;
|
|
2751
|
-
} // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
|
|
2755
|
-
return true;
|
|
2756
|
-
}
|
|
2757
|
-
|
|
2758
|
-
if (typeof type === 'object' && type !== null) {
|
|
2759
|
-
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
|
|
2760
|
-
// types supported by any Flight configuration anywhere since
|
|
2761
|
-
// we don't know which Flight build this will end up being used
|
|
2762
|
-
// with.
|
|
2763
|
-
type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
|
|
2764
|
-
return true;
|
|
2765
|
-
}
|
|
2766
|
-
}
|
|
2767
|
-
|
|
2768
|
-
return false;
|
|
2769
|
-
}
|
|
2770
|
-
|
|
2771
|
-
function typeOf(object) {
|
|
2772
|
-
if (typeof object === 'object' && object !== null) {
|
|
2773
|
-
var $$typeof = object.$$typeof;
|
|
2774
|
-
|
|
2775
|
-
switch ($$typeof) {
|
|
2776
|
-
case REACT_ELEMENT_TYPE:
|
|
2777
|
-
var type = object.type;
|
|
2778
|
-
|
|
2779
|
-
switch (type) {
|
|
2780
|
-
case REACT_FRAGMENT_TYPE:
|
|
2781
|
-
case REACT_PROFILER_TYPE:
|
|
2782
|
-
case REACT_STRICT_MODE_TYPE:
|
|
2783
|
-
case REACT_SUSPENSE_TYPE:
|
|
2784
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
2785
|
-
return type;
|
|
2786
|
-
|
|
2787
|
-
default:
|
|
2788
|
-
var $$typeofType = type && type.$$typeof;
|
|
2789
|
-
|
|
2790
|
-
switch ($$typeofType) {
|
|
2791
|
-
case REACT_SERVER_CONTEXT_TYPE:
|
|
2792
|
-
case REACT_CONTEXT_TYPE:
|
|
2793
|
-
case REACT_FORWARD_REF_TYPE:
|
|
2794
|
-
case REACT_LAZY_TYPE:
|
|
2795
|
-
case REACT_MEMO_TYPE:
|
|
2796
|
-
case REACT_PROVIDER_TYPE:
|
|
2797
|
-
return $$typeofType;
|
|
2798
|
-
|
|
2799
|
-
default:
|
|
2800
|
-
return $$typeof;
|
|
2801
|
-
}
|
|
2802
|
-
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2805
|
-
case REACT_PORTAL_TYPE:
|
|
2806
|
-
return $$typeof;
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
|
-
return undefined;
|
|
2811
|
-
}
|
|
2812
|
-
var ContextConsumer = REACT_CONTEXT_TYPE;
|
|
2813
|
-
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
2814
|
-
var Element = REACT_ELEMENT_TYPE;
|
|
2815
|
-
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
2816
|
-
var Fragment = REACT_FRAGMENT_TYPE;
|
|
2817
|
-
var Lazy = REACT_LAZY_TYPE;
|
|
2818
|
-
var Memo = REACT_MEMO_TYPE;
|
|
2819
|
-
var Portal = REACT_PORTAL_TYPE;
|
|
2820
|
-
var Profiler = REACT_PROFILER_TYPE;
|
|
2821
|
-
var StrictMode = REACT_STRICT_MODE_TYPE;
|
|
2822
|
-
var Suspense = REACT_SUSPENSE_TYPE;
|
|
2823
|
-
var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
2824
|
-
var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
|
2825
|
-
var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
|
|
2826
|
-
|
|
2827
|
-
function isAsyncMode(object) {
|
|
2828
|
-
{
|
|
2829
|
-
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
|
2830
|
-
hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
2831
|
-
|
|
2832
|
-
console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
|
|
2833
|
-
}
|
|
2834
|
-
}
|
|
2835
|
-
|
|
2836
|
-
return false;
|
|
2837
|
-
}
|
|
2838
|
-
function isConcurrentMode(object) {
|
|
2839
|
-
{
|
|
2840
|
-
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
|
|
2841
|
-
hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
|
|
2842
|
-
|
|
2843
|
-
console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
|
|
2844
|
-
}
|
|
2845
|
-
}
|
|
2846
|
-
|
|
2847
|
-
return false;
|
|
2848
|
-
}
|
|
2849
|
-
function isContextConsumer(object) {
|
|
2850
|
-
return typeOf(object) === REACT_CONTEXT_TYPE;
|
|
2851
|
-
}
|
|
2852
|
-
function isContextProvider(object) {
|
|
2853
|
-
return typeOf(object) === REACT_PROVIDER_TYPE;
|
|
2854
|
-
}
|
|
2855
|
-
function isElement(object) {
|
|
2856
|
-
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
2857
|
-
}
|
|
2858
|
-
function isForwardRef(object) {
|
|
2859
|
-
return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
|
2860
|
-
}
|
|
2861
|
-
function isFragment(object) {
|
|
2862
|
-
return typeOf(object) === REACT_FRAGMENT_TYPE;
|
|
2863
|
-
}
|
|
2864
|
-
function isLazy(object) {
|
|
2865
|
-
return typeOf(object) === REACT_LAZY_TYPE;
|
|
2866
|
-
}
|
|
2867
|
-
function isMemo(object) {
|
|
2868
|
-
return typeOf(object) === REACT_MEMO_TYPE;
|
|
2869
|
-
}
|
|
2870
|
-
function isPortal(object) {
|
|
2871
|
-
return typeOf(object) === REACT_PORTAL_TYPE;
|
|
2872
|
-
}
|
|
2873
|
-
function isProfiler(object) {
|
|
2874
|
-
return typeOf(object) === REACT_PROFILER_TYPE;
|
|
2875
|
-
}
|
|
2876
|
-
function isStrictMode(object) {
|
|
2877
|
-
return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
|
2878
|
-
}
|
|
2879
|
-
function isSuspense(object) {
|
|
2880
|
-
return typeOf(object) === REACT_SUSPENSE_TYPE;
|
|
2881
|
-
}
|
|
2882
|
-
function isSuspenseList(object) {
|
|
2883
|
-
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
|
|
2884
|
-
}
|
|
2885
|
-
|
|
2886
|
-
reactIs_development.ContextConsumer = ContextConsumer;
|
|
2887
|
-
reactIs_development.ContextProvider = ContextProvider;
|
|
2888
|
-
reactIs_development.Element = Element;
|
|
2889
|
-
reactIs_development.ForwardRef = ForwardRef;
|
|
2890
|
-
reactIs_development.Fragment = Fragment;
|
|
2891
|
-
reactIs_development.Lazy = Lazy;
|
|
2892
|
-
reactIs_development.Memo = Memo;
|
|
2893
|
-
reactIs_development.Portal = Portal;
|
|
2894
|
-
reactIs_development.Profiler = Profiler;
|
|
2895
|
-
reactIs_development.StrictMode = StrictMode;
|
|
2896
|
-
reactIs_development.Suspense = Suspense;
|
|
2897
|
-
reactIs_development.SuspenseList = SuspenseList;
|
|
2898
|
-
reactIs_development.isAsyncMode = isAsyncMode;
|
|
2899
|
-
reactIs_development.isConcurrentMode = isConcurrentMode;
|
|
2900
|
-
reactIs_development.isContextConsumer = isContextConsumer;
|
|
2901
|
-
reactIs_development.isContextProvider = isContextProvider;
|
|
2902
|
-
reactIs_development.isElement = isElement;
|
|
2903
|
-
reactIs_development.isForwardRef = isForwardRef;
|
|
2904
|
-
reactIs_development.isFragment = isFragment;
|
|
2905
|
-
reactIs_development.isLazy = isLazy;
|
|
2906
|
-
reactIs_development.isMemo = isMemo;
|
|
2907
|
-
reactIs_development.isPortal = isPortal;
|
|
2908
|
-
reactIs_development.isProfiler = isProfiler;
|
|
2909
|
-
reactIs_development.isStrictMode = isStrictMode;
|
|
2910
|
-
reactIs_development.isSuspense = isSuspense;
|
|
2911
|
-
reactIs_development.isSuspenseList = isSuspenseList;
|
|
2912
|
-
reactIs_development.isValidElementType = isValidElementType;
|
|
2913
|
-
reactIs_development.typeOf = typeOf;
|
|
2914
|
-
})();
|
|
2915
|
-
}
|
|
2916
|
-
return reactIs_development;
|
|
2917
|
-
}
|
|
2918
|
-
|
|
2919
|
-
(function (module) {
|
|
2920
|
-
|
|
2921
|
-
if (process.env.NODE_ENV === 'production') {
|
|
2922
|
-
module.exports = requireReactIs_production_min();
|
|
2923
|
-
} else {
|
|
2924
|
-
module.exports = requireReactIs_development();
|
|
2925
|
-
}
|
|
2926
|
-
} (reactIs));
|
|
2927
|
-
|
|
2928
|
-
// well as nesting subscriptions of descendant components, so that we can ensure the
|
|
2929
|
-
// ancestor components re-render before descendants
|
|
2930
|
-
|
|
2931
|
-
function createListenerCollection() {
|
|
2932
|
-
const batch = getBatch();
|
|
2933
|
-
let first = null;
|
|
2934
|
-
let last = null;
|
|
2935
|
-
return {
|
|
2936
|
-
clear() {
|
|
2937
|
-
first = null;
|
|
2938
|
-
last = null;
|
|
2939
|
-
},
|
|
2940
|
-
|
|
2941
|
-
notify() {
|
|
2942
|
-
batch(() => {
|
|
2943
|
-
let listener = first;
|
|
2944
|
-
|
|
2945
|
-
while (listener) {
|
|
2946
|
-
listener.callback();
|
|
2947
|
-
listener = listener.next;
|
|
2948
|
-
}
|
|
2949
|
-
});
|
|
2950
|
-
},
|
|
2951
|
-
|
|
2952
|
-
get() {
|
|
2953
|
-
let listeners = [];
|
|
2954
|
-
let listener = first;
|
|
2955
|
-
|
|
2956
|
-
while (listener) {
|
|
2957
|
-
listeners.push(listener);
|
|
2958
|
-
listener = listener.next;
|
|
2959
|
-
}
|
|
2960
|
-
|
|
2961
|
-
return listeners;
|
|
2962
|
-
},
|
|
2963
|
-
|
|
2964
|
-
subscribe(callback) {
|
|
2965
|
-
let isSubscribed = true;
|
|
2966
|
-
let listener = last = {
|
|
2967
|
-
callback,
|
|
2968
|
-
next: null,
|
|
2969
|
-
prev: last
|
|
2970
|
-
};
|
|
2971
|
-
|
|
2972
|
-
if (listener.prev) {
|
|
2973
|
-
listener.prev.next = listener;
|
|
2974
|
-
} else {
|
|
2975
|
-
first = listener;
|
|
2976
|
-
}
|
|
2977
|
-
|
|
2978
|
-
return function unsubscribe() {
|
|
2979
|
-
if (!isSubscribed || first === null) return;
|
|
2980
|
-
isSubscribed = false;
|
|
2981
|
-
|
|
2982
|
-
if (listener.next) {
|
|
2983
|
-
listener.next.prev = listener.prev;
|
|
2984
|
-
} else {
|
|
2985
|
-
last = listener.prev;
|
|
2986
|
-
}
|
|
2987
|
-
|
|
2988
|
-
if (listener.prev) {
|
|
2989
|
-
listener.prev.next = listener.next;
|
|
2990
|
-
} else {
|
|
2991
|
-
first = listener.next;
|
|
2992
|
-
}
|
|
2993
|
-
};
|
|
2994
|
-
}
|
|
2995
|
-
|
|
2996
|
-
};
|
|
2997
|
-
}
|
|
2998
|
-
|
|
2999
|
-
const nullListeners = {
|
|
3000
|
-
notify() {},
|
|
3001
|
-
|
|
3002
|
-
get: () => []
|
|
3003
|
-
};
|
|
3004
|
-
function createSubscription(store, parentSub) {
|
|
3005
|
-
let unsubscribe;
|
|
3006
|
-
let listeners = nullListeners;
|
|
3007
|
-
|
|
3008
|
-
function addNestedSub(listener) {
|
|
3009
|
-
trySubscribe();
|
|
3010
|
-
return listeners.subscribe(listener);
|
|
3011
|
-
}
|
|
3012
|
-
|
|
3013
|
-
function notifyNestedSubs() {
|
|
3014
|
-
listeners.notify();
|
|
3015
|
-
}
|
|
3016
|
-
|
|
3017
|
-
function handleChangeWrapper() {
|
|
3018
|
-
if (subscription.onStateChange) {
|
|
3019
|
-
subscription.onStateChange();
|
|
3020
|
-
}
|
|
3021
|
-
}
|
|
3022
|
-
|
|
3023
|
-
function isSubscribed() {
|
|
3024
|
-
return Boolean(unsubscribe);
|
|
3025
|
-
}
|
|
3026
|
-
|
|
3027
|
-
function trySubscribe() {
|
|
3028
|
-
if (!unsubscribe) {
|
|
3029
|
-
unsubscribe = parentSub ? parentSub.addNestedSub(handleChangeWrapper) : store.subscribe(handleChangeWrapper);
|
|
3030
|
-
listeners = createListenerCollection();
|
|
3031
|
-
}
|
|
3032
|
-
}
|
|
3033
|
-
|
|
3034
|
-
function tryUnsubscribe() {
|
|
3035
|
-
if (unsubscribe) {
|
|
3036
|
-
unsubscribe();
|
|
3037
|
-
unsubscribe = undefined;
|
|
3038
|
-
listeners.clear();
|
|
3039
|
-
listeners = nullListeners;
|
|
3040
|
-
}
|
|
3041
|
-
}
|
|
3042
|
-
|
|
3043
|
-
const subscription = {
|
|
3044
|
-
addNestedSub,
|
|
3045
|
-
notifyNestedSubs,
|
|
3046
|
-
handleChangeWrapper,
|
|
3047
|
-
isSubscribed,
|
|
3048
|
-
trySubscribe,
|
|
3049
|
-
tryUnsubscribe,
|
|
3050
|
-
getListeners: () => listeners
|
|
3051
|
-
};
|
|
3052
|
-
return subscription;
|
|
3053
|
-
}
|
|
3054
|
-
|
|
3055
|
-
// To get around it, we can conditionally useEffect on the server (no-op) and
|
|
3056
|
-
// useLayoutEffect in the browser. We need useLayoutEffect to ensure the store
|
|
3057
|
-
// subscription callback always has the selector from the latest render commit
|
|
3058
|
-
// available, otherwise a store update may happen between render and the effect,
|
|
3059
|
-
// which may cause missed updates; we also must ensure the store subscription
|
|
3060
|
-
// is created synchronously, otherwise a store update may occur before the
|
|
3061
|
-
// subscription is created and an inconsistent state may be observed
|
|
3062
|
-
// Matches logic in React's `shared/ExecutionEnvironment` file
|
|
3063
|
-
|
|
3064
|
-
const canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
3065
|
-
const useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
|
|
3066
|
-
|
|
3067
|
-
function Provider({
|
|
3068
|
-
store,
|
|
3069
|
-
context,
|
|
3070
|
-
children,
|
|
3071
|
-
serverState
|
|
3072
|
-
}) {
|
|
3073
|
-
const contextValue = useMemo(() => {
|
|
3074
|
-
const subscription = createSubscription(store);
|
|
3075
|
-
return {
|
|
3076
|
-
store,
|
|
3077
|
-
subscription,
|
|
3078
|
-
getServerState: serverState ? () => serverState : undefined
|
|
3079
|
-
};
|
|
3080
|
-
}, [store, serverState]);
|
|
3081
|
-
const previousState = useMemo(() => store.getState(), [store]);
|
|
3082
|
-
useIsomorphicLayoutEffect(() => {
|
|
3083
|
-
const {
|
|
3084
|
-
subscription
|
|
3085
|
-
} = contextValue;
|
|
3086
|
-
subscription.onStateChange = subscription.notifyNestedSubs;
|
|
3087
|
-
subscription.trySubscribe();
|
|
3088
|
-
|
|
3089
|
-
if (previousState !== store.getState()) {
|
|
3090
|
-
subscription.notifyNestedSubs();
|
|
3091
|
-
}
|
|
3092
|
-
|
|
3093
|
-
return () => {
|
|
3094
|
-
subscription.tryUnsubscribe();
|
|
3095
|
-
subscription.onStateChange = undefined;
|
|
3096
|
-
};
|
|
3097
|
-
}, [contextValue, previousState]);
|
|
3098
|
-
const Context = context || ReactReduxContext; // @ts-ignore 'AnyAction' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype
|
|
3099
|
-
|
|
3100
|
-
return /*#__PURE__*/React__default.createElement(Context.Provider, {
|
|
3101
|
-
value: contextValue
|
|
3102
|
-
}, children);
|
|
3103
|
-
}
|
|
3104
|
-
|
|
3105
|
-
// The primary entry point assumes we're working with standard ReactDOM/RN, but
|
|
3106
|
-
initializeUseSelector(withSelector.exports.useSyncExternalStoreWithSelector);
|
|
3107
|
-
// with standard React renderers (ReactDOM, React Native)
|
|
3108
|
-
|
|
3109
|
-
setBatch(unstable_batchedUpdates);
|
|
3110
|
-
|
|
3111
|
-
var CustomStorage = {
|
|
3112
|
-
getItem: function (_key) {
|
|
3113
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
3114
|
-
return __generator(this, function (_a) {
|
|
3115
|
-
return [2 /*return*/, {}];
|
|
3116
|
-
});
|
|
3117
|
-
});
|
|
3118
|
-
},
|
|
3119
|
-
setItem: function (_key, _value) {
|
|
3120
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
3121
|
-
return __generator(this, function (_a) {
|
|
3122
|
-
return [2 /*return*/, {}];
|
|
3123
|
-
});
|
|
3124
|
-
});
|
|
3125
|
-
},
|
|
3126
|
-
removeItem: function (_key) {
|
|
3127
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
3128
|
-
return __generator(this, function (_a) {
|
|
3129
|
-
return [2 /*return*/, {}];
|
|
3130
|
-
});
|
|
3131
|
-
});
|
|
3132
|
-
},
|
|
3133
|
-
};
|
|
3134
|
-
var persistConfig = {
|
|
3135
|
-
key: 'root',
|
|
3136
|
-
storage: CustomStorage
|
|
3137
|
-
};
|
|
3138
|
-
var reducer = combineReducers({
|
|
3139
|
-
reducer: persistReducer(persistConfig, appReducer),
|
|
3140
|
-
});
|
|
3141
|
-
var store = configureStore({
|
|
3142
|
-
reducer: reducer,
|
|
3143
|
-
middleware: [thunk$1],
|
|
3144
|
-
});
|
|
3145
|
-
var useAppDispatch = store.dispatch;
|
|
3146
|
-
var useAppSelector = useSelector;
|
|
3147
|
-
var persistor = persistStore(store);
|
|
3148
|
-
|
|
3149
|
-
var useClientContext = (function () {
|
|
3150
|
-
var context = useContext(ClientContext);
|
|
3151
|
-
return context;
|
|
3152
|
-
});
|
|
3153
|
-
|
|
3154
|
-
var ContentContext = createContext(null);
|
|
3155
|
-
var ContentProvider = function (props) {
|
|
3156
|
-
var client = useClientContext();
|
|
3157
|
-
var dispatch = useAppDispatch;
|
|
3158
|
-
var _a = React.useState(props.collections || []), collections = _a[0]; _a[1];
|
|
3159
|
-
var actions = {
|
|
3160
|
-
subscribe: function (collectionName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3161
|
-
return __generator(this, function (_a) {
|
|
3162
|
-
switch (_a.label) {
|
|
3163
|
-
case 0:
|
|
3164
|
-
// save local that collectionName should be subscribed
|
|
3165
|
-
return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.realtime.subscribe(collectionName, function (event) {
|
|
3166
|
-
switch (event.action) {
|
|
3167
|
-
case 'create':
|
|
3168
|
-
dispatch(recordsAction.addRecord(collectionName, event.record));
|
|
3169
|
-
break;
|
|
3170
|
-
case 'update':
|
|
3171
|
-
dispatch(recordsAction.updateRecord(collectionName, event.record));
|
|
3172
|
-
break;
|
|
3173
|
-
case 'delete':
|
|
3174
|
-
dispatch(recordsAction.deleteRecord(collectionName, event.record));
|
|
3175
|
-
break;
|
|
3176
|
-
}
|
|
3177
|
-
}))];
|
|
3178
|
-
case 1:
|
|
3179
|
-
// save local that collectionName should be subscribed
|
|
3180
|
-
_a.sent();
|
|
3181
|
-
return [2 /*return*/];
|
|
3182
|
-
}
|
|
3183
|
-
});
|
|
3184
|
-
}); },
|
|
3185
|
-
unsubscribe: function (collectionName) {
|
|
3186
|
-
if (collectionName) {
|
|
3187
|
-
client === null || client === void 0 ? void 0 : client.realtime.unsubscribe(collectionName);
|
|
3188
|
-
}
|
|
3189
|
-
else {
|
|
3190
|
-
client === null || client === void 0 ? void 0 : client.realtime.unsubscribe();
|
|
3191
|
-
}
|
|
3192
|
-
},
|
|
3193
|
-
fetch: function (collectionName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3194
|
-
var records;
|
|
3195
|
-
return __generator(this, function (_a) {
|
|
3196
|
-
switch (_a.label) {
|
|
3197
|
-
case 0: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.records.getFullList(collectionName, 200))];
|
|
3198
|
-
case 1:
|
|
3199
|
-
records = _a.sent();
|
|
3200
|
-
dispatch(recordsAction.setRecords(collectionName, records));
|
|
3201
|
-
return [2 /*return*/];
|
|
3202
|
-
}
|
|
3203
|
-
});
|
|
3204
|
-
}); },
|
|
3205
|
-
create: function (collectionName, record) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3206
|
-
return __generator(this, function (_a) {
|
|
3207
|
-
switch (_a.label) {
|
|
3208
|
-
case 0: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.records.create(collectionName, record))];
|
|
3209
|
-
case 1:
|
|
3210
|
-
_a.sent();
|
|
3211
|
-
return [2 /*return*/];
|
|
3212
|
-
}
|
|
3213
|
-
});
|
|
3214
|
-
}); },
|
|
3215
|
-
update: function (collectionName, recordId, record) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3216
|
-
return __generator(this, function (_a) {
|
|
3217
|
-
switch (_a.label) {
|
|
3218
|
-
case 0: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.records.update(collectionName, recordId, record))];
|
|
3219
|
-
case 1:
|
|
3220
|
-
_a.sent();
|
|
3221
|
-
return [2 /*return*/];
|
|
3222
|
-
}
|
|
3223
|
-
});
|
|
3224
|
-
}); },
|
|
3225
|
-
delete: function (collectionName, recordId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3226
|
-
return __generator(this, function (_a) {
|
|
3227
|
-
switch (_a.label) {
|
|
3228
|
-
case 0: return [4 /*yield*/, (client === null || client === void 0 ? void 0 : client.records.delete(collectionName, recordId))];
|
|
3229
|
-
case 1:
|
|
3230
|
-
_a.sent();
|
|
3231
|
-
return [2 /*return*/];
|
|
3232
|
-
}
|
|
3233
|
-
});
|
|
3234
|
-
}); },
|
|
3235
|
-
};
|
|
3236
|
-
useEffect(function () {
|
|
3237
|
-
if (collections) {
|
|
3238
|
-
collections.forEach(function (collectionName) {
|
|
3239
|
-
actions.fetch(collectionName);
|
|
3240
|
-
});
|
|
3241
|
-
}
|
|
3242
|
-
return function () { return actions.unsubscribe(); };
|
|
3243
|
-
}, [collections]);
|
|
3244
|
-
return (React.createElement(ContentContext.Provider, { value: actions }, props.children));
|
|
3245
|
-
};
|
|
3246
|
-
|
|
3247
|
-
var ClientContext = createContext(null);
|
|
3248
|
-
var ClientProvider = function (props) {
|
|
3249
|
-
return React.createElement(ClientContext.Provider, { value: props.client }, props.children);
|
|
3250
|
-
};
|
|
3251
|
-
|
|
3252
|
-
var PersistGate_1 = void 0;
|
|
3253
|
-
|
|
3254
|
-
var _react = _interopRequireWildcard(React__default);
|
|
3255
|
-
|
|
3256
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
3257
|
-
|
|
3258
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
3259
|
-
|
|
3260
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3261
|
-
|
|
3262
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
3263
|
-
|
|
3264
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
3265
|
-
|
|
3266
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
3267
|
-
|
|
3268
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
3269
|
-
|
|
3270
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
3271
|
-
|
|
3272
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
3273
|
-
|
|
3274
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
3275
|
-
|
|
3276
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
3277
|
-
|
|
3278
|
-
var PersistGate =
|
|
3279
|
-
/*#__PURE__*/
|
|
3280
|
-
function (_PureComponent) {
|
|
3281
|
-
_inherits(PersistGate, _PureComponent);
|
|
3282
|
-
|
|
3283
|
-
function PersistGate() {
|
|
3284
|
-
var _getPrototypeOf2;
|
|
3285
|
-
|
|
3286
|
-
var _this;
|
|
3287
|
-
|
|
3288
|
-
_classCallCheck(this, PersistGate);
|
|
3289
|
-
|
|
3290
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3291
|
-
args[_key] = arguments[_key];
|
|
3292
|
-
}
|
|
3293
|
-
|
|
3294
|
-
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(PersistGate)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
3295
|
-
|
|
3296
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
3297
|
-
bootstrapped: false
|
|
3298
|
-
});
|
|
3299
|
-
|
|
3300
|
-
_defineProperty(_assertThisInitialized(_this), "_unsubscribe", void 0);
|
|
3301
|
-
|
|
3302
|
-
_defineProperty(_assertThisInitialized(_this), "handlePersistorState", function () {
|
|
3303
|
-
var persistor = _this.props.persistor;
|
|
3304
|
-
|
|
3305
|
-
var _persistor$getState = persistor.getState(),
|
|
3306
|
-
bootstrapped = _persistor$getState.bootstrapped;
|
|
3307
|
-
|
|
3308
|
-
if (bootstrapped) {
|
|
3309
|
-
if (_this.props.onBeforeLift) {
|
|
3310
|
-
Promise.resolve(_this.props.onBeforeLift()).finally(function () {
|
|
3311
|
-
return _this.setState({
|
|
3312
|
-
bootstrapped: true
|
|
3313
|
-
});
|
|
3314
|
-
});
|
|
3315
|
-
} else {
|
|
3316
|
-
_this.setState({
|
|
3317
|
-
bootstrapped: true
|
|
3318
|
-
});
|
|
3319
|
-
}
|
|
3320
|
-
|
|
3321
|
-
_this._unsubscribe && _this._unsubscribe();
|
|
3322
|
-
}
|
|
3323
|
-
});
|
|
3324
|
-
|
|
3325
|
-
return _this;
|
|
3326
|
-
}
|
|
3327
|
-
|
|
3328
|
-
_createClass(PersistGate, [{
|
|
3329
|
-
key: "componentDidMount",
|
|
3330
|
-
value: function componentDidMount() {
|
|
3331
|
-
this._unsubscribe = this.props.persistor.subscribe(this.handlePersistorState);
|
|
3332
|
-
this.handlePersistorState();
|
|
3333
|
-
}
|
|
3334
|
-
}, {
|
|
3335
|
-
key: "componentWillUnmount",
|
|
3336
|
-
value: function componentWillUnmount() {
|
|
3337
|
-
this._unsubscribe && this._unsubscribe();
|
|
3338
|
-
}
|
|
3339
|
-
}, {
|
|
3340
|
-
key: "render",
|
|
3341
|
-
value: function render() {
|
|
3342
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3343
|
-
if (typeof this.props.children === 'function' && this.props.loading) console.error('redux-persist: PersistGate expects either a function child or loading prop, but not both. The loading prop will be ignored.');
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
if (typeof this.props.children === 'function') {
|
|
3347
|
-
return this.props.children(this.state.bootstrapped);
|
|
3348
|
-
}
|
|
3349
|
-
|
|
3350
|
-
return this.state.bootstrapped ? this.props.children : this.props.loading;
|
|
3351
|
-
}
|
|
3352
|
-
}]);
|
|
3353
|
-
|
|
3354
|
-
return PersistGate;
|
|
3355
|
-
}(_react.PureComponent);
|
|
3356
|
-
|
|
3357
|
-
PersistGate_1 = PersistGate;
|
|
3358
|
-
|
|
3359
|
-
_defineProperty(PersistGate, "defaultProps", {
|
|
3360
|
-
children: null,
|
|
3361
|
-
loading: null
|
|
3362
|
-
});
|
|
3363
|
-
|
|
3364
|
-
var PocketbaseContext = createContext(null);
|
|
3365
|
-
var Pocketbase = function (props) {
|
|
3366
|
-
var _a = React.useState(null), client = _a[0], setClient = _a[1];
|
|
3367
|
-
useEffect(function () {
|
|
3368
|
-
var reducer = combineReducers({
|
|
3369
|
-
reducer: persistReducer(__assign(__assign({}, persistConfig), { storage: props.storage }), appReducer),
|
|
3370
|
-
});
|
|
3371
|
-
store.replaceReducer(reducer);
|
|
3372
|
-
var client = new PocketBase(props.serverURL);
|
|
3373
|
-
client.admins.authViaEmail(props.credentials.username, props.credentials.password).then(function () {
|
|
3374
|
-
setClient(client);
|
|
3375
|
-
console.log('Pocketbase client initialized');
|
|
3376
|
-
});
|
|
3377
|
-
}, [props.serverURL]);
|
|
3378
|
-
return client ? (React.createElement(ClientProvider, { client: client },
|
|
3379
|
-
React.createElement(Provider, { store: store },
|
|
3380
|
-
React.createElement(PersistGate_1, { persistor: persistor },
|
|
3381
|
-
React.createElement(ContentProvider, { collections: props.initialCollections }, props.children))))) : null;
|
|
3382
|
-
};
|
|
3383
|
-
|
|
3384
|
-
function useAppContent(collectionName, initialFetch) {
|
|
3385
|
-
var _this = this;
|
|
3386
|
-
var _a;
|
|
3387
|
-
if (initialFetch === void 0) { initialFetch = false; }
|
|
3388
|
-
var records = ((_a = useAppSelector(function (state) { return state.reducer.records[collectionName]; })) !== null && _a !== void 0 ? _a : []);
|
|
3389
|
-
var context = useContext(ContentContext);
|
|
3390
|
-
useEffect(function () {
|
|
3391
|
-
if (initialFetch) {
|
|
3392
|
-
context === null || context === void 0 ? void 0 : context.fetch(collectionName);
|
|
3393
|
-
}
|
|
3394
|
-
}, [collectionName, initialFetch]);
|
|
3395
|
-
var actions = {
|
|
3396
|
-
subscribe: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3397
|
-
switch (_a.label) {
|
|
3398
|
-
case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.subscribe(collectionName))];
|
|
3399
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
3400
|
-
}
|
|
3401
|
-
}); }); },
|
|
3402
|
-
unsubscribe: function () { return context === null || context === void 0 ? void 0 : context.unsubscribe(collectionName); },
|
|
3403
|
-
refetch: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3404
|
-
switch (_a.label) {
|
|
3405
|
-
case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.fetch(collectionName))];
|
|
3406
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
3407
|
-
}
|
|
3408
|
-
}); }); },
|
|
3409
|
-
create: function (record) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3410
|
-
switch (_a.label) {
|
|
3411
|
-
case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.create(collectionName, record))];
|
|
3412
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
3413
|
-
}
|
|
3414
|
-
}); }); },
|
|
3415
|
-
update: function (id, record) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3416
|
-
switch (_a.label) {
|
|
3417
|
-
case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.update(collectionName, id, record))];
|
|
3418
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
3419
|
-
}
|
|
3420
|
-
}); }); },
|
|
3421
|
-
delete: function (id) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
3422
|
-
switch (_a.label) {
|
|
3423
|
-
case 0: return [4 /*yield*/, (context === null || context === void 0 ? void 0 : context.delete(collectionName, id))];
|
|
3424
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
3425
|
-
}
|
|
3426
|
-
}); }); },
|
|
3427
|
-
};
|
|
3428
|
-
return { records: records, actions: actions };
|
|
3429
|
-
}
|
|
3430
|
-
|
|
3431
|
-
export { ADD_RECORD, ADD_RECORDS, ClientContext, ClientProvider, ContentContext, ContentProvider, DELETE_RECORD, DELETE_RECORDS, Pocketbase, PocketbaseContext, SET_RECORDS, UPDATE_RECORD, persistConfig, persistor, recordsAction, store, useAppContent, useAppDispatch, useAppSelector };
|
|
3432
|
-
//# sourceMappingURL=index.js.map
|