atom.io 0.20.3 → 0.21.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/data/dist/index.cjs +4 -4
- package/data/dist/index.js +1 -1
- package/data/src/join.ts +3 -8
- package/dist/{chunk-SMZRGPN6.js → chunk-HITX3MO4.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 +56 -74
- package/internal/dist/index.d.ts +11 -7
- package/internal/dist/index.js +55 -73
- 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/future.ts +6 -20
- package/internal/src/get-state/get-from-store.ts +1 -2
- package/internal/src/mutable/tracker.ts +2 -24
- package/internal/src/operation.ts +0 -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/internal/src/subscribe/recall-state.ts +3 -3
- package/internal/src/subscribe/subscribe-to-state.ts +16 -3
- package/introspection/dist/index.cjs +251 -119
- package/introspection/dist/index.d.ts +43 -6
- package/introspection/dist/index.js +226 -96
- package/introspection/src/attach-atom-index.ts +68 -47
- package/introspection/src/attach-introspection-states.ts +0 -1
- package/introspection/src/attach-selector-index.ts +76 -59
- package/introspection/src/attach-timeline-family.ts +2 -17
- package/introspection/src/auditor.ts +135 -0
- package/introspection/src/index.ts +8 -18
- package/package.json +12 -12
- 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/src/validators.ts +0 -6
- package/internal/src/atom/delete-atom.ts +0 -40
package/data/dist/index.cjs
CHANGED
|
@@ -5,14 +5,14 @@ var atom_io = require('atom.io');
|
|
|
5
5
|
var setRtx = require('atom.io/transceivers/set-rtx');
|
|
6
6
|
|
|
7
7
|
// data/src/dict.ts
|
|
8
|
-
function dict(
|
|
8
|
+
function dict(findState, index, store = internal.IMPLICIT.STORE) {
|
|
9
9
|
return internal.createStandaloneSelector(
|
|
10
10
|
{
|
|
11
|
-
key: `${
|
|
11
|
+
key: `${findState.key}Dict`,
|
|
12
12
|
get: ({ get }) => {
|
|
13
13
|
const keys = get(index);
|
|
14
14
|
return keys.reduce((acc, key) => {
|
|
15
|
-
acc[key] = get(internal.findInStore(
|
|
15
|
+
acc[key] = get(internal.findInStore(findState, key, store));
|
|
16
16
|
return acc;
|
|
17
17
|
}, {});
|
|
18
18
|
}
|
|
@@ -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-HITX3MO4.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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
2
|
import type {
|
|
3
|
+
findState,
|
|
3
4
|
MutableAtomFamily,
|
|
4
5
|
MutableAtomFamilyToken,
|
|
5
6
|
MutableAtomToken,
|
|
@@ -10,7 +11,7 @@ import type {
|
|
|
10
11
|
Transactors,
|
|
11
12
|
Write,
|
|
12
13
|
} from "atom.io"
|
|
13
|
-
import {
|
|
14
|
+
import { disposeState, getState, setState } from "atom.io"
|
|
14
15
|
import type { Store } from "atom.io/internal"
|
|
15
16
|
import {
|
|
16
17
|
createMutableAtomFamily,
|
|
@@ -37,12 +38,6 @@ import type {
|
|
|
37
38
|
import { Junction } from "~/packages/rel8/junction/src"
|
|
38
39
|
import type * as Rel8 from "~/packages/rel8/types/src"
|
|
39
40
|
|
|
40
|
-
const TRANSACTORS: Transactors = {
|
|
41
|
-
get: getState,
|
|
42
|
-
set: setState,
|
|
43
|
-
find: findState,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
41
|
function capitalize<S extends string>(string: S): Capitalize<S> {
|
|
47
42
|
return (string[0].toUpperCase() + string.slice(1)) as Capitalize<S>
|
|
48
43
|
}
|
|
@@ -343,7 +338,7 @@ export class Join<
|
|
|
343
338
|
set(find(contentAtoms, key), content)
|
|
344
339
|
}
|
|
345
340
|
const deleteContent: Write<(key: string) => void> = ({ find }, key) => {
|
|
346
|
-
|
|
341
|
+
disposeState(find(contentAtoms, key))
|
|
347
342
|
}
|
|
348
343
|
const externalStoreWithContentConfiguration = {
|
|
349
344
|
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
|
@@ -31,44 +31,30 @@ function arbitrary(random = Math.random) {
|
|
|
31
31
|
// internal/src/future.ts
|
|
32
32
|
var Future = class extends Promise {
|
|
33
33
|
constructor(executor) {
|
|
34
|
-
let promise;
|
|
35
34
|
let superResolve;
|
|
36
35
|
let superReject;
|
|
37
36
|
super((resolve, reject) => {
|
|
38
37
|
superResolve = resolve;
|
|
39
38
|
superReject = reject;
|
|
40
|
-
promise = executor instanceof Promise ? executor : new Promise(executor);
|
|
41
|
-
promise.then(
|
|
42
|
-
(value) => {
|
|
43
|
-
if (promise) {
|
|
44
|
-
this.pass(promise, value);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
(reason) => {
|
|
48
|
-
if (promise) {
|
|
49
|
-
this.fail(promise, reason);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
39
|
});
|
|
54
|
-
this.destiny = promise;
|
|
55
40
|
this.resolve = superResolve;
|
|
56
41
|
this.reject = superReject;
|
|
42
|
+
this.use(executor instanceof Promise ? executor : new Promise(executor));
|
|
57
43
|
}
|
|
58
44
|
pass(promise, value) {
|
|
59
|
-
if (promise === this.
|
|
45
|
+
if (promise === this.fate) {
|
|
60
46
|
this.resolve(value);
|
|
61
47
|
}
|
|
62
48
|
}
|
|
63
49
|
fail(promise, reason) {
|
|
64
|
-
if (promise === this.
|
|
50
|
+
if (promise === this.fate) {
|
|
65
51
|
this.reject(reason);
|
|
66
52
|
}
|
|
67
53
|
}
|
|
68
54
|
use(value) {
|
|
69
55
|
if (value instanceof Promise) {
|
|
70
56
|
const promise = value;
|
|
71
|
-
this.
|
|
57
|
+
this.fate = promise;
|
|
72
58
|
promise.then(
|
|
73
59
|
(resolved) => {
|
|
74
60
|
this.pass(promise, resolved);
|
|
@@ -79,7 +65,7 @@ var Future = class extends Promise {
|
|
|
79
65
|
);
|
|
80
66
|
} else {
|
|
81
67
|
this.resolve(value);
|
|
82
|
-
this.
|
|
68
|
+
this.fate = void 0;
|
|
83
69
|
}
|
|
84
70
|
}
|
|
85
71
|
};
|
|
@@ -436,9 +422,11 @@ var Store = class {
|
|
|
436
422
|
);
|
|
437
423
|
this.on = {
|
|
438
424
|
atomCreation: new Subject(),
|
|
425
|
+
atomDisposal: new Subject(),
|
|
439
426
|
selectorCreation: new Subject(),
|
|
440
|
-
|
|
427
|
+
selectorDisposal: new Subject(),
|
|
441
428
|
timelineCreation: new Subject(),
|
|
429
|
+
transactionCreation: new Subject(),
|
|
442
430
|
transactionApplying: new StatefulSubject(
|
|
443
431
|
null
|
|
444
432
|
),
|
|
@@ -1220,8 +1208,8 @@ function createStandaloneSelector(options, store) {
|
|
|
1220
1208
|
return createReadonlySelector(options, void 0, store);
|
|
1221
1209
|
}
|
|
1222
1210
|
|
|
1223
|
-
// internal/src/selector/
|
|
1224
|
-
function
|
|
1211
|
+
// internal/src/selector/dispose-selector.ts
|
|
1212
|
+
function disposeSelector(selectorToken, store) {
|
|
1225
1213
|
const target = newest(store);
|
|
1226
1214
|
const { key } = selectorToken;
|
|
1227
1215
|
switch (selectorToken.type) {
|
|
@@ -1242,20 +1230,21 @@ function deleteSelector(selectorToken, store) {
|
|
|
1242
1230
|
);
|
|
1243
1231
|
for (const downstreamToken of downstreamTokens) {
|
|
1244
1232
|
if (downstreamToken) {
|
|
1245
|
-
|
|
1233
|
+
disposeSelector(downstreamToken, store);
|
|
1246
1234
|
}
|
|
1247
1235
|
}
|
|
1248
1236
|
target.selectorGraph.delete(key);
|
|
1249
1237
|
store.logger.info(`\u{1F525}`, selectorToken.type, key, `deleted`);
|
|
1238
|
+
store.on.selectorDisposal.next(selectorToken);
|
|
1250
1239
|
}
|
|
1251
1240
|
|
|
1252
1241
|
// internal/src/subscribe/recall-state.ts
|
|
1253
1242
|
var recallState = (state, store) => {
|
|
1254
1243
|
const target = newest(store);
|
|
1255
|
-
if (
|
|
1256
|
-
return target.
|
|
1244
|
+
if (target.operation.open) {
|
|
1245
|
+
return target.operation.prev.get(state.key);
|
|
1257
1246
|
}
|
|
1258
|
-
return target.
|
|
1247
|
+
return target.valueMap.get(state.key);
|
|
1259
1248
|
};
|
|
1260
1249
|
|
|
1261
1250
|
// internal/src/subscribe/subscribe-to-root-atoms.ts
|
|
@@ -1304,11 +1293,24 @@ var subscribeToRootAtoms = (selector, store) => {
|
|
|
1304
1293
|
|
|
1305
1294
|
// internal/src/subscribe/subscribe-to-state.ts
|
|
1306
1295
|
function subscribeToState(token, handleUpdate, key, store) {
|
|
1296
|
+
function safelyHandleUpdate(update) {
|
|
1297
|
+
if (store.operation.open) {
|
|
1298
|
+
const unsubscribe2 = store.on.operationClose.subscribe(
|
|
1299
|
+
`state subscription ${key}`,
|
|
1300
|
+
() => {
|
|
1301
|
+
unsubscribe2();
|
|
1302
|
+
handleUpdate(update);
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
} else {
|
|
1306
|
+
handleUpdate(update);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1307
1309
|
const state = withdrawOrCreate(token, store);
|
|
1308
1310
|
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
1309
1311
|
const isSelector = state.type === `selector` || state.type === `readonly_selector`;
|
|
1310
1312
|
let dependencyUnsubFunctions = null;
|
|
1311
|
-
let updateHandler =
|
|
1313
|
+
let updateHandler = safelyHandleUpdate;
|
|
1312
1314
|
if (isSelector) {
|
|
1313
1315
|
dependencyUnsubFunctions = subscribeToRootAtoms(state, store);
|
|
1314
1316
|
updateHandler = (update) => {
|
|
@@ -1316,7 +1318,7 @@ function subscribeToState(token, handleUpdate, key, store) {
|
|
|
1316
1318
|
dependencyUnsubFunctions.length = 0;
|
|
1317
1319
|
dependencyUnsubFunctions.push(...subscribeToRootAtoms(state, store));
|
|
1318
1320
|
}
|
|
1319
|
-
|
|
1321
|
+
safelyHandleUpdate(update);
|
|
1320
1322
|
};
|
|
1321
1323
|
}
|
|
1322
1324
|
const mainUnsubFunction = state.subject.subscribe(key, updateHandler);
|
|
@@ -1405,18 +1407,7 @@ var Tracker = class {
|
|
|
1405
1407
|
this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
|
|
1406
1408
|
subscriptionKey,
|
|
1407
1409
|
(update) => {
|
|
1408
|
-
|
|
1409
|
-
const unsubscribe = target.on.operationClose.subscribe(
|
|
1410
|
-
subscriptionKey,
|
|
1411
|
-
() => {
|
|
1412
|
-
unsubscribe();
|
|
1413
|
-
setIntoStore(latestUpdateState, update, target);
|
|
1414
|
-
}
|
|
1415
|
-
);
|
|
1416
|
-
} else {
|
|
1417
|
-
setIntoStore(mutableState, (current) => current, target);
|
|
1418
|
-
setIntoStore(latestUpdateState, update, target);
|
|
1419
|
-
}
|
|
1410
|
+
setIntoStore(latestUpdateState, update, target);
|
|
1420
1411
|
}
|
|
1421
1412
|
);
|
|
1422
1413
|
this.unsubscribeFromState = subscribeToState(
|
|
@@ -1427,18 +1418,7 @@ var Tracker = class {
|
|
|
1427
1418
|
this.unsubscribeFromInnerValue = update.newValue.subscribe(
|
|
1428
1419
|
subscriptionKey,
|
|
1429
1420
|
(transceiverUpdate) => {
|
|
1430
|
-
|
|
1431
|
-
const unsubscribe = target.on.operationClose.subscribe(
|
|
1432
|
-
subscriptionKey,
|
|
1433
|
-
() => {
|
|
1434
|
-
unsubscribe();
|
|
1435
|
-
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1436
|
-
}
|
|
1437
|
-
);
|
|
1438
|
-
} else {
|
|
1439
|
-
setIntoStore(mutableState, (current) => current, target);
|
|
1440
|
-
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1441
|
-
}
|
|
1421
|
+
setIntoStore(latestUpdateState, transceiverUpdate, target);
|
|
1442
1422
|
}
|
|
1443
1423
|
);
|
|
1444
1424
|
}
|
|
@@ -1875,8 +1855,8 @@ function createStandaloneAtom(options, store) {
|
|
|
1875
1855
|
return createRegularAtom(options, void 0, store);
|
|
1876
1856
|
}
|
|
1877
1857
|
|
|
1878
|
-
// internal/src/atom/
|
|
1879
|
-
function
|
|
1858
|
+
// internal/src/atom/dispose-atom.ts
|
|
1859
|
+
function disposeAtom(atomToken, store) {
|
|
1880
1860
|
var _a, _b;
|
|
1881
1861
|
const target = newest(store);
|
|
1882
1862
|
const { key } = atomToken;
|
|
@@ -1888,27 +1868,29 @@ function deleteAtom(atomToken, store) {
|
|
|
1888
1868
|
key,
|
|
1889
1869
|
`Tried to delete atom, but it does not exist in the store.`
|
|
1890
1870
|
);
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1871
|
+
} else {
|
|
1872
|
+
(_a = atom.cleanup) == null ? void 0 : _a.call(atom);
|
|
1873
|
+
target.atoms.delete(key);
|
|
1874
|
+
target.valueMap.delete(key);
|
|
1875
|
+
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
1876
|
+
if (selectorKeys) {
|
|
1877
|
+
for (const selectorKey of selectorKeys) {
|
|
1878
|
+
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
1879
|
+
if (token) {
|
|
1880
|
+
disposeSelector(token, store);
|
|
1881
|
+
}
|
|
1901
1882
|
}
|
|
1902
1883
|
}
|
|
1884
|
+
target.selectorAtoms.delete(key);
|
|
1885
|
+
target.atomsThatAreDefault.delete(key);
|
|
1886
|
+
target.timelineAtoms.delete(key);
|
|
1887
|
+
if (atomToken.type === `mutable_atom`) {
|
|
1888
|
+
const updateToken = getUpdateToken(atomToken);
|
|
1889
|
+
disposeAtom(updateToken, store);
|
|
1890
|
+
}
|
|
1891
|
+
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1892
|
+
store.on.atomDisposal.next(atomToken);
|
|
1903
1893
|
}
|
|
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
1894
|
}
|
|
1913
1895
|
|
|
1914
1896
|
// internal/src/get-environment-data.ts
|
|
@@ -2597,9 +2579,9 @@ exports.createStandaloneSelector = createStandaloneSelector;
|
|
|
2597
2579
|
exports.createTimeline = createTimeline;
|
|
2598
2580
|
exports.createTransaction = createTransaction;
|
|
2599
2581
|
exports.createWritableSelector = createWritableSelector;
|
|
2600
|
-
exports.deleteAtom = deleteAtom;
|
|
2601
|
-
exports.deleteSelector = deleteSelector;
|
|
2602
2582
|
exports.deposit = deposit;
|
|
2583
|
+
exports.disposeAtom = disposeAtom;
|
|
2584
|
+
exports.disposeSelector = disposeSelector;
|
|
2603
2585
|
exports.evictCachedValue = evictCachedValue;
|
|
2604
2586
|
exports.findInStore = findInStore;
|
|
2605
2587
|
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;
|
|
@@ -338,7 +342,7 @@ declare const markAtomAsNotDefault: (key: string, store: Store) => void;
|
|
|
338
342
|
* Can be constructed like a Promise, or from an existing Promise.
|
|
339
343
|
*/
|
|
340
344
|
declare class Future<T> extends Promise<T> {
|
|
341
|
-
private
|
|
345
|
+
private fate;
|
|
342
346
|
private resolve;
|
|
343
347
|
private reject;
|
|
344
348
|
constructor(executor: Promise<T> | ((resolve: (value: T) => void, reject: (reason?: any) => void) => 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 };
|