@gaddario98/react-core 2.0.5 → 2.0.7
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 +4 -4
- package/dist/auth/index.js +1 -1
- 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 +155 -143
- package/dist/form/index.js.map +1 -1
- package/dist/form/index.mjs +153 -141
- package/dist/form/index.mjs.map +1 -1
- package/dist/index.d.ts +43 -41
- package/dist/index.js +770 -1548
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +761 -1539
- package/dist/index.mjs.map +1 -1
- package/dist/pages/index.d.ts +31 -32
- package/dist/pages/index.js +148 -143
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/index.mjs +148 -143
- package/dist/pages/index.mjs.map +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/queries/index.d.ts +1 -1
- package/dist/queries/index.js +371 -314
- package/dist/queries/index.js.map +1 -1
- package/dist/queries/index.mjs +371 -314
- package/dist/queries/index.mjs.map +1 -1
- package/dist/state/index.js +183 -151
- package/dist/state/index.js.map +1 -1
- package/dist/state/index.mjs +183 -151
- package/dist/state/index.mjs.map +1 -1
- package/dist/utiles/index.js +230 -151
- package/dist/utiles/index.js.map +1 -1
- package/dist/utiles/index.mjs +230 -151
- package/dist/utiles/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/pages/index.js
CHANGED
|
@@ -88,29 +88,22 @@ function getMountedOrPendingDependents(atom, atomState, mountedMap) {
|
|
|
88
88
|
}
|
|
89
89
|
return dependents;
|
|
90
90
|
}
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
if (atom.unstable_onInit) {
|
|
98
|
-
console.warn(
|
|
99
|
-
"[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
|
|
100
|
-
);
|
|
101
|
-
return atom.unstable_onInit(store);
|
|
102
|
-
}
|
|
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);
|
|
103
96
|
};
|
|
104
|
-
const
|
|
97
|
+
const BUILDING_BLOCK_atomOnMount = (_store, atom, setAtom) => {
|
|
105
98
|
var _a;
|
|
106
99
|
return (_a = atom.onMount) == null ? void 0 : _a.call(atom, setAtom);
|
|
107
100
|
};
|
|
108
|
-
const
|
|
101
|
+
const BUILDING_BLOCK_ensureAtomState = (store, atom) => {
|
|
109
102
|
var _a;
|
|
110
103
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
111
104
|
const atomStateMap = buildingBlocks[0];
|
|
112
105
|
const storeHooks = buildingBlocks[6];
|
|
113
|
-
const
|
|
106
|
+
const atomOnInit = buildingBlocks[9];
|
|
114
107
|
if ((undefined ? undefined.MODE : void 0) !== "production" && !atom) {
|
|
115
108
|
throw new Error("Atom is undefined or null");
|
|
116
109
|
}
|
|
@@ -119,18 +112,18 @@ const ensureAtomState = (store, atom) => {
|
|
|
119
112
|
atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };
|
|
120
113
|
atomStateMap.set(atom, atomState);
|
|
121
114
|
(_a = storeHooks.i) == null ? void 0 : _a.call(storeHooks, atom);
|
|
122
|
-
|
|
115
|
+
atomOnInit == null ? void 0 : atomOnInit(store, atom);
|
|
123
116
|
}
|
|
124
117
|
return atomState;
|
|
125
118
|
};
|
|
126
|
-
const
|
|
119
|
+
const BUILDING_BLOCK_flushCallbacks = (store) => {
|
|
127
120
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
128
121
|
const mountedMap = buildingBlocks[1];
|
|
129
122
|
const changedAtoms = buildingBlocks[3];
|
|
130
123
|
const mountCallbacks = buildingBlocks[4];
|
|
131
124
|
const unmountCallbacks = buildingBlocks[5];
|
|
132
125
|
const storeHooks = buildingBlocks[6];
|
|
133
|
-
const
|
|
126
|
+
const recomputeInvalidatedAtoms = buildingBlocks[13];
|
|
134
127
|
const errors = [];
|
|
135
128
|
const call = (fn) => {
|
|
136
129
|
try {
|
|
@@ -156,28 +149,28 @@ const flushCallbacks = (store) => {
|
|
|
156
149
|
mountCallbacks.clear();
|
|
157
150
|
callbacks.forEach(call);
|
|
158
151
|
if (changedAtoms.size) {
|
|
159
|
-
|
|
152
|
+
recomputeInvalidatedAtoms(store);
|
|
160
153
|
}
|
|
161
154
|
} while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
|
|
162
155
|
if (errors.length) {
|
|
163
156
|
throw new AggregateError(errors);
|
|
164
157
|
}
|
|
165
158
|
};
|
|
166
|
-
const
|
|
159
|
+
const BUILDING_BLOCK_recomputeInvalidatedAtoms = (store) => {
|
|
167
160
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
168
161
|
const mountedMap = buildingBlocks[1];
|
|
169
162
|
const invalidatedAtoms = buildingBlocks[2];
|
|
170
163
|
const changedAtoms = buildingBlocks[3];
|
|
171
|
-
const
|
|
172
|
-
const
|
|
173
|
-
const
|
|
164
|
+
const ensureAtomState = buildingBlocks[11];
|
|
165
|
+
const readAtomState = buildingBlocks[14];
|
|
166
|
+
const mountDependencies = buildingBlocks[17];
|
|
174
167
|
const topSortedReversed = [];
|
|
175
168
|
const visiting = /* @__PURE__ */ new WeakSet();
|
|
176
169
|
const visited = /* @__PURE__ */ new WeakSet();
|
|
177
170
|
const stack = Array.from(changedAtoms);
|
|
178
171
|
while (stack.length) {
|
|
179
172
|
const a = stack[stack.length - 1];
|
|
180
|
-
const aState =
|
|
173
|
+
const aState = ensureAtomState(store, a);
|
|
181
174
|
if (visited.has(a)) {
|
|
182
175
|
stack.pop();
|
|
183
176
|
continue;
|
|
@@ -209,35 +202,36 @@ const recomputeInvalidatedAtoms = (store) => {
|
|
|
209
202
|
}
|
|
210
203
|
}
|
|
211
204
|
if (hasChangedDeps) {
|
|
212
|
-
|
|
213
|
-
|
|
205
|
+
readAtomState(store, a);
|
|
206
|
+
mountDependencies(store, a);
|
|
214
207
|
}
|
|
215
208
|
invalidatedAtoms.delete(a);
|
|
216
209
|
}
|
|
217
210
|
};
|
|
218
211
|
const storeMutationSet = /* @__PURE__ */ new WeakSet();
|
|
219
|
-
const
|
|
212
|
+
const BUILDING_BLOCK_readAtomState = (store, atom) => {
|
|
220
213
|
var _a, _b;
|
|
221
214
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
222
215
|
const mountedMap = buildingBlocks[1];
|
|
223
216
|
const invalidatedAtoms = buildingBlocks[2];
|
|
224
217
|
const changedAtoms = buildingBlocks[3];
|
|
225
218
|
const storeHooks = buildingBlocks[6];
|
|
226
|
-
const
|
|
227
|
-
const
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
const
|
|
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);
|
|
234
228
|
if (isAtomStateInitialized(atomState)) {
|
|
235
229
|
if (mountedMap.has(atom) && invalidatedAtoms.get(atom) !== atomState.n) {
|
|
236
230
|
return atomState;
|
|
237
231
|
}
|
|
238
232
|
let hasChangedDeps = false;
|
|
239
233
|
for (const [a, n] of atomState.d) {
|
|
240
|
-
if (
|
|
234
|
+
if (readAtomState(store, a).n !== n) {
|
|
241
235
|
hasChangedDeps = true;
|
|
242
236
|
break;
|
|
243
237
|
}
|
|
@@ -250,15 +244,15 @@ const readAtomState = (store, atom) => {
|
|
|
250
244
|
let isSync = true;
|
|
251
245
|
function mountDependenciesIfAsync() {
|
|
252
246
|
if (mountedMap.has(atom)) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
247
|
+
mountDependencies(store, atom);
|
|
248
|
+
recomputeInvalidatedAtoms(store);
|
|
249
|
+
flushCallbacks(store);
|
|
256
250
|
}
|
|
257
251
|
}
|
|
258
252
|
function getter(a) {
|
|
259
253
|
var _a2;
|
|
260
254
|
if (a === atom) {
|
|
261
|
-
const aState2 =
|
|
255
|
+
const aState2 = ensureAtomState(store, a);
|
|
262
256
|
if (!isAtomStateInitialized(aState2)) {
|
|
263
257
|
if (hasInitialValue(a)) {
|
|
264
258
|
setAtomStateValueOrPromise(store, a, a.init);
|
|
@@ -268,7 +262,7 @@ const readAtomState = (store, atom) => {
|
|
|
268
262
|
}
|
|
269
263
|
return returnAtomValue(aState2);
|
|
270
264
|
}
|
|
271
|
-
const aState =
|
|
265
|
+
const aState = readAtomState(store, a);
|
|
272
266
|
try {
|
|
273
267
|
return returnAtomValue(aState);
|
|
274
268
|
} finally {
|
|
@@ -294,6 +288,11 @@ const readAtomState = (store, atom) => {
|
|
|
294
288
|
return controller.signal;
|
|
295
289
|
},
|
|
296
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
|
+
}
|
|
297
296
|
if ((undefined ? undefined.MODE : void 0) !== "production" && !isActuallyWritableAtom(atom)) {
|
|
298
297
|
console.warn("setSelf function cannot be used with read-only atom");
|
|
299
298
|
}
|
|
@@ -304,10 +303,10 @@ const readAtomState = (store, atom) => {
|
|
|
304
303
|
}
|
|
305
304
|
if (!isSync) {
|
|
306
305
|
try {
|
|
307
|
-
return
|
|
306
|
+
return writeAtomState(store, atom, ...args);
|
|
308
307
|
} finally {
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
recomputeInvalidatedAtoms(store);
|
|
309
|
+
flushCallbacks(store);
|
|
311
310
|
}
|
|
312
311
|
}
|
|
313
312
|
};
|
|
@@ -320,7 +319,7 @@ const readAtomState = (store, atom) => {
|
|
|
320
319
|
if ((undefined ? undefined.MODE : void 0) !== "production") {
|
|
321
320
|
storeMutationSet.delete(store);
|
|
322
321
|
}
|
|
323
|
-
const valueOrPromise =
|
|
322
|
+
const valueOrPromise = atomRead(store, atom, getter, options);
|
|
324
323
|
if ((undefined ? undefined.MODE : void 0) !== "production" && storeMutationSet.has(store)) {
|
|
325
324
|
console.warn(
|
|
326
325
|
"Detected store mutation during atom read. This is not supported."
|
|
@@ -347,38 +346,40 @@ const readAtomState = (store, atom) => {
|
|
|
347
346
|
}
|
|
348
347
|
}
|
|
349
348
|
};
|
|
350
|
-
const
|
|
349
|
+
const BUILDING_BLOCK_invalidateDependents = (store, atom) => {
|
|
351
350
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
352
351
|
const mountedMap = buildingBlocks[1];
|
|
353
352
|
const invalidatedAtoms = buildingBlocks[2];
|
|
354
|
-
const
|
|
353
|
+
const ensureAtomState = buildingBlocks[11];
|
|
355
354
|
const stack = [atom];
|
|
356
355
|
while (stack.length) {
|
|
357
356
|
const a = stack.pop();
|
|
358
|
-
const aState =
|
|
357
|
+
const aState = ensureAtomState(store, a);
|
|
359
358
|
for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
|
|
360
|
-
const dState =
|
|
359
|
+
const dState = ensureAtomState(store, d);
|
|
361
360
|
invalidatedAtoms.set(d, dState.n);
|
|
362
361
|
stack.push(d);
|
|
363
362
|
}
|
|
364
363
|
}
|
|
365
364
|
};
|
|
366
|
-
const
|
|
365
|
+
const BUILDING_BLOCK_writeAtomState = (store, atom, ...args) => {
|
|
367
366
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
368
367
|
const changedAtoms = buildingBlocks[3];
|
|
369
368
|
const storeHooks = buildingBlocks[6];
|
|
370
|
-
const
|
|
371
|
-
const
|
|
372
|
-
const
|
|
373
|
-
const
|
|
374
|
-
const
|
|
375
|
-
const
|
|
376
|
-
const
|
|
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];
|
|
377
378
|
let isSync = true;
|
|
378
|
-
const getter = (a) => returnAtomValue(
|
|
379
|
+
const getter = (a) => returnAtomValue(readAtomState(store, a));
|
|
379
380
|
const setter = (a, ...args2) => {
|
|
380
381
|
var _a;
|
|
381
|
-
const aState =
|
|
382
|
+
const aState = ensureAtomState(store, a);
|
|
382
383
|
try {
|
|
383
384
|
if (a === atom) {
|
|
384
385
|
if (!hasInitialValue(a)) {
|
|
@@ -390,10 +391,10 @@ const writeAtomState = (store, atom, ...args) => {
|
|
|
390
391
|
const prevEpochNumber = aState.n;
|
|
391
392
|
const v = args2[0];
|
|
392
393
|
setAtomStateValueOrPromise(store, a, v);
|
|
393
|
-
|
|
394
|
+
mountDependencies(store, a);
|
|
394
395
|
if (prevEpochNumber !== aState.n) {
|
|
395
396
|
changedAtoms.add(a);
|
|
396
|
-
|
|
397
|
+
invalidateDependents(store, a);
|
|
397
398
|
(_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
|
|
398
399
|
}
|
|
399
400
|
return void 0;
|
|
@@ -402,39 +403,39 @@ const writeAtomState = (store, atom, ...args) => {
|
|
|
402
403
|
}
|
|
403
404
|
} finally {
|
|
404
405
|
if (!isSync) {
|
|
405
|
-
|
|
406
|
-
|
|
406
|
+
recomputeInvalidatedAtoms(store);
|
|
407
|
+
flushCallbacks(store);
|
|
407
408
|
}
|
|
408
409
|
}
|
|
409
410
|
};
|
|
410
411
|
try {
|
|
411
|
-
return
|
|
412
|
+
return atomWrite(store, atom, getter, setter, ...args);
|
|
412
413
|
} finally {
|
|
413
414
|
isSync = false;
|
|
414
415
|
}
|
|
415
416
|
};
|
|
416
|
-
const
|
|
417
|
+
const BUILDING_BLOCK_mountDependencies = (store, atom) => {
|
|
417
418
|
var _a;
|
|
418
419
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
419
420
|
const mountedMap = buildingBlocks[1];
|
|
420
421
|
const changedAtoms = buildingBlocks[3];
|
|
421
422
|
const storeHooks = buildingBlocks[6];
|
|
422
|
-
const
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
-
const
|
|
426
|
-
const atomState =
|
|
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);
|
|
427
428
|
const mounted = mountedMap.get(atom);
|
|
428
429
|
if (mounted && !isPendingPromise(atomState.v)) {
|
|
429
430
|
for (const [a, n] of atomState.d) {
|
|
430
431
|
if (!mounted.d.has(a)) {
|
|
431
|
-
const aState =
|
|
432
|
-
const aMounted =
|
|
432
|
+
const aState = ensureAtomState(store, a);
|
|
433
|
+
const aMounted = mountAtom(store, a);
|
|
433
434
|
aMounted.t.add(atom);
|
|
434
435
|
mounted.d.add(a);
|
|
435
436
|
if (n !== aState.n) {
|
|
436
437
|
changedAtoms.add(a);
|
|
437
|
-
|
|
438
|
+
invalidateDependents(store, a);
|
|
438
439
|
(_a = storeHooks.c) == null ? void 0 : _a.call(storeHooks, a);
|
|
439
440
|
}
|
|
440
441
|
}
|
|
@@ -442,28 +443,29 @@ const mountDependencies = (store, atom) => {
|
|
|
442
443
|
for (const a of mounted.d) {
|
|
443
444
|
if (!atomState.d.has(a)) {
|
|
444
445
|
mounted.d.delete(a);
|
|
445
|
-
const aMounted =
|
|
446
|
+
const aMounted = unmountAtom(store, a);
|
|
446
447
|
aMounted == null ? void 0 : aMounted.t.delete(atom);
|
|
447
448
|
}
|
|
448
449
|
}
|
|
449
450
|
}
|
|
450
451
|
};
|
|
451
|
-
const
|
|
452
|
+
const BUILDING_BLOCK_mountAtom = (store, atom) => {
|
|
452
453
|
var _a;
|
|
453
454
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
454
455
|
const mountedMap = buildingBlocks[1];
|
|
455
456
|
const mountCallbacks = buildingBlocks[4];
|
|
456
457
|
const storeHooks = buildingBlocks[6];
|
|
457
|
-
const
|
|
458
|
-
const
|
|
459
|
-
const
|
|
460
|
-
const
|
|
461
|
-
const
|
|
462
|
-
const
|
|
463
|
-
const
|
|
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);
|
|
464
466
|
let mounted = mountedMap.get(atom);
|
|
465
467
|
if (!mounted) {
|
|
466
|
-
|
|
468
|
+
readAtomState(store, atom);
|
|
467
469
|
for (const a of atomState.d.keys()) {
|
|
468
470
|
const aMounted = mountAtom(store, a);
|
|
469
471
|
aMounted.t.add(atom);
|
|
@@ -479,16 +481,16 @@ const mountAtom = (store, atom) => {
|
|
|
479
481
|
let isSync = true;
|
|
480
482
|
const setAtom = (...args) => {
|
|
481
483
|
try {
|
|
482
|
-
return
|
|
484
|
+
return writeAtomState(store, atom, ...args);
|
|
483
485
|
} finally {
|
|
484
486
|
if (!isSync) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
+
recomputeInvalidatedAtoms(store);
|
|
488
|
+
flushCallbacks(store);
|
|
487
489
|
}
|
|
488
490
|
}
|
|
489
491
|
};
|
|
490
492
|
try {
|
|
491
|
-
const onUnmount =
|
|
493
|
+
const onUnmount = atomOnMount(store, atom, setAtom);
|
|
492
494
|
if (onUnmount) {
|
|
493
495
|
mounted.u = () => {
|
|
494
496
|
isSync = true;
|
|
@@ -509,15 +511,15 @@ const mountAtom = (store, atom) => {
|
|
|
509
511
|
}
|
|
510
512
|
return mounted;
|
|
511
513
|
};
|
|
512
|
-
const
|
|
514
|
+
const BUILDING_BLOCK_unmountAtom = (store, atom) => {
|
|
513
515
|
var _a, _b;
|
|
514
516
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
515
517
|
const mountedMap = buildingBlocks[1];
|
|
516
518
|
const unmountCallbacks = buildingBlocks[5];
|
|
517
519
|
const storeHooks = buildingBlocks[6];
|
|
518
|
-
const
|
|
519
|
-
const
|
|
520
|
-
const atomState =
|
|
520
|
+
const ensureAtomState = buildingBlocks[11];
|
|
521
|
+
const unmountAtom = buildingBlocks[19];
|
|
522
|
+
const atomState = ensureAtomState(store, atom);
|
|
521
523
|
let mounted = mountedMap.get(atom);
|
|
522
524
|
if (!mounted || mounted.l.size) {
|
|
523
525
|
return mounted;
|
|
@@ -536,7 +538,7 @@ const unmountAtom = (store, atom) => {
|
|
|
536
538
|
mounted = void 0;
|
|
537
539
|
mountedMap.delete(atom);
|
|
538
540
|
for (const a of atomState.d.keys()) {
|
|
539
|
-
const aMounted =
|
|
541
|
+
const aMounted = unmountAtom(store, a);
|
|
540
542
|
aMounted == null ? void 0 : aMounted.t.delete(atom);
|
|
541
543
|
}
|
|
542
544
|
(_b = storeHooks.u) == null ? void 0 : _b.call(storeHooks, atom);
|
|
@@ -544,9 +546,9 @@ const unmountAtom = (store, atom) => {
|
|
|
544
546
|
}
|
|
545
547
|
return mounted;
|
|
546
548
|
};
|
|
547
|
-
const
|
|
548
|
-
const
|
|
549
|
-
const atomState =
|
|
549
|
+
const BUILDING_BLOCK_setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
|
|
550
|
+
const ensureAtomState = getInternalBuildingBlocks(store)[11];
|
|
551
|
+
const atomState = ensureAtomState(store, atom);
|
|
550
552
|
const hasPrevValue = "v" in atomState;
|
|
551
553
|
const prevValue = atomState.v;
|
|
552
554
|
if (isPromiseLike$1(valueOrPromise)) {
|
|
@@ -554,7 +556,7 @@ const setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
|
|
|
554
556
|
addPendingPromiseToDependency(
|
|
555
557
|
atom,
|
|
556
558
|
valueOrPromise,
|
|
557
|
-
|
|
559
|
+
ensureAtomState(store, a)
|
|
558
560
|
);
|
|
559
561
|
}
|
|
560
562
|
}
|
|
@@ -567,35 +569,35 @@ const setAtomStateValueOrPromise = (store, atom, valueOrPromise) => {
|
|
|
567
569
|
}
|
|
568
570
|
}
|
|
569
571
|
};
|
|
570
|
-
const
|
|
571
|
-
const
|
|
572
|
-
return returnAtomValue(
|
|
572
|
+
const BUILDING_BLOCK_storeGet = (store, atom) => {
|
|
573
|
+
const readAtomState = getInternalBuildingBlocks(store)[14];
|
|
574
|
+
return returnAtomValue(readAtomState(store, atom));
|
|
573
575
|
};
|
|
574
|
-
const
|
|
576
|
+
const BUILDING_BLOCK_storeSet = (store, atom, ...args) => {
|
|
575
577
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
576
|
-
const
|
|
577
|
-
const
|
|
578
|
-
const
|
|
578
|
+
const flushCallbacks = buildingBlocks[12];
|
|
579
|
+
const recomputeInvalidatedAtoms = buildingBlocks[13];
|
|
580
|
+
const writeAtomState = buildingBlocks[16];
|
|
579
581
|
try {
|
|
580
|
-
return
|
|
582
|
+
return writeAtomState(store, atom, ...args);
|
|
581
583
|
} finally {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
+
recomputeInvalidatedAtoms(store);
|
|
585
|
+
flushCallbacks(store);
|
|
584
586
|
}
|
|
585
587
|
};
|
|
586
|
-
const
|
|
588
|
+
const BUILDING_BLOCK_storeSub = (store, atom, listener) => {
|
|
587
589
|
const buildingBlocks = getInternalBuildingBlocks(store);
|
|
588
|
-
const
|
|
589
|
-
const
|
|
590
|
-
const
|
|
591
|
-
const mounted =
|
|
590
|
+
const flushCallbacks = buildingBlocks[12];
|
|
591
|
+
const mountAtom = buildingBlocks[18];
|
|
592
|
+
const unmountAtom = buildingBlocks[19];
|
|
593
|
+
const mounted = mountAtom(store, atom);
|
|
592
594
|
const listeners = mounted.l;
|
|
593
595
|
listeners.add(listener);
|
|
594
|
-
|
|
596
|
+
flushCallbacks(store);
|
|
595
597
|
return () => {
|
|
596
598
|
listeners.delete(listener);
|
|
597
|
-
|
|
598
|
-
|
|
599
|
+
unmountAtom(store, atom);
|
|
600
|
+
flushCallbacks(store);
|
|
599
601
|
};
|
|
600
602
|
};
|
|
601
603
|
const buildingBlockMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -611,16 +613,16 @@ const getInternalBuildingBlocks = (store) => {
|
|
|
611
613
|
function buildStore(...buildArgs) {
|
|
612
614
|
const store = {
|
|
613
615
|
get(atom) {
|
|
614
|
-
const
|
|
615
|
-
return
|
|
616
|
+
const storeGet = getInternalBuildingBlocks(store)[21];
|
|
617
|
+
return storeGet(store, atom);
|
|
616
618
|
},
|
|
617
619
|
set(atom, ...args) {
|
|
618
|
-
const
|
|
619
|
-
return
|
|
620
|
+
const storeSet = getInternalBuildingBlocks(store)[22];
|
|
621
|
+
return storeSet(store, atom, ...args);
|
|
620
622
|
},
|
|
621
623
|
sub(atom, listener) {
|
|
622
|
-
const
|
|
623
|
-
return
|
|
624
|
+
const storeSub = getInternalBuildingBlocks(store)[23];
|
|
625
|
+
return storeSub(store, atom, listener);
|
|
624
626
|
}
|
|
625
627
|
};
|
|
626
628
|
const buildingBlocks = [
|
|
@@ -640,24 +642,24 @@ function buildStore(...buildArgs) {
|
|
|
640
642
|
{},
|
|
641
643
|
// storeHooks
|
|
642
644
|
// atom interceptors
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
645
|
+
BUILDING_BLOCK_atomRead,
|
|
646
|
+
BUILDING_BLOCK_atomWrite,
|
|
647
|
+
BUILDING_BLOCK_atomOnInit,
|
|
648
|
+
BUILDING_BLOCK_atomOnMount,
|
|
647
649
|
// building-block functions
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
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,
|
|
661
663
|
void 0
|
|
662
664
|
].map((fn, i) => buildArgs[i] || fn);
|
|
663
665
|
buildingBlockMap.set(store, Object.freeze(buildingBlocks));
|
|
@@ -2472,10 +2474,11 @@ function resolveEnabled(enabled, query) {
|
|
|
2472
2474
|
return typeof enabled === "function" ? enabled(query) : enabled;
|
|
2473
2475
|
}
|
|
2474
2476
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
2475
|
-
function replaceEqualDeep(a, b) {
|
|
2477
|
+
function replaceEqualDeep(a, b, depth = 0) {
|
|
2476
2478
|
if (a === b) {
|
|
2477
2479
|
return a;
|
|
2478
2480
|
}
|
|
2481
|
+
if (depth > 500) return b;
|
|
2479
2482
|
const array = isPlainArray(a) && isPlainArray(b);
|
|
2480
2483
|
if (!array && !(isPlainObject(a) && isPlainObject(b))) return b;
|
|
2481
2484
|
const aItems = array ? a : Object.keys(a);
|
|
@@ -2497,7 +2500,7 @@ function replaceEqualDeep(a, b) {
|
|
|
2497
2500
|
copy[key] = bItem;
|
|
2498
2501
|
continue;
|
|
2499
2502
|
}
|
|
2500
|
-
const v = replaceEqualDeep(aItem, bItem);
|
|
2503
|
+
const v = replaceEqualDeep(aItem, bItem, depth + 1);
|
|
2501
2504
|
copy[key] = v;
|
|
2502
2505
|
if (v === aItem) equalItems++;
|
|
2503
2506
|
}
|
|
@@ -3090,10 +3093,12 @@ var QueryObserver = class extends Subscribable {
|
|
|
3090
3093
|
};
|
|
3091
3094
|
const nextResult = result;
|
|
3092
3095
|
if (this.options.experimental_prefetchInRender) {
|
|
3096
|
+
const hasResultData = nextResult.data !== void 0;
|
|
3097
|
+
const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
|
|
3093
3098
|
const finalizeThenableIfPossible = thenable => {
|
|
3094
|
-
if (
|
|
3099
|
+
if (isErrorWithoutData) {
|
|
3095
3100
|
thenable.reject(nextResult.error);
|
|
3096
|
-
} else if (
|
|
3101
|
+
} else if (hasResultData) {
|
|
3097
3102
|
thenable.resolve(nextResult.data);
|
|
3098
3103
|
}
|
|
3099
3104
|
};
|
|
@@ -3109,12 +3114,12 @@ var QueryObserver = class extends Subscribable {
|
|
|
3109
3114
|
}
|
|
3110
3115
|
break;
|
|
3111
3116
|
case "fulfilled":
|
|
3112
|
-
if (
|
|
3117
|
+
if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
|
|
3113
3118
|
recreateThenable();
|
|
3114
3119
|
}
|
|
3115
3120
|
break;
|
|
3116
3121
|
case "rejected":
|
|
3117
|
-
if (
|
|
3122
|
+
if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
|
|
3118
3123
|
recreateThenable();
|
|
3119
3124
|
}
|
|
3120
3125
|
break;
|