atom.io 0.12.0 → 0.12.1
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/internal/dist/index.cjs +39 -7
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +12 -2
- package/internal/dist/index.d.ts +12 -2
- package/internal/dist/index.js +39 -8
- package/internal/dist/index.js.map +1 -1
- package/internal/dist/metafile-cjs.json +1 -1
- package/internal/dist/metafile-esm.json +1 -1
- package/internal/src/index.ts +3 -2
- package/internal/src/lazy-map.ts +33 -0
- package/internal/src/transaction/build-transaction.ts +8 -7
- package/package.json +1 -1
|
@@ -378,12 +378,22 @@ declare function createReadonlySelectorFamily<T, K extends Json.Serializable>(op
|
|
|
378
378
|
declare function createSelectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>, store: Store): SelectorFamily<T, K>;
|
|
379
379
|
declare function createSelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
|
|
380
380
|
|
|
381
|
-
declare
|
|
381
|
+
declare class LazyMap<K, V> extends Map<K, V> {
|
|
382
|
+
protected readonly source: Map<K, V>;
|
|
383
|
+
deleted: Set<K>;
|
|
384
|
+
constructor(source: Map<K, V>);
|
|
385
|
+
get(key: K): V | undefined;
|
|
386
|
+
_has(key: K): boolean;
|
|
387
|
+
has(key: K): boolean;
|
|
388
|
+
delete(key: K): boolean;
|
|
389
|
+
}
|
|
382
390
|
|
|
383
391
|
declare class NotFoundError extends Error {
|
|
384
392
|
constructor(token: ReadonlySelectorToken<any> | StateToken<any>, store: Store);
|
|
385
393
|
}
|
|
386
394
|
|
|
395
|
+
declare const readOrComputeValue: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => T;
|
|
396
|
+
|
|
387
397
|
type Modify<T> = (thing: T) => T;
|
|
388
398
|
declare const become: <T>(nextVersionOfThing: T | Modify<T>) => (originalThing: T) => T;
|
|
389
399
|
|
|
@@ -391,4 +401,4 @@ declare const setAtomOrSelector: <T>(state: Atom<T> | Selector<T>, value: T | ((
|
|
|
391
401
|
|
|
392
402
|
declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>, store: Store) => (() => void)[] | null;
|
|
393
403
|
|
|
394
|
-
export { type Atom, type AtomKey, FamilyTracker, Future, IMPLICIT, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadonlySelector, type ReadonlySelectorKey, type Selector, type SelectorKey, type Signal, type StateKey, Store, type StoreCore, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionIdle, type TransactionPhase, type TransactionStatus, type TransactionUpdateInProgress, type Transceiver, type TransceiverMode, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, target, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
|
404
|
+
export { type Atom, type AtomKey, FamilyTracker, Future, IMPLICIT, LazyMap, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadonlySelector, type ReadonlySelectorKey, type Selector, type SelectorKey, type Signal, type StateKey, Store, type StoreCore, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionIdle, type TransactionPhase, type TransactionStatus, type TransactionUpdateInProgress, type Transceiver, type TransceiverMode, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, target, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -378,12 +378,22 @@ declare function createReadonlySelectorFamily<T, K extends Json.Serializable>(op
|
|
|
378
378
|
declare function createSelectorFamily<T, K extends Json.Serializable>(options: SelectorFamilyOptions<T, K>, store: Store): SelectorFamily<T, K>;
|
|
379
379
|
declare function createSelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
|
|
380
380
|
|
|
381
|
-
declare
|
|
381
|
+
declare class LazyMap<K, V> extends Map<K, V> {
|
|
382
|
+
protected readonly source: Map<K, V>;
|
|
383
|
+
deleted: Set<K>;
|
|
384
|
+
constructor(source: Map<K, V>);
|
|
385
|
+
get(key: K): V | undefined;
|
|
386
|
+
_has(key: K): boolean;
|
|
387
|
+
has(key: K): boolean;
|
|
388
|
+
delete(key: K): boolean;
|
|
389
|
+
}
|
|
382
390
|
|
|
383
391
|
declare class NotFoundError extends Error {
|
|
384
392
|
constructor(token: ReadonlySelectorToken<any> | StateToken<any>, store: Store);
|
|
385
393
|
}
|
|
386
394
|
|
|
395
|
+
declare const readOrComputeValue: <T>(state: Atom<T> | ReadonlySelector<T> | Selector<T>, store: Store) => T;
|
|
396
|
+
|
|
387
397
|
type Modify<T> = (thing: T) => T;
|
|
388
398
|
declare const become: <T>(nextVersionOfThing: T | Modify<T>) => (originalThing: T) => T;
|
|
389
399
|
|
|
@@ -391,4 +401,4 @@ declare const setAtomOrSelector: <T>(state: Atom<T> | Selector<T>, value: T | ((
|
|
|
391
401
|
|
|
392
402
|
declare const subscribeToRootAtoms: <T>(state: ReadonlySelector<T> | Selector<T>, store: Store) => (() => void)[] | null;
|
|
393
403
|
|
|
394
|
-
export { type Atom, type AtomKey, FamilyTracker, Future, IMPLICIT, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadonlySelector, type ReadonlySelectorKey, type Selector, type SelectorKey, type Signal, type StateKey, Store, type StoreCore, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionIdle, type TransactionPhase, type TransactionStatus, type TransactionUpdateInProgress, type Transceiver, type TransceiverMode, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, target, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
|
404
|
+
export { type Atom, type AtomKey, FamilyTracker, Future, IMPLICIT, LazyMap, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadonlySelector, type ReadonlySelectorKey, type Selector, type SelectorKey, type Signal, type StateKey, Store, type StoreCore, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionIdle, type TransactionPhase, type TransactionStatus, type TransactionUpdateInProgress, type Transceiver, type TransceiverMode, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, target, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
package/internal/dist/index.js
CHANGED
|
@@ -909,6 +909,37 @@ var applyTransaction = (output, store) => {
|
|
|
909
909
|
store.transactionStatus = { phase: `idle` };
|
|
910
910
|
};
|
|
911
911
|
|
|
912
|
+
// src/lazy-map.ts
|
|
913
|
+
var LazyMap = class extends Map {
|
|
914
|
+
constructor(source) {
|
|
915
|
+
super();
|
|
916
|
+
this.source = source;
|
|
917
|
+
this.deleted = /* @__PURE__ */ new Set();
|
|
918
|
+
}
|
|
919
|
+
get(key) {
|
|
920
|
+
const has = super.has(key);
|
|
921
|
+
if (has) {
|
|
922
|
+
return super.get(key);
|
|
923
|
+
}
|
|
924
|
+
if (!this.deleted.has(key) && this.source.has(key)) {
|
|
925
|
+
const value = this.source.get(key);
|
|
926
|
+
super.set(key, value);
|
|
927
|
+
return value;
|
|
928
|
+
}
|
|
929
|
+
return void 0;
|
|
930
|
+
}
|
|
931
|
+
_has(key) {
|
|
932
|
+
return super.has(key);
|
|
933
|
+
}
|
|
934
|
+
has(key) {
|
|
935
|
+
return !this.deleted.has(key) && (super.has(key) || this.source.has(key));
|
|
936
|
+
}
|
|
937
|
+
delete(key) {
|
|
938
|
+
this.deleted.add(key);
|
|
939
|
+
return super.delete(key);
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
|
|
912
943
|
// src/transaction/build-transaction.ts
|
|
913
944
|
var buildTransaction = (key, params, store) => {
|
|
914
945
|
store.transactionStatus = {
|
|
@@ -916,21 +947,21 @@ var buildTransaction = (key, params, store) => {
|
|
|
916
947
|
phase: `building`,
|
|
917
948
|
time: Date.now(),
|
|
918
949
|
core: {
|
|
919
|
-
atoms: new
|
|
950
|
+
atoms: new LazyMap(store.atoms),
|
|
920
951
|
atomsThatAreDefault: new Set(store.atomsThatAreDefault),
|
|
921
|
-
families: new
|
|
952
|
+
families: new LazyMap(store.families),
|
|
922
953
|
operation: { open: false },
|
|
923
|
-
readonlySelectors: new
|
|
924
|
-
timelines: new
|
|
954
|
+
readonlySelectors: new LazyMap(store.readonlySelectors),
|
|
955
|
+
timelines: new LazyMap(store.timelines),
|
|
925
956
|
timelineAtoms: new Junction(store.timelineAtoms.toJSON()),
|
|
926
957
|
trackers: /* @__PURE__ */ new Map(),
|
|
927
|
-
transactions: new
|
|
958
|
+
transactions: new LazyMap(store.transactions),
|
|
928
959
|
selectorAtoms: new Junction(store.selectorAtoms.toJSON()),
|
|
929
960
|
selectorGraph: new Junction(store.selectorGraph.toJSON(), {
|
|
930
961
|
makeContentKey: (...keys) => keys.sort().join(`:`)
|
|
931
962
|
}),
|
|
932
|
-
selectors: new
|
|
933
|
-
valueMap: new
|
|
963
|
+
selectors: new LazyMap(store.selectors),
|
|
964
|
+
valueMap: new LazyMap(store.valueMap)
|
|
934
965
|
},
|
|
935
966
|
atomUpdates: [],
|
|
936
967
|
params,
|
|
@@ -2090,6 +2121,6 @@ var subscribeToRootAtoms = (state, store) => {
|
|
|
2090
2121
|
return dependencySubscriptions;
|
|
2091
2122
|
};
|
|
2092
2123
|
|
|
2093
|
-
export { FamilyTracker, Future, IMPLICIT, NotFoundError, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, target, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
|
2124
|
+
export { FamilyTracker, Future, IMPLICIT, LazyMap, NotFoundError, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, createTimeline, createTransaction, deleteAtom, deleteSelector, deposit, evictCachedValue, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, readOrComputeValue, redoTransactionUpdate, registerSelector, setAtomOrSelector, subscribeToRootAtoms, target, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, undoTransactionUpdate, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
|
|
2094
2125
|
//# sourceMappingURL=out.js.map
|
|
2095
2126
|
//# sourceMappingURL=index.js.map
|