valdres 0.2.0-alpha.5 → 0.2.0-alpha.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/index.js +88 -75
- package/package.json +8 -3
- package/dist/index.d.ts +0 -19
- package/dist/src/atom.d.ts +0 -9
- package/dist/src/atomFamily.d.ts +0 -4
- package/dist/src/createStore.d.ts +0 -2
- package/dist/src/getDefaultStore.d.ts +0 -2
- package/dist/src/lib/createStoreData.d.ts +0 -2
- package/dist/src/lib/getState.d.ts +0 -3
- package/dist/src/lib/initAtom.d.ts +0 -4
- package/dist/src/lib/initSelector.d.ts +0 -4
- package/dist/src/lib/propagateUpdatedAtoms.d.ts +0 -3
- package/dist/src/lib/resetAtom.d.ts +0 -3
- package/dist/src/lib/setAtom.d.ts +0 -3
- package/dist/src/lib/setAtoms.d.ts +0 -3
- package/dist/src/lib/stableStringify.d.ts +0 -1
- package/dist/src/lib/storeFromStoreData.d.ts +0 -3
- package/dist/src/lib/subscribe.d.ts +0 -4
- package/dist/src/lib/transaction.d.ts +0 -8
- package/dist/src/lib/unsubscribe.d.ts +0 -3
- package/dist/src/lib/updateSelectorSubscribers.d.ts +0 -3
- package/dist/src/lib/updateStateSubscribers.d.ts +0 -3
- package/dist/src/selector.d.ts +0 -3
- package/dist/src/selectorFamily.d.ts +0 -2
- package/dist/src/types/Atom.d.ts +0 -10
- package/dist/src/types/AtomFamily.d.ts +0 -5
- package/dist/src/types/Family.d.ts +0 -3
- package/dist/src/types/GetValue.d.ts +0 -2
- package/dist/src/types/ResetAtom.d.ts +0 -2
- package/dist/src/types/Selector.d.ts +0 -8
- package/dist/src/types/SelectorFamily.d.ts +0 -5
- package/dist/src/types/SetAtom.d.ts +0 -2
- package/dist/src/types/State.d.ts +0 -3
- package/dist/src/types/Store.d.ts +0 -14
- package/dist/src/types/StoreData.d.ts +0 -9
- package/dist/src/types/SubscribeFn.d.ts +0 -2
- package/dist/src/types/TransactionFn.d.ts +0 -4
- package/dist/src/utils/isAtom.d.ts +0 -2
- package/dist/src/utils/isFamily.d.ts +0 -1
- package/dist/src/utils/isPromiseLike.d.ts +0 -1
- package/dist/src/utils/isSelector.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -101,8 +101,8 @@ var createStoreData = (id = generateId()) => ({
|
|
|
101
101
|
// src/utils/isAtom.ts
|
|
102
102
|
var isAtom = (state) => Object.hasOwn(state, "defaultValue");
|
|
103
103
|
|
|
104
|
-
// src/
|
|
105
|
-
|
|
104
|
+
// src/lib/getState.ts
|
|
105
|
+
import equal4 from "fast-deep-equal";
|
|
106
106
|
|
|
107
107
|
// src/lib/updateStateSubscribers.ts
|
|
108
108
|
var updateStateSubscribers = (state, data) => {
|
|
@@ -148,7 +148,7 @@ var evaluateSelector = (selector, data) => {
|
|
|
148
148
|
let result;
|
|
149
149
|
try {
|
|
150
150
|
result = selector.get((state) => {
|
|
151
|
-
const value =
|
|
151
|
+
const value = getState(state, data);
|
|
152
152
|
updatedDependencies.add(state);
|
|
153
153
|
if (isPromiseLike(value))
|
|
154
154
|
throw new SuspendAndWaitForResolveError(value);
|
|
@@ -182,6 +182,7 @@ var handleSelectorResult = (value, selector, data) => {
|
|
|
182
182
|
value.then((resolved) => {
|
|
183
183
|
data.values.set(selector, resolved);
|
|
184
184
|
updateStateSubscribers(selector, data);
|
|
185
|
+
console.log("Should we reEvaluate?");
|
|
185
186
|
});
|
|
186
187
|
return value;
|
|
187
188
|
} else {
|
|
@@ -208,7 +209,7 @@ var updateSelectorSubscribers = (selector, data) => {
|
|
|
208
209
|
const familySubscriptions = selector.family && data.subscriptions.get(selector.family);
|
|
209
210
|
if (!subscribtions?.size && !familySubscriptions?.size)
|
|
210
211
|
return;
|
|
211
|
-
if (subscribtions?.size && data.subscriptionsRequireEqualCheck.get(selector) || familySubscriptions?.size && data.subscriptionsRequireEqualCheck.get(selector.family)) {
|
|
212
|
+
if (subscribtions?.size && data.subscriptionsRequireEqualCheck.get(selector) || familySubscriptions?.size && selector.family && data.subscriptionsRequireEqualCheck.get(selector.family)) {
|
|
212
213
|
try {
|
|
213
214
|
const oldValue = data.expiredValues.get(selector);
|
|
214
215
|
const newValue = initSelector(selector, data);
|
|
@@ -245,13 +246,13 @@ var recursivlyResetSelectorTree = (selectors, data, clearedSelectors) => {
|
|
|
245
246
|
};
|
|
246
247
|
var propagateUpdatedAtoms = (atoms, data) => {
|
|
247
248
|
const clearedSelectors = new Set;
|
|
248
|
-
for (const
|
|
249
|
-
const consumers = data.stateConsumers.get(
|
|
249
|
+
for (const atom2 of atoms) {
|
|
250
|
+
const consumers = data.stateConsumers.get(atom2);
|
|
250
251
|
if (consumers && consumers.size) {
|
|
251
252
|
recursivlyResetSelectorTree(consumers, data, clearedSelectors);
|
|
252
253
|
}
|
|
253
|
-
if (
|
|
254
|
-
const consumersFamily = data.stateConsumers.get(
|
|
254
|
+
if (atom2.family) {
|
|
255
|
+
const consumersFamily = data.stateConsumers.get(atom2.family);
|
|
255
256
|
if (consumersFamily?.size) {
|
|
256
257
|
recursivlyResetSelectorTree(consumersFamily, data, clearedSelectors);
|
|
257
258
|
}
|
|
@@ -260,15 +261,15 @@ var propagateUpdatedAtoms = (atoms, data) => {
|
|
|
260
261
|
for (const selector of clearedSelectors) {
|
|
261
262
|
updateSelectorSubscribers(selector, data);
|
|
262
263
|
}
|
|
263
|
-
for (const
|
|
264
|
-
updateStateSubscribers(
|
|
264
|
+
for (const atom2 of atoms) {
|
|
265
|
+
updateStateSubscribers(atom2, data);
|
|
265
266
|
}
|
|
266
267
|
};
|
|
267
268
|
|
|
268
269
|
// src/lib/setAtom.ts
|
|
269
270
|
import equal3 from "fast-deep-equal";
|
|
270
|
-
var setAtom = (
|
|
271
|
-
const currentValue =
|
|
271
|
+
var setAtom = (atom2, newValue, data) => {
|
|
272
|
+
const currentValue = getState(atom2, data);
|
|
272
273
|
if (typeof newValue === "function") {
|
|
273
274
|
newValue = newValue(currentValue);
|
|
274
275
|
if (isPromiseLike(newValue) || isPromiseLike(currentValue))
|
|
@@ -276,16 +277,16 @@ var setAtom = (atom3, newValue, data) => {
|
|
|
276
277
|
}
|
|
277
278
|
if (equal3(currentValue, newValue))
|
|
278
279
|
return;
|
|
279
|
-
data.values.set(
|
|
280
|
+
data.values.set(atom2, newValue);
|
|
280
281
|
if (currentValue?.__isEmptyAtomPromise__) {
|
|
281
282
|
currentValue.__resolveEmptyAtomPromise__(newValue);
|
|
282
283
|
}
|
|
283
|
-
propagateUpdatedAtoms([
|
|
284
|
+
propagateUpdatedAtoms([atom2], data);
|
|
284
285
|
};
|
|
285
286
|
|
|
286
287
|
// src/lib/initAtom.ts
|
|
287
|
-
var getAtomInitValue = (
|
|
288
|
-
if (
|
|
288
|
+
var getAtomInitValue = (atom2, data) => {
|
|
289
|
+
if (atom2.defaultValue === undefined) {
|
|
289
290
|
let promiseResolve;
|
|
290
291
|
const promise = new Promise((resolve) => {
|
|
291
292
|
promiseResolve = resolve;
|
|
@@ -293,34 +294,38 @@ var getAtomInitValue = (atom3, data) => {
|
|
|
293
294
|
promise.__isEmptyAtomPromise__ = true;
|
|
294
295
|
promise.__resolveEmptyAtomPromise__ = promiseResolve;
|
|
295
296
|
return promise;
|
|
296
|
-
} else if (typeof
|
|
297
|
-
const value =
|
|
297
|
+
} else if (typeof atom2.defaultValue === "function") {
|
|
298
|
+
const value = atom2.defaultValue();
|
|
298
299
|
if (isPromiseLike(value)) {
|
|
299
300
|
value.then((resolvedValue) => {
|
|
300
|
-
data.values.set(
|
|
301
|
-
propagateUpdatedAtoms([
|
|
301
|
+
data.values.set(atom2, resolvedValue);
|
|
302
|
+
propagateUpdatedAtoms([atom2], data);
|
|
302
303
|
});
|
|
303
304
|
}
|
|
304
305
|
return value;
|
|
305
306
|
} else {
|
|
306
|
-
return
|
|
307
|
+
return atom2.defaultValue;
|
|
307
308
|
}
|
|
308
309
|
};
|
|
309
|
-
var initAtom = (
|
|
310
|
-
|
|
311
|
-
data.values.set(
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
310
|
+
var initAtom = (atom2, data) => {
|
|
311
|
+
let value = getAtomInitValue(atom2, data);
|
|
312
|
+
data.values.set(atom2, value);
|
|
313
|
+
if (atom2.onInit)
|
|
314
|
+
atom2.onInit((newVal) => {
|
|
315
|
+
value = newVal;
|
|
316
|
+
setAtom(atom2, newVal, data);
|
|
315
317
|
});
|
|
316
318
|
return value;
|
|
317
319
|
};
|
|
318
320
|
|
|
321
|
+
// src/utils/isSelector.ts
|
|
322
|
+
var isSelector = (state) => Object.hasOwn(state, "get");
|
|
323
|
+
|
|
319
324
|
// src/utils/isFamily.ts
|
|
320
325
|
var isFamily = (state) => Object.hasOwn(state, "_map");
|
|
321
326
|
|
|
322
327
|
// src/lib/getState.ts
|
|
323
|
-
|
|
328
|
+
function getState(state, data) {
|
|
324
329
|
if (data.values.has(state))
|
|
325
330
|
return data.values.get(state);
|
|
326
331
|
if (isAtom(state))
|
|
@@ -328,20 +333,20 @@ var getState2 = (state, data) => {
|
|
|
328
333
|
if (isSelector(state))
|
|
329
334
|
return initSelector(state, data);
|
|
330
335
|
if (isFamily(state)) {
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
return
|
|
336
|
+
const array = Array.from(state._map.keys());
|
|
337
|
+
if (equal4(array, state._keyArray))
|
|
338
|
+
return state._keyArray;
|
|
339
|
+
state._keyArray = array;
|
|
340
|
+
return array;
|
|
336
341
|
}
|
|
337
342
|
throw new Error("Invalid object passed to get");
|
|
338
|
-
}
|
|
343
|
+
}
|
|
339
344
|
|
|
340
345
|
// src/lib/resetAtom.ts
|
|
341
|
-
var resetAtom = (
|
|
342
|
-
const res = initAtom(
|
|
346
|
+
var resetAtom = (atom2, data) => {
|
|
347
|
+
const res = initAtom(atom2, data);
|
|
343
348
|
if (!isPromiseLike(res)) {
|
|
344
|
-
propagateUpdatedAtoms([
|
|
349
|
+
propagateUpdatedAtoms([atom2], data);
|
|
345
350
|
}
|
|
346
351
|
return res;
|
|
347
352
|
};
|
|
@@ -365,8 +370,8 @@ var unsubscribe = (state, subscription, data, mount) => {
|
|
|
365
370
|
}
|
|
366
371
|
if (mount) {
|
|
367
372
|
if (subscribers.size === mount.mountSubscriptions.size) {
|
|
368
|
-
if (
|
|
369
|
-
|
|
373
|
+
if (typeof mount.onUnmount === "function") {
|
|
374
|
+
mount.onUnmount();
|
|
370
375
|
}
|
|
371
376
|
}
|
|
372
377
|
}
|
|
@@ -400,7 +405,7 @@ var subscribe = (state, callback, requireDeepEqualCheckBeforeCallback, data) =>
|
|
|
400
405
|
subscribers.add(subscription);
|
|
401
406
|
let mount;
|
|
402
407
|
if (subscribers.size === 1 && state.onMount) {
|
|
403
|
-
const store =
|
|
408
|
+
const store = storeFromStoreData(data);
|
|
404
409
|
const mountSubscriptions = new Set;
|
|
405
410
|
const originalSub = store.sub;
|
|
406
411
|
store.sub = (state2, callback2) => {
|
|
@@ -408,7 +413,7 @@ var subscribe = (state, callback, requireDeepEqualCheckBeforeCallback, data) =>
|
|
|
408
413
|
return originalSub(state2, callback2);
|
|
409
414
|
};
|
|
410
415
|
mount = {
|
|
411
|
-
|
|
416
|
+
onUnmount: state.onMount(store, state),
|
|
412
417
|
mountSubscriptions
|
|
413
418
|
};
|
|
414
419
|
}
|
|
@@ -419,14 +424,14 @@ var subscribe = (state, callback, requireDeepEqualCheckBeforeCallback, data) =>
|
|
|
419
424
|
};
|
|
420
425
|
|
|
421
426
|
// src/lib/setAtoms.ts
|
|
422
|
-
import
|
|
427
|
+
import equal5 from "fast-deep-equal";
|
|
423
428
|
var setAtoms = (pairs, data) => {
|
|
424
429
|
const updatedAtoms = [];
|
|
425
|
-
for (let [
|
|
426
|
-
const currentValue =
|
|
427
|
-
if (!
|
|
428
|
-
updatedAtoms.push(
|
|
429
|
-
data.values.set(
|
|
430
|
+
for (let [atom2, value] of pairs) {
|
|
431
|
+
const currentValue = getState(atom2, data);
|
|
432
|
+
if (!equal5(currentValue, value)) {
|
|
433
|
+
updatedAtoms.push(atom2);
|
|
434
|
+
data.values.set(atom2, value);
|
|
430
435
|
}
|
|
431
436
|
}
|
|
432
437
|
propagateUpdatedAtoms(updatedAtoms, data);
|
|
@@ -460,7 +465,7 @@ var transaction = (callback, data) => {
|
|
|
460
465
|
let dirtySelectors = new Set;
|
|
461
466
|
const txnGet = (state) => {
|
|
462
467
|
if (isAtom(state)) {
|
|
463
|
-
return txnAtomMap.has(state) ? txnAtomMap.get(state) :
|
|
468
|
+
return txnAtomMap.has(state) ? txnAtomMap.get(state) : getState(state, data);
|
|
464
469
|
} else if (isSelector(state)) {
|
|
465
470
|
if (txnSelectorCache.has(state)) {
|
|
466
471
|
return txnSelectorCache.get(state);
|
|
@@ -482,25 +487,25 @@ var transaction = (callback, data) => {
|
|
|
482
487
|
throw new Error("Unsupported state");
|
|
483
488
|
}
|
|
484
489
|
};
|
|
485
|
-
const txnSet = (
|
|
486
|
-
if (!isAtom(
|
|
490
|
+
const txnSet = (atom2, value) => {
|
|
491
|
+
if (!isAtom(atom2))
|
|
487
492
|
throw new Error("Not an atom");
|
|
488
493
|
if (typeof value === "function") {
|
|
489
|
-
const currentValue = txnGet(
|
|
494
|
+
const currentValue = txnGet(atom2);
|
|
490
495
|
value = value(currentValue);
|
|
491
496
|
}
|
|
492
|
-
for (const selector of findDependencies(
|
|
497
|
+
for (const selector of findDependencies(atom2, data)) {
|
|
493
498
|
dirtySelectors.add(selector);
|
|
494
499
|
txnSelectorCache.delete(selector);
|
|
495
500
|
}
|
|
496
|
-
if (txnSubscribers.get(
|
|
497
|
-
recursivlyResetTxnSelectorCache(
|
|
501
|
+
if (txnSubscribers.get(atom2)?.size) {
|
|
502
|
+
recursivlyResetTxnSelectorCache(atom2, txnSubscribers, txnSelectorCache);
|
|
498
503
|
}
|
|
499
|
-
txnAtomMap.set(
|
|
504
|
+
txnAtomMap.set(atom2, value);
|
|
500
505
|
};
|
|
501
|
-
const txnReset = (
|
|
502
|
-
const value = getAtomInitValue(
|
|
503
|
-
txnAtomMap.set(
|
|
506
|
+
const txnReset = (atom2) => {
|
|
507
|
+
const value = getAtomInitValue(atom2, data);
|
|
508
|
+
txnAtomMap.set(atom2, value);
|
|
504
509
|
return value;
|
|
505
510
|
};
|
|
506
511
|
const commit = () => {
|
|
@@ -513,24 +518,14 @@ var transaction = (callback, data) => {
|
|
|
513
518
|
};
|
|
514
519
|
|
|
515
520
|
// src/lib/storeFromStoreData.ts
|
|
516
|
-
var
|
|
517
|
-
const get = (state) =>
|
|
521
|
+
var storeFromStoreData = (data) => {
|
|
522
|
+
const get = (state) => getState(state, data);
|
|
518
523
|
const set = (state, value) => {
|
|
519
|
-
if (isAtom(state))
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
if (isSelector(state)) {
|
|
523
|
-
if (state.set) {
|
|
524
|
-
txn((set2, get2) => state.set({ get: get2, set: set2 }, value));
|
|
525
|
-
return;
|
|
526
|
-
} else {
|
|
527
|
-
throw new Error("set on selector is not supported");
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
throw new Error("Invalid state object passed to set");
|
|
531
|
-
}
|
|
524
|
+
if (!isAtom(state))
|
|
525
|
+
throw new Error("Invalid state object");
|
|
526
|
+
return setAtom(state, value, data);
|
|
532
527
|
};
|
|
533
|
-
const reset = (
|
|
528
|
+
const reset = (atom2) => resetAtom(atom2, data);
|
|
534
529
|
const sub = (state, callback, deepEqualCheckBeforeCallback = true) => subscribe(state, callback, deepEqualCheckBeforeCallback, data);
|
|
535
530
|
const txn = (callback) => transaction(callback, data);
|
|
536
531
|
return {
|
|
@@ -546,7 +541,24 @@ var storeFromStoreData2 = (data) => {
|
|
|
546
541
|
// src/createStore.ts
|
|
547
542
|
var createStore = (id) => {
|
|
548
543
|
const data = createStoreData(id);
|
|
549
|
-
return
|
|
544
|
+
return storeFromStoreData(data);
|
|
545
|
+
};
|
|
546
|
+
// src/createStoreWithSelectorSet.ts
|
|
547
|
+
var setSelector = (selector, values, store) => {
|
|
548
|
+
return selector.set(store.set, store.get, store.reset, ...values);
|
|
549
|
+
};
|
|
550
|
+
var createStoreWithSelectorSet = (id) => {
|
|
551
|
+
const data = createStoreData(id);
|
|
552
|
+
const store = storeFromStoreData(data);
|
|
553
|
+
store.set = (state, value, ...rest) => {
|
|
554
|
+
if (isAtom(state))
|
|
555
|
+
return setAtom(state, value, data);
|
|
556
|
+
if (isSelector(state))
|
|
557
|
+
return setSelector(state, [value, ...rest], store);
|
|
558
|
+
throw new Error("Invalid state object");
|
|
559
|
+
};
|
|
560
|
+
store.kind = "storeWithSelectorSet";
|
|
561
|
+
return store;
|
|
550
562
|
};
|
|
551
563
|
// src/getDefaultStore.ts
|
|
552
564
|
if (!globalThis._valdresStore) {
|
|
@@ -590,6 +602,7 @@ export {
|
|
|
590
602
|
isFamily,
|
|
591
603
|
isAtom,
|
|
592
604
|
getDefaultStore,
|
|
605
|
+
createStoreWithSelectorSet,
|
|
593
606
|
createStore,
|
|
594
607
|
atomFamily,
|
|
595
608
|
atom
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valdres",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Eigil Sagafos"
|
|
7
7
|
},
|
|
8
|
+
"homepage": "https://valdres.dev",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/eigilsagafos/valdres.git"
|
|
12
|
+
},
|
|
8
13
|
"type": "module",
|
|
9
14
|
"exports": {
|
|
10
15
|
"types": "./dist/index.d.ts",
|
|
@@ -28,11 +33,11 @@
|
|
|
28
33
|
"react": ">=18",
|
|
29
34
|
"react-dom": ">=18",
|
|
30
35
|
"recoil": "0.7.7",
|
|
31
|
-
"typescript": "5.
|
|
36
|
+
"typescript": "5.6.2"
|
|
32
37
|
},
|
|
33
38
|
"publishConfig": {
|
|
34
39
|
"access": "public",
|
|
35
40
|
"registry": "https://registry.npmjs.org/"
|
|
36
41
|
},
|
|
37
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "3ef9fcf34827ece4d4e32b81b28b4b21aaa1b887"
|
|
38
43
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export { atom } from "./src/atom";
|
|
2
|
-
export { atomFamily } from "./src/atomFamily";
|
|
3
|
-
export { createStore } from "./src/createStore";
|
|
4
|
-
export { getDefaultStore, resetDefaultStore } from "./src/getDefaultStore";
|
|
5
|
-
export { selector } from "./src/selector";
|
|
6
|
-
export { selectorFamily } from "./src/selectorFamily";
|
|
7
|
-
export { isAtom } from "./src/utils/isAtom";
|
|
8
|
-
export { isSelector } from "./src/utils/isSelector";
|
|
9
|
-
export { isFamily } from "./src/utils/isFamily";
|
|
10
|
-
export { isPromiseLike } from "./src/utils/isPromiseLike";
|
|
11
|
-
export type { Atom } from "./src/types/Atom";
|
|
12
|
-
export type { AtomFamily } from "./src/types/AtomFamily";
|
|
13
|
-
export type { GetValue } from "./src/types/GetValue";
|
|
14
|
-
export type { Selector } from "./src/types/Selector";
|
|
15
|
-
export type { SelectorFamily } from "./src/types/SelectorFamily";
|
|
16
|
-
export type { SetAtom } from "./src/types/SetAtom";
|
|
17
|
-
export type { State } from "./src/types/State";
|
|
18
|
-
export type { Store } from "./src/types/Store";
|
|
19
|
-
export type { StoreData } from "./src/types/StoreData";
|
package/dist/src/atom.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Atom } from "./types/Atom";
|
|
2
|
-
type AtomOptions<MountRes = undefined> = {
|
|
3
|
-
label?: string;
|
|
4
|
-
onInit?: () => void;
|
|
5
|
-
onMount?: () => MountRes;
|
|
6
|
-
onUnmount?: (mountRes?: MountRes) => void;
|
|
7
|
-
};
|
|
8
|
-
export declare const atom: <Value, FamilyKey = undefined, MountReturnValue = undefined>(defaultValue?: Value | (() => Value | Promise<Value>), options?: AtomOptions<MountReturnValue>) => Atom<Value, FamilyKey>;
|
|
9
|
-
export {};
|
package/dist/src/atomFamily.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { AtomFamily } from "./types/AtomFamily";
|
|
2
|
-
type DefaultValueCallback<Key, Value> = (arg: Key) => Value | Promise<Value>;
|
|
3
|
-
export declare const atomFamily: <Value, Key>(defaultValue?: Value | DefaultValueCallback<Key, Value>, debugLabel?: string) => AtomFamily<Value, Key>;
|
|
4
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { StoreData } from "../types/StoreData";
|
|
2
|
-
import type { Selector } from "../types/Selector";
|
|
3
|
-
export declare const reEvaluateSelector: <V>(selector: Selector<V>, data: StoreData) => void;
|
|
4
|
-
export declare const initSelector: <V>(selector: Selector<V>, data: StoreData) => V | Promise<V>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stableStringify: (x: any) => string | number | boolean;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Family } from "../types/Family";
|
|
2
|
-
import type { State } from "../types/State";
|
|
3
|
-
import type { StoreData } from "../types/StoreData";
|
|
4
|
-
export declare const subscribe: <V>(state: State<V> | Family<V>, callback: any, requireDeepEqualCheckBeforeCallback: boolean, data: StoreData) => () => void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { State } from "../types/State";
|
|
2
|
-
import type { StoreData } from "../types/StoreData";
|
|
3
|
-
type GetValdresValue = <V>(state: State<V>) => V;
|
|
4
|
-
type SetValdresValue = <V>(state: State<V>, value: V) => void;
|
|
5
|
-
type ResetValdresValue = <V>(state: State<V>) => V;
|
|
6
|
-
type TransactionInterface = (set: SetValdresValue, get: GetValdresValue, reset: ResetValdresValue, commit: () => void) => void;
|
|
7
|
-
export declare const transaction: (callback: TransactionInterface, data: StoreData) => void;
|
|
8
|
-
export {};
|
package/dist/src/selector.d.ts
DELETED
package/dist/src/types/Atom.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { AtomFamily } from "./AtomFamily";
|
|
2
|
-
export type Atom<Value = unknown, FamilyKey = undefined, MountRes = undefined> = {
|
|
3
|
-
defaultValue?: Value | (() => Value | Promise<Value>);
|
|
4
|
-
label?: string;
|
|
5
|
-
family?: AtomFamily<Value, FamilyKey>;
|
|
6
|
-
familyKey?: FamilyKey;
|
|
7
|
-
onInit?: () => void;
|
|
8
|
-
onMount?: () => MountRes;
|
|
9
|
-
onUnmount?: (mountRes?: MountRes) => void;
|
|
10
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { GetValue } from "./GetValue";
|
|
2
|
-
import type { SelectorFamily } from "./SelectorFamily";
|
|
3
|
-
export type Selector<Value = any, FamilyKey = undefined> = {
|
|
4
|
-
get: (get: GetValue) => Value;
|
|
5
|
-
debugLabel?: string;
|
|
6
|
-
family?: SelectorFamily<Value, FamilyKey>;
|
|
7
|
-
familyKey?: FamilyKey;
|
|
8
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { GetValue } from "./GetValue";
|
|
2
|
-
import type { ResetAtom } from "./ResetAtom";
|
|
3
|
-
import type { SetAtom } from "./SetAtom";
|
|
4
|
-
import type { StoreData } from "./StoreData";
|
|
5
|
-
import type { SubscribeFn } from "./SubscribeFn";
|
|
6
|
-
import type { TransactionFn } from "./TransactionFn";
|
|
7
|
-
export type Store = {
|
|
8
|
-
data: StoreData;
|
|
9
|
-
get: GetValue;
|
|
10
|
-
set: SetAtom;
|
|
11
|
-
sub: SubscribeFn;
|
|
12
|
-
reset: ResetAtom;
|
|
13
|
-
txn: (callback: TransactionFn) => void;
|
|
14
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type StoreData = {
|
|
2
|
-
id: string;
|
|
3
|
-
values: WeakMap<WeakKey, any>;
|
|
4
|
-
expiredValues: WeakMap<WeakKey, any>;
|
|
5
|
-
subscriptions: WeakMap<WeakKey, Set<any>>;
|
|
6
|
-
subscriptionsRequireEqualCheck: WeakMap<WeakKey, boolean>;
|
|
7
|
-
stateConsumers: WeakMap<WeakKey, any>;
|
|
8
|
-
stateDependencies: WeakMap<WeakKey, any>;
|
|
9
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isFamily: (state: any) => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isPromiseLike: <T>(object: any) => object is Promise<T>;
|