@gaddario98/react-core 2.0.8 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +2 -2
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +1 -1
- package/dist/auth/index.mjs.map +1 -1
- package/dist/form/index.js +52 -3930
- package/dist/form/index.js.map +1 -1
- package/dist/form/index.mjs +2 -3880
- package/dist/form/index.mjs.map +1 -1
- package/dist/index.d.ts +627 -97
- package/dist/index.js +14 -20037
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -20031
- package/dist/index.mjs.map +1 -1
- package/dist/notifications/index.d.ts +2 -2
- package/dist/notifications/index.js +3 -3
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/index.mjs +2 -2
- package/dist/notifications/index.mjs.map +1 -1
- package/dist/pages/index.d.ts +3 -3
- package/dist/pages/index.js +58 -1789
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/index.mjs +13 -1744
- package/dist/pages/index.mjs.map +1 -1
- package/dist/queries/index.js +235 -7463
- package/dist/queries/index.js.map +1 -1
- package/dist/queries/index.mjs +228 -7456
- package/dist/queries/index.mjs.map +1 -1
- package/dist/state/index.js +10 -1783
- package/dist/state/index.js.map +1 -1
- package/dist/state/index.mjs +2 -1775
- package/dist/state/index.mjs.map +1 -1
- package/package.json +8 -6
package/dist/pages/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var jsxRuntime=require('react/jsx-runtime'),
|
|
1
|
+
'use strict';var jsxRuntime=require('react/jsx-runtime'),react=require('react'),reactQueries=require('@gaddario98/react-queries'),jotai=require('jotai'),compilerRuntime=require('react/compiler-runtime'),reactState=require('@gaddario98/react-state'),equal=require('fast-deep-equal'),reactForm=require('@gaddario98/react-form'),jotaiFamily=require('jotai-family'),reactQuery=require('@tanstack/react-query');/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -25,839 +25,7 @@ function __rest(s, e) {
|
|
|
25
25
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
26
26
|
var e = new Error(message);
|
|
27
27
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
28
|
-
}
|
|
29
|
-
return "init" in atom;
|
|
30
|
-
}
|
|
31
|
-
function isActuallyWritableAtom(atom) {
|
|
32
|
-
return !!atom.write;
|
|
33
|
-
}
|
|
34
|
-
function isAtomStateInitialized(atomState) {
|
|
35
|
-
return "v" in atomState || "e" in atomState;
|
|
36
|
-
}
|
|
37
|
-
function returnAtomValue(atomState) {
|
|
38
|
-
if ("e" in atomState) {
|
|
39
|
-
throw atomState.e;
|
|
40
|
-
}
|
|
41
|
-
if ((undefined ? undefined.MODE : void 0) !== "production" && !("v" in atomState)) {
|
|
42
|
-
throw new Error("[Bug] atom state is not initialized");
|
|
43
|
-
}
|
|
44
|
-
return atomState.v;
|
|
45
|
-
}
|
|
46
|
-
const promiseStateMap = /* @__PURE__ */ new WeakMap();
|
|
47
|
-
function isPendingPromise(value) {
|
|
48
|
-
var _a;
|
|
49
|
-
return isPromiseLike$1(value) && !!((_a = promiseStateMap.get(value)) == null ? void 0 : _a[0]);
|
|
50
|
-
}
|
|
51
|
-
function abortPromise(promise) {
|
|
52
|
-
const promiseState = promiseStateMap.get(promise);
|
|
53
|
-
if (promiseState == null ? void 0 : promiseState[0]) {
|
|
54
|
-
promiseState[0] = false;
|
|
55
|
-
promiseState[1].forEach((fn) => fn());
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function registerAbortHandler(promise, abortHandler) {
|
|
59
|
-
let promiseState = promiseStateMap.get(promise);
|
|
60
|
-
if (!promiseState) {
|
|
61
|
-
promiseState = [true, /* @__PURE__ */ new Set()];
|
|
62
|
-
promiseStateMap.set(promise, promiseState);
|
|
63
|
-
const settle = () => {
|
|
64
|
-
promiseState[0] = false;
|
|
65
|
-
};
|
|
66
|
-
promise.then(settle, settle);
|
|
67
|
-
}
|
|
68
|
-
promiseState[1].add(abortHandler);
|
|
69
|
-
}
|
|
70
|
-
function isPromiseLike$1(p) {
|
|
71
|
-
return typeof (p == null ? void 0 : p.then) === "function";
|
|
72
|
-
}
|
|
73
|
-
function addPendingPromiseToDependency(atom, promise, dependencyAtomState) {
|
|
74
|
-
if (!dependencyAtomState.p.has(atom)) {
|
|
75
|
-
dependencyAtomState.p.add(atom);
|
|
76
|
-
const cleanup = () => dependencyAtomState.p.delete(atom);
|
|
77
|
-
promise.then(cleanup, cleanup);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function getMountedOrPendingDependents(atom, atomState, mountedMap) {
|
|
81
|
-
var _a;
|
|
82
|
-
const dependents = /* @__PURE__ */ new Set();
|
|
83
|
-
for (const a of ((_a = mountedMap.get(atom)) == null ? void 0 : _a.t) || []) {
|
|
84
|
-
dependents.add(a);
|
|
85
|
-
}
|
|
86
|
-
for (const atomWithPendingPromise of atomState.p) {
|
|
87
|
-
dependents.add(atomWithPendingPromise);
|
|
88
|
-
}
|
|
89
|
-
return dependents;
|
|
90
|
-
}
|
|
91
|
-
const BUILDING_BLOCK_atomRead = (_store, atom, ...params) => atom.read(...params);
|
|
92
|
-
const BUILDING_BLOCK_atomWrite = (_store, atom, ...params) => atom.write(...params);
|
|
93
|
-
const BUILDING_BLOCK_atomOnInit = (store, atom) => {
|
|
94
|
-
var _a;
|
|
95
|
-
return (_a = atom.INTERNAL_onInit) == null ? void 0 : _a.call(atom, store);
|
|
96
|
-
};
|
|
97
|
-
const BUILDING_BLOCK_atomOnMount = (_store, atom, setAtom) => {
|
|
98
|
-
var _a;
|
|
99
|
-
return (_a = atom.onMount) == null ? void 0 : _a.call(atom, setAtom);
|
|
100
|
-
};
|
|
101
|
-
const BUILDING_BLOCK_ensureAtomState = (store, atom) => {
|
|
102
|
-
var _a;
|
|
103
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
104
|
-
const atomStateMap = buildingBlocks[0];
|
|
105
|
-
const storeHooks = buildingBlocks[6];
|
|
106
|
-
const atomOnInit = buildingBlocks[9];
|
|
107
|
-
if ((undefined ? undefined.MODE : void 0) !== "production" && !atom) {
|
|
108
|
-
throw new Error("Atom is undefined or null");
|
|
109
|
-
}
|
|
110
|
-
let atomState = atomStateMap.get(atom);
|
|
111
|
-
if (!atomState) {
|
|
112
|
-
atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };
|
|
113
|
-
atomStateMap.set(atom, atomState);
|
|
114
|
-
(_a = storeHooks.i) == null ? void 0 : _a.call(storeHooks, atom);
|
|
115
|
-
atomOnInit == null ? void 0 : atomOnInit(store, atom);
|
|
116
|
-
}
|
|
117
|
-
return atomState;
|
|
118
|
-
};
|
|
119
|
-
const BUILDING_BLOCK_flushCallbacks = (store) => {
|
|
120
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
121
|
-
const mountedMap = buildingBlocks[1];
|
|
122
|
-
const changedAtoms = buildingBlocks[3];
|
|
123
|
-
const mountCallbacks = buildingBlocks[4];
|
|
124
|
-
const unmountCallbacks = buildingBlocks[5];
|
|
125
|
-
const storeHooks = buildingBlocks[6];
|
|
126
|
-
const recomputeInvalidatedAtoms = buildingBlocks[13];
|
|
127
|
-
const errors = [];
|
|
128
|
-
const call = (fn) => {
|
|
129
|
-
try {
|
|
130
|
-
fn();
|
|
131
|
-
} catch (e) {
|
|
132
|
-
errors.push(e);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
do {
|
|
136
|
-
if (storeHooks.f) {
|
|
137
|
-
call(storeHooks.f);
|
|
138
|
-
}
|
|
139
|
-
const callbacks = /* @__PURE__ */ new Set();
|
|
140
|
-
const add = callbacks.add.bind(callbacks);
|
|
141
|
-
changedAtoms.forEach((atom) => {
|
|
142
|
-
var _a;
|
|
143
|
-
return (_a = mountedMap.get(atom)) == null ? void 0 : _a.l.forEach(add);
|
|
144
|
-
});
|
|
145
|
-
changedAtoms.clear();
|
|
146
|
-
unmountCallbacks.forEach(add);
|
|
147
|
-
unmountCallbacks.clear();
|
|
148
|
-
mountCallbacks.forEach(add);
|
|
149
|
-
mountCallbacks.clear();
|
|
150
|
-
callbacks.forEach(call);
|
|
151
|
-
if (changedAtoms.size) {
|
|
152
|
-
recomputeInvalidatedAtoms(store);
|
|
153
|
-
}
|
|
154
|
-
} while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
|
|
155
|
-
if (errors.length) {
|
|
156
|
-
throw new AggregateError(errors);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const BUILDING_BLOCK_recomputeInvalidatedAtoms = (store) => {
|
|
160
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
161
|
-
const mountedMap = buildingBlocks[1];
|
|
162
|
-
const invalidatedAtoms = buildingBlocks[2];
|
|
163
|
-
const changedAtoms = buildingBlocks[3];
|
|
164
|
-
const ensureAtomState = buildingBlocks[11];
|
|
165
|
-
const readAtomState = buildingBlocks[14];
|
|
166
|
-
const mountDependencies = buildingBlocks[17];
|
|
167
|
-
const topSortedReversed = [];
|
|
168
|
-
const visiting = /* @__PURE__ */ new WeakSet();
|
|
169
|
-
const visited = /* @__PURE__ */ new WeakSet();
|
|
170
|
-
const stack = Array.from(changedAtoms);
|
|
171
|
-
while (stack.length) {
|
|
172
|
-
const a = stack[stack.length - 1];
|
|
173
|
-
const aState = ensureAtomState(store, a);
|
|
174
|
-
if (visited.has(a)) {
|
|
175
|
-
stack.pop();
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (visiting.has(a)) {
|
|
179
|
-
if (invalidatedAtoms.get(a) === aState.n) {
|
|
180
|
-
topSortedReversed.push([a, aState]);
|
|
181
|
-
} else if ((undefined ? undefined.MODE : void 0) !== "production" && invalidatedAtoms.has(a)) {
|
|
182
|
-
throw new Error("[Bug] invalidated atom exists");
|
|
183
|
-
}
|
|
184
|
-
visited.add(a);
|
|
185
|
-
stack.pop();
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
visiting.add(a);
|
|
189
|
-
for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
|
|
190
|
-
if (!visiting.has(d)) {
|
|
191
|
-
stack.push(d);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
for (let i = topSortedReversed.length - 1; i >= 0; --i) {
|
|
196
|
-
const [a, aState] = topSortedReversed[i];
|
|
197
|
-
let hasChangedDeps = false;
|
|
198
|
-
for (const dep of aState.d.keys()) {
|
|
199
|
-
if (dep !== a && changedAtoms.has(dep)) {
|
|
200
|
-
hasChangedDeps = true;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (hasChangedDeps) {
|
|
205
|
-
readAtomState(store, a);
|
|
206
|
-
mountDependencies(store, a);
|
|
207
|
-
}
|
|
208
|
-
invalidatedAtoms.delete(a);
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
const storeMutationSet = /* @__PURE__ */ new WeakSet();
|
|
212
|
-
const BUILDING_BLOCK_readAtomState = (store, atom) => {
|
|
213
|
-
var _a, _b;
|
|
214
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
215
|
-
const mountedMap = buildingBlocks[1];
|
|
216
|
-
const invalidatedAtoms = buildingBlocks[2];
|
|
217
|
-
const changedAtoms = buildingBlocks[3];
|
|
218
|
-
const storeHooks = buildingBlocks[6];
|
|
219
|
-
const atomRead = buildingBlocks[7];
|
|
220
|
-
const ensureAtomState = buildingBlocks[11];
|
|
221
|
-
const flushCallbacks = buildingBlocks[12];
|
|
222
|
-
const recomputeInvalidatedAtoms = buildingBlocks[13];
|
|
223
|
-
const readAtomState = buildingBlocks[14];
|
|
224
|
-
const writeAtomState = buildingBlocks[16];
|
|
225
|
-
const mountDependencies = buildingBlocks[17];
|
|
226
|
-
const setAtomStateValueOrPromise = buildingBlocks[20];
|
|
227
|
-
const atomState = ensureAtomState(store, atom);
|
|
228
|
-
if (isAtomStateInitialized(atomState)) {
|
|
229
|
-
if (mountedMap.has(atom) && invalidatedAtoms.get(atom) !== atomState.n) {
|
|
230
|
-
return atomState;
|
|
231
|
-
}
|
|
232
|
-
let hasChangedDeps = false;
|
|
233
|
-
for (const [a, n] of atomState.d) {
|
|
234
|
-
if (readAtomState(store, a).n !== n) {
|
|
235
|
-
hasChangedDeps = true;
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (!hasChangedDeps) {
|
|
240
|
-
return atomState;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
atomState.d.clear();
|
|
244
|
-
let isSync = true;
|
|
245
|
-
function mountDependenciesIfAsync() {
|
|
246
|
-
if (mountedMap.has(atom)) {
|
|
247
|
-
mountDependencies(store, atom);
|
|
248
|
-
recomputeInvalidatedAtoms(store);
|
|
249
|
-
flushCallbacks(store);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
function getter(a) {
|
|
253
|
-
var _a2;
|
|
254
|
-
if (a === atom) {
|
|
255
|
-
const aState2 = ensureAtomState(store, a);
|
|
256
|
-
if (!isAtomStateInitialized(aState2)) {
|
|
257
|
-
if (hasInitialValue(a)) {
|
|
258
|
-
setAtomStateValueOrPromise(store, a, a.init);
|
|
259
|
-
} else {
|
|
260
|
-
throw new Error("no atom init");
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return returnAtomValue(aState2);
|
|
264
|
-
}
|
|
265
|
-
const aState = readAtomState(store, a);
|
|
266
|
-
try {
|
|
267
|
-
return returnAtomValue(aState);
|
|
268
|
-
} finally {
|
|
269
|
-
atomState.d.set(a, aState.n);
|
|
270
|
-
if (isPendingPromise(atomState.v)) {
|
|
271
|
-
addPendingPromiseToDependency(atom, atomState.v, aState);
|
|
272
|
-
}
|
|
273
|
-
if (mountedMap.has(atom)) {
|
|
274
|
-
(_a2 = mountedMap.get(a)) == null ? void 0 : _a2.t.add(atom);
|
|
275
|
-
}
|
|
276
|
-
if (!isSync) {
|
|
277
|
-
mountDependenciesIfAsync();
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
let controller;
|
|
282
|
-
let setSelf;
|
|
283
|
-
const options = {
|
|
284
|
-
get signal() {
|
|
285
|
-
if (!controller) {
|
|
286
|
-
controller = new AbortController();
|
|
287
|
-
}
|
|
288
|
-
return controller.signal;
|
|
289
|
-
},
|
|
290
|
-
get setSelf() {
|
|
291
|
-
if ((undefined ? undefined.MODE : void 0) !== "production") {
|
|
292
|
-
console.warn(
|
|
293
|
-
"[DEPRECATED] setSelf is deprecated and will be removed in v3."
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
if ((undefined ? undefined.MODE : void 0) !== "production" && !isActuallyWritableAtom(atom)) {
|
|
297
|
-
console.warn("setSelf function cannot be used with read-only atom");
|
|
298
|
-
}
|
|
299
|
-
if (!setSelf && isActuallyWritableAtom(atom)) {
|
|
300
|
-
setSelf = (...args) => {
|
|
301
|
-
if ((undefined ? undefined.MODE : void 0) !== "production" && isSync) {
|
|
302
|
-
console.warn("setSelf function cannot be called in sync");
|
|
303
|
-
}
|
|
304
|
-
if (!isSync) {
|
|
305
|
-
try {
|
|
306
|
-
return writeAtomState(store, atom, ...args);
|
|
307
|
-
} finally {
|
|
308
|
-
recomputeInvalidatedAtoms(store);
|
|
309
|
-
flushCallbacks(store);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
return setSelf;
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
const prevEpochNumber = atomState.n;
|
|
318
|
-
try {
|
|
319
|
-
if ((undefined ? undefined.MODE : void 0) !== "production") {
|
|
320
|
-
storeMutationSet.delete(store);
|
|
321
|
-
}
|
|
322
|
-
const valueOrPromise = atomRead(store, atom, getter, options);
|
|
323
|
-
if ((undefined ? undefined.MODE : void 0) !== "production" && storeMutationSet.has(store)) {
|
|
324
|
-
console.warn(
|
|
325
|
-
"Detected store mutation during atom read. This is not supported."
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
setAtomStateValueOrPromise(store, atom, valueOrPromise);
|
|
329
|
-
if (isPromiseLike$1(valueOrPromise)) {
|
|
330
|
-
registerAbortHandler(valueOrPromise, () => controller == null ? void 0 : controller.abort());
|
|
331
|
-
valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);
|
|
332
|
-
}
|
|
333
|
-
(_a = storeHooks.r) == null ? void 0 : _a.call(storeHooks, atom);
|
|
334
|
-
return atomState;
|
|
335
|
-
} catch (error) {
|
|
336
|
-
delete atomState.v;
|
|
337
|
-
atomState.e = error;
|
|
338
|
-
++atomState.n;
|
|
339
|
-
return atomState;
|
|
340
|
-
} finally {
|
|
341
|
-
isSync = false;
|
|
342
|
-
if (prevEpochNumber !== atomState.n && invalidatedAtoms.get(atom) === prevEpochNumber) {
|
|
343
|
-
invalidatedAtoms.set(atom, atomState.n);
|
|
344
|
-
changedAtoms.add(atom);
|
|
345
|
-
(_b = storeHooks.c) == null ? void 0 : _b.call(storeHooks, atom);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
const BUILDING_BLOCK_invalidateDependents = (store, atom) => {
|
|
350
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
351
|
-
const mountedMap = buildingBlocks[1];
|
|
352
|
-
const invalidatedAtoms = buildingBlocks[2];
|
|
353
|
-
const ensureAtomState = buildingBlocks[11];
|
|
354
|
-
const stack = [atom];
|
|
355
|
-
while (stack.length) {
|
|
356
|
-
const a = stack.pop();
|
|
357
|
-
const aState = ensureAtomState(store, a);
|
|
358
|
-
for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
|
|
359
|
-
const dState = ensureAtomState(store, d);
|
|
360
|
-
invalidatedAtoms.set(d, dState.n);
|
|
361
|
-
stack.push(d);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
const BUILDING_BLOCK_writeAtomState = (store, atom, ...args) => {
|
|
366
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
367
|
-
const changedAtoms = buildingBlocks[3];
|
|
368
|
-
const storeHooks = buildingBlocks[6];
|
|
369
|
-
const atomWrite = buildingBlocks[8];
|
|
370
|
-
const ensureAtomState = buildingBlocks[11];
|
|
371
|
-
const flushCallbacks = buildingBlocks[12];
|
|
372
|
-
const recomputeInvalidatedAtoms = buildingBlocks[13];
|
|
373
|
-
const readAtomState = buildingBlocks[14];
|
|
374
|
-
const invalidateDependents = buildingBlocks[15];
|
|
375
|
-
const writeAtomState = buildingBlocks[16];
|
|
376
|
-
const mountDependencies = buildingBlocks[17];
|
|
377
|
-
const setAtomStateValueOrPromise = buildingBlocks[20];
|
|
378
|
-
let isSync = true;
|
|
379
|
-
const getter = (a) => returnAtomValue(readAtomState(store, a));
|
|
380
|
-
const setter = (a, ...args2) => {
|
|
381
|
-
var _a;
|
|
382
|
-
const aState = ensureAtomState(store, a);
|
|
383
|
-
try {
|
|
384
|
-
if (a === atom) {
|
|
385
|
-
if (!hasInitialValue(a)) {
|
|
386
|
-
throw new Error("atom not writable");
|
|
387
|
-
}
|
|
388
|
-
if ((undefined ? undefined.MODE : void 0) !== "production") {
|
|
389
|
-
storeMutationSet.add(store);
|
|
390
|
-
}
|
|
391
|
-
const prevEpochNumber = aState.n;
|
|
392
|
-
const v = args2[0];
|
|
393
|
-
setAtomStateValueOrPromise(store, a, v);
|
|
394
|
-
mountDependencies(store, a);
|
|
395
|
-
if (prevEpochNumber !== aState.n) {
|
|
396
|
-
changedAtoms.add(a);
|
|
397
|
-
invalidateDependents(store, a);
|
|
398
|
-
(_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
|
|
399
|
-
}
|
|
400
|
-
return void 0;
|
|
401
|
-
} else {
|
|
402
|
-
return writeAtomState(store, a, ...args2);
|
|
403
|
-
}
|
|
404
|
-
} finally {
|
|
405
|
-
if (!isSync) {
|
|
406
|
-
recomputeInvalidatedAtoms(store);
|
|
407
|
-
flushCallbacks(store);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
try {
|
|
412
|
-
return atomWrite(store, atom, getter, setter, ...args);
|
|
413
|
-
} finally {
|
|
414
|
-
isSync = false;
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
const BUILDING_BLOCK_mountDependencies = (store, atom) => {
|
|
418
|
-
var _a;
|
|
419
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
420
|
-
const mountedMap = buildingBlocks[1];
|
|
421
|
-
const changedAtoms = buildingBlocks[3];
|
|
422
|
-
const storeHooks = buildingBlocks[6];
|
|
423
|
-
const ensureAtomState = buildingBlocks[11];
|
|
424
|
-
const invalidateDependents = buildingBlocks[15];
|
|
425
|
-
const mountAtom = buildingBlocks[18];
|
|
426
|
-
const unmountAtom = buildingBlocks[19];
|
|
427
|
-
const atomState = ensureAtomState(store, atom);
|
|
428
|
-
const mounted = mountedMap.get(atom);
|
|
429
|
-
if (mounted && !isPendingPromise(atomState.v)) {
|
|
430
|
-
for (const [a, n] of atomState.d) {
|
|
431
|
-
if (!mounted.d.has(a)) {
|
|
432
|
-
const aState = ensureAtomState(store, a);
|
|
433
|
-
const aMounted = mountAtom(store, a);
|
|
434
|
-
aMounted.t.add(atom);
|
|
435
|
-
mounted.d.add(a);
|
|
436
|
-
if (n !== aState.n) {
|
|
437
|
-
changedAtoms.add(a);
|
|
438
|
-
invalidateDependents(store, a);
|
|
439
|
-
(_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
for (const a of mounted.d) {
|
|
444
|
-
if (!atomState.d.has(a)) {
|
|
445
|
-
mounted.d.delete(a);
|
|
446
|
-
const aMounted = unmountAtom(store, a);
|
|
447
|
-
aMounted == null ? void 0 : aMounted.t.delete(atom);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
const BUILDING_BLOCK_mountAtom = (store, atom) => {
|
|
453
|
-
var _a;
|
|
454
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
455
|
-
const mountedMap = buildingBlocks[1];
|
|
456
|
-
const mountCallbacks = buildingBlocks[4];
|
|
457
|
-
const storeHooks = buildingBlocks[6];
|
|
458
|
-
const atomOnMount = buildingBlocks[10];
|
|
459
|
-
const ensureAtomState = buildingBlocks[11];
|
|
460
|
-
const flushCallbacks = buildingBlocks[12];
|
|
461
|
-
const recomputeInvalidatedAtoms = buildingBlocks[13];
|
|
462
|
-
const readAtomState = buildingBlocks[14];
|
|
463
|
-
const writeAtomState = buildingBlocks[16];
|
|
464
|
-
const mountAtom = buildingBlocks[18];
|
|
465
|
-
const atomState = ensureAtomState(store, atom);
|
|
466
|
-
let mounted = mountedMap.get(atom);
|
|
467
|
-
if (!mounted) {
|
|
468
|
-
readAtomState(store, atom);
|
|
469
|
-
for (const a of atomState.d.keys()) {
|
|
470
|
-
const aMounted = mountAtom(store, a);
|
|
471
|
-
aMounted.t.add(atom);
|
|
472
|
-
}
|
|
473
|
-
mounted = {
|
|
474
|
-
l: /* @__PURE__ */ new Set(),
|
|
475
|
-
d: new Set(atomState.d.keys()),
|
|
476
|
-
t: /* @__PURE__ */ new Set()
|
|
477
|
-
};
|
|
478
|
-
mountedMap.set(atom, mounted);
|
|
479
|
-
if (isActuallyWritableAtom(atom)) {
|
|
480
|
-
const processOnMount = () => {
|
|
481
|
-
let isSync = true;
|
|
482
|
-
const setAtom = (...args) => {
|
|
483
|
-
try {
|
|
484
|
-
return writeAtomState(store, atom, ...args);
|
|
485
|
-
} finally {
|
|
486
|
-
if (!isSync) {
|
|
487
|
-
recomputeInvalidatedAtoms(store);
|
|
488
|
-
flushCallbacks(store);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
};
|
|
492
|
-
try {
|
|
493
|
-
const onUnmount = atomOnMount(store, atom, setAtom);
|
|
494
|
-
if (onUnmount) {
|
|
495
|
-
mounted.u = () => {
|
|
496
|
-
isSync = true;
|
|
497
|
-
try {
|
|
498
|
-
onUnmount();
|
|
499
|
-
} finally {
|
|
500
|
-
isSync = false;
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
} finally {
|
|
505
|
-
isSync = false;
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
mountCallbacks.add(processOnMount);
|
|
509
|
-
}
|
|
510
|
-
(_a = storeHooks.m) == null ? void 0 : _a.call(storeHooks, atom);
|
|
511
|
-
}
|
|
512
|
-
return mounted;
|
|
513
|
-
};
|
|
514
|
-
const BUILDING_BLOCK_unmountAtom = (store, atom) => {
|
|
515
|
-
var _a, _b;
|
|
516
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
517
|
-
const mountedMap = buildingBlocks[1];
|
|
518
|
-
const unmountCallbacks = buildingBlocks[5];
|
|
519
|
-
const storeHooks = buildingBlocks[6];
|
|
520
|
-
const ensureAtomState = buildingBlocks[11];
|
|
521
|
-
const unmountAtom = buildingBlocks[19];
|
|
522
|
-
const atomState = ensureAtomState(store, atom);
|
|
523
|
-
let mounted = mountedMap.get(atom);
|
|
524
|
-
if (!mounted || mounted.l.size) {
|
|
525
|
-
return mounted;
|
|
526
|
-
}
|
|
527
|
-
let isDependent = false;
|
|
528
|
-
for (const a of mounted.t) {
|
|
529
|
-
if ((_a = mountedMap.get(a)) == null ? void 0 : _a.d.has(atom)) {
|
|
530
|
-
isDependent = true;
|
|
531
|
-
break;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
if (!isDependent) {
|
|
535
|
-
if (mounted.u) {
|
|
536
|
-
unmountCallbacks.add(mounted.u);
|
|
537
|
-
}
|
|
538
|
-
mounted = void 0;
|
|
539
|
-
mountedMap.delete(atom);
|
|
540
|
-
for (const a of atomState.d.keys()) {
|
|
541
|
-
const aMounted = unmountAtom(store, a);
|
|
542
|
-
aMounted == null ? void 0 : aMounted.t.delete(atom);
|
|
543
|
-
}
|
|
544
|
-
(_b = storeHooks.u) == null ? void 0 : _b.call(storeHooks, atom);
|
|
545
|
-
return void 0;
|
|
546
|
-
}
|
|
547
|
-
return mounted;
|
|
548
|
-
};
|
|
549
|
-
const BUILDING_BLOCK_setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
|
|
550
|
-
const ensureAtomState = getInternalBuildingBlocks(store)[11];
|
|
551
|
-
const atomState = ensureAtomState(store, atom);
|
|
552
|
-
const hasPrevValue = "v" in atomState;
|
|
553
|
-
const prevValue = atomState.v;
|
|
554
|
-
if (isPromiseLike$1(valueOrPromise)) {
|
|
555
|
-
for (const a of atomState.d.keys()) {
|
|
556
|
-
addPendingPromiseToDependency(
|
|
557
|
-
atom,
|
|
558
|
-
valueOrPromise,
|
|
559
|
-
ensureAtomState(store, a)
|
|
560
|
-
);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
atomState.v = valueOrPromise;
|
|
564
|
-
delete atomState.e;
|
|
565
|
-
if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
|
|
566
|
-
++atomState.n;
|
|
567
|
-
if (isPromiseLike$1(prevValue)) {
|
|
568
|
-
abortPromise(prevValue);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
const BUILDING_BLOCK_storeGet = (store, atom) => {
|
|
573
|
-
const readAtomState = getInternalBuildingBlocks(store)[14];
|
|
574
|
-
return returnAtomValue(readAtomState(store, atom));
|
|
575
|
-
};
|
|
576
|
-
const BUILDING_BLOCK_storeSet = (store, atom, ...args) => {
|
|
577
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
578
|
-
const flushCallbacks = buildingBlocks[12];
|
|
579
|
-
const recomputeInvalidatedAtoms = buildingBlocks[13];
|
|
580
|
-
const writeAtomState = buildingBlocks[16];
|
|
581
|
-
try {
|
|
582
|
-
return writeAtomState(store, atom, ...args);
|
|
583
|
-
} finally {
|
|
584
|
-
recomputeInvalidatedAtoms(store);
|
|
585
|
-
flushCallbacks(store);
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
const BUILDING_BLOCK_storeSub = (store, atom, listener) => {
|
|
589
|
-
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
590
|
-
const flushCallbacks = buildingBlocks[12];
|
|
591
|
-
const mountAtom = buildingBlocks[18];
|
|
592
|
-
const unmountAtom = buildingBlocks[19];
|
|
593
|
-
const mounted = mountAtom(store, atom);
|
|
594
|
-
const listeners = mounted.l;
|
|
595
|
-
listeners.add(listener);
|
|
596
|
-
flushCallbacks(store);
|
|
597
|
-
return () => {
|
|
598
|
-
listeners.delete(listener);
|
|
599
|
-
unmountAtom(store, atom);
|
|
600
|
-
flushCallbacks(store);
|
|
601
|
-
};
|
|
602
|
-
};
|
|
603
|
-
const buildingBlockMap = /* @__PURE__ */ new WeakMap();
|
|
604
|
-
const getInternalBuildingBlocks = (store) => {
|
|
605
|
-
const buildingBlocks = buildingBlockMap.get(store);
|
|
606
|
-
if ((undefined ? undefined.MODE : void 0) !== "production" && !buildingBlocks) {
|
|
607
|
-
throw new Error(
|
|
608
|
-
"Store must be created by buildStore to read its building blocks"
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
return buildingBlocks;
|
|
612
|
-
};
|
|
613
|
-
function buildStore(...buildArgs) {
|
|
614
|
-
const store = {
|
|
615
|
-
get(atom) {
|
|
616
|
-
const storeGet = getInternalBuildingBlocks(store)[21];
|
|
617
|
-
return storeGet(store, atom);
|
|
618
|
-
},
|
|
619
|
-
set(atom, ...args) {
|
|
620
|
-
const storeSet = getInternalBuildingBlocks(store)[22];
|
|
621
|
-
return storeSet(store, atom, ...args);
|
|
622
|
-
},
|
|
623
|
-
sub(atom, listener) {
|
|
624
|
-
const storeSub = getInternalBuildingBlocks(store)[23];
|
|
625
|
-
return storeSub(store, atom, listener);
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
const buildingBlocks = [
|
|
629
|
-
// store state
|
|
630
|
-
/* @__PURE__ */ new WeakMap(),
|
|
631
|
-
// atomStateMap
|
|
632
|
-
/* @__PURE__ */ new WeakMap(),
|
|
633
|
-
// mountedMap
|
|
634
|
-
/* @__PURE__ */ new WeakMap(),
|
|
635
|
-
// invalidatedAtoms
|
|
636
|
-
/* @__PURE__ */ new Set(),
|
|
637
|
-
// changedAtoms
|
|
638
|
-
/* @__PURE__ */ new Set(),
|
|
639
|
-
// mountCallbacks
|
|
640
|
-
/* @__PURE__ */ new Set(),
|
|
641
|
-
// unmountCallbacks
|
|
642
|
-
{},
|
|
643
|
-
// storeHooks
|
|
644
|
-
// atom interceptors
|
|
645
|
-
BUILDING_BLOCK_atomRead,
|
|
646
|
-
BUILDING_BLOCK_atomWrite,
|
|
647
|
-
BUILDING_BLOCK_atomOnInit,
|
|
648
|
-
BUILDING_BLOCK_atomOnMount,
|
|
649
|
-
// building-block functions
|
|
650
|
-
BUILDING_BLOCK_ensureAtomState,
|
|
651
|
-
BUILDING_BLOCK_flushCallbacks,
|
|
652
|
-
BUILDING_BLOCK_recomputeInvalidatedAtoms,
|
|
653
|
-
BUILDING_BLOCK_readAtomState,
|
|
654
|
-
BUILDING_BLOCK_invalidateDependents,
|
|
655
|
-
BUILDING_BLOCK_writeAtomState,
|
|
656
|
-
BUILDING_BLOCK_mountDependencies,
|
|
657
|
-
BUILDING_BLOCK_mountAtom,
|
|
658
|
-
BUILDING_BLOCK_unmountAtom,
|
|
659
|
-
BUILDING_BLOCK_setAtomStateValueOrPromise,
|
|
660
|
-
BUILDING_BLOCK_storeGet,
|
|
661
|
-
BUILDING_BLOCK_storeSet,
|
|
662
|
-
BUILDING_BLOCK_storeSub,
|
|
663
|
-
void 0
|
|
664
|
-
].map((fn, i) => buildArgs[i] || fn);
|
|
665
|
-
buildingBlockMap.set(store, Object.freeze(buildingBlocks));
|
|
666
|
-
return store;
|
|
667
|
-
}let keyCount = 0;
|
|
668
|
-
function atom(read, write) {
|
|
669
|
-
const key = `atom${++keyCount}`;
|
|
670
|
-
const config = {
|
|
671
|
-
toString() {
|
|
672
|
-
return (undefined ? undefined.MODE : void 0) !== "production" && this.debugLabel ? key + ":" + this.debugLabel : key;
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
if (typeof read === "function") {
|
|
676
|
-
config.read = read;
|
|
677
|
-
} else {
|
|
678
|
-
config.init = read;
|
|
679
|
-
config.read = defaultRead;
|
|
680
|
-
config.write = defaultWrite;
|
|
681
|
-
}
|
|
682
|
-
if (write) {
|
|
683
|
-
config.write = write;
|
|
684
|
-
}
|
|
685
|
-
return config;
|
|
686
|
-
}
|
|
687
|
-
function defaultRead(get) {
|
|
688
|
-
return get(this);
|
|
689
|
-
}
|
|
690
|
-
function defaultWrite(get, set, arg) {
|
|
691
|
-
return set(
|
|
692
|
-
this,
|
|
693
|
-
typeof arg === "function" ? arg(get(this)) : arg
|
|
694
|
-
);
|
|
695
|
-
}
|
|
696
|
-
function createStore() {
|
|
697
|
-
return buildStore();
|
|
698
|
-
}
|
|
699
|
-
let defaultStore;
|
|
700
|
-
function getDefaultStore() {
|
|
701
|
-
if (!defaultStore) {
|
|
702
|
-
defaultStore = createStore();
|
|
703
|
-
if ((undefined ? undefined.MODE : void 0) !== "production") {
|
|
704
|
-
globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore);
|
|
705
|
-
if (globalThis.__JOTAI_DEFAULT_STORE__ !== defaultStore) {
|
|
706
|
-
console.warn(
|
|
707
|
-
"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
|
|
708
|
-
);
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
return defaultStore;
|
|
713
|
-
}const StoreContext = React.createContext(
|
|
714
|
-
void 0
|
|
715
|
-
);
|
|
716
|
-
function useStore(options) {
|
|
717
|
-
const store = React.useContext(StoreContext);
|
|
718
|
-
return store || getDefaultStore();
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
const isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
722
|
-
const attachPromiseStatus = (promise) => {
|
|
723
|
-
if (!promise.status) {
|
|
724
|
-
promise.status = "pending";
|
|
725
|
-
promise.then(
|
|
726
|
-
(v) => {
|
|
727
|
-
promise.status = "fulfilled";
|
|
728
|
-
promise.value = v;
|
|
729
|
-
},
|
|
730
|
-
(e) => {
|
|
731
|
-
promise.status = "rejected";
|
|
732
|
-
promise.reason = e;
|
|
733
|
-
}
|
|
734
|
-
);
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
const use = React.use || // A shim for older React versions
|
|
738
|
-
((promise) => {
|
|
739
|
-
if (promise.status === "pending") {
|
|
740
|
-
throw promise;
|
|
741
|
-
} else if (promise.status === "fulfilled") {
|
|
742
|
-
return promise.value;
|
|
743
|
-
} else if (promise.status === "rejected") {
|
|
744
|
-
throw promise.reason;
|
|
745
|
-
} else {
|
|
746
|
-
attachPromiseStatus(promise);
|
|
747
|
-
throw promise;
|
|
748
|
-
}
|
|
749
|
-
});
|
|
750
|
-
const continuablePromiseMap = /* @__PURE__ */ new WeakMap();
|
|
751
|
-
const createContinuablePromise = (promise, getValue) => {
|
|
752
|
-
let continuablePromise = continuablePromiseMap.get(promise);
|
|
753
|
-
if (!continuablePromise) {
|
|
754
|
-
continuablePromise = new Promise((resolve, reject) => {
|
|
755
|
-
let curr = promise;
|
|
756
|
-
const onFulfilled = (me) => (v) => {
|
|
757
|
-
if (curr === me) {
|
|
758
|
-
resolve(v);
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
const onRejected = (me) => (e) => {
|
|
762
|
-
if (curr === me) {
|
|
763
|
-
reject(e);
|
|
764
|
-
}
|
|
765
|
-
};
|
|
766
|
-
const onAbort = () => {
|
|
767
|
-
try {
|
|
768
|
-
const nextValue = getValue();
|
|
769
|
-
if (isPromiseLike(nextValue)) {
|
|
770
|
-
continuablePromiseMap.set(nextValue, continuablePromise);
|
|
771
|
-
curr = nextValue;
|
|
772
|
-
nextValue.then(onFulfilled(nextValue), onRejected(nextValue));
|
|
773
|
-
registerAbortHandler(nextValue, onAbort);
|
|
774
|
-
} else {
|
|
775
|
-
resolve(nextValue);
|
|
776
|
-
}
|
|
777
|
-
} catch (e) {
|
|
778
|
-
reject(e);
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
promise.then(onFulfilled(promise), onRejected(promise));
|
|
782
|
-
registerAbortHandler(promise, onAbort);
|
|
783
|
-
});
|
|
784
|
-
continuablePromiseMap.set(promise, continuablePromise);
|
|
785
|
-
}
|
|
786
|
-
return continuablePromise;
|
|
787
|
-
};
|
|
788
|
-
function useAtomValue(atom, options) {
|
|
789
|
-
const { delay, unstable_promiseStatus: promiseStatus = !React.use } = {};
|
|
790
|
-
const store = useStore();
|
|
791
|
-
const [[valueFromReducer, storeFromReducer, atomFromReducer], rerender] = React.useReducer(
|
|
792
|
-
(prev) => {
|
|
793
|
-
const nextValue = store.get(atom);
|
|
794
|
-
if (Object.is(prev[0], nextValue) && prev[1] === store && prev[2] === atom) {
|
|
795
|
-
return prev;
|
|
796
|
-
}
|
|
797
|
-
return [nextValue, store, atom];
|
|
798
|
-
},
|
|
799
|
-
void 0,
|
|
800
|
-
() => [store.get(atom), store, atom]
|
|
801
|
-
);
|
|
802
|
-
let value = valueFromReducer;
|
|
803
|
-
if (storeFromReducer !== store || atomFromReducer !== atom) {
|
|
804
|
-
rerender();
|
|
805
|
-
value = store.get(atom);
|
|
806
|
-
}
|
|
807
|
-
React.useEffect(() => {
|
|
808
|
-
const unsub = store.sub(atom, () => {
|
|
809
|
-
if (promiseStatus) {
|
|
810
|
-
try {
|
|
811
|
-
const value2 = store.get(atom);
|
|
812
|
-
if (isPromiseLike(value2)) {
|
|
813
|
-
attachPromiseStatus(
|
|
814
|
-
createContinuablePromise(value2, () => store.get(atom))
|
|
815
|
-
);
|
|
816
|
-
}
|
|
817
|
-
} catch (e) {
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
if (typeof delay === "number") {
|
|
821
|
-
setTimeout(rerender, delay);
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
rerender();
|
|
825
|
-
});
|
|
826
|
-
rerender();
|
|
827
|
-
return unsub;
|
|
828
|
-
}, [store, atom, delay, promiseStatus]);
|
|
829
|
-
React.useDebugValue(value);
|
|
830
|
-
if (isPromiseLike(value)) {
|
|
831
|
-
const promise = createContinuablePromise(value, () => store.get(atom));
|
|
832
|
-
if (promiseStatus) {
|
|
833
|
-
attachPromiseStatus(promise);
|
|
834
|
-
}
|
|
835
|
-
return use(promise);
|
|
836
|
-
}
|
|
837
|
-
return value;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
function useSetAtom(atom, options) {
|
|
841
|
-
const store = useStore();
|
|
842
|
-
const setAtom = React.useCallback(
|
|
843
|
-
(...args) => {
|
|
844
|
-
if ((undefined ? undefined.MODE : void 0) !== "production" && !("write" in atom)) {
|
|
845
|
-
throw new Error("not writable atom");
|
|
846
|
-
}
|
|
847
|
-
return store.set(atom, ...args);
|
|
848
|
-
},
|
|
849
|
-
[store, atom]
|
|
850
|
-
);
|
|
851
|
-
return setAtom;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
function useAtom(atom, options) {
|
|
855
|
-
return [
|
|
856
|
-
useAtomValue(atom),
|
|
857
|
-
// We do wrong type assertion here, which results in throwing an error.
|
|
858
|
-
useSetAtom(atom)
|
|
859
|
-
];
|
|
860
|
-
}/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
28
|
+
};/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
861
29
|
/**
|
|
862
30
|
* Optimized shallow equality check for objects and functions
|
|
863
31
|
* @param objA - First object to compare
|
|
@@ -982,67 +150,12 @@ function memoize(fn, cacheKeyFn) {
|
|
|
982
150
|
cache.set(cacheKey, result);
|
|
983
151
|
return result;
|
|
984
152
|
};
|
|
985
|
-
}
|
|
986
|
-
let shouldRemove = null;
|
|
987
|
-
const atoms = new Map();
|
|
988
|
-
const listeners = new Set();
|
|
989
|
-
function createAtom(param) {
|
|
990
|
-
let item;
|
|
991
|
-
{
|
|
992
|
-
item = atoms.get(param);
|
|
993
|
-
}
|
|
994
|
-
if (item !== undefined) {
|
|
995
|
-
if (shouldRemove?.(item[1], param)) {
|
|
996
|
-
createAtom.remove(param);
|
|
997
|
-
}
|
|
998
|
-
else {
|
|
999
|
-
return item[0];
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
const newAtom = initializeAtom(param);
|
|
1003
|
-
atoms.set(param, [newAtom, Date.now()]);
|
|
1004
|
-
notifyListeners('CREATE', param, newAtom);
|
|
1005
|
-
return newAtom;
|
|
1006
|
-
}
|
|
1007
|
-
function notifyListeners(type, param, atom) {
|
|
1008
|
-
for (const listener of listeners) {
|
|
1009
|
-
listener({ type, param, atom });
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
createAtom.unstable_listen = (callback) => {
|
|
1013
|
-
listeners.add(callback);
|
|
1014
|
-
return () => {
|
|
1015
|
-
listeners.delete(callback);
|
|
1016
|
-
};
|
|
1017
|
-
};
|
|
1018
|
-
createAtom.getParams = () => atoms.keys();
|
|
1019
|
-
createAtom.remove = (param) => {
|
|
1020
|
-
{
|
|
1021
|
-
if (!atoms.has(param))
|
|
1022
|
-
return;
|
|
1023
|
-
const [atom] = atoms.get(param);
|
|
1024
|
-
atoms.delete(param);
|
|
1025
|
-
notifyListeners('REMOVE', param, atom);
|
|
1026
|
-
}
|
|
1027
|
-
};
|
|
1028
|
-
createAtom.setShouldRemove = (fn) => {
|
|
1029
|
-
shouldRemove = fn;
|
|
1030
|
-
if (!shouldRemove)
|
|
1031
|
-
return;
|
|
1032
|
-
for (const [key, [atom, createdAt]] of atoms) {
|
|
1033
|
-
if (shouldRemove(createdAt, key)) {
|
|
1034
|
-
atoms.delete(key);
|
|
1035
|
-
notifyListeners('REMOVE', key, atom);
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
return createAtom;
|
|
1040
|
-
}const pageVariablesAtomFamily = atomFamily(_pageId => atom({}));
|
|
153
|
+
}const pageVariablesAtomFamily = jotaiFamily.atomFamily(_pageId => jotai.atom({}));
|
|
1041
154
|
/**
|
|
1042
155
|
* Global atom storing all page variables.
|
|
1043
156
|
* Key format: "scopeId:pageId"
|
|
1044
157
|
*/
|
|
1045
|
-
const pageVariablesAtom = atom({});
|
|
158
|
+
const pageVariablesAtom = jotai.atom({});
|
|
1046
159
|
/**
|
|
1047
160
|
* Helper to generate composite keys for page variables.
|
|
1048
161
|
*/
|
|
@@ -1050,7 +163,7 @@ const getPageVariablesCompositeKey = (scopeId, key) => `${scopeId}:${key}`;
|
|
|
1050
163
|
/**
|
|
1051
164
|
* Creates a derived atom for accessing page variables of a specific scope.
|
|
1052
165
|
*/
|
|
1053
|
-
const createScopePageVariablesAtom = scopeId => atom(get => {
|
|
166
|
+
const createScopePageVariablesAtom = scopeId => jotai.atom(get => {
|
|
1054
167
|
const allPageVariables = get(pageVariablesAtom);
|
|
1055
168
|
const prefix = `${scopeId}:`;
|
|
1056
169
|
const scopePageVariables = {};
|
|
@@ -1102,21 +215,21 @@ const usePageValues = ({
|
|
|
1102
215
|
} = reactForm.useFormValues({
|
|
1103
216
|
formId: pageId
|
|
1104
217
|
});
|
|
1105
|
-
const subscriptions =
|
|
1106
|
-
const [trigger, setTrigger] =
|
|
1107
|
-
const [pageVariables, setPageVariables] = useAtom(pageVariablesAtomFamily(pageId));
|
|
1108
|
-
const initialized =
|
|
1109
|
-
|
|
218
|
+
const subscriptions = react.useRef(new Map());
|
|
219
|
+
const [trigger, setTrigger] = react.useState(0);
|
|
220
|
+
const [pageVariables, setPageVariables] = jotai.useAtom(pageVariablesAtomFamily(pageId));
|
|
221
|
+
const initialized = react.useRef(false);
|
|
222
|
+
react.useEffect(() => {
|
|
1110
223
|
if (!initialized.current && initialValues) {
|
|
1111
224
|
setPageVariables(initialValues);
|
|
1112
225
|
initialized.current = true;
|
|
1113
226
|
}
|
|
1114
227
|
}, [initialValues, setPageVariables]);
|
|
1115
|
-
const dataRef =
|
|
228
|
+
const dataRef = react.useRef({
|
|
1116
229
|
state: pageVariables
|
|
1117
230
|
});
|
|
1118
231
|
// Sync dataRef with latest values
|
|
1119
|
-
|
|
232
|
+
react.useEffect(() => {
|
|
1120
233
|
let internalTrigger = false;
|
|
1121
234
|
subscriptions.current.forEach((_, key) => {
|
|
1122
235
|
const [type, keyPath] = key.split(':');
|
|
@@ -1135,7 +248,7 @@ const usePageValues = ({
|
|
|
1135
248
|
}
|
|
1136
249
|
}, [pageVariables]);
|
|
1137
250
|
// get che legge dallo store e registra le dipendenze
|
|
1138
|
-
const get =
|
|
251
|
+
const get = react.useCallback((type, key, defaultValue) => {
|
|
1139
252
|
var _a;
|
|
1140
253
|
const keyMap = `${type}:${key}`;
|
|
1141
254
|
switch (type) {
|
|
@@ -1169,7 +282,7 @@ const usePageValues = ({
|
|
|
1169
282
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1170
283
|
[pageId, trigger, getApiValues, getFormValues]);
|
|
1171
284
|
// set stabile
|
|
1172
|
-
const set =
|
|
285
|
+
const set = react.useCallback(type => {
|
|
1173
286
|
if (type === 'form') {
|
|
1174
287
|
return setFormValues;
|
|
1175
288
|
}
|
|
@@ -1199,7 +312,7 @@ const PageContentItemInner = ({
|
|
|
1199
312
|
} = usePageValues({
|
|
1200
313
|
pageId
|
|
1201
314
|
});
|
|
1202
|
-
const isHidden =
|
|
315
|
+
const isHidden = react.useMemo(() => {
|
|
1203
316
|
if (typeof item.hidden === 'function') {
|
|
1204
317
|
return item.hidden({
|
|
1205
318
|
get,
|
|
@@ -1215,7 +328,7 @@ const PageContentItemInner = ({
|
|
|
1215
328
|
pageId: pageId
|
|
1216
329
|
}, (_a = item.key) !== null && _a !== void 0 ? _a : '');
|
|
1217
330
|
};
|
|
1218
|
-
const PageContentItem =
|
|
331
|
+
const PageContentItem = react.memo(PageContentItemInner);
|
|
1219
332
|
const useGenerateContentRender = ({
|
|
1220
333
|
pageId,
|
|
1221
334
|
ns = '',
|
|
@@ -1228,7 +341,7 @@ const useGenerateContentRender = ({
|
|
|
1228
341
|
} = usePageValues({
|
|
1229
342
|
pageId
|
|
1230
343
|
});
|
|
1231
|
-
const contentsWithQueriesDeps =
|
|
344
|
+
const contentsWithQueriesDeps = react.useMemo(() => {
|
|
1232
345
|
if (typeof contents === 'function') {
|
|
1233
346
|
return contents({
|
|
1234
347
|
get,
|
|
@@ -1238,14 +351,14 @@ const useGenerateContentRender = ({
|
|
|
1238
351
|
return Array.isArray(contents) ? contents : [];
|
|
1239
352
|
}, [contents, get, set]);
|
|
1240
353
|
// Memoize form elements separately - only recalculate when formData.elements changes
|
|
1241
|
-
const formElementsWithKey =
|
|
354
|
+
const formElementsWithKey = react.useMemo(() => {
|
|
1242
355
|
if (!Array.isArray(formData.elements)) return [];
|
|
1243
356
|
return formData.elements.map((el, idx) => Object.assign(Object.assign({}, el), {
|
|
1244
357
|
key: `form-element-${el.index || idx}`
|
|
1245
358
|
}));
|
|
1246
359
|
}, [formData.elements]);
|
|
1247
360
|
// Memoize dynamic elements - only recalculate when contents change
|
|
1248
|
-
const dynamicElements =
|
|
361
|
+
const dynamicElements = react.useMemo(() => contentsWithQueriesDeps.map((content, index) => {
|
|
1249
362
|
var _a;
|
|
1250
363
|
const stableKey = getStableKey(content, index);
|
|
1251
364
|
return {
|
|
@@ -1261,7 +374,7 @@ const useGenerateContentRender = ({
|
|
|
1261
374
|
};
|
|
1262
375
|
}), [contentsWithQueriesDeps, ns, pageId]);
|
|
1263
376
|
// Merge and sort - only when either array changes
|
|
1264
|
-
const memorizedContents =
|
|
377
|
+
const memorizedContents = react.useMemo(() => [...dynamicElements, ...formElementsWithKey].sort((a, b) => a.index - b.index || String(a.key).localeCompare(String(b.key))), [dynamicElements, formElementsWithKey]);
|
|
1265
378
|
return {
|
|
1266
379
|
components: memorizedContents,
|
|
1267
380
|
allContents: [...contentsWithQueriesDeps, ...formData.formContents]
|
|
@@ -2070,7 +1183,7 @@ function resolveMetadata(meta, ctx) {
|
|
|
2070
1183
|
resolved.customMeta = customMeta;
|
|
2071
1184
|
}
|
|
2072
1185
|
return resolved;
|
|
2073
|
-
}const MetadataStoreContext =
|
|
1186
|
+
}const MetadataStoreContext = react.createContext(null);
|
|
2074
1187
|
/**
|
|
2075
1188
|
* Provides a request-scoped MetadataStore via React Context.
|
|
2076
1189
|
*
|
|
@@ -2124,7 +1237,7 @@ function MetadataStoreProvider(t0) {
|
|
|
2124
1237
|
* Returns `null` if no provider is found (falls back to global store in consumers).
|
|
2125
1238
|
*/
|
|
2126
1239
|
function useMetadataStore() {
|
|
2127
|
-
return
|
|
1240
|
+
return react.useContext(MetadataStoreContext);
|
|
2128
1241
|
}/**
|
|
2129
1242
|
* Optional dev-only metadata logging.
|
|
2130
1243
|
*
|
|
@@ -2187,9 +1300,9 @@ let _pageConfig = {
|
|
|
2187
1300
|
HeaderContainer: DefaultContainer,
|
|
2188
1301
|
FooterContainer: DefaultContainer,
|
|
2189
1302
|
BodyContainer: DefaultContainer,
|
|
2190
|
-
authPageImage:
|
|
1303
|
+
authPageImage: "",
|
|
2191
1304
|
authPageProps: {
|
|
2192
|
-
id:
|
|
1305
|
+
id: "auth-page"
|
|
2193
1306
|
},
|
|
2194
1307
|
isLogged: val => !!(val === null || val === void 0 ? void 0 : val.id) && !!val.isLogged,
|
|
2195
1308
|
ItemsContainer: ({
|
|
@@ -2199,8 +1312,8 @@ let _pageConfig = {
|
|
|
2199
1312
|
children
|
|
2200
1313
|
}) => children,
|
|
2201
1314
|
meta: {
|
|
2202
|
-
title:
|
|
2203
|
-
description:
|
|
1315
|
+
title: "",
|
|
1316
|
+
description: ""
|
|
2204
1317
|
},
|
|
2205
1318
|
// Metadata configuration
|
|
2206
1319
|
defaultMetadata: {},
|
|
@@ -2213,7 +1326,7 @@ let _pageConfig = {
|
|
|
2213
1326
|
preloadOnHover: false,
|
|
2214
1327
|
preloadOnFocus: false,
|
|
2215
1328
|
timeout: 30000,
|
|
2216
|
-
logMetrics: process.env.NODE_ENV ===
|
|
1329
|
+
logMetrics: process.env.NODE_ENV === "development"
|
|
2217
1330
|
}
|
|
2218
1331
|
};
|
|
2219
1332
|
/**
|
|
@@ -2225,9 +1338,9 @@ function initializePageConfig() {
|
|
|
2225
1338
|
HeaderContainer: DefaultContainer,
|
|
2226
1339
|
FooterContainer: DefaultContainer,
|
|
2227
1340
|
BodyContainer: DefaultContainer,
|
|
2228
|
-
authPageImage:
|
|
1341
|
+
authPageImage: "",
|
|
2229
1342
|
authPageProps: {
|
|
2230
|
-
id:
|
|
1343
|
+
id: "auth-page"
|
|
2231
1344
|
},
|
|
2232
1345
|
isLogged: val => !!(val === null || val === void 0 ? void 0 : val.id) && !!val.isLogged,
|
|
2233
1346
|
ItemsContainer: ({
|
|
@@ -2237,8 +1350,8 @@ function initializePageConfig() {
|
|
|
2237
1350
|
children
|
|
2238
1351
|
}) => children,
|
|
2239
1352
|
meta: {
|
|
2240
|
-
title:
|
|
2241
|
-
description:
|
|
1353
|
+
title: "",
|
|
1354
|
+
description: ""
|
|
2242
1355
|
},
|
|
2243
1356
|
// Metadata configuration
|
|
2244
1357
|
defaultMetadata: {},
|
|
@@ -2251,7 +1364,7 @@ function initializePageConfig() {
|
|
|
2251
1364
|
preloadOnHover: false,
|
|
2252
1365
|
preloadOnFocus: false,
|
|
2253
1366
|
timeout: 30000,
|
|
2254
|
-
logMetrics: process.env.NODE_ENV ===
|
|
1367
|
+
logMetrics: process.env.NODE_ENV === "development"
|
|
2255
1368
|
}
|
|
2256
1369
|
};
|
|
2257
1370
|
return _pageConfig;
|
|
@@ -2266,7 +1379,7 @@ const {
|
|
|
2266
1379
|
useState: usePageConfigState,
|
|
2267
1380
|
useReset: usePageConfigReset
|
|
2268
1381
|
} = reactState.atomStateGenerator({
|
|
2269
|
-
key:
|
|
1382
|
+
key: "pageConfig",
|
|
2270
1383
|
defaultValue: _pageConfig,
|
|
2271
1384
|
persist: false
|
|
2272
1385
|
});/**
|
|
@@ -2329,7 +1442,7 @@ function useFormData({
|
|
|
2329
1442
|
} = usePageValues({
|
|
2330
1443
|
pageId
|
|
2331
1444
|
});
|
|
2332
|
-
const hiddenMapped =
|
|
1445
|
+
const hiddenMapped = react.useCallback(() => {
|
|
2333
1446
|
const isHidden = form === null || form === void 0 ? void 0 : form.hidden;
|
|
2334
1447
|
if (!isHidden) return false;
|
|
2335
1448
|
if (typeof isHidden === 'function') {
|
|
@@ -2341,7 +1454,7 @@ function useFormData({
|
|
|
2341
1454
|
return !!isHidden;
|
|
2342
1455
|
}
|
|
2343
1456
|
}, [form === null || form === void 0 ? void 0 : form.hidden, get, set]);
|
|
2344
|
-
const mappedFormData =
|
|
1457
|
+
const mappedFormData = react.useMemo(() => {
|
|
2345
1458
|
if (!(form === null || form === void 0 ? void 0 : form.data) || hiddenMapped()) return [];
|
|
2346
1459
|
return form.data.map(el => {
|
|
2347
1460
|
if (typeof el === 'function') {
|
|
@@ -2360,7 +1473,7 @@ function useFormData({
|
|
|
2360
1473
|
});
|
|
2361
1474
|
});
|
|
2362
1475
|
}, [form, get, hiddenMapped, set]);
|
|
2363
|
-
const formSubmit =
|
|
1476
|
+
const formSubmit = react.useMemo(() => {
|
|
2364
1477
|
if (!(form === null || form === void 0 ? void 0 : form.submit) || hiddenMapped()) return [];
|
|
2365
1478
|
const submitFn = form.submit;
|
|
2366
1479
|
return (typeof submitFn === 'function' ? submitFn({
|
|
@@ -2377,850 +1490,6 @@ function useFormData({
|
|
|
2377
1490
|
mappedFormData,
|
|
2378
1491
|
formSubmit
|
|
2379
1492
|
};
|
|
2380
|
-
}// src/subscribable.ts
|
|
2381
|
-
var Subscribable = class {
|
|
2382
|
-
constructor() {
|
|
2383
|
-
this.listeners = /* @__PURE__ */new Set();
|
|
2384
|
-
this.subscribe = this.subscribe.bind(this);
|
|
2385
|
-
}
|
|
2386
|
-
subscribe(listener) {
|
|
2387
|
-
this.listeners.add(listener);
|
|
2388
|
-
this.onSubscribe();
|
|
2389
|
-
return () => {
|
|
2390
|
-
this.listeners.delete(listener);
|
|
2391
|
-
this.onUnsubscribe();
|
|
2392
|
-
};
|
|
2393
|
-
}
|
|
2394
|
-
hasListeners() {
|
|
2395
|
-
return this.listeners.size > 0;
|
|
2396
|
-
}
|
|
2397
|
-
onSubscribe() {}
|
|
2398
|
-
onUnsubscribe() {}
|
|
2399
|
-
};// src/timeoutManager.ts
|
|
2400
|
-
var defaultTimeoutProvider = {
|
|
2401
|
-
// We need the wrapper function syntax below instead of direct references to
|
|
2402
|
-
// global setTimeout etc.
|
|
2403
|
-
//
|
|
2404
|
-
// BAD: `setTimeout: setTimeout`
|
|
2405
|
-
// GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
|
|
2406
|
-
//
|
|
2407
|
-
// If we use direct references here, then anything that wants to spy on or
|
|
2408
|
-
// replace the global setTimeout (like tests) won't work since we'll already
|
|
2409
|
-
// have a hard reference to the original implementation at the time when this
|
|
2410
|
-
// file was imported.
|
|
2411
|
-
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
2412
|
-
clearTimeout: timeoutId => clearTimeout(timeoutId),
|
|
2413
|
-
setInterval: (callback, delay) => setInterval(callback, delay),
|
|
2414
|
-
clearInterval: intervalId => clearInterval(intervalId)
|
|
2415
|
-
};
|
|
2416
|
-
var TimeoutManager = class {
|
|
2417
|
-
// We cannot have TimeoutManager<T> as we must instantiate it with a concrete
|
|
2418
|
-
// type at app boot; and if we leave that type, then any new timer provider
|
|
2419
|
-
// would need to support ReturnType<typeof setTimeout>, which is infeasible.
|
|
2420
|
-
//
|
|
2421
|
-
// We settle for type safety for the TimeoutProvider type, and accept that
|
|
2422
|
-
// this class is unsafe internally to allow for extension.
|
|
2423
|
-
#provider = defaultTimeoutProvider;
|
|
2424
|
-
#providerCalled = false;
|
|
2425
|
-
setTimeoutProvider(provider) {
|
|
2426
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2427
|
-
if (this.#providerCalled && provider !== this.#provider) {
|
|
2428
|
-
console.error(`[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`, {
|
|
2429
|
-
previous: this.#provider,
|
|
2430
|
-
provider
|
|
2431
|
-
});
|
|
2432
|
-
}
|
|
2433
|
-
}
|
|
2434
|
-
this.#provider = provider;
|
|
2435
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2436
|
-
this.#providerCalled = false;
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
setTimeout(callback, delay) {
|
|
2440
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2441
|
-
this.#providerCalled = true;
|
|
2442
|
-
}
|
|
2443
|
-
return this.#provider.setTimeout(callback, delay);
|
|
2444
|
-
}
|
|
2445
|
-
clearTimeout(timeoutId) {
|
|
2446
|
-
this.#provider.clearTimeout(timeoutId);
|
|
2447
|
-
}
|
|
2448
|
-
setInterval(callback, delay) {
|
|
2449
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2450
|
-
this.#providerCalled = true;
|
|
2451
|
-
}
|
|
2452
|
-
return this.#provider.setInterval(callback, delay);
|
|
2453
|
-
}
|
|
2454
|
-
clearInterval(intervalId) {
|
|
2455
|
-
this.#provider.clearInterval(intervalId);
|
|
2456
|
-
}
|
|
2457
|
-
};
|
|
2458
|
-
var timeoutManager = new TimeoutManager();
|
|
2459
|
-
function systemSetTimeoutZero(callback) {
|
|
2460
|
-
setTimeout(callback, 0);
|
|
2461
|
-
}// src/utils.ts
|
|
2462
|
-
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
2463
|
-
function noop() {}
|
|
2464
|
-
function isValidTimeout(value) {
|
|
2465
|
-
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
2466
|
-
}
|
|
2467
|
-
function timeUntilStale(updatedAt, staleTime) {
|
|
2468
|
-
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
2469
|
-
}
|
|
2470
|
-
function resolveStaleTime(staleTime, query) {
|
|
2471
|
-
return typeof staleTime === "function" ? staleTime(query) : staleTime;
|
|
2472
|
-
}
|
|
2473
|
-
function resolveEnabled(enabled, query) {
|
|
2474
|
-
return typeof enabled === "function" ? enabled(query) : enabled;
|
|
2475
|
-
}
|
|
2476
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
2477
|
-
function replaceEqualDeep(a, b, depth = 0) {
|
|
2478
|
-
if (a === b) {
|
|
2479
|
-
return a;
|
|
2480
|
-
}
|
|
2481
|
-
if (depth > 500) return b;
|
|
2482
|
-
const array = isPlainArray(a) && isPlainArray(b);
|
|
2483
|
-
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
|
|
2484
|
-
const aItems = array ? a : Object.keys(a);
|
|
2485
|
-
const aSize = aItems.length;
|
|
2486
|
-
const bItems = array ? b : Object.keys(b);
|
|
2487
|
-
const bSize = bItems.length;
|
|
2488
|
-
const copy = array ? new Array(bSize) : {};
|
|
2489
|
-
let equalItems = 0;
|
|
2490
|
-
for (let i = 0; i < bSize; i++) {
|
|
2491
|
-
const key = array ? i : bItems[i];
|
|
2492
|
-
const aItem = a[key];
|
|
2493
|
-
const bItem = b[key];
|
|
2494
|
-
if (aItem === bItem) {
|
|
2495
|
-
copy[key] = aItem;
|
|
2496
|
-
if (array ? i < aSize : hasOwn.call(a, key)) equalItems++;
|
|
2497
|
-
continue;
|
|
2498
|
-
}
|
|
2499
|
-
if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
|
|
2500
|
-
copy[key] = bItem;
|
|
2501
|
-
continue;
|
|
2502
|
-
}
|
|
2503
|
-
const v = replaceEqualDeep(aItem, bItem, depth + 1);
|
|
2504
|
-
copy[key] = v;
|
|
2505
|
-
if (v === aItem) equalItems++;
|
|
2506
|
-
}
|
|
2507
|
-
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
2508
|
-
}
|
|
2509
|
-
function shallowEqualObjects(a, b) {
|
|
2510
|
-
if (!b || Object.keys(a).length !== Object.keys(b).length) {
|
|
2511
|
-
return false;
|
|
2512
|
-
}
|
|
2513
|
-
for (const key in a) {
|
|
2514
|
-
if (a[key] !== b[key]) {
|
|
2515
|
-
return false;
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
return true;
|
|
2519
|
-
}
|
|
2520
|
-
function isPlainArray(value) {
|
|
2521
|
-
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
2522
|
-
}
|
|
2523
|
-
function isPlainObject(o) {
|
|
2524
|
-
if (!hasObjectPrototype(o)) {
|
|
2525
|
-
return false;
|
|
2526
|
-
}
|
|
2527
|
-
const ctor = o.constructor;
|
|
2528
|
-
if (ctor === void 0) {
|
|
2529
|
-
return true;
|
|
2530
|
-
}
|
|
2531
|
-
const prot = ctor.prototype;
|
|
2532
|
-
if (!hasObjectPrototype(prot)) {
|
|
2533
|
-
return false;
|
|
2534
|
-
}
|
|
2535
|
-
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
2536
|
-
return false;
|
|
2537
|
-
}
|
|
2538
|
-
if (Object.getPrototypeOf(o) !== Object.prototype) {
|
|
2539
|
-
return false;
|
|
2540
|
-
}
|
|
2541
|
-
return true;
|
|
2542
|
-
}
|
|
2543
|
-
function hasObjectPrototype(o) {
|
|
2544
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
2545
|
-
}
|
|
2546
|
-
function replaceData(prevData, data, options) {
|
|
2547
|
-
if (typeof options.structuralSharing === "function") {
|
|
2548
|
-
return options.structuralSharing(prevData, data);
|
|
2549
|
-
} else if (options.structuralSharing !== false) {
|
|
2550
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2551
|
-
try {
|
|
2552
|
-
return replaceEqualDeep(prevData, data);
|
|
2553
|
-
} catch (error) {
|
|
2554
|
-
console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`);
|
|
2555
|
-
throw error;
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
return replaceEqualDeep(prevData, data);
|
|
2559
|
-
}
|
|
2560
|
-
return data;
|
|
2561
|
-
}// src/focusManager.ts
|
|
2562
|
-
var FocusManager = class extends Subscribable {
|
|
2563
|
-
#focused;
|
|
2564
|
-
#cleanup;
|
|
2565
|
-
#setup;
|
|
2566
|
-
constructor() {
|
|
2567
|
-
super();
|
|
2568
|
-
this.#setup = onFocus => {
|
|
2569
|
-
if (!isServer && window.addEventListener) {
|
|
2570
|
-
const listener = () => onFocus();
|
|
2571
|
-
window.addEventListener("visibilitychange", listener, false);
|
|
2572
|
-
return () => {
|
|
2573
|
-
window.removeEventListener("visibilitychange", listener);
|
|
2574
|
-
};
|
|
2575
|
-
}
|
|
2576
|
-
return;
|
|
2577
|
-
};
|
|
2578
|
-
}
|
|
2579
|
-
onSubscribe() {
|
|
2580
|
-
if (!this.#cleanup) {
|
|
2581
|
-
this.setEventListener(this.#setup);
|
|
2582
|
-
}
|
|
2583
|
-
}
|
|
2584
|
-
onUnsubscribe() {
|
|
2585
|
-
if (!this.hasListeners()) {
|
|
2586
|
-
this.#cleanup?.();
|
|
2587
|
-
this.#cleanup = void 0;
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
setEventListener(setup) {
|
|
2591
|
-
this.#setup = setup;
|
|
2592
|
-
this.#cleanup?.();
|
|
2593
|
-
this.#cleanup = setup(focused => {
|
|
2594
|
-
if (typeof focused === "boolean") {
|
|
2595
|
-
this.setFocused(focused);
|
|
2596
|
-
} else {
|
|
2597
|
-
this.onFocus();
|
|
2598
|
-
}
|
|
2599
|
-
});
|
|
2600
|
-
}
|
|
2601
|
-
setFocused(focused) {
|
|
2602
|
-
const changed = this.#focused !== focused;
|
|
2603
|
-
if (changed) {
|
|
2604
|
-
this.#focused = focused;
|
|
2605
|
-
this.onFocus();
|
|
2606
|
-
}
|
|
2607
|
-
}
|
|
2608
|
-
onFocus() {
|
|
2609
|
-
const isFocused = this.isFocused();
|
|
2610
|
-
this.listeners.forEach(listener => {
|
|
2611
|
-
listener(isFocused);
|
|
2612
|
-
});
|
|
2613
|
-
}
|
|
2614
|
-
isFocused() {
|
|
2615
|
-
if (typeof this.#focused === "boolean") {
|
|
2616
|
-
return this.#focused;
|
|
2617
|
-
}
|
|
2618
|
-
return globalThis.document?.visibilityState !== "hidden";
|
|
2619
|
-
}
|
|
2620
|
-
};
|
|
2621
|
-
var focusManager = new FocusManager();// src/thenable.ts
|
|
2622
|
-
function pendingThenable() {
|
|
2623
|
-
let resolve;
|
|
2624
|
-
let reject;
|
|
2625
|
-
const thenable = new Promise((_resolve, _reject) => {
|
|
2626
|
-
resolve = _resolve;
|
|
2627
|
-
reject = _reject;
|
|
2628
|
-
});
|
|
2629
|
-
thenable.status = "pending";
|
|
2630
|
-
thenable.catch(() => {});
|
|
2631
|
-
function finalize(data) {
|
|
2632
|
-
Object.assign(thenable, data);
|
|
2633
|
-
delete thenable.resolve;
|
|
2634
|
-
delete thenable.reject;
|
|
2635
|
-
}
|
|
2636
|
-
thenable.resolve = value => {
|
|
2637
|
-
finalize({
|
|
2638
|
-
status: "fulfilled",
|
|
2639
|
-
value
|
|
2640
|
-
});
|
|
2641
|
-
resolve(value);
|
|
2642
|
-
};
|
|
2643
|
-
thenable.reject = reason => {
|
|
2644
|
-
finalize({
|
|
2645
|
-
status: "rejected",
|
|
2646
|
-
reason
|
|
2647
|
-
});
|
|
2648
|
-
reject(reason);
|
|
2649
|
-
};
|
|
2650
|
-
return thenable;
|
|
2651
|
-
}// src/notifyManager.ts
|
|
2652
|
-
var defaultScheduler = systemSetTimeoutZero;
|
|
2653
|
-
function createNotifyManager() {
|
|
2654
|
-
let queue = [];
|
|
2655
|
-
let transactions = 0;
|
|
2656
|
-
let notifyFn = callback => {
|
|
2657
|
-
callback();
|
|
2658
|
-
};
|
|
2659
|
-
let batchNotifyFn = callback => {
|
|
2660
|
-
callback();
|
|
2661
|
-
};
|
|
2662
|
-
let scheduleFn = defaultScheduler;
|
|
2663
|
-
const schedule = callback => {
|
|
2664
|
-
if (transactions) {
|
|
2665
|
-
queue.push(callback);
|
|
2666
|
-
} else {
|
|
2667
|
-
scheduleFn(() => {
|
|
2668
|
-
notifyFn(callback);
|
|
2669
|
-
});
|
|
2670
|
-
}
|
|
2671
|
-
};
|
|
2672
|
-
const flush = () => {
|
|
2673
|
-
const originalQueue = queue;
|
|
2674
|
-
queue = [];
|
|
2675
|
-
if (originalQueue.length) {
|
|
2676
|
-
scheduleFn(() => {
|
|
2677
|
-
batchNotifyFn(() => {
|
|
2678
|
-
originalQueue.forEach(callback => {
|
|
2679
|
-
notifyFn(callback);
|
|
2680
|
-
});
|
|
2681
|
-
});
|
|
2682
|
-
});
|
|
2683
|
-
}
|
|
2684
|
-
};
|
|
2685
|
-
return {
|
|
2686
|
-
batch: callback => {
|
|
2687
|
-
let result;
|
|
2688
|
-
transactions++;
|
|
2689
|
-
try {
|
|
2690
|
-
result = callback();
|
|
2691
|
-
} finally {
|
|
2692
|
-
transactions--;
|
|
2693
|
-
if (!transactions) {
|
|
2694
|
-
flush();
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
return result;
|
|
2698
|
-
},
|
|
2699
|
-
/**
|
|
2700
|
-
* All calls to the wrapped function will be batched.
|
|
2701
|
-
*/
|
|
2702
|
-
batchCalls: callback => {
|
|
2703
|
-
return (...args) => {
|
|
2704
|
-
schedule(() => {
|
|
2705
|
-
callback(...args);
|
|
2706
|
-
});
|
|
2707
|
-
};
|
|
2708
|
-
},
|
|
2709
|
-
schedule,
|
|
2710
|
-
/**
|
|
2711
|
-
* Use this method to set a custom notify function.
|
|
2712
|
-
* This can be used to for example wrap notifications with `React.act` while running tests.
|
|
2713
|
-
*/
|
|
2714
|
-
setNotifyFunction: fn => {
|
|
2715
|
-
notifyFn = fn;
|
|
2716
|
-
},
|
|
2717
|
-
/**
|
|
2718
|
-
* Use this method to set a custom function to batch notifications together into a single tick.
|
|
2719
|
-
* By default React Query will use the batch function provided by ReactDOM or React Native.
|
|
2720
|
-
*/
|
|
2721
|
-
setBatchNotifyFunction: fn => {
|
|
2722
|
-
batchNotifyFn = fn;
|
|
2723
|
-
},
|
|
2724
|
-
setScheduler: fn => {
|
|
2725
|
-
scheduleFn = fn;
|
|
2726
|
-
}
|
|
2727
|
-
};
|
|
2728
|
-
}
|
|
2729
|
-
var notifyManager = createNotifyManager();// src/onlineManager.ts
|
|
2730
|
-
var OnlineManager = class extends Subscribable {
|
|
2731
|
-
#online = true;
|
|
2732
|
-
#cleanup;
|
|
2733
|
-
#setup;
|
|
2734
|
-
constructor() {
|
|
2735
|
-
super();
|
|
2736
|
-
this.#setup = onOnline => {
|
|
2737
|
-
if (!isServer && window.addEventListener) {
|
|
2738
|
-
const onlineListener = () => onOnline(true);
|
|
2739
|
-
const offlineListener = () => onOnline(false);
|
|
2740
|
-
window.addEventListener("online", onlineListener, false);
|
|
2741
|
-
window.addEventListener("offline", offlineListener, false);
|
|
2742
|
-
return () => {
|
|
2743
|
-
window.removeEventListener("online", onlineListener);
|
|
2744
|
-
window.removeEventListener("offline", offlineListener);
|
|
2745
|
-
};
|
|
2746
|
-
}
|
|
2747
|
-
return;
|
|
2748
|
-
};
|
|
2749
|
-
}
|
|
2750
|
-
onSubscribe() {
|
|
2751
|
-
if (!this.#cleanup) {
|
|
2752
|
-
this.setEventListener(this.#setup);
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
onUnsubscribe() {
|
|
2756
|
-
if (!this.hasListeners()) {
|
|
2757
|
-
this.#cleanup?.();
|
|
2758
|
-
this.#cleanup = void 0;
|
|
2759
|
-
}
|
|
2760
|
-
}
|
|
2761
|
-
setEventListener(setup) {
|
|
2762
|
-
this.#setup = setup;
|
|
2763
|
-
this.#cleanup?.();
|
|
2764
|
-
this.#cleanup = setup(this.setOnline.bind(this));
|
|
2765
|
-
}
|
|
2766
|
-
setOnline(online) {
|
|
2767
|
-
const changed = this.#online !== online;
|
|
2768
|
-
if (changed) {
|
|
2769
|
-
this.#online = online;
|
|
2770
|
-
this.listeners.forEach(listener => {
|
|
2771
|
-
listener(online);
|
|
2772
|
-
});
|
|
2773
|
-
}
|
|
2774
|
-
}
|
|
2775
|
-
isOnline() {
|
|
2776
|
-
return this.#online;
|
|
2777
|
-
}
|
|
2778
|
-
};
|
|
2779
|
-
var onlineManager = new OnlineManager();// src/retryer.ts
|
|
2780
|
-
function canFetch(networkMode) {
|
|
2781
|
-
return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
|
|
2782
|
-
}// src/query.ts
|
|
2783
|
-
function fetchState(data, options) {
|
|
2784
|
-
return {
|
|
2785
|
-
fetchFailureCount: 0,
|
|
2786
|
-
fetchFailureReason: null,
|
|
2787
|
-
fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
|
|
2788
|
-
...(data === void 0 && {
|
|
2789
|
-
error: null,
|
|
2790
|
-
status: "pending"
|
|
2791
|
-
})
|
|
2792
|
-
};
|
|
2793
|
-
}// src/queryObserver.ts
|
|
2794
|
-
var QueryObserver = class extends Subscribable {
|
|
2795
|
-
constructor(client, options) {
|
|
2796
|
-
super();
|
|
2797
|
-
this.options = options;
|
|
2798
|
-
this.#client = client;
|
|
2799
|
-
this.#selectError = null;
|
|
2800
|
-
this.#currentThenable = pendingThenable();
|
|
2801
|
-
this.bindMethods();
|
|
2802
|
-
this.setOptions(options);
|
|
2803
|
-
}
|
|
2804
|
-
#client;
|
|
2805
|
-
#currentQuery = void 0;
|
|
2806
|
-
#currentQueryInitialState = void 0;
|
|
2807
|
-
#currentResult = void 0;
|
|
2808
|
-
#currentResultState;
|
|
2809
|
-
#currentResultOptions;
|
|
2810
|
-
#currentThenable;
|
|
2811
|
-
#selectError;
|
|
2812
|
-
#selectFn;
|
|
2813
|
-
#selectResult;
|
|
2814
|
-
// This property keeps track of the last query with defined data.
|
|
2815
|
-
// It will be used to pass the previous data and query to the placeholder function between renders.
|
|
2816
|
-
#lastQueryWithDefinedData;
|
|
2817
|
-
#staleTimeoutId;
|
|
2818
|
-
#refetchIntervalId;
|
|
2819
|
-
#currentRefetchInterval;
|
|
2820
|
-
#trackedProps = /* @__PURE__ */new Set();
|
|
2821
|
-
bindMethods() {
|
|
2822
|
-
this.refetch = this.refetch.bind(this);
|
|
2823
|
-
}
|
|
2824
|
-
onSubscribe() {
|
|
2825
|
-
if (this.listeners.size === 1) {
|
|
2826
|
-
this.#currentQuery.addObserver(this);
|
|
2827
|
-
if (shouldFetchOnMount(this.#currentQuery, this.options)) {
|
|
2828
|
-
this.#executeFetch();
|
|
2829
|
-
} else {
|
|
2830
|
-
this.updateResult();
|
|
2831
|
-
}
|
|
2832
|
-
this.#updateTimers();
|
|
2833
|
-
}
|
|
2834
|
-
}
|
|
2835
|
-
onUnsubscribe() {
|
|
2836
|
-
if (!this.hasListeners()) {
|
|
2837
|
-
this.destroy();
|
|
2838
|
-
}
|
|
2839
|
-
}
|
|
2840
|
-
shouldFetchOnReconnect() {
|
|
2841
|
-
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnReconnect);
|
|
2842
|
-
}
|
|
2843
|
-
shouldFetchOnWindowFocus() {
|
|
2844
|
-
return shouldFetchOn(this.#currentQuery, this.options, this.options.refetchOnWindowFocus);
|
|
2845
|
-
}
|
|
2846
|
-
destroy() {
|
|
2847
|
-
this.listeners = /* @__PURE__ */new Set();
|
|
2848
|
-
this.#clearStaleTimeout();
|
|
2849
|
-
this.#clearRefetchInterval();
|
|
2850
|
-
this.#currentQuery.removeObserver(this);
|
|
2851
|
-
}
|
|
2852
|
-
setOptions(options) {
|
|
2853
|
-
const prevOptions = this.options;
|
|
2854
|
-
const prevQuery = this.#currentQuery;
|
|
2855
|
-
this.options = this.#client.defaultQueryOptions(options);
|
|
2856
|
-
if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, this.#currentQuery) !== "boolean") {
|
|
2857
|
-
throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
|
|
2858
|
-
}
|
|
2859
|
-
this.#updateQuery();
|
|
2860
|
-
this.#currentQuery.setOptions(this.options);
|
|
2861
|
-
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
|
|
2862
|
-
this.#client.getQueryCache().notify({
|
|
2863
|
-
type: "observerOptionsUpdated",
|
|
2864
|
-
query: this.#currentQuery,
|
|
2865
|
-
observer: this
|
|
2866
|
-
});
|
|
2867
|
-
}
|
|
2868
|
-
const mounted = this.hasListeners();
|
|
2869
|
-
if (mounted && shouldFetchOptionally(this.#currentQuery, prevQuery, this.options, prevOptions)) {
|
|
2870
|
-
this.#executeFetch();
|
|
2871
|
-
}
|
|
2872
|
-
this.updateResult();
|
|
2873
|
-
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) {
|
|
2874
|
-
this.#updateStaleTimeout();
|
|
2875
|
-
}
|
|
2876
|
-
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
2877
|
-
if (mounted && (this.#currentQuery !== prevQuery || resolveEnabled(this.options.enabled, this.#currentQuery) !== resolveEnabled(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) {
|
|
2878
|
-
this.#updateRefetchInterval(nextRefetchInterval);
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2881
|
-
getOptimisticResult(options) {
|
|
2882
|
-
const query = this.#client.getQueryCache().build(this.#client, options);
|
|
2883
|
-
const result = this.createResult(query, options);
|
|
2884
|
-
if (shouldAssignObserverCurrentProperties(this, result)) {
|
|
2885
|
-
this.#currentResult = result;
|
|
2886
|
-
this.#currentResultOptions = this.options;
|
|
2887
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
2888
|
-
}
|
|
2889
|
-
return result;
|
|
2890
|
-
}
|
|
2891
|
-
getCurrentResult() {
|
|
2892
|
-
return this.#currentResult;
|
|
2893
|
-
}
|
|
2894
|
-
trackResult(result, onPropTracked) {
|
|
2895
|
-
return new Proxy(result, {
|
|
2896
|
-
get: (target, key) => {
|
|
2897
|
-
this.trackProp(key);
|
|
2898
|
-
onPropTracked?.(key);
|
|
2899
|
-
if (key === "promise") {
|
|
2900
|
-
this.trackProp("data");
|
|
2901
|
-
if (!this.options.experimental_prefetchInRender && this.#currentThenable.status === "pending") {
|
|
2902
|
-
this.#currentThenable.reject(new Error("experimental_prefetchInRender feature flag is not enabled"));
|
|
2903
|
-
}
|
|
2904
|
-
}
|
|
2905
|
-
return Reflect.get(target, key);
|
|
2906
|
-
}
|
|
2907
|
-
});
|
|
2908
|
-
}
|
|
2909
|
-
trackProp(key) {
|
|
2910
|
-
this.#trackedProps.add(key);
|
|
2911
|
-
}
|
|
2912
|
-
getCurrentQuery() {
|
|
2913
|
-
return this.#currentQuery;
|
|
2914
|
-
}
|
|
2915
|
-
refetch({
|
|
2916
|
-
...options
|
|
2917
|
-
} = {}) {
|
|
2918
|
-
return this.fetch({
|
|
2919
|
-
...options
|
|
2920
|
-
});
|
|
2921
|
-
}
|
|
2922
|
-
fetchOptimistic(options) {
|
|
2923
|
-
const defaultedOptions = this.#client.defaultQueryOptions(options);
|
|
2924
|
-
const query = this.#client.getQueryCache().build(this.#client, defaultedOptions);
|
|
2925
|
-
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
2926
|
-
}
|
|
2927
|
-
fetch(fetchOptions) {
|
|
2928
|
-
return this.#executeFetch({
|
|
2929
|
-
...fetchOptions,
|
|
2930
|
-
cancelRefetch: fetchOptions.cancelRefetch ?? true
|
|
2931
|
-
}).then(() => {
|
|
2932
|
-
this.updateResult();
|
|
2933
|
-
return this.#currentResult;
|
|
2934
|
-
});
|
|
2935
|
-
}
|
|
2936
|
-
#executeFetch(fetchOptions) {
|
|
2937
|
-
this.#updateQuery();
|
|
2938
|
-
let promise = this.#currentQuery.fetch(this.options, fetchOptions);
|
|
2939
|
-
if (!fetchOptions?.throwOnError) {
|
|
2940
|
-
promise = promise.catch(noop);
|
|
2941
|
-
}
|
|
2942
|
-
return promise;
|
|
2943
|
-
}
|
|
2944
|
-
#updateStaleTimeout() {
|
|
2945
|
-
this.#clearStaleTimeout();
|
|
2946
|
-
const staleTime = resolveStaleTime(this.options.staleTime, this.#currentQuery);
|
|
2947
|
-
if (isServer || this.#currentResult.isStale || !isValidTimeout(staleTime)) {
|
|
2948
|
-
return;
|
|
2949
|
-
}
|
|
2950
|
-
const time = timeUntilStale(this.#currentResult.dataUpdatedAt, staleTime);
|
|
2951
|
-
const timeout = time + 1;
|
|
2952
|
-
this.#staleTimeoutId = timeoutManager.setTimeout(() => {
|
|
2953
|
-
if (!this.#currentResult.isStale) {
|
|
2954
|
-
this.updateResult();
|
|
2955
|
-
}
|
|
2956
|
-
}, timeout);
|
|
2957
|
-
}
|
|
2958
|
-
#computeRefetchInterval() {
|
|
2959
|
-
return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.#currentQuery) : this.options.refetchInterval) ?? false;
|
|
2960
|
-
}
|
|
2961
|
-
#updateRefetchInterval(nextInterval) {
|
|
2962
|
-
this.#clearRefetchInterval();
|
|
2963
|
-
this.#currentRefetchInterval = nextInterval;
|
|
2964
|
-
if (isServer || resolveEnabled(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
2965
|
-
return;
|
|
2966
|
-
}
|
|
2967
|
-
this.#refetchIntervalId = timeoutManager.setInterval(() => {
|
|
2968
|
-
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
2969
|
-
this.#executeFetch();
|
|
2970
|
-
}
|
|
2971
|
-
}, this.#currentRefetchInterval);
|
|
2972
|
-
}
|
|
2973
|
-
#updateTimers() {
|
|
2974
|
-
this.#updateStaleTimeout();
|
|
2975
|
-
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
2976
|
-
}
|
|
2977
|
-
#clearStaleTimeout() {
|
|
2978
|
-
if (this.#staleTimeoutId) {
|
|
2979
|
-
timeoutManager.clearTimeout(this.#staleTimeoutId);
|
|
2980
|
-
this.#staleTimeoutId = void 0;
|
|
2981
|
-
}
|
|
2982
|
-
}
|
|
2983
|
-
#clearRefetchInterval() {
|
|
2984
|
-
if (this.#refetchIntervalId) {
|
|
2985
|
-
timeoutManager.clearInterval(this.#refetchIntervalId);
|
|
2986
|
-
this.#refetchIntervalId = void 0;
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
createResult(query, options) {
|
|
2990
|
-
const prevQuery = this.#currentQuery;
|
|
2991
|
-
const prevOptions = this.options;
|
|
2992
|
-
const prevResult = this.#currentResult;
|
|
2993
|
-
const prevResultState = this.#currentResultState;
|
|
2994
|
-
const prevResultOptions = this.#currentResultOptions;
|
|
2995
|
-
const queryChange = query !== prevQuery;
|
|
2996
|
-
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
|
|
2997
|
-
const {
|
|
2998
|
-
state
|
|
2999
|
-
} = query;
|
|
3000
|
-
let newState = {
|
|
3001
|
-
...state
|
|
3002
|
-
};
|
|
3003
|
-
let isPlaceholderData = false;
|
|
3004
|
-
let data;
|
|
3005
|
-
if (options._optimisticResults) {
|
|
3006
|
-
const mounted = this.hasListeners();
|
|
3007
|
-
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
3008
|
-
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
3009
|
-
if (fetchOnMount || fetchOptionally) {
|
|
3010
|
-
newState = {
|
|
3011
|
-
...newState,
|
|
3012
|
-
...fetchState(state.data, query.options)
|
|
3013
|
-
};
|
|
3014
|
-
}
|
|
3015
|
-
if (options._optimisticResults === "isRestoring") {
|
|
3016
|
-
newState.fetchStatus = "idle";
|
|
3017
|
-
}
|
|
3018
|
-
}
|
|
3019
|
-
let {
|
|
3020
|
-
error,
|
|
3021
|
-
errorUpdatedAt,
|
|
3022
|
-
status
|
|
3023
|
-
} = newState;
|
|
3024
|
-
data = newState.data;
|
|
3025
|
-
let skipSelect = false;
|
|
3026
|
-
if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
|
|
3027
|
-
let placeholderData;
|
|
3028
|
-
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
3029
|
-
placeholderData = prevResult.data;
|
|
3030
|
-
skipSelect = true;
|
|
3031
|
-
} else {
|
|
3032
|
-
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(this.#lastQueryWithDefinedData?.state.data, this.#lastQueryWithDefinedData) : options.placeholderData;
|
|
3033
|
-
}
|
|
3034
|
-
if (placeholderData !== void 0) {
|
|
3035
|
-
status = "success";
|
|
3036
|
-
data = replaceData(prevResult?.data, placeholderData, options);
|
|
3037
|
-
isPlaceholderData = true;
|
|
3038
|
-
}
|
|
3039
|
-
}
|
|
3040
|
-
if (options.select && data !== void 0 && !skipSelect) {
|
|
3041
|
-
if (prevResult && data === prevResultState?.data && options.select === this.#selectFn) {
|
|
3042
|
-
data = this.#selectResult;
|
|
3043
|
-
} else {
|
|
3044
|
-
try {
|
|
3045
|
-
this.#selectFn = options.select;
|
|
3046
|
-
data = options.select(data);
|
|
3047
|
-
data = replaceData(prevResult?.data, data, options);
|
|
3048
|
-
this.#selectResult = data;
|
|
3049
|
-
this.#selectError = null;
|
|
3050
|
-
} catch (selectError) {
|
|
3051
|
-
this.#selectError = selectError;
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
}
|
|
3055
|
-
if (this.#selectError) {
|
|
3056
|
-
error = this.#selectError;
|
|
3057
|
-
data = this.#selectResult;
|
|
3058
|
-
errorUpdatedAt = Date.now();
|
|
3059
|
-
status = "error";
|
|
3060
|
-
}
|
|
3061
|
-
const isFetching = newState.fetchStatus === "fetching";
|
|
3062
|
-
const isPending = status === "pending";
|
|
3063
|
-
const isError = status === "error";
|
|
3064
|
-
const isLoading = isPending && isFetching;
|
|
3065
|
-
const hasData = data !== void 0;
|
|
3066
|
-
const result = {
|
|
3067
|
-
status,
|
|
3068
|
-
fetchStatus: newState.fetchStatus,
|
|
3069
|
-
isPending,
|
|
3070
|
-
isSuccess: status === "success",
|
|
3071
|
-
isError,
|
|
3072
|
-
isInitialLoading: isLoading,
|
|
3073
|
-
isLoading,
|
|
3074
|
-
data,
|
|
3075
|
-
dataUpdatedAt: newState.dataUpdatedAt,
|
|
3076
|
-
error,
|
|
3077
|
-
errorUpdatedAt,
|
|
3078
|
-
failureCount: newState.fetchFailureCount,
|
|
3079
|
-
failureReason: newState.fetchFailureReason,
|
|
3080
|
-
errorUpdateCount: newState.errorUpdateCount,
|
|
3081
|
-
isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0,
|
|
3082
|
-
isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
3083
|
-
isFetching,
|
|
3084
|
-
isRefetching: isFetching && !isPending,
|
|
3085
|
-
isLoadingError: isError && !hasData,
|
|
3086
|
-
isPaused: newState.fetchStatus === "paused",
|
|
3087
|
-
isPlaceholderData,
|
|
3088
|
-
isRefetchError: isError && hasData,
|
|
3089
|
-
isStale: isStale(query, options),
|
|
3090
|
-
refetch: this.refetch,
|
|
3091
|
-
promise: this.#currentThenable,
|
|
3092
|
-
isEnabled: resolveEnabled(options.enabled, query) !== false
|
|
3093
|
-
};
|
|
3094
|
-
const nextResult = result;
|
|
3095
|
-
if (this.options.experimental_prefetchInRender) {
|
|
3096
|
-
const hasResultData = nextResult.data !== void 0;
|
|
3097
|
-
const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
|
|
3098
|
-
const finalizeThenableIfPossible = thenable => {
|
|
3099
|
-
if (isErrorWithoutData) {
|
|
3100
|
-
thenable.reject(nextResult.error);
|
|
3101
|
-
} else if (hasResultData) {
|
|
3102
|
-
thenable.resolve(nextResult.data);
|
|
3103
|
-
}
|
|
3104
|
-
};
|
|
3105
|
-
const recreateThenable = () => {
|
|
3106
|
-
const pending = this.#currentThenable = nextResult.promise = pendingThenable();
|
|
3107
|
-
finalizeThenableIfPossible(pending);
|
|
3108
|
-
};
|
|
3109
|
-
const prevThenable = this.#currentThenable;
|
|
3110
|
-
switch (prevThenable.status) {
|
|
3111
|
-
case "pending":
|
|
3112
|
-
if (query.queryHash === prevQuery.queryHash) {
|
|
3113
|
-
finalizeThenableIfPossible(prevThenable);
|
|
3114
|
-
}
|
|
3115
|
-
break;
|
|
3116
|
-
case "fulfilled":
|
|
3117
|
-
if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
|
|
3118
|
-
recreateThenable();
|
|
3119
|
-
}
|
|
3120
|
-
break;
|
|
3121
|
-
case "rejected":
|
|
3122
|
-
if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
|
|
3123
|
-
recreateThenable();
|
|
3124
|
-
}
|
|
3125
|
-
break;
|
|
3126
|
-
}
|
|
3127
|
-
}
|
|
3128
|
-
return nextResult;
|
|
3129
|
-
}
|
|
3130
|
-
updateResult() {
|
|
3131
|
-
const prevResult = this.#currentResult;
|
|
3132
|
-
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
3133
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
3134
|
-
this.#currentResultOptions = this.options;
|
|
3135
|
-
if (this.#currentResultState.data !== void 0) {
|
|
3136
|
-
this.#lastQueryWithDefinedData = this.#currentQuery;
|
|
3137
|
-
}
|
|
3138
|
-
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
3139
|
-
return;
|
|
3140
|
-
}
|
|
3141
|
-
this.#currentResult = nextResult;
|
|
3142
|
-
const shouldNotifyListeners = () => {
|
|
3143
|
-
if (!prevResult) {
|
|
3144
|
-
return true;
|
|
3145
|
-
}
|
|
3146
|
-
const {
|
|
3147
|
-
notifyOnChangeProps
|
|
3148
|
-
} = this.options;
|
|
3149
|
-
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
3150
|
-
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.#trackedProps.size) {
|
|
3151
|
-
return true;
|
|
3152
|
-
}
|
|
3153
|
-
const includedProps = new Set(notifyOnChangePropsValue ?? this.#trackedProps);
|
|
3154
|
-
if (this.options.throwOnError) {
|
|
3155
|
-
includedProps.add("error");
|
|
3156
|
-
}
|
|
3157
|
-
return Object.keys(this.#currentResult).some(key => {
|
|
3158
|
-
const typedKey = key;
|
|
3159
|
-
const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
|
|
3160
|
-
return changed && includedProps.has(typedKey);
|
|
3161
|
-
});
|
|
3162
|
-
};
|
|
3163
|
-
this.#notify({
|
|
3164
|
-
listeners: shouldNotifyListeners()
|
|
3165
|
-
});
|
|
3166
|
-
}
|
|
3167
|
-
#updateQuery() {
|
|
3168
|
-
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
3169
|
-
if (query === this.#currentQuery) {
|
|
3170
|
-
return;
|
|
3171
|
-
}
|
|
3172
|
-
const prevQuery = this.#currentQuery;
|
|
3173
|
-
this.#currentQuery = query;
|
|
3174
|
-
this.#currentQueryInitialState = query.state;
|
|
3175
|
-
if (this.hasListeners()) {
|
|
3176
|
-
prevQuery?.removeObserver(this);
|
|
3177
|
-
query.addObserver(this);
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
onQueryUpdate() {
|
|
3181
|
-
this.updateResult();
|
|
3182
|
-
if (this.hasListeners()) {
|
|
3183
|
-
this.#updateTimers();
|
|
3184
|
-
}
|
|
3185
|
-
}
|
|
3186
|
-
#notify(notifyOptions) {
|
|
3187
|
-
notifyManager.batch(() => {
|
|
3188
|
-
if (notifyOptions.listeners) {
|
|
3189
|
-
this.listeners.forEach(listener => {
|
|
3190
|
-
listener(this.#currentResult);
|
|
3191
|
-
});
|
|
3192
|
-
}
|
|
3193
|
-
this.#client.getQueryCache().notify({
|
|
3194
|
-
query: this.#currentQuery,
|
|
3195
|
-
type: "observerResultsUpdated"
|
|
3196
|
-
});
|
|
3197
|
-
});
|
|
3198
|
-
}
|
|
3199
|
-
};
|
|
3200
|
-
function shouldLoadOnMount(query, options) {
|
|
3201
|
-
return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false);
|
|
3202
|
-
}
|
|
3203
|
-
function shouldFetchOnMount(query, options) {
|
|
3204
|
-
return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
3205
|
-
}
|
|
3206
|
-
function shouldFetchOn(query, options, field) {
|
|
3207
|
-
if (resolveEnabled(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
3208
|
-
const value = typeof field === "function" ? field(query) : field;
|
|
3209
|
-
return value === "always" || value !== false && isStale(query, options);
|
|
3210
|
-
}
|
|
3211
|
-
return false;
|
|
3212
|
-
}
|
|
3213
|
-
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
3214
|
-
return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
3215
|
-
}
|
|
3216
|
-
function isStale(query, options) {
|
|
3217
|
-
return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
3218
|
-
}
|
|
3219
|
-
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
3220
|
-
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
3221
|
-
return true;
|
|
3222
|
-
}
|
|
3223
|
-
return false;
|
|
3224
1493
|
}const usePageFormManager = ({
|
|
3225
1494
|
form,
|
|
3226
1495
|
pageId,
|
|
@@ -3230,14 +1499,14 @@ function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
|
3230
1499
|
const {
|
|
3231
1500
|
queryClient
|
|
3232
1501
|
} = reactQueries.useApiConfigValue();
|
|
3233
|
-
const [defaultValueQuery, setDefaultValueQuery] =
|
|
3234
|
-
|
|
1502
|
+
const [defaultValueQuery, setDefaultValueQuery] = react.useState(form === null || form === void 0 ? void 0 : form.defaultValues);
|
|
1503
|
+
react.useEffect(() => {
|
|
3235
1504
|
if (!(form === null || form === void 0 ? void 0 : form.defaultValueQueryKey)) {
|
|
3236
1505
|
// setDefaultValueQuery(form?.defaultValues)
|
|
3237
1506
|
return;
|
|
3238
1507
|
}
|
|
3239
1508
|
queryClient.getQueryData(form.defaultValueQueryKey);
|
|
3240
|
-
const observer = new QueryObserver(queryClient, {
|
|
1509
|
+
const observer = new reactQuery.QueryObserver(queryClient, {
|
|
3241
1510
|
queryKey: form.defaultValueQueryKey,
|
|
3242
1511
|
enabled: true,
|
|
3243
1512
|
notifyOnChangeProps: ["data"],
|
|
@@ -3250,7 +1519,7 @@ function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
|
3250
1519
|
});
|
|
3251
1520
|
return () => unsubscribe();
|
|
3252
1521
|
}, [form === null || form === void 0 ? void 0 : form.defaultValueQueryKey, form === null || form === void 0 ? void 0 : form.defaultValues, queryClient]);
|
|
3253
|
-
const defaultValues =
|
|
1522
|
+
const defaultValues = react.useMemo(() => {
|
|
3254
1523
|
var _a, _b;
|
|
3255
1524
|
return Object.assign(Object.assign({}, defaultValueQuery !== null && defaultValueQuery !== void 0 ? defaultValueQuery : {}), (_b = (_a = form === null || form === void 0 ? void 0 : form.defaultValueQueryMap) === null || _a === void 0 ? void 0 : _a.call(form, defaultValueQuery)) !== null && _b !== void 0 ? _b : {});
|
|
3256
1525
|
}, [defaultValueQuery, form]);
|
|
@@ -3273,7 +1542,7 @@ function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
|
3273
1542
|
formId: pageId
|
|
3274
1543
|
})
|
|
3275
1544
|
}));
|
|
3276
|
-
const formData =
|
|
1545
|
+
const formData = react.useMemo(() => Object.assign(Object.assign({}, rawFormData), {
|
|
3277
1546
|
formContents: rawFormData.formContents
|
|
3278
1547
|
}), [rawFormData]);
|
|
3279
1548
|
return {
|
|
@@ -3444,7 +1713,7 @@ function useMetadata({
|
|
|
3444
1713
|
translateText,
|
|
3445
1714
|
locale
|
|
3446
1715
|
} = usePageConfigValue();
|
|
3447
|
-
const t =
|
|
1716
|
+
const t = react.useMemo(() => translateText !== null && translateText !== void 0 ? translateText : key => key, [translateText]);
|
|
3448
1717
|
const {
|
|
3449
1718
|
get,
|
|
3450
1719
|
set
|
|
@@ -3453,7 +1722,7 @@ function useMetadata({
|
|
|
3453
1722
|
});
|
|
3454
1723
|
const metadataStore = useMetadataStore();
|
|
3455
1724
|
// Step 1: Evaluate metadata (if function)
|
|
3456
|
-
const evaluatedMeta =
|
|
1725
|
+
const evaluatedMeta = react.useMemo(() => {
|
|
3457
1726
|
if (!meta) return {};
|
|
3458
1727
|
if (typeof meta === 'function') {
|
|
3459
1728
|
return meta({
|
|
@@ -3464,12 +1733,12 @@ function useMetadata({
|
|
|
3464
1733
|
return meta;
|
|
3465
1734
|
}, [meta, get, set]);
|
|
3466
1735
|
// Step 2: Resolve all dynamic evaluator functions into plain values
|
|
3467
|
-
const resolved =
|
|
1736
|
+
const resolved = react.useMemo(() => resolveMetadata(evaluatedMeta, {
|
|
3468
1737
|
get,
|
|
3469
1738
|
set
|
|
3470
1739
|
}), [evaluatedMeta, get, set]);
|
|
3471
1740
|
// Step 3: Translate metadata strings (i18n)
|
|
3472
|
-
const translated =
|
|
1741
|
+
const translated = react.useMemo(() => {
|
|
3473
1742
|
var _a;
|
|
3474
1743
|
const result = Object.assign({}, resolved);
|
|
3475
1744
|
// Translate basic fields
|
|
@@ -3540,7 +1809,7 @@ function useMetadata({
|
|
|
3540
1809
|
return result;
|
|
3541
1810
|
}, [resolved, t, locale]);
|
|
3542
1811
|
// Step 4: Apply metadata
|
|
3543
|
-
|
|
1812
|
+
react.useEffect(() => {
|
|
3544
1813
|
if (!autoApply) return;
|
|
3545
1814
|
// If we have a request-scoped store (SSR), write to it
|
|
3546
1815
|
if (metadataStore) {
|
|
@@ -3637,8 +1906,8 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
|
|
|
3637
1906
|
authValues,
|
|
3638
1907
|
authPageProps
|
|
3639
1908
|
} = usePageConfigValue();
|
|
3640
|
-
const isUnlogged =
|
|
3641
|
-
const selectedProps =
|
|
1909
|
+
const isUnlogged = react.useMemo(() => enableAuthControl && !isLogged(authValues ? authValues : null), [enableAuthControl, authValues, isLogged]);
|
|
1910
|
+
const selectedProps = react.useMemo(() => {
|
|
3642
1911
|
return enableAuthControl && isUnlogged ? authPageProps : props;
|
|
3643
1912
|
}, [enableAuthControl, isUnlogged, authPageProps, props]);
|
|
3644
1913
|
const {
|
|
@@ -3648,7 +1917,7 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
|
|
|
3648
1917
|
id = 'default-page-id',
|
|
3649
1918
|
viewSettings,
|
|
3650
1919
|
ns
|
|
3651
|
-
} =
|
|
1920
|
+
} = react.useMemo(() => selectedProps, [selectedProps]);
|
|
3652
1921
|
const config = usePageConfig({
|
|
3653
1922
|
queries,
|
|
3654
1923
|
form,
|
|
@@ -3671,25 +1940,25 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
|
|
|
3671
1940
|
ns,
|
|
3672
1941
|
pageConfig: config
|
|
3673
1942
|
});
|
|
3674
|
-
const LayoutComponent =
|
|
1943
|
+
const LayoutComponent = react.useMemo(() => {
|
|
3675
1944
|
var _a_0;
|
|
3676
1945
|
return (_a_0 = mappedViewSettings.layoutComponent) !== null && _a_0 !== void 0 ? _a_0 : BodyContainer;
|
|
3677
1946
|
}, [mappedViewSettings.layoutComponent, BodyContainer]);
|
|
3678
|
-
const layoutProps =
|
|
1947
|
+
const layoutProps = react.useMemo(() => {
|
|
3679
1948
|
var _a_1;
|
|
3680
1949
|
return (_a_1 = mappedViewSettings.layoutProps) !== null && _a_1 !== void 0 ? _a_1 : {};
|
|
3681
1950
|
}, [mappedViewSettings.layoutProps]);
|
|
3682
|
-
const PageContainerComponent =
|
|
1951
|
+
const PageContainerComponent = react.useMemo(() => {
|
|
3683
1952
|
var _a_2;
|
|
3684
1953
|
return (_a_2 = mappedViewSettings.pageContainerComponent) !== null && _a_2 !== void 0 ? _a_2 : PageContainer;
|
|
3685
1954
|
}, [mappedViewSettings.pageContainerComponent, PageContainer]);
|
|
3686
|
-
const pageContainerProps =
|
|
1955
|
+
const pageContainerProps = react.useMemo(() => {
|
|
3687
1956
|
var _a_3;
|
|
3688
1957
|
return (_a_3 = mappedViewSettings.pageContainerProps) !== null && _a_3 !== void 0 ? _a_3 : {};
|
|
3689
1958
|
}, [mappedViewSettings.pageContainerProps]);
|
|
3690
|
-
const layoutBody =
|
|
3691
|
-
const store = useStore();
|
|
3692
|
-
const refreshQueries =
|
|
1959
|
+
const layoutBody = react.useMemo(() => body, [body]);
|
|
1960
|
+
const store = jotai.useStore();
|
|
1961
|
+
const refreshQueries = react.useCallback(() => {
|
|
3693
1962
|
const val = store.get(reactQueries.queriesAtom);
|
|
3694
1963
|
Object.values(val).forEach(query => {
|
|
3695
1964
|
query.refetch();
|
|
@@ -3802,7 +2071,7 @@ const MetadataManager = MetadataManagerImpl;const PageGenerator = _a => {
|
|
|
3802
2071
|
return t4;
|
|
3803
2072
|
};
|
|
3804
2073
|
// Export with React.memo and fast-deep-equal comparator for optimal performance
|
|
3805
|
-
const Container =
|
|
2074
|
+
const Container = react.memo(ContainerImpl, (prevProps, nextProps) => {
|
|
3806
2075
|
// Return true if props are equal (component should NOT re-render)
|
|
3807
2076
|
return deepEqual(prevProps, nextProps);
|
|
3808
2077
|
});
|
|
@@ -3862,7 +2131,7 @@ const RenderComponentImpl = ({
|
|
|
3862
2131
|
}
|
|
3863
2132
|
};
|
|
3864
2133
|
// Export with React.memo and fast-deep-equal comparator for optimal performance
|
|
3865
|
-
const RenderComponent =
|
|
2134
|
+
const RenderComponent = react.memo(RenderComponentImpl, (prevProps, nextProps) => {
|
|
3866
2135
|
// Return true if props are equal (component should NOT re-render)
|
|
3867
2136
|
return deepEqual(prevProps, nextProps);
|
|
3868
2137
|
});const RenderComponents = props => {
|