valdres 0.2.0-pre.1 → 0.2.0-pre.11

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.
Files changed (81) hide show
  1. package/dist/index.js +124 -155
  2. package/dist/types/{src/index.d.ts → index.d.ts} +1 -0
  3. package/dist/types/lib/isFunction.d.ts +1 -0
  4. package/dist/types/lib/transaction.d.ts +32 -0
  5. package/dist/types/{src/types → types}/Atom.d.ts +1 -0
  6. package/dist/types/{src/types → types}/AtomFamily.d.ts +1 -0
  7. package/dist/types/{src/types → types}/AtomOptions.d.ts +1 -0
  8. package/dist/types/types/TransactionFn.d.ts +2 -0
  9. package/package.json +1 -1
  10. package/dist/types/src/lib/isFunction.d.ts +0 -1
  11. package/dist/types/src/lib/transaction.d.ts +0 -8
  12. package/dist/types/src/types/TransactionFn.d.ts +0 -2
  13. /package/dist/types/{src/atom.d.ts → atom.d.ts} +0 -0
  14. /package/dist/types/{src/atomFamily.d.ts → atomFamily.d.ts} +0 -0
  15. /package/dist/types/{src/createStoreWithSelectorSet.d.ts → createStoreWithSelectorSet.d.ts} +0 -0
  16. /package/dist/types/{src/errors → errors}/SelectorCircularDependencyError.d.ts +0 -0
  17. /package/dist/types/{src/errors → errors}/SelectorEvaluationError.d.ts +0 -0
  18. /package/dist/types/{src/errors → errors}/lib/generateSelectorTrace.d.ts +0 -0
  19. /package/dist/types/{src/globalStore.d.ts → globalStore.d.ts} +0 -0
  20. /package/dist/types/{src/indexConstructor.d.ts → indexConstructor.d.ts} +0 -0
  21. /package/dist/types/{src/lib → lib}/atomFamilyAtom.d.ts +0 -0
  22. /package/dist/types/{src/lib → lib}/createAtomFamily.d.ts +0 -0
  23. /package/dist/types/{src/lib → lib}/createGlobalAtomFamily.d.ts +0 -0
  24. /package/dist/types/{src/lib → lib}/createStoreData.d.ts +0 -0
  25. /package/dist/types/{src/lib → lib}/deleteFamilyAtom.d.ts +0 -0
  26. /package/dist/types/{src/lib → lib}/equal.d.ts +0 -0
  27. /package/dist/types/{src/lib → lib}/getState.d.ts +0 -0
  28. /package/dist/types/{src/lib → lib}/globalAtom.d.ts +0 -0
  29. /package/dist/types/{src/lib → lib}/initAtom.d.ts +0 -0
  30. /package/dist/types/{src/lib → lib}/initSelector.d.ts +0 -0
  31. /package/dist/types/{src/lib → lib}/isProd.d.ts +0 -0
  32. /package/dist/types/{src/lib → lib}/propagateUpdatedAtoms.d.ts +0 -0
  33. /package/dist/types/{src/lib → lib}/resetAtom.d.ts +0 -0
  34. /package/dist/types/{src/lib → lib}/setAtom.d.ts +0 -0
  35. /package/dist/types/{src/lib → lib}/setAtoms.d.ts +0 -0
  36. /package/dist/types/{src/lib → lib}/setValueInData.d.ts +0 -0
  37. /package/dist/types/{src/lib → lib}/stableStringify.d.ts +0 -0
  38. /package/dist/types/{src/lib → lib}/storeFromStoreData.d.ts +0 -0
  39. /package/dist/types/{src/lib → lib}/stringifyFamilyArgs.d.ts +0 -0
  40. /package/dist/types/{src/lib → lib}/subscribe.d.ts +0 -0
  41. /package/dist/types/{src/lib → lib}/unsubscribe.d.ts +0 -0
  42. /package/dist/types/{src/selector.d.ts → selector.d.ts} +0 -0
  43. /package/dist/types/{src/selectorFamily.d.ts → selectorFamily.d.ts} +0 -0
  44. /package/dist/types/{src/store.d.ts → store.d.ts} +0 -0
  45. /package/dist/types/{src/types → types}/AtomDefaultValue.d.ts +0 -0
  46. /package/dist/types/{src/types → types}/AtomFamilyAtom.d.ts +0 -0
  47. /package/dist/types/{src/types → types}/AtomFamilyDefaultValue.d.ts +0 -0
  48. /package/dist/types/{src/types → types}/AtomFamilyGlobalAtom.d.ts +0 -0
  49. /package/dist/types/{src/types → types}/AtomFamilySelector.d.ts +0 -0
  50. /package/dist/types/{src/types → types}/AtomOnInit.d.ts +0 -0
  51. /package/dist/types/{src/types → types}/AtomOnSet.d.ts +0 -0
  52. /package/dist/types/{src/types → types}/EqualFunc.d.ts +0 -0
  53. /package/dist/types/{src/types → types}/Family.d.ts +0 -0
  54. /package/dist/types/{src/types → types}/FamilyKey.d.ts +0 -0
  55. /package/dist/types/{src/types → types}/GetValue.d.ts +0 -0
  56. /package/dist/types/{src/types → types}/GlobalAtom.d.ts +0 -0
  57. /package/dist/types/{src/types → types}/GlobalAtomGetSelfFunc.d.ts +0 -0
  58. /package/dist/types/{src/types → types}/GlobalAtomResetSelfFunc.d.ts +0 -0
  59. /package/dist/types/{src/types → types}/GlobalAtomSetSelfFunc.d.ts +0 -0
  60. /package/dist/types/{src/types → types}/ResetAtom.d.ts +0 -0
  61. /package/dist/types/{src/types → types}/Selector.d.ts +0 -0
  62. /package/dist/types/{src/types → types}/SelectorFamily.d.ts +0 -0
  63. /package/dist/types/{src/types → types}/SelectorOptions.d.ts +0 -0
  64. /package/dist/types/{src/types → types}/SetAtom.d.ts +0 -0
  65. /package/dist/types/{src/types → types}/SetAtomValue.d.ts +0 -0
  66. /package/dist/types/{src/types → types}/State.d.ts +0 -0
  67. /package/dist/types/{src/types → types}/Store.d.ts +0 -0
  68. /package/dist/types/{src/types → types}/StoreData.d.ts +0 -0
  69. /package/dist/types/{src/types → types}/SubscribeFn.d.ts +0 -0
  70. /package/dist/types/{src/types → types}/Subscription.d.ts +0 -0
  71. /package/dist/types/{src/types → types}/TransactionInterface.d.ts +0 -0
  72. /package/dist/types/{src/utils → utils}/deepFreeze.d.ts +0 -0
  73. /package/dist/types/{src/utils → utils}/isAtom.d.ts +0 -0
  74. /package/dist/types/{src/utils → utils}/isAtomFamily.d.ts +0 -0
  75. /package/dist/types/{src/utils → utils}/isFamily.d.ts +0 -0
  76. /package/dist/types/{src/utils → utils}/isFamilyAtom.d.ts +0 -0
  77. /package/dist/types/{src/utils → utils}/isFamilySelector.d.ts +0 -0
  78. /package/dist/types/{src/utils → utils}/isFamilyState.d.ts +0 -0
  79. /package/dist/types/{src/utils → utils}/isPromiseLike.d.ts +0 -0
  80. /package/dist/types/{src/utils → utils}/isSelector.d.ts +0 -0
  81. /package/dist/types/{src/utils → utils}/isSelectorFamily.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,6 +1,3 @@
