valdres 0.2.0-pre.1 → 0.2.0-pre.10
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 +124 -155
- package/dist/types/{src/index.d.ts → index.d.ts} +1 -0
- package/dist/types/lib/isFunction.d.ts +1 -0
- package/dist/types/lib/transaction.d.ts +32 -0
- package/dist/types/{src/types → types}/Atom.d.ts +1 -0
- package/dist/types/{src/types → types}/AtomFamily.d.ts +1 -0
- package/dist/types/{src/types → types}/AtomOptions.d.ts +1 -0
- package/dist/types/types/TransactionFn.d.ts +2 -0
- package/package.json +1 -1
- package/dist/types/src/lib/isFunction.d.ts +0 -1
- package/dist/types/src/lib/transaction.d.ts +0 -8
- package/dist/types/src/types/TransactionFn.d.ts +0 -2
- /package/dist/types/{src/atom.d.ts → atom.d.ts} +0 -0
- /package/dist/types/{src/atomFamily.d.ts → atomFamily.d.ts} +0 -0
- /package/dist/types/{src/createStoreWithSelectorSet.d.ts → createStoreWithSelectorSet.d.ts} +0 -0
- /package/dist/types/{src/errors → errors}/SelectorCircularDependencyError.d.ts +0 -0
- /package/dist/types/{src/errors → errors}/SelectorEvaluationError.d.ts +0 -0
- /package/dist/types/{src/errors → errors}/lib/generateSelectorTrace.d.ts +0 -0
- /package/dist/types/{src/globalStore.d.ts → globalStore.d.ts} +0 -0
- /package/dist/types/{src/indexConstructor.d.ts → indexConstructor.d.ts} +0 -0
- /package/dist/types/{src/lib → lib}/atomFamilyAtom.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/createAtomFamily.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/createGlobalAtomFamily.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/createStoreData.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/deleteFamilyAtom.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/equal.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/getState.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/globalAtom.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/initAtom.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/initSelector.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/isProd.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/propagateUpdatedAtoms.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/resetAtom.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/setAtom.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/setAtoms.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/setValueInData.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/stableStringify.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/storeFromStoreData.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/stringifyFamilyArgs.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/subscribe.d.ts +0 -0
- /package/dist/types/{src/lib → lib}/unsubscribe.d.ts +0 -0
- /package/dist/types/{src/selector.d.ts → selector.d.ts} +0 -0
- /package/dist/types/{src/selectorFamily.d.ts → selectorFamily.d.ts} +0 -0
- /package/dist/types/{src/store.d.ts → store.d.ts} +0 -0
- /package/dist/types/{src/types → types}/AtomDefaultValue.d.ts +0 -0
- /package/dist/types/{src/types → types}/AtomFamilyAtom.d.ts +0 -0
- /package/dist/types/{src/types → types}/AtomFamilyDefaultValue.d.ts +0 -0
- /package/dist/types/{src/types → types}/AtomFamilyGlobalAtom.d.ts +0 -0
- /package/dist/types/{src/types → types}/AtomFamilySelector.d.ts +0 -0
- /package/dist/types/{src/types → types}/AtomOnInit.d.ts +0 -0
- /package/dist/types/{src/types → types}/AtomOnSet.d.ts +0 -0
- /package/dist/types/{src/types → types}/EqualFunc.d.ts +0 -0
- /package/dist/types/{src/types → types}/Family.d.ts +0 -0
- /package/dist/types/{src/types → types}/FamilyKey.d.ts +0 -0
- /package/dist/types/{src/types → types}/GetValue.d.ts +0 -0
- /package/dist/types/{src/types → types}/GlobalAtom.d.ts +0 -0
- /package/dist/types/{src/types → types}/GlobalAtomGetSelfFunc.d.ts +0 -0
- /package/dist/types/{src/types → types}/GlobalAtomResetSelfFunc.d.ts +0 -0
- /package/dist/types/{src/types → types}/GlobalAtomSetSelfFunc.d.ts +0 -0
- /package/dist/types/{src/types → types}/ResetAtom.d.ts +0 -0
- /package/dist/types/{src/types → types}/Selector.d.ts +0 -0
- /package/dist/types/{src/types → types}/SelectorFamily.d.ts +0 -0
- /package/dist/types/{src/types → types}/SelectorOptions.d.ts +0 -0
- /package/dist/types/{src/types → types}/SetAtom.d.ts +0 -0
- /package/dist/types/{src/types → types}/SetAtomValue.d.ts +0 -0
- /package/dist/types/{src/types → types}/State.d.ts +0 -0
- /package/dist/types/{src/types → types}/Store.d.ts +0 -0
- /package/dist/types/{src/types → types}/StoreData.d.ts +0 -0
- /package/dist/types/{src/types → types}/SubscribeFn.d.ts +0 -0
- /package/dist/types/{src/types → types}/Subscription.d.ts +0 -0
- /package/dist/types/{src/types → types}/TransactionInterface.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/deepFreeze.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/isAtom.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/isAtomFamily.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/isFamily.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/isFamilyAtom.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/isFamilySelector.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/isFamilyState.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/isPromiseLike.d.ts +0 -0
- /package/dist/types/{src/utils → utils}/isSelector.d.ts +0 -0
- /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 (
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
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
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
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 (
|
|
806
|
-
return
|
|
759
|
+
if (this.parentTransaction) {
|
|
760
|
+
return this.parentTransaction.valueFromTxnOrData(state);
|
|
807
761
|
}
|
|
808
762
|
};
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
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 (
|
|
818
|
-
|
|
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
|
-
|
|
823
|
-
|
|
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
|
-
|
|
830
|
-
}
|
|
831
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
797
|
+
this.atomMap.set(atom, value);
|
|
858
798
|
} else {
|
|
859
|
-
|
|
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 =
|
|
804
|
+
const currentFamilyList = this.get(atom.family);
|
|
863
805
|
if (!currentFamilyList.includes(atom)) {
|
|
864
806
|
const newArr = [...currentFamilyList, atom];
|
|
865
|
-
|
|
807
|
+
this.atomMap.set(atom.family, newArr);
|
|
866
808
|
}
|
|
867
809
|
}
|
|
868
810
|
return value;
|
|
869
811
|
};
|
|
870
|
-
|
|
871
|
-
const
|
|
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
|
-
|
|
883
|
-
if (data.values.has(atom)) {
|
|
884
|
-
|
|
819
|
+
this.atomMap.set(atom.family, newArr);
|
|
820
|
+
if (this.data.values.has(atom)) {
|
|
821
|
+
this.deleteSet.add(atom);
|
|
885
822
|
}
|
|
886
|
-
if (
|
|
887
|
-
|
|
823
|
+
if (this.atomMap.has(atom)) {
|
|
824
|
+
this.atomMap.delete(atom);
|
|
888
825
|
}
|
|
889
826
|
};
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
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
|
-
|
|
896
|
-
|
|
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
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
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: ${
|
|
1301
|
+
throw new Error(`Error! An instance of valdres is already loaded. Loaded: ${globalThis.__valdres__}. Attempted to load: ${"0.2.0-pre.10"}`);
|
|
1333
1302
|
} else {
|
|
1334
|
-
globalThis.__valdres__ =
|
|
1303
|
+
globalThis.__valdres__ = "0.2.0-pre.10";
|
|
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;
|
package/package.json
CHANGED
|
@@ -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 {};
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|