atom.io 0.20.3 → 0.21.0
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/data/dist/index.cjs +1 -1
- package/data/dist/index.js +1 -1
- package/data/src/join.ts +2 -2
- package/dist/{chunk-SMZRGPN6.js → chunk-KGZGBCYS.js} +2 -2
- package/dist/chunk-PNIHPILQ.js +8 -0
- package/dist/{chunk-2AIFLP2B.js → chunk-RT43TVKP.js} +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -7
- package/internal/dist/index.cjs +31 -26
- package/internal/dist/index.d.ts +10 -6
- package/internal/dist/index.js +30 -25
- package/internal/src/atom/create-regular-atom.ts +1 -1
- package/internal/src/atom/dispose-atom.ts +42 -0
- package/internal/src/atom/index.ts +1 -1
- package/internal/src/selector/{delete-selector.ts → dispose-selector.ts} +3 -2
- package/internal/src/selector/index.ts +1 -1
- package/internal/src/store/deposit.ts +5 -0
- package/internal/src/store/store.ts +5 -1
- package/introspection/dist/index.cjs +250 -106
- package/introspection/dist/index.d.ts +43 -6
- package/introspection/dist/index.js +225 -83
- package/introspection/src/attach-atom-index.ts +68 -47
- package/introspection/src/attach-selector-index.ts +76 -59
- package/introspection/src/auditor.ts +135 -0
- package/introspection/src/index.ts +8 -18
- package/package.json +9 -9
- package/react-devtools/dist/index.cjs +3 -3
- package/react-devtools/dist/index.d.ts +5 -5
- package/react-devtools/dist/index.js +4 -4
- package/react-devtools/src/StateIndex.tsx +8 -27
- package/realtime-client/dist/index.cjs +1 -1
- package/realtime-client/dist/index.js +1 -1
- package/realtime-client/src/sync-continuity.ts +2 -2
- package/realtime-react/dist/index.cjs +1 -1
- package/realtime-react/dist/index.js +1 -1
- package/realtime-server/dist/index.cjs +2 -2
- package/realtime-server/dist/index.js +1 -1
- package/realtime-testing/dist/index.cjs +4 -4
- package/realtime-testing/dist/index.js +1 -1
- package/src/dispose.ts +3 -3
- package/internal/src/atom/delete-atom.ts +0 -40
package/data/dist/index.cjs
CHANGED
|
@@ -443,7 +443,7 @@ var Join = class _Join {
|
|
|
443
443
|
set(find(contentAtoms, key), content);
|
|
444
444
|
};
|
|
445
445
|
const deleteContent = ({ find }, key) => {
|
|
446
|
-
atom_io.
|
|
446
|
+
atom_io.disposeState(find(contentAtoms, key));
|
|
447
447
|
};
|
|
448
448
|
const externalStoreWithContentConfiguration = {
|
|
449
449
|
getContent: (contentKey) => {
|
package/data/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-
|
|
1
|
+
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-KGZGBCYS.js';
|
|
2
2
|
import '../../dist/chunk-FTONNX2R.js';
|
|
3
3
|
import '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { createStandaloneSelector, findInStore, IMPLICIT, createRegularAtom, createRegularAtomFamily, createSelectorFamily } from 'atom.io/internal';
|
package/data/src/join.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
Transactors,
|
|
11
11
|
Write,
|
|
12
12
|
} from "atom.io"
|
|
13
|
-
import {
|
|
13
|
+
import { disposeState, findState, getState, setState } from "atom.io"
|
|
14
14
|
import type { Store } from "atom.io/internal"
|
|
15
15
|
import {
|
|
16
16
|
createMutableAtomFamily,
|
|
@@ -343,7 +343,7 @@ export class Join<
|
|
|
343
343
|
set(find(contentAtoms, key), content)
|
|
344
344
|
}
|
|
345
345
|
const deleteContent: Write<(key: string) => void> = ({ find }, key) => {
|
|
346
|
-
|
|
346
|
+
disposeState(find(contentAtoms, key))
|
|
347
347
|
}
|
|
348
348
|
const externalStoreWithContentConfiguration = {
|
|
349
349
|
getContent: (contentKey: string) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Junction } from './chunk-FTONNX2R.js';
|
|
2
|
-
import {
|
|
2
|
+
import { disposeState } from 'atom.io';
|
|
3
3
|
import { getFromStore, setIntoStore, findInStore, createMutableAtomFamily, createRegularAtomFamily, IMPLICIT, newest, isChildStore, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
4
4
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
5
5
|
|
|
@@ -166,7 +166,7 @@ var Join = class _Join {
|
|
|
166
166
|
set(find(contentAtoms, key), content);
|
|
167
167
|
};
|
|
168
168
|
const deleteContent = ({ find }, key) => {
|
|
169
|
-
|
|
169
|
+
disposeState(find(contentAtoms, key));
|
|
170
170
|
};
|
|
171
171
|
const externalStoreWithContentConfiguration = {
|
|
172
172
|
getContent: (contentKey) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFromStore, assignTransactionToContinuity, subscribeToTransaction, setIntoStore,
|
|
1
|
+
import { getFromStore, assignTransactionToContinuity, subscribeToTransaction, setIntoStore, disposeAtom, setEpochNumberOfContinuity, getEpochNumberOfContinuity, isRootStore, ingestTransactionUpdate, getJsonToken, actUponStore } from 'atom.io/internal';
|
|
2
2
|
import { optimisticUpdateQueue, confirmedUpdateQueue } from 'atom.io/realtime-client';
|
|
3
3
|
|
|
4
4
|
// realtime-client/src/sync-continuity.ts
|
|
@@ -313,7 +313,7 @@ function syncContinuity(continuity, socket, store) {
|
|
|
313
313
|
`conceal:${continuityKey}`,
|
|
314
314
|
(concealed) => {
|
|
315
315
|
for (const token of concealed) {
|
|
316
|
-
|
|
316
|
+
disposeAtom(token, store);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
);
|
package/dist/index.cjs
CHANGED
|
@@ -29,15 +29,15 @@ function atom(options) {
|
|
|
29
29
|
function atomFamily(options) {
|
|
30
30
|
return Internal.createAtomFamily(options, Internal.IMPLICIT.STORE);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function disposeState(token, store = Internal__namespace.IMPLICIT.STORE) {
|
|
33
33
|
switch (token.type) {
|
|
34
34
|
case `atom`:
|
|
35
35
|
case `mutable_atom`:
|
|
36
|
-
Internal__namespace.
|
|
36
|
+
Internal__namespace.disposeAtom(token, store);
|
|
37
37
|
break;
|
|
38
38
|
case `selector`:
|
|
39
39
|
case `readonly_selector`:
|
|
40
|
-
Internal__namespace.
|
|
40
|
+
Internal__namespace.disposeSelector(token, store);
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -170,7 +170,7 @@ exports.Silo = Silo;
|
|
|
170
170
|
exports.atom = atom;
|
|
171
171
|
exports.atomFamily = atomFamily;
|
|
172
172
|
exports.belongsTo = belongsTo;
|
|
173
|
-
exports.
|
|
173
|
+
exports.disposeState = disposeState;
|
|
174
174
|
exports.findState = findState;
|
|
175
175
|
exports.getState = getState;
|
|
176
176
|
exports.isToken = isToken;
|
package/dist/index.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ type SelectorFamilyToken<T, K extends Json.Serializable> = ReadonlySelectorFamil
|
|
|
153
153
|
declare function selectorFamily<T, K extends Json.Serializable>(options: WritableSelectorFamilyOptions<T, K>): WritableSelectorFamilyTokenWithCall<T, K>;
|
|
154
154
|
declare function selectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamilyTokenWithCall<T, K>;
|
|
155
155
|
|
|
156
|
-
declare function
|
|
156
|
+
declare function disposeState(token: ReadableToken<any>, store?: Internal.Store): void;
|
|
157
157
|
|
|
158
158
|
declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(token: MutableAtomFamilyToken$1<T, J, K>, key: Key): MutableAtomToken$1<T, J>;
|
|
159
159
|
declare function findState<T, K extends Json.Serializable, Key extends K>(token: RegularAtomFamilyToken$1<T, K>, key: Key): RegularAtomToken$1<T>;
|
|
@@ -336,4 +336,4 @@ type FamilyMetadata = {
|
|
|
336
336
|
subKey: string;
|
|
337
337
|
};
|
|
338
338
|
|
|
339
|
-
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomToken, type Effectors, type FamilyMetadata, type Func, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, Silo, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type Transactors, type TransactorsWithRunAndEnv, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo,
|
|
339
|
+
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomToken, type Effectors, type FamilyMetadata, type Func, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomFamilyTokenWithCall, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorFamilyTokenWithCall, type ReadonlySelectorOptions, type ReadonlySelectorToken, type ReadonlyTransactors, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomFamilyTokenWithCall, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, Silo, type StateUpdate, type TimelineManageable, type TimelineOptions, type TimelineToken, type TimelineUpdate, type TokenDenomination, type TokenType, type Transact, type TransactionIO, type TransactionOptions, type TransactionToken, type TransactionUpdate, type TransactionUpdateContent, type TransactionUpdateHandler, type Transactors, type TransactorsWithRunAndEnv, type UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorFamilyTokenWithCall, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState, findState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { getState } from './chunk-PNIHPILQ.js';
|
|
1
2
|
import './chunk-F2X4B4VY.js';
|
|
2
3
|
import * as Internal from 'atom.io/internal';
|
|
3
4
|
import { createStandaloneAtom, IMPLICIT, createAtomFamily, findInStore, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, getFromStore, setIntoStore, timeTravel, subscribeToTimeline, subscribeToTransaction, subscribeToState, arbitrary, actUponStore } from 'atom.io/internal';
|
|
@@ -8,15 +9,15 @@ function atom(options) {
|
|
|
8
9
|
function atomFamily(options) {
|
|
9
10
|
return createAtomFamily(options, IMPLICIT.STORE);
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function disposeState(token, store = Internal.IMPLICIT.STORE) {
|
|
12
13
|
switch (token.type) {
|
|
13
14
|
case `atom`:
|
|
14
15
|
case `mutable_atom`:
|
|
15
|
-
Internal.
|
|
16
|
+
Internal.disposeAtom(token, store);
|
|
16
17
|
break;
|
|
17
18
|
case `selector`:
|
|
18
19
|
case `readonly_selector`:
|
|
19
|
-
Internal.
|
|
20
|
+
Internal.disposeSelector(token, store);
|
|
20
21
|
break;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -24,9 +25,6 @@ function findState(token, key) {
|
|
|
24
25
|
const state = findInStore(token, key, IMPLICIT.STORE);
|
|
25
26
|
return state;
|
|
26
27
|
}
|
|
27
|
-
function getState(token) {
|
|
28
|
-
return Internal.getFromStore(token, Internal.IMPLICIT.STORE);
|
|
29
|
-
}
|
|
30
28
|
|
|
31
29
|
// src/logger.ts
|
|
32
30
|
var LOG_LEVELS = [`info`, `warn`, `error`];
|
|
@@ -143,4 +141,4 @@ function belongsTo(family, unknownToken) {
|
|
|
143
141
|
return family.key === ((_a = unknownToken.family) == null ? void 0 : _a.key);
|
|
144
142
|
}
|
|
145
143
|
|
|
146
|
-
export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, belongsTo,
|
|
144
|
+
export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, belongsTo, disposeState, findState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
package/internal/dist/index.cjs
CHANGED
|
@@ -436,9 +436,11 @@ var Store = class {
|
|
|
436
436
|
);
|
|
437
437
|
this.on = {
|
|
438
438
|
atomCreation: new Subject(),
|
|
439
|
+
atomDisposal: new Subject(),
|
|
439
440
|
selectorCreation: new Subject(),
|
|
440
|
-
|
|
441
|
+
selectorDisposal: new Subject(),
|
|
441
442
|
timelineCreation: new Subject(),
|
|
443
|
+
transactionCreation: new Subject(),
|
|
442
444
|
transactionApplying: new StatefulSubject(
|
|
443
445
|
null
|
|
444
446
|
),
|
|
@@ -1220,8 +1222,8 @@ function createStandaloneSelector(options, store) {
|
|
|
1220
1222
|
return createReadonlySelector(options, void 0, store);
|
|
1221
1223
|
}
|
|
1222
1224
|
|
|
1223
|
-
// internal/src/selector/
|
|
1224
|
-
function
|
|
1225
|
+
// internal/src/selector/dispose-selector.ts
|
|
1226
|
+
function disposeSelector(selectorToken, store) {
|
|
1225
1227
|
const target = newest(store);
|
|
1226
1228
|
const { key } = selectorToken;
|
|
1227
1229
|
switch (selectorToken.type) {
|
|
@@ -1242,11 +1244,12 @@ function deleteSelector(selectorToken, store) {
|
|
|
1242
1244
|
);
|
|
1243
1245
|
for (const downstreamToken of downstreamTokens) {
|
|
1244
1246
|
if (downstreamToken) {
|
|
1245
|
-
|
|
1247
|
+
disposeSelector(downstreamToken, store);
|
|
1246
1248
|
}
|
|
1247
1249
|
}
|
|
1248
1250
|
target.selectorGraph.delete(key);
|
|
1249
1251
|
store.logger.info(`\u{1F525}`, selectorToken.type, key, `deleted`);
|
|
1252
|
+
store.on.selectorDisposal.next(selectorToken);
|
|
1250
1253
|
}
|
|
1251
1254
|
|
|
1252
1255
|
// internal/src/subscribe/recall-state.ts
|
|
@@ -1875,8 +1878,8 @@ function createStandaloneAtom(options, store) {
|
|
|
1875
1878
|
return createRegularAtom(options, void 0, store);
|
|
1876
1879
|
}
|
|
1877
1880
|
|
|
1878
|
-
// internal/src/atom/
|
|
1879
|
-
function
|
|
1881
|
+
// internal/src/atom/dispose-atom.ts
|
|
1882
|
+
function disposeAtom(atomToken, store) {
|
|
1880
1883
|
var _a, _b;
|
|
1881
1884
|
const target = newest(store);
|
|
1882
1885
|
const { key } = atomToken;
|
|
@@ -1888,27 +1891,29 @@ function deleteAtom(atomToken, store) {
|
|
|
1888
1891
|
key,
|
|
1889
1892
|
`Tried to delete atom, but it does not exist in the store.`
|
|
1890
1893
|
);
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1894
|
+
} else {
|
|
1895
|
+
(_a = atom.cleanup) == null ? void 0 : _a.call(atom);
|
|
1896
|
+
target.atoms.delete(key);
|
|
1897
|
+
target.valueMap.delete(key);
|
|
1898
|
+
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
1899
|
+
if (selectorKeys) {
|
|
1900
|
+
for (const selectorKey of selectorKeys) {
|
|
1901
|
+
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
1902
|
+
if (token) {
|
|
1903
|
+
disposeSelector(token, store);
|
|
1904
|
+
}
|
|
1901
1905
|
}
|
|
1902
1906
|
}
|
|
1907
|
+
target.selectorAtoms.delete(key);
|
|
1908
|
+
target.atomsThatAreDefault.delete(key);
|
|
1909
|
+
target.timelineAtoms.delete(key);
|
|
1910
|
+
if (atomToken.type === `mutable_atom`) {
|
|
1911
|
+
const updateToken = getUpdateToken(atomToken);
|
|
1912
|
+
disposeAtom(updateToken, store);
|
|
1913
|
+
}
|
|
1914
|
+
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1915
|
+
store.on.atomDisposal.next(atomToken);
|
|
1903
1916
|
}
|
|
1904
|
-
target.selectorAtoms.delete(key);
|
|
1905
|
-
target.atomsThatAreDefault.delete(key);
|
|
1906
|
-
target.timelineAtoms.delete(key);
|
|
1907
|
-
if (atomToken.type === `mutable_atom`) {
|
|
1908
|
-
const updateToken = getUpdateToken(atomToken);
|
|
1909
|
-
deleteAtom(updateToken, store);
|
|
1910
|
-
}
|
|
1911
|
-
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1912
1917
|
}
|
|
1913
1918
|
|
|
1914
1919
|
// internal/src/get-environment-data.ts
|
|
@@ -2597,9 +2602,9 @@ exports.createStandaloneSelector = createStandaloneSelector;
|
|
|
2597
2602
|
exports.createTimeline = createTimeline;
|
|
2598
2603
|
exports.createTransaction = createTransaction;
|
|
2599
2604
|
exports.createWritableSelector = createWritableSelector;
|
|
2600
|
-
exports.deleteAtom = deleteAtom;
|
|
2601
|
-
exports.deleteSelector = deleteSelector;
|
|
2602
2605
|
exports.deposit = deposit;
|
|
2606
|
+
exports.disposeAtom = disposeAtom;
|
|
2607
|
+
exports.disposeSelector = disposeSelector;
|
|
2603
2608
|
exports.evictCachedValue = evictCachedValue;
|
|
2604
2609
|
exports.findInStore = findInStore;
|
|
2605
2610
|
exports.getContinuityKey = getContinuityKey;
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Func, TransactionToken, TransactionUpdate, TransactionOptions, TransactorsWithRunAndEnv, RegularAtomToken, MutableAtomToken, WritableSelectorToken, ReadonlySelectorToken, WritableToken, ReadableToken, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, TimelineUpdate, TimelineOptions, TimelineToken,
|
|
1
|
+
import { Func, TransactionToken, TransactionUpdate, TransactionOptions, TransactorsWithRunAndEnv, RegularAtomToken, MutableAtomToken, AtomToken, WritableSelectorToken, ReadonlySelectorToken, SelectorToken, WritableToken, ReadableToken, TimelineManageable, StateUpdate, TokenType, FamilyMetadata, TimelineUpdate, TimelineOptions, TimelineToken, WritableSelectorFamily, MutableAtomFamily, RegularAtomFamily, ReadonlySelectorFamily, AtomIOLogger, Logger, AtomFamily, SelectorFamily, RegularAtomFamilyToken, MutableAtomFamilyToken, AtomFamilyToken, ReadonlySelectorFamilyToken, WritableSelectorFamilyToken, SelectorFamilyToken, MutableAtomOptions, MutableAtomFamilyOptions, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, WritableFamilyToken, ReadableFamilyToken, KeyedStateUpdate, ReadonlySelectorOptions, WritableSelectorOptions, Transactors, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
2
2
|
import { Json, JsonInterface } from 'atom.io/json';
|
|
3
3
|
|
|
4
4
|
type primitive = boolean | number | string | null;
|
|
@@ -141,8 +141,10 @@ type TransactionEpoch = {
|
|
|
141
141
|
|
|
142
142
|
declare function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>;
|
|
143
143
|
declare function deposit<T extends Transceiver<any>>(state: MutableAtom<T, any>): MutableAtomToken<T, any>;
|
|
144
|
+
declare function deposit<T>(state: Atom<T>): AtomToken<T>;
|
|
144
145
|
declare function deposit<T>(state: WritableSelector<T>): WritableSelectorToken<T>;
|
|
145
146
|
declare function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>;
|
|
147
|
+
declare function deposit<T>(state: Selector<T>): SelectorToken<T>;
|
|
146
148
|
declare function deposit<T>(state: WritableState<T>): WritableToken<T>;
|
|
147
149
|
declare function deposit<T extends Func>(state: Transaction<T>): TransactionToken<T>;
|
|
148
150
|
declare function deposit<T>(state: ReadableState<T>): ReadableToken<T>;
|
|
@@ -221,9 +223,11 @@ declare class Store implements Lineage {
|
|
|
221
223
|
}>;
|
|
222
224
|
on: {
|
|
223
225
|
atomCreation: Subject<AtomToken<unknown>>;
|
|
226
|
+
atomDisposal: Subject<AtomToken<unknown>>;
|
|
224
227
|
selectorCreation: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
|
|
225
|
-
|
|
228
|
+
selectorDisposal: Subject<ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>>;
|
|
226
229
|
timelineCreation: Subject<TimelineToken<unknown>>;
|
|
230
|
+
transactionCreation: Subject<TransactionToken<Func>>;
|
|
227
231
|
transactionApplying: StatefulSubject<TransactionProgress<Func> | null>;
|
|
228
232
|
operationClose: Subject<OperationProgress>;
|
|
229
233
|
};
|
|
@@ -317,12 +321,12 @@ declare class FamilyTracker<Core extends Transceiver<any>, FamilyMemberKey exten
|
|
|
317
321
|
|
|
318
322
|
declare function arbitrary(random?: () => number): string;
|
|
319
323
|
|
|
320
|
-
declare function createRegularAtom<T>(options:
|
|
324
|
+
declare function createRegularAtom<T>(options: RegularAtomOptions<T>, family: FamilyMetadata | undefined, store: Store): RegularAtomToken<T>;
|
|
321
325
|
|
|
322
326
|
declare function createStandaloneAtom<T>(options: RegularAtomOptions<T>, store: Store): RegularAtomToken<T>;
|
|
323
327
|
declare function createStandaloneAtom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>, store: Store): MutableAtomToken<T, J>;
|
|
324
328
|
|
|
325
|
-
declare function
|
|
329
|
+
declare function disposeAtom(atomToken: AtomToken<unknown>, store: Store): void;
|
|
326
330
|
|
|
327
331
|
declare const isAtomDefault: (key: string, store: Store) => boolean;
|
|
328
332
|
declare const markAtomAsDefault: (key: string, store: Store) => void;
|
|
@@ -429,7 +433,7 @@ declare function createStandaloneSelector<T>(options: ReadonlySelectorOptions<T>
|
|
|
429
433
|
|
|
430
434
|
declare const createWritableSelector: <T>(options: WritableSelectorOptions<T>, family: FamilyMetadata | undefined, store: Store) => WritableSelectorToken<T>;
|
|
431
435
|
|
|
432
|
-
declare function
|
|
436
|
+
declare function disposeSelector(selectorToken: ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>, store: Store): void;
|
|
433
437
|
|
|
434
438
|
declare const getSelectorDependencyKeys: (key: string, store: Store) => (AtomKey<unknown> | ReadonlySelectorKey<unknown> | SelectorKey<unknown>)[];
|
|
435
439
|
|
|
@@ -488,4 +492,4 @@ type Selector<T> = ReadonlySelector<T> | WritableSelector<T>;
|
|
|
488
492
|
type WritableState<T> = Atom<T> | WritableSelector<T>;
|
|
489
493
|
type ReadableState<T> = Atom<T> | Selector<T>;
|
|
490
494
|
|
|
491
|
-
export { type Atom, type AtomIOState, type AtomKey, type ChildStore, type EnvironmentData, FamilyTracker, Future, IMPLICIT, LazyMap, type Lineage, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadableState, type ReadonlySelector, type ReadonlySelectorKey, type RegularAtom, type RootStore, type Selector, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableSelector, type WritableState, abortTransaction, actUponStore, addAtomToTimeline, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector,
|
|
495
|
+
export { type Atom, type AtomIOState, type AtomKey, type ChildStore, type EnvironmentData, FamilyTracker, Future, IMPLICIT, LazyMap, type Lineage, type Modify, type MutableAtom, NotFoundError, type OperationProgress, type ReadableState, type ReadonlySelector, type ReadonlySelectorKey, type RegularAtom, type RootStore, type Selector, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineSelectorUpdate, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type Withdrawable, type WritableSelector, type WritableState, abortTransaction, actUponStore, addAtomToTimeline, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeSelector, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, ingestAtomUpdate, ingestSelectorUpdate, ingestTransactionUpdate, isAtomDefault, isAtomKey, isChildStore, isDone, isMutable, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw, withdrawOrCreate };
|
package/internal/dist/index.js
CHANGED
|
@@ -158,9 +158,11 @@ var Store = class {
|
|
|
158
158
|
);
|
|
159
159
|
this.on = {
|
|
160
160
|
atomCreation: new Subject(),
|
|
161
|
+
atomDisposal: new Subject(),
|
|
161
162
|
selectorCreation: new Subject(),
|
|
162
|
-
|
|
163
|
+
selectorDisposal: new Subject(),
|
|
163
164
|
timelineCreation: new Subject(),
|
|
165
|
+
transactionCreation: new Subject(),
|
|
164
166
|
transactionApplying: new StatefulSubject(
|
|
165
167
|
null
|
|
166
168
|
),
|
|
@@ -942,8 +944,8 @@ function createStandaloneSelector(options, store) {
|
|
|
942
944
|
return createReadonlySelector(options, void 0, store);
|
|
943
945
|
}
|
|
944
946
|
|
|
945
|
-
// internal/src/selector/
|
|
946
|
-
function
|
|
947
|
+
// internal/src/selector/dispose-selector.ts
|
|
948
|
+
function disposeSelector(selectorToken, store) {
|
|
947
949
|
const target = newest(store);
|
|
948
950
|
const { key } = selectorToken;
|
|
949
951
|
switch (selectorToken.type) {
|
|
@@ -964,11 +966,12 @@ function deleteSelector(selectorToken, store) {
|
|
|
964
966
|
);
|
|
965
967
|
for (const downstreamToken of downstreamTokens) {
|
|
966
968
|
if (downstreamToken) {
|
|
967
|
-
|
|
969
|
+
disposeSelector(downstreamToken, store);
|
|
968
970
|
}
|
|
969
971
|
}
|
|
970
972
|
target.selectorGraph.delete(key);
|
|
971
973
|
store.logger.info(`\u{1F525}`, selectorToken.type, key, `deleted`);
|
|
974
|
+
store.on.selectorDisposal.next(selectorToken);
|
|
972
975
|
}
|
|
973
976
|
|
|
974
977
|
// internal/src/subscribe/recall-state.ts
|
|
@@ -1597,8 +1600,8 @@ function createStandaloneAtom(options, store) {
|
|
|
1597
1600
|
return createRegularAtom(options, void 0, store);
|
|
1598
1601
|
}
|
|
1599
1602
|
|
|
1600
|
-
// internal/src/atom/
|
|
1601
|
-
function
|
|
1603
|
+
// internal/src/atom/dispose-atom.ts
|
|
1604
|
+
function disposeAtom(atomToken, store) {
|
|
1602
1605
|
var _a, _b;
|
|
1603
1606
|
const target = newest(store);
|
|
1604
1607
|
const { key } = atomToken;
|
|
@@ -1610,27 +1613,29 @@ function deleteAtom(atomToken, store) {
|
|
|
1610
1613
|
key,
|
|
1611
1614
|
`Tried to delete atom, but it does not exist in the store.`
|
|
1612
1615
|
);
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1616
|
+
} else {
|
|
1617
|
+
(_a = atom.cleanup) == null ? void 0 : _a.call(atom);
|
|
1618
|
+
target.atoms.delete(key);
|
|
1619
|
+
target.valueMap.delete(key);
|
|
1620
|
+
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
1621
|
+
if (selectorKeys) {
|
|
1622
|
+
for (const selectorKey of selectorKeys) {
|
|
1623
|
+
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
1624
|
+
if (token) {
|
|
1625
|
+
disposeSelector(token, store);
|
|
1626
|
+
}
|
|
1623
1627
|
}
|
|
1624
1628
|
}
|
|
1629
|
+
target.selectorAtoms.delete(key);
|
|
1630
|
+
target.atomsThatAreDefault.delete(key);
|
|
1631
|
+
target.timelineAtoms.delete(key);
|
|
1632
|
+
if (atomToken.type === `mutable_atom`) {
|
|
1633
|
+
const updateToken = getUpdateToken(atomToken);
|
|
1634
|
+
disposeAtom(updateToken, store);
|
|
1635
|
+
}
|
|
1636
|
+
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1637
|
+
store.on.atomDisposal.next(atomToken);
|
|
1625
1638
|
}
|
|
1626
|
-
target.selectorAtoms.delete(key);
|
|
1627
|
-
target.atomsThatAreDefault.delete(key);
|
|
1628
|
-
target.timelineAtoms.delete(key);
|
|
1629
|
-
if (atomToken.type === `mutable_atom`) {
|
|
1630
|
-
const updateToken = getUpdateToken(atomToken);
|
|
1631
|
-
deleteAtom(updateToken, store);
|
|
1632
|
-
}
|
|
1633
|
-
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1634
1639
|
}
|
|
1635
1640
|
|
|
1636
1641
|
// internal/src/get-environment-data.ts
|
|
@@ -2285,4 +2290,4 @@ function getEpochNumberOfAction(transactionKey, store) {
|
|
|
2285
2290
|
// internal/src/transaction/index.ts
|
|
2286
2291
|
var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
|
|
2287
2292
|
|
|
2288
|
-
export { FamilyTracker, Future, IMPLICIT, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, addAtomToTimeline, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector,
|
|
2293
|
+
export { FamilyTracker, Future, IMPLICIT, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, addAtomToTimeline, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deposit, disposeAtom, disposeSelector, evictCachedValue, findInStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getUpdateToken, ingestAtomUpdate, ingestSelectorUpdate, ingestTransactionUpdate, isAtomDefault, isAtomKey, isChildStore, isDone, isMutable, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, readCachedValue, readOrComputeValue, registerSelector, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw, withdrawOrCreate };
|
|
@@ -16,7 +16,7 @@ import { subscribeToState } from "../subscribe"
|
|
|
16
16
|
import { markAtomAsDefault } from "./is-default"
|
|
17
17
|
|
|
18
18
|
export function createRegularAtom<T>(
|
|
19
|
-
options:
|
|
19
|
+
options: RegularAtomOptions<T>,
|
|
20
20
|
family: FamilyMetadata | undefined,
|
|
21
21
|
store: Store,
|
|
22
22
|
): RegularAtomToken<T> {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AtomToken } from "atom.io"
|
|
2
|
+
|
|
3
|
+
import type { Store } from ".."
|
|
4
|
+
import { disposeSelector, getUpdateToken, newest } from ".."
|
|
5
|
+
|
|
6
|
+
export function disposeAtom(atomToken: AtomToken<unknown>, store: Store): void {
|
|
7
|
+
const target = newest(store)
|
|
8
|
+
const { key } = atomToken
|
|
9
|
+
const atom = target.atoms.get(key)
|
|
10
|
+
if (!atom) {
|
|
11
|
+
store.logger.error(
|
|
12
|
+
`❌`,
|
|
13
|
+
`atom`,
|
|
14
|
+
key,
|
|
15
|
+
`Tried to delete atom, but it does not exist in the store.`,
|
|
16
|
+
)
|
|
17
|
+
} else {
|
|
18
|
+
atom.cleanup?.()
|
|
19
|
+
target.atoms.delete(key)
|
|
20
|
+
target.valueMap.delete(key)
|
|
21
|
+
const selectorKeys = target.selectorAtoms.getRelatedKeys(key)
|
|
22
|
+
if (selectorKeys) {
|
|
23
|
+
for (const selectorKey of selectorKeys) {
|
|
24
|
+
const token =
|
|
25
|
+
target.selectors.get(selectorKey) ??
|
|
26
|
+
target.readonlySelectors.get(selectorKey)
|
|
27
|
+
if (token) {
|
|
28
|
+
disposeSelector(token, store)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
target.selectorAtoms.delete(key)
|
|
33
|
+
target.atomsThatAreDefault.delete(key)
|
|
34
|
+
target.timelineAtoms.delete(key)
|
|
35
|
+
if (atomToken.type === `mutable_atom`) {
|
|
36
|
+
const updateToken = getUpdateToken(atomToken)
|
|
37
|
+
disposeAtom(updateToken, store)
|
|
38
|
+
}
|
|
39
|
+
store.logger.info(`🔥`, `atom`, key, `deleted`)
|
|
40
|
+
store.on.atomDisposal.next(atomToken)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { ReadonlySelectorToken, WritableSelectorToken } from "atom.io"
|
|
|
3
3
|
import type { Store } from ".."
|
|
4
4
|
import { newest } from ".."
|
|
5
5
|
|
|
6
|
-
export function
|
|
6
|
+
export function disposeSelector(
|
|
7
7
|
selectorToken: ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>,
|
|
8
8
|
store: Store,
|
|
9
9
|
): void {
|
|
@@ -29,9 +29,10 @@ export function deleteSelector(
|
|
|
29
29
|
)
|
|
30
30
|
for (const downstreamToken of downstreamTokens) {
|
|
31
31
|
if (downstreamToken) {
|
|
32
|
-
|
|
32
|
+
disposeSelector(downstreamToken, store)
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
target.selectorGraph.delete(key)
|
|
36
36
|
store.logger.info(`🔥`, selectorToken.type, key, `deleted`)
|
|
37
|
+
store.on.selectorDisposal.next(selectorToken)
|
|
37
38
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./create-readonly-selector"
|
|
2
2
|
export * from "./create-standalone-selector"
|
|
3
3
|
export * from "./create-writable-selector"
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./dispose-selector"
|
|
5
5
|
export * from "./get-selector-dependency-keys"
|
|
6
6
|
export * from "./register-selector"
|
|
7
7
|
export * from "./trace-selector-atoms"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
AtomToken,
|
|
2
3
|
Func,
|
|
3
4
|
MutableAtomToken,
|
|
4
5
|
ReadableToken,
|
|
@@ -11,10 +12,12 @@ import type {
|
|
|
11
12
|
} from "atom.io"
|
|
12
13
|
|
|
13
14
|
import type {
|
|
15
|
+
Atom,
|
|
14
16
|
MutableAtom,
|
|
15
17
|
ReadableState,
|
|
16
18
|
ReadonlySelector,
|
|
17
19
|
RegularAtom,
|
|
20
|
+
Selector,
|
|
18
21
|
Transceiver,
|
|
19
22
|
WritableSelector,
|
|
20
23
|
WritableState,
|
|
@@ -25,8 +28,10 @@ export function deposit<T>(state: RegularAtom<T>): RegularAtomToken<T>
|
|
|
25
28
|
export function deposit<T extends Transceiver<any>>(
|
|
26
29
|
state: MutableAtom<T, any>,
|
|
27
30
|
): MutableAtomToken<T, any>
|
|
31
|
+
export function deposit<T>(state: Atom<T>): AtomToken<T>
|
|
28
32
|
export function deposit<T>(state: WritableSelector<T>): WritableSelectorToken<T>
|
|
29
33
|
export function deposit<T>(state: ReadonlySelector<T>): ReadonlySelectorToken<T>
|
|
34
|
+
export function deposit<T>(state: Selector<T>): SelectorToken<T>
|
|
30
35
|
export function deposit<T>(state: WritableState<T>): WritableToken<T>
|
|
31
36
|
export function deposit<T extends Func>(
|
|
32
37
|
state: Transaction<T>,
|
|
@@ -82,11 +82,15 @@ export class Store implements Lineage {
|
|
|
82
82
|
|
|
83
83
|
public on = {
|
|
84
84
|
atomCreation: new Subject<AtomToken<unknown>>(),
|
|
85
|
+
atomDisposal: new Subject<AtomToken<unknown>>(),
|
|
85
86
|
selectorCreation: new Subject<
|
|
86
87
|
ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>
|
|
87
88
|
>(),
|
|
88
|
-
|
|
89
|
+
selectorDisposal: new Subject<
|
|
90
|
+
ReadonlySelectorToken<unknown> | WritableSelectorToken<unknown>
|
|
91
|
+
>(),
|
|
89
92
|
timelineCreation: new Subject<TimelineToken<unknown>>(),
|
|
93
|
+
transactionCreation: new Subject<TransactionToken<Func>>(),
|
|
90
94
|
transactionApplying: new StatefulSubject<TransactionProgress<Func> | null>(
|
|
91
95
|
null,
|
|
92
96
|
),
|