1
- // src/index.ts
2
- import { version } from "../package.json";
3
-
4
1
  // src/lib/equal.ts
5
2
  var hasElementType = typeof Element !== "undefined";
6
3
  var hasMap = typeof Map === "function";
@@ -190,7 +187,7 @@ var isProd = () => {
190
187
 
191
188
  // src/lib/setValueInData.ts
192
189
  var setValueInData = (atom, value, data) => {
193
- if (isProd()) {
190
+ if (atom.mutable || isProd()) {
194
191
  data.values.set(atom, value);
195
192
  return value;
196
193
  } else {
@@ -499,18 +496,6 @@ var propagateDirtySelectors = (updatedAtoms, selectors, data, subscriptions, fam
499
496
  }
500
497
  }
501
498
  };
502
- var findAllDependents = (selector, data, depsRes = new Set, subsRes = new Set) => {
503
- const dependents = data.stateDependents.get(selector);
504
- const subscriptions = data.subscriptions.get(selector);
505
- addSetToSet(dependents, depsRes);
506
- addSetToSet(subscriptions, subsRes);
507
- if (dependents && dependents.size > 0) {
508
- for (const dependent of dependents) {
509
- findAllDependents(dependent, data, depsRes, subsRes);
510
- }
511
- }
512
- return [depsRes, subsRes];
513
- };
514
499
  var recursivlyHandleSelectorUpdates = (selectors, data, collectedSubscribers, updatedInitializedAtoms, seen = new Set) => {
515
500
  const selectorsForNextPass = new Set;
516
501
  for (const selector of selectors) {
@@ -526,23 +511,10 @@ var recursivlyHandleSelectorUpdates = (selectors, data, collectedSubscribers, up
526
511
  data.values.delete(selector);
527
512
  } else {
528
513
  const [wasValueUpdated, didEvalCrash, error] = reEvaluteSelector(selector, data, updatedInitializedAtoms);
529
- if (didEvalCrash) {
530
- const [deps, subs] = findAllDependents(selector, data);
531
- if (deps.size > 0) {
532
- for (const dep of deps) {
533
- data.expiredValues.set(dep, data.values.get(dep));
534
- data.values.delete(dep);
535
- }
536
- }
537
- if (subs.size > 0) {
538
- addSetToSet(subs, collectedSubscribers);
539
- }
540
- } else {
541
- if (!wasValueUpdated)
542
- continue;
543
- addSetToSet(data.stateDependents.get(selector), selectorsForNextPass);
544
- addSetToSet(subscribers, collectedSubscribers);
545
- }
514
+ if (!wasValueUpdated)
515
+ continue;
516
+ addSetToSet(data.stateDependents.get(selector), selectorsForNextPass);
517
+ addSetToSet(subscribers, collectedSubscribers);
546
518
  }
547
519
  }
548
520
  if (selectorsForNextPass.size > 0) {
@@ -756,174 +728,171 @@ var setAtoms = (pairs, data, initializedAtomsSet) => {
756
728
  };
757
729
 
758
730
  // src/lib/transaction.ts
759
- var findDependencies = (state, data, result = new Set) => {
760
- const dependents = data.stateDependents.get(state);
761
- if (dependents?.size) {
762
- for (const dependent of dependents) {
763
- if (!result.has(dependent)) {
764
- result.add(dependent);
765
- findDependencies(dependent, data, result);
766
- }
767
- }
768
- }
769
- return result;
770
- };
771
- var recursivlyResetTxnSelectorCache = (state, txnSubscribers, txnSelectorCache) => {
772
- for (const dep of txnSubscribers.get(state)) {
773
- txnSelectorCache.delete(dep);
774
- if (txnSubscribers.get(dep)?.size) {
775
- recursivlyResetTxnSelectorCache(dep, txnSubscribers, txnSelectorCache);
776
- }
777
- }
778
- };
779
- var captureScopedTransaction = (scopedData, parentGetInTxnOrData) => {
780
- let txn;
781
- transaction((scopedTxn) => {
782
- txn = scopedTxn;
783
- }, scopedData, false, parentGetInTxnOrData);
784
- return txn;
785
- };
786
731
  var deleteAtomFamilyAtoms = (set, data) => {
787
732
  set.forEach((atom) => {
788
733
  data.values.delete(atom);
789
734
  });
790
735
  };
791
- var transaction = (callback, data, autoCommit = true, parentGetInTxnOrData) => {
792
- const txnAtomMap = new Map;
793
- const txnAtomDeleteSet = new Set;
794
- const txnSelectorCache = new Map;
795
- const txnSubscribers = new Map;
796
- const dirtySelectors = new Set;
797
- let scopedTransactions;
798
- const getInTxnOrData = (state) => {
799
- if (txnAtomMap.has(state)) {
800
- return txnAtomMap.get(state);
736
+
737
+ class Transaction {
738
+ data;
739
+ parentTransaction;
740
+ dirty;
741
+ _scopedTransactions;
742
+ _initializedAtomsSet;
743
+ _deleteSet;
744
+ _selectorDependencies;
745
+ _selectorCache;
746
+ _atomMap;
747
+ constructor(data, parentTransaction) {
748
+ this.data = data;
749
+ this.parentTransaction = parentTransaction;
750
+ this.dirty = false;
751
+ }
752
+ valueFromTxnOrData = (state) => {
753
+ if (this.atomMap.has(state)) {
754
+ return this.atomMap.get(state);
801
755
  }
802
- if (data.values.has(state)) {
803
- return data.values.get(state);
756
+ if (this.data.values.has(state)) {
757
+ return this.data.values.get(state);
804
758
  }
805
- if (parentGetInTxnOrData) {
806
- return parentGetInTxnOrData(state);
759
+ if (this.parentTransaction) {
760
+ return this.parentTransaction.valueFromTxnOrData(state);
807
761
  }
808
762
  };
809
- const initializedAtomsSet = new Set;
810
- const txnGet = (state) => {
811
- if (isAtom(state)) {
812
- const value = getInTxnOrData(state);
763
+ get = (state) => {
764
+ if (isAtom(state) || isAtomFamily(state)) {
765
+ const value = this.valueFromTxnOrData(state);
813
766
  if (value)
814
767
  return value;
815
- return getState(state, data, initializedAtomsSet);
768
+ return getState(state, this.data, this.initializedAtomsSet);
816
769
  } else if (isSelector(state)) {
817
- if (txnSelectorCache.has(state)) {
818
- return txnSelectorCache.get(state);
770
+ if (this.dirty) {
771
+ this.selectorCache.clear();
772
+ this.selectorDependencies.clear();
773
+ this.dirty = false;
774
+ } else if (this.selectorCache.has(state)) {
775
+ return this.selectorCache.get(state);
819
776
  }
820
- const deps = new Set;
821
777
  const res = state.get((s) => {
822
- deps.add(s);
823
- return txnGet(s);
824
- }, data.id);
825
- for (const dep of deps) {
826
- if (!txnSubscribers.has(dep)) {
827
- txnSubscribers.set(dep, new Set);
778
+ if (!this.selectorDependencies.has(s)) {
779
+ this.selectorDependencies.add(s);
828
780
  }
829
- txnSubscribers.get(dep).add(state);
830
- }
831
- txnSelectorCache.set(state, res);
781
+ return this.get(s);
782
+ }, this.data.id);
783
+ this.selectorCache.set(state, res);
832
784
  return res;
833
- } else if (isAtomFamily(state)) {
834
- const value = getInTxnOrData(state);
835
- if (value)
836
- return value;
837
- return getState(state, data, initializedAtomsSet);
838
785
  } else {
839
786
  throw new Error("Unsupported state");
840
787
  }
841
788
  };
842
- const txnSet = (atom, value) => {
789
+ set = (atom, value) => {
843
790
  if (!isAtom(atom))
844
791
  throw new Error("Not an atom");
845
792
  if (isFunction(value)) {
846
- const currentValue = txnGet(atom);
793
+ const currentValue = this.get(atom);
847
794
  value = value(currentValue);
848
795
  }
849
- for (const selector of findDependencies(atom, data)) {
850
- dirtySelectors.add(selector);
851
- txnSelectorCache.delete(selector);
852
- }
853
- if (txnSubscribers.get(atom)?.size) {
854
- recursivlyResetTxnSelectorCache(atom, txnSubscribers, txnSelectorCache);
855
- }
856
796
  if (isProd()) {
857
- txnAtomMap.set(atom, value);
797
+ this.atomMap.set(atom, value);
858
798
  } else {
859
- txnAtomMap.set(atom, deepFreeze(value));
799
+ this.atomMap.set(atom, deepFreeze(value));
860
800
  }
801
+ if (!this.dirty)
802
+ this.dirty = true;
861
803
  if (isFamilyAtom(atom)) {
862
- const currentFamilyList = txnGet(atom.family);
804
+ const currentFamilyList = this.get(atom.family);
863
805
  if (!currentFamilyList.includes(atom)) {
864
806
  const newArr = [...currentFamilyList, atom];
865
- txnAtomMap.set(atom.family, newArr);
807
+ this.atomMap.set(atom.family, newArr);
866
808
  }
867
809
  }
868
810
  return value;
869
811
  };
870
- const txnReset = (atom) => {
871
- const value = getAtomInitValue(atom, data, initializedAtomsSet);
872
- txnAtomMap.set(atom, value);
873
- return value;
874
- };
875
- const txnDel = (atom) => {
876
- const array = txnGet(atom.family);
812
+ del = (atom) => {
813
+ const array = this.get(atom.family);
877
814
  const index = array.indexOf(atom);
878
815
  const newArr = [
879
816
  ...array.slice(0, index),
880
817
  ...array.slice(index + 1)
881
818
  ];
882
- txnAtomMap.set(atom.family, newArr);
883
- if (data.values.has(atom)) {
884
- txnAtomDeleteSet.add(atom);
819
+ this.atomMap.set(atom.family, newArr);
820
+ if (this.data.values.has(atom)) {
821
+ this.deleteSet.add(atom);
885
822
  }
886
- if (txnAtomMap.has(atom)) {
887
- txnAtomMap.delete(atom);
823
+ if (this.atomMap.has(atom)) {
824
+ this.atomMap.delete(atom);
888
825
  }
889
826
  };
890
- const commit = () => {
891
- setAtoms(txnAtomMap, data, initializedAtomsSet);
892
- if (txnAtomDeleteSet.size) {
893
- deleteAtomFamilyAtoms(txnAtomDeleteSet, data);
827
+ scope = (scopeId, callback) => {
828
+ if (scopeId in this.data.scopes) {
829
+ return this.scopedTransaction(scopeId).execute(callback, false);
830
+ } else {
831
+ throw new Error(`Scope '${scopeId}' not found. Registered scopes: ${Object.keys(this.data.scopes).join(", ")}`);
832
+ }
833
+ };
834
+ reset = (atom) => {
835
+ const value = getAtomInitValue(atom, this.data, this.initializedAtomsSet);
836
+ this.atomMap.set(atom, value);
837
+ return value;
838
+ };
839
+ execute = (callback, autoCommit = true) => {
840
+ const result = callback(this);
841
+ if (autoCommit)
842
+ this.commit();
843
+ return result;
844
+ };
845
+ commit = () => {
846
+ const initializedAtomsSet = new Set;
847
+ setAtoms(this.atomMap, this.data, initializedAtomsSet);
848
+ if (this.deleteSet?.size) {
849
+ deleteAtomFamilyAtoms(this.deleteSet, this.data);
894
850
  }
895
- dirtySelectors.clear();
896
- if (scopedTransactions) {
897
- for (const scopedTxn of Object.values(scopedTransactions)) {
851
+ if (this._scopedTransactions) {
852
+ for (const scopedTxn of Object.values(this._scopedTransactions)) {
898
853
  scopedTxn.commit();
899
854
  }
900
855
  }
901
856
  };
902
- const result = callback({
903
- set: txnSet,
904
- get: txnGet,
905
- del: txnDel,
906
- reset: txnReset,
907
- commit,
908
- scope: (scopeId, callback2) => {
909
- if (scopeId in data.scopes) {
910
- const scopedData = data.scopes[scopeId];
911
- if (scopedTransactions === undefined) {
912
- scopedTransactions = {};
913
- }
914
- if (scopedTransactions[scopeId] === undefined) {
915
- scopedTransactions[scopeId] = captureScopedTransaction(scopedData, getInTxnOrData);
916
- }
917
- return callback2(scopedTransactions[scopeId]);
918
- } else {
919
- throw new Error(`Scope '${scopeId}' not found. Registered scopes: ${Object.keys(data.scopes).join(", ")}`);
920
- }
921
- },
922
- data
923
- });
924
- if (autoCommit)
925
- commit();
926
- return result;
857
+ get atomMap() {
858
+ if (!this._atomMap)
859
+ this._atomMap = new Map;
860
+ return this._atomMap;
861
+ }
862
+ get selectorCache() {
863
+ if (!this._selectorCache)
864
+ this._selectorCache = new Map;
865
+ return this._selectorCache;
866
+ }
867
+ get selectorDependencies() {
868
+ if (!this._selectorDependencies)
869
+ this._selectorDependencies = new Set;
870
+ return this._selectorDependencies;
871
+ }
872
+ get deleteSet() {
873
+ if (!this._deleteSet)
874
+ this._deleteSet = new Set;
875
+ return this._deleteSet;
876
+ }
877
+ get initializedAtomsSet() {
878
+ if (!this._initializedAtomsSet)
879
+ this._initializedAtomsSet = new Set;
880
+ return this._initializedAtomsSet;
881
+ }
882
+ scopedTransaction(scopeId) {
883
+ if (!this._scopedTransactions)
884
+ this._scopedTransactions = {};
885
+ if (!this._scopedTransactions[scopeId]) {
886
+ const scopedData = this.data.scopes[scopeId];
887
+ const scopedTransaction = new Transaction(scopedData, this);
888
+ this._scopedTransactions[scopeId] = scopedTransaction;
889
+ }
890
+ return this._scopedTransactions[scopeId];
891
+ }
892
+ }
893
+ var transaction = (callback, data) => {
894
+ const txn = new Transaction(data);
895
+ return txn.execute(callback);
927
896
  };
928
897
 
929
898
  // src/lib/storeFromStoreData.ts
@@ -1329,9 +1298,9 @@ var isFamilySelector = (state) => isFamilyState(state) && isSelector(state);
1329
1298
 
1330
1299
  // src/index.ts
1331
1300
  if (globalThis.__valdres__) {
1332
- throw new Error(`Error! An instance of valdres is already loaded. Loaded: ${globalThis.__valdres__}. Attempted to load: ${version}`);
1301
+ throw new Error(`Error! An instance of valdres is already loaded. Loaded: ${globalThis.__valdres__}. Attempted to load: ${"0.2.0-pre.11"}`);
1333
1302
  } else {
1334
- globalThis.__valdres__ = version;
1303
+ globalThis.__valdres__ = "0.2.0-pre.11";
1335
1304
  }
1336
1305
  export {
1337
1306
  store,
@@ -34,3 +34,4 @@ export type { Store } from "./types/Store";
34
34
  export type { StoreData } from "./types/StoreData";
35
35
  export type { TransactionFn } from "./types/TransactionFn";
36
36
  export type { TransactionInterface } from "./types/TransactionInterface";
37
+ export type { Transaction } from "./lib/transaction";
@@ -0,0 +1 @@
1
+ export declare const isFunction: (value: any) => value is Function;
@@ -0,0 +1,32 @@
1
+ import type { Atom } from "../types/Atom";
2
+ import type { AtomFamilyAtom } from "../types/AtomFamilyAtom";
3
+ import type { GetValue } from "../types/GetValue";
4
+ import type { StoreData } from "../types/StoreData";
5
+ import type { TransactionFn } from "../types/TransactionFn";
6
+ export declare class Transaction {
7
+ data: StoreData;
8
+ parentTransaction: Transaction | undefined;
9
+ dirty: boolean;
10
+ private _scopedTransactions;
11
+ private _initializedAtomsSet;
12
+ private _deleteSet;
13
+ private _selectorDependencies;
14
+ private _selectorCache;
15
+ private _atomMap;
16
+ constructor(data: StoreData, parentTransaction?: Transaction);
17
+ private valueFromTxnOrData;
18
+ get: GetValue;
19
+ set: <V>(atom: Atom<V>, value: V | ((currentValue: V) => V)) => V;
20
+ del: (atom: AtomFamilyAtom<any, any>) => void;
21
+ scope: (scopeId: string, callback: (txn: Transaction) => any) => any;
22
+ reset: (atom: Atom) => any;
23
+ execute: (callback: TransactionFn, autoCommit?: boolean) => any;
24
+ commit: () => void;
25
+ private get atomMap();
26
+ private get selectorCache();
27
+ private get selectorDependencies();
28
+ private get deleteSet();
29
+ private get initializedAtomsSet();
30
+ private scopedTransaction;
31
+ }
32
+ export declare const transaction: (callback: TransactionFn, data: StoreData) => any;
@@ -10,5 +10,6 @@ export type Atom<Value = unknown> = {
10
10
  onSet?: AtomOnSet<Value>;
11
11
  onMount?: () => void | (() => void);
12
12
  maxAge?: number;
13
+ mutable?: boolean;
13
14
  staleWhileRevalidate?: number;
14
15
  };
@@ -5,5 +5,6 @@ export type AtomFamily<Value extends any, Args extends [any, ...any[]] = [any, .
5
5
  release: (...args: Args) => void;
6
6
  equal: EqualFunc<Value>;
7
7
  name?: string;
8
+ mutable?: boolean;
8
9
  __valdresAtomFamilyMap: Map<Value, AtomFamilyAtom<Value, Args>>;
9
10
  };
@@ -8,6 +8,7 @@ export type AtomOptions<Value = unknown> = {
8
8
  onSet?: AtomOnSet<Value>;
9
9
  onMount?: () => () => void;
10
10
  maxAge?: number;
11
+ mutable?: boolean;
11
12
  staleWhileRevalidate?: number;
12
13
  equal?: EqualFunc<Value>;
13
14
  };
@@ -0,0 +1,2 @@
1
+ import type { Transaction } from "../lib/transaction";
2
+ export type TransactionFn = (args: Transaction) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valdres",
3
- "version": "0.2.0-pre.1",
3
+ "version": "0.2.0-pre.11",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Eigil Sagafos"
@@ -1 +0,0 @@
1
- export declare const isFunction: (value: unknown) => value is Function;
@@ -1,8 +0,0 @@
1
- import type { Atom } from "../types/Atom";
2
- import type { StoreData } from "../types/StoreData";
3
- import type { TransactionFn } from "../types/TransactionFn";
4
- type GetAtomValue = {
5
- <V>(atom: Atom<V>): V;
6
- };
7
- export declare const transaction: (callback: TransactionFn, data: StoreData, autoCommit?: boolean, parentGetInTxnOrData?: GetAtomValue) => any;
8
- export {};
@@ -1,2 +0,0 @@
1
- import type { TransactionInterface } from "./TransactionInterface";
2
- export type TransactionFn = (args: TransactionInterface) => any;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes