atom.io 0.22.0 → 0.23.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 +17 -1
- package/data/dist/index.js +1 -1
- package/data/src/join.ts +30 -1
- package/dist/chunk-6MLFYN32.js +18 -0
- package/dist/{chunk-JA4V7TJY.js → chunk-7DT3PVS3.js} +18 -2
- package/dist/chunk-OAYGID5B.js +27 -0
- package/dist/index.cjs +2 -11
- package/dist/index.d.ts +51 -23
- package/dist/index.js +2 -11
- package/ephemeral/dist/index.d.ts +12 -0
- package/eslint-plugin/dist/index.cjs +0 -1
- package/eslint-plugin/dist/index.d.ts +73 -0
- package/eslint-plugin/dist/index.js +0 -1
- package/eslint-plugin/src/rules/lifespan.ts +0 -1
- package/immortal/dist/index.cjs +180 -20
- package/immortal/dist/index.d.ts +103 -0
- package/immortal/dist/index.js +134 -19
- package/immortal/src/index.ts +1 -0
- package/immortal/src/make-molecule.ts +222 -0
- package/immortal/src/molecule.ts +49 -16
- package/immortal/src/seek-state.ts +15 -2
- package/internal/dist/index.cjs +1119 -754
- package/internal/dist/index.d.ts +109 -12
- package/internal/dist/index.js +1098 -760
- package/internal/src/atom/create-regular-atom.ts +0 -2
- package/internal/src/atom/create-standalone-atom.ts +6 -2
- package/internal/src/atom/dispose-atom.ts +22 -2
- package/internal/src/families/create-readonly-selector-family.ts +7 -2
- package/internal/src/families/create-regular-atom-family.ts +6 -2
- package/internal/src/families/create-writable-selector-family.ts +7 -2
- package/internal/src/families/dispose-from-store.ts +22 -0
- package/internal/src/families/find-in-store.ts +0 -1
- package/internal/src/families/index.ts +1 -0
- package/internal/src/families/init-family-member.ts +22 -1
- package/internal/src/families/seek-in-store.ts +23 -6
- package/internal/src/ingest-updates/index.ts +1 -0
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +104 -0
- package/internal/src/ingest-updates/ingest-transaction-update.ts +26 -4
- package/internal/src/mutable/create-mutable-atom-family.ts +6 -2
- package/internal/src/mutable/create-mutable-atom.ts +0 -2
- package/internal/src/mutable/get-json-token.ts +0 -1
- package/internal/src/mutable/tracker-family.ts +7 -7
- package/internal/src/not-found-error.ts +5 -0
- package/internal/src/selector/create-readonly-selector.ts +2 -3
- package/internal/src/selector/create-standalone-selector.ts +6 -2
- package/internal/src/selector/create-writable-selector.ts +2 -3
- package/internal/src/selector/dispose-selector.ts +32 -5
- package/internal/src/selector/register-selector.ts +2 -0
- package/internal/src/set-state/stow-update.ts +5 -1
- package/internal/src/store/deposit.ts +41 -7
- package/internal/src/store/store.ts +11 -0
- package/internal/src/store/withdraw.ts +28 -1
- package/internal/src/timeline/add-atom-to-timeline.ts +206 -182
- package/internal/src/timeline/create-timeline.ts +181 -60
- package/internal/src/timeline/time-travel.ts +20 -0
- package/internal/src/transaction/apply-transaction.ts +2 -12
- package/internal/src/transaction/build-transaction.ts +11 -2
- package/introspection/dist/index.cjs +2 -1
- package/introspection/dist/index.js +2 -1
- package/introspection/src/attach-timeline-family.ts +1 -0
- package/json/dist/index.cjs +3 -3
- package/json/dist/index.js +6 -5
- package/json/src/select-json-family.ts +3 -4
- package/package.json +8 -5
- package/react-devtools/dist/index.cjs +58 -47
- package/react-devtools/dist/index.js +60 -48
- package/react-devtools/src/TimelineIndex.tsx +15 -13
- package/react-devtools/src/Updates.tsx +41 -32
- package/realtime-server/dist/index.cjs +21 -10
- package/realtime-server/dist/index.d.ts +1 -1
- package/realtime-server/dist/index.js +21 -11
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +21 -11
- package/realtime-testing/dist/index.cjs +1 -0
- package/realtime-testing/dist/index.js +1 -1
- package/src/atom.ts +9 -3
- package/src/dispose-state.ts +3 -12
- package/src/index.ts +4 -0
- package/src/selector.ts +3 -3
- package/src/subscribe.ts +8 -4
- package/src/timeline.ts +18 -1
- package/src/transaction.ts +56 -4
- package/dist/chunk-BF4MVQF6.js +0 -44
package/data/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var internal = require('atom.io/internal');
|
|
4
4
|
var atom_io = require('atom.io');
|
|
5
|
+
var immortal = require('atom.io/immortal');
|
|
5
6
|
var json = require('atom.io/json');
|
|
6
7
|
var setRtx = require('atom.io/transceivers/set-rtx');
|
|
7
8
|
|
|
@@ -299,7 +300,8 @@ var Join = class _Join {
|
|
|
299
300
|
internal.setIntoStore(token, value, store);
|
|
300
301
|
},
|
|
301
302
|
find: (token, key) => internal.findInStore(token, key, store),
|
|
302
|
-
seek: (token, key) => internal.seekInStore(token, key, store)
|
|
303
|
+
seek: (token, key) => internal.seekInStore(token, key, store),
|
|
304
|
+
json: (token) => internal.getJsonToken(token, store)
|
|
303
305
|
};
|
|
304
306
|
this.retrieve = (token, key) => {
|
|
305
307
|
const maybeToken = this.transactors.seek(token, key);
|
|
@@ -470,6 +472,7 @@ var Join = class _Join {
|
|
|
470
472
|
};
|
|
471
473
|
let externalStore;
|
|
472
474
|
let contentAtoms;
|
|
475
|
+
let contentMolecules;
|
|
473
476
|
if (defaultContent) {
|
|
474
477
|
contentAtoms = internal.createRegularAtomFamily(
|
|
475
478
|
{
|
|
@@ -478,6 +481,17 @@ var Join = class _Join {
|
|
|
478
481
|
},
|
|
479
482
|
store
|
|
480
483
|
);
|
|
484
|
+
contentMolecules = immortal.createMoleculeFamily(
|
|
485
|
+
{
|
|
486
|
+
key: `${options.key}/content-molecules`,
|
|
487
|
+
new: (s) => class ContentMolecule extends immortal.Molecule {
|
|
488
|
+
constructor(context, token) {
|
|
489
|
+
super(s, context, token);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
store
|
|
494
|
+
);
|
|
481
495
|
const getContent = ({ get }, key) => get(this.retrieve(contentAtoms, key));
|
|
482
496
|
const setContent = ({ set }, key, content) => {
|
|
483
497
|
set(this.retrieve(contentAtoms, key), content);
|
|
@@ -516,6 +530,8 @@ var Join = class _Join {
|
|
|
516
530
|
if (store.config.lifespan === `immortal` && m0 && m1) {
|
|
517
531
|
const composite = m0.with(m1)(compositeKey);
|
|
518
532
|
this.molecules.set(`"${compositeKey}"`, composite);
|
|
533
|
+
const target = internal.newest(store);
|
|
534
|
+
immortal.makeMoleculeInStore(target, [m0, m1], contentMolecules, compositeKey);
|
|
519
535
|
}
|
|
520
536
|
return compositeKey;
|
|
521
537
|
}
|
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-7DT3PVS3.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
|
@@ -12,7 +12,16 @@ import type {
|
|
|
12
12
|
} from "atom.io"
|
|
13
13
|
import { disposeState } from "atom.io"
|
|
14
14
|
import type { findState } from "atom.io/ephemeral"
|
|
15
|
-
import type {
|
|
15
|
+
import type {
|
|
16
|
+
MoleculeFamilyToken,
|
|
17
|
+
MoleculeToken,
|
|
18
|
+
seekState,
|
|
19
|
+
} from "atom.io/immortal"
|
|
20
|
+
import {
|
|
21
|
+
createMoleculeFamily,
|
|
22
|
+
makeMoleculeInStore,
|
|
23
|
+
Molecule,
|
|
24
|
+
} from "atom.io/immortal"
|
|
16
25
|
import type { Store } from "atom.io/internal"
|
|
17
26
|
import {
|
|
18
27
|
createMutableAtomFamily,
|
|
@@ -21,6 +30,7 @@ import {
|
|
|
21
30
|
findInStore,
|
|
22
31
|
getFromStore,
|
|
23
32
|
getJsonFamily,
|
|
33
|
+
getJsonToken,
|
|
24
34
|
IMPLICIT,
|
|
25
35
|
initFamilyMember,
|
|
26
36
|
isChildStore,
|
|
@@ -192,6 +202,7 @@ export class Join<
|
|
|
192
202
|
},
|
|
193
203
|
find: ((token, key) => findInStore(token, key, store)) as typeof findState,
|
|
194
204
|
seek: ((token, key) => seekInStore(token, key, store)) as typeof seekState,
|
|
205
|
+
json: (token) => getJsonToken(token, store),
|
|
195
206
|
}
|
|
196
207
|
this.retrieve = (
|
|
197
208
|
token: ReadableFamilyToken<any, any>,
|
|
@@ -388,6 +399,7 @@ export class Join<
|
|
|
388
399
|
}
|
|
389
400
|
let externalStore: ExternalStoreConfiguration<Content>
|
|
390
401
|
let contentAtoms: RegularAtomFamily<Content, string>
|
|
402
|
+
let contentMolecules: MoleculeFamilyToken<string, any, any>
|
|
391
403
|
if (defaultContent) {
|
|
392
404
|
contentAtoms = createRegularAtomFamily<Content, string>(
|
|
393
405
|
{
|
|
@@ -396,6 +408,21 @@ export class Join<
|
|
|
396
408
|
},
|
|
397
409
|
store,
|
|
398
410
|
)
|
|
411
|
+
contentMolecules = createMoleculeFamily(
|
|
412
|
+
{
|
|
413
|
+
key: `${options.key}/content-molecules`,
|
|
414
|
+
new: (s) =>
|
|
415
|
+
class ContentMolecule extends Molecule<string> {
|
|
416
|
+
public constructor(
|
|
417
|
+
context: Molecule<any>[],
|
|
418
|
+
token: MoleculeToken<string, any, any>,
|
|
419
|
+
) {
|
|
420
|
+
super(s, context, token)
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
store,
|
|
425
|
+
)
|
|
399
426
|
const getContent: Read<(key: string) => Content | null> = ({ get }, key) =>
|
|
400
427
|
get(this.retrieve(contentAtoms, key))
|
|
401
428
|
const setContent: Write<(key: string, content: Content) => void> = (
|
|
@@ -443,6 +470,8 @@ export class Join<
|
|
|
443
470
|
if (store.config.lifespan === `immortal` && m0 && m1) {
|
|
444
471
|
const composite = m0.with(m1)(compositeKey)
|
|
445
472
|
this.molecules.set(`"${compositeKey}"`, composite)
|
|
473
|
+
const target = newest(store)
|
|
474
|
+
makeMoleculeInStore(target, [m0, m1], contentMolecules, compositeKey)
|
|
446
475
|
}
|
|
447
476
|
return compositeKey
|
|
448
477
|
},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// ../anvl/src/primitive/index.ts
|
|
2
|
+
var isString = (input) => {
|
|
3
|
+
return typeof input === `string`;
|
|
4
|
+
};
|
|
5
|
+
var isNumber = (input) => {
|
|
6
|
+
return typeof input === `number`;
|
|
7
|
+
};
|
|
8
|
+
var isBoolean = (input) => {
|
|
9
|
+
return typeof input === `boolean`;
|
|
10
|
+
};
|
|
11
|
+
var isNull = (input) => {
|
|
12
|
+
return input === null;
|
|
13
|
+
};
|
|
14
|
+
var isPrimitive = (input) => {
|
|
15
|
+
return isString(input) || isNumber(input) || isBoolean(input) || isNull(input);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { isBoolean, isNull, isNumber, isPrimitive, isString };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Junction } from './chunk-FTONNX2R.js';
|
|
2
2
|
import { disposeState } from 'atom.io';
|
|
3
|
-
import {
|
|
3
|
+
import { createMoleculeFamily, Molecule, makeMoleculeInStore } from 'atom.io/immortal';
|
|
4
|
+
import { getFromStore, setIntoStore, findInStore, seekInStore, getJsonToken, initFamilyMember, createMutableAtomFamily, createRegularAtomFamily, newest, IMPLICIT, isChildStore, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
4
5
|
import { stringifyJson } from 'atom.io/json';
|
|
5
6
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
6
7
|
|
|
@@ -22,7 +23,8 @@ var Join = class _Join {
|
|
|
22
23
|
setIntoStore(token, value, store);
|
|
23
24
|
},
|
|
24
25
|
find: (token, key) => findInStore(token, key, store),
|
|
25
|
-
seek: (token, key) => seekInStore(token, key, store)
|
|
26
|
+
seek: (token, key) => seekInStore(token, key, store),
|
|
27
|
+
json: (token) => getJsonToken(token, store)
|
|
26
28
|
};
|
|
27
29
|
this.retrieve = (token, key) => {
|
|
28
30
|
const maybeToken = this.transactors.seek(token, key);
|
|
@@ -193,6 +195,7 @@ var Join = class _Join {
|
|
|
193
195
|
};
|
|
194
196
|
let externalStore;
|
|
195
197
|
let contentAtoms;
|
|
198
|
+
let contentMolecules;
|
|
196
199
|
if (defaultContent) {
|
|
197
200
|
contentAtoms = createRegularAtomFamily(
|
|
198
201
|
{
|
|
@@ -201,6 +204,17 @@ var Join = class _Join {
|
|
|
201
204
|
},
|
|
202
205
|
store
|
|
203
206
|
);
|
|
207
|
+
contentMolecules = createMoleculeFamily(
|
|
208
|
+
{
|
|
209
|
+
key: `${options.key}/content-molecules`,
|
|
210
|
+
new: (s) => class ContentMolecule extends Molecule {
|
|
211
|
+
constructor(context, token) {
|
|
212
|
+
super(s, context, token);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
store
|
|
217
|
+
);
|
|
204
218
|
const getContent = ({ get }, key) => get(this.retrieve(contentAtoms, key));
|
|
205
219
|
const setContent = ({ set }, key, content) => {
|
|
206
220
|
set(this.retrieve(contentAtoms, key), content);
|
|
@@ -239,6 +253,8 @@ var Join = class _Join {
|
|
|
239
253
|
if (store.config.lifespan === `immortal` && m0 && m1) {
|
|
240
254
|
const composite = m0.with(m1)(compositeKey);
|
|
241
255
|
this.molecules.set(`"${compositeKey}"`, composite);
|
|
256
|
+
const target = newest(store);
|
|
257
|
+
makeMoleculeInStore(target, [m0, m1], contentMolecules, compositeKey);
|
|
242
258
|
}
|
|
243
259
|
return compositeKey;
|
|
244
260
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// ../anvl/src/json/json-interface.ts
|
|
2
|
+
var stringSetJsonInterface = {
|
|
3
|
+
toJson: (stringSet) => Array.from(stringSet),
|
|
4
|
+
fromJson: (json) => new Set(json)
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// ../anvl/src/json/index.ts
|
|
8
|
+
var parseJson = (str) => JSON.parse(str);
|
|
9
|
+
var stringifyJson = (json) => JSON.stringify(json);
|
|
10
|
+
var JSON_TYPE_NAMES = [
|
|
11
|
+
`array`,
|
|
12
|
+
`boolean`,
|
|
13
|
+
`null`,
|
|
14
|
+
`number`,
|
|
15
|
+
`object`,
|
|
16
|
+
`string`
|
|
17
|
+
];
|
|
18
|
+
var JSON_DEFAULTS = {
|
|
19
|
+
array: [],
|
|
20
|
+
boolean: false,
|
|
21
|
+
null: null,
|
|
22
|
+
number: 0,
|
|
23
|
+
object: {},
|
|
24
|
+
string: ``
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { JSON_DEFAULTS, JSON_TYPE_NAMES, parseJson, stringSetJsonInterface, stringifyJson };
|
package/dist/index.cjs
CHANGED
|
@@ -29,17 +29,8 @@ function atom(options) {
|
|
|
29
29
|
function atomFamily(options) {
|
|
30
30
|
return Internal.createAtomFamily(options, Internal.IMPLICIT.STORE);
|
|
31
31
|
}
|
|
32
|
-
function disposeState(token
|
|
33
|
-
|
|
34
|
-
case `atom`:
|
|
35
|
-
case `mutable_atom`:
|
|
36
|
-
Internal__namespace.disposeAtom(token, store);
|
|
37
|
-
break;
|
|
38
|
-
case `selector`:
|
|
39
|
-
case `readonly_selector`:
|
|
40
|
-
Internal__namespace.disposeSelector(token, store);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
32
|
+
function disposeState(token) {
|
|
33
|
+
Internal__namespace.disposeFromStore(token, Internal__namespace.IMPLICIT.STORE);
|
|
43
34
|
}
|
|
44
35
|
function getState(token) {
|
|
45
36
|
return Internal__namespace.getFromStore(token, Internal__namespace.IMPLICIT.STORE);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Transceiver, Subject, Store, EnvironmentData, Timeline, TimelineAtomUpdate, TimelineSelectorUpdate, TimelineTransactionUpdate } from 'atom.io/internal';
|
|
1
|
+
import { Transceiver, Subject, Store, EnvironmentData, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
|
|
3
2
|
import { Json, JsonInterface } from 'atom.io/json';
|
|
4
3
|
import { findState } from 'atom.io/ephemeral';
|
|
5
|
-
import {
|
|
4
|
+
import { MoleculeToken, MoleculeFamilyToken, seekState, makeMolecule } from 'atom.io/immortal';
|
|
5
|
+
import { ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1, RegularAtomToken as RegularAtomToken$1, MutableAtomToken as MutableAtomToken$1, WritableSelectorToken as WritableSelectorToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, WritableToken as WritableToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, MutableAtomFamilyToken as MutableAtomFamilyToken$1, WritableSelectorFamilyToken as WritableSelectorFamilyToken$1, ReadonlySelectorFamilyToken as ReadonlySelectorFamilyToken$1, WritableFamilyToken as WritableFamilyToken$1 } from 'atom.io';
|
|
6
6
|
|
|
7
7
|
type Effectors<T> = {
|
|
8
8
|
setSelf: <V extends T>(next: V | ((oldValue: T) => V)) => void;
|
|
@@ -40,7 +40,7 @@ type RegularAtomFamilyTokenWithCall<T, K extends Json.Serializable> = RegularAto
|
|
|
40
40
|
};
|
|
41
41
|
type RegularAtomFamily<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> & {
|
|
42
42
|
(key: K): RegularAtomToken<T>;
|
|
43
|
-
subject: Subject<
|
|
43
|
+
subject: Subject<StateCreation<AtomToken<T>> | StateDisposal<AtomToken<T>>>;
|
|
44
44
|
install: (store: Store) => void;
|
|
45
45
|
};
|
|
46
46
|
type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = JsonInterface<T, J> & {
|
|
@@ -62,7 +62,7 @@ type MutableAtomFamilyTokenWithCall<T extends Transceiver<any>, J extends Json.S
|
|
|
62
62
|
};
|
|
63
63
|
type MutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = JsonInterface<T, J> & MutableAtomFamilyToken<T, J, K> & {
|
|
64
64
|
(key: K): MutableAtomToken<T, J>;
|
|
65
|
-
subject: Subject<MutableAtomToken<T, J
|
|
65
|
+
subject: Subject<StateCreation<MutableAtomToken<T, J>> | StateDisposal<MutableAtomToken<T, J>>>;
|
|
66
66
|
install: (store: Store) => void;
|
|
67
67
|
};
|
|
68
68
|
type AtomFamily<T, K extends Json.Serializable = Json.Serializable> = MutableAtomFamily<T extends Transceiver<any> ? T : never, any, K> | RegularAtomFamily<T, K>;
|
|
@@ -70,20 +70,37 @@ type AtomFamilyToken<T, K extends Json.Serializable = Json.Serializable> = Mutab
|
|
|
70
70
|
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyTokenWithCall<T, J, K>;
|
|
71
71
|
declare function atomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>): RegularAtomFamilyTokenWithCall<T, K>;
|
|
72
72
|
|
|
73
|
-
declare function seekState<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> | undefined;
|
|
74
|
-
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: RegularAtomFamilyToken$1<T, K>, key: Key): RegularAtomToken$1<T> | undefined;
|
|
75
|
-
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: WritableSelectorFamilyToken$1<T, K>, key: Key): WritableSelectorToken$1<T> | undefined;
|
|
76
|
-
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: ReadonlySelectorFamilyToken$1<T, K>, key: Key): ReadonlySelectorToken$1<T> | undefined;
|
|
77
|
-
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: WritableFamilyToken$1<T, K>, key: Key): WritableToken$1<T> | undefined;
|
|
78
|
-
declare function seekState<T, K extends Json.Serializable, Key extends K>(token: ReadableFamilyToken$1<T, K>, key: Key): ReadableToken$1<T> | undefined;
|
|
79
|
-
|
|
80
73
|
type TransactionToken<F extends Func> = {
|
|
81
74
|
key: string;
|
|
82
75
|
type: `transaction`;
|
|
83
76
|
__F?: F;
|
|
84
77
|
};
|
|
85
|
-
type
|
|
78
|
+
type StateCreation<Token extends ReadableToken<any>> = {
|
|
79
|
+
type: `state_creation`;
|
|
80
|
+
token: Token;
|
|
81
|
+
};
|
|
82
|
+
type StateDisposal<Token extends ReadableToken<any>> = {
|
|
83
|
+
type: `state_disposal`;
|
|
84
|
+
token: Token;
|
|
85
|
+
value?: TokenType<Token>;
|
|
86
|
+
};
|
|
87
|
+
type MoleculeCreation<Key extends Json.Serializable> = {
|
|
88
|
+
type: `molecule_creation`;
|
|
89
|
+
token: MoleculeToken<Key, any, any>;
|
|
90
|
+
family: MoleculeFamilyToken<Key, any, any>;
|
|
91
|
+
context: MoleculeToken<any, any, any>[];
|
|
92
|
+
params: any[];
|
|
93
|
+
};
|
|
94
|
+
type MoleculeDisposal<Key extends Json.Serializable> = {
|
|
95
|
+
type: `molecule_disposal`;
|
|
96
|
+
token: MoleculeToken<Key, any, any>;
|
|
97
|
+
family: MoleculeFamilyToken<any, any, any>;
|
|
98
|
+
context: MoleculeToken<any, any, any>[];
|
|
99
|
+
familyKeys: string[];
|
|
100
|
+
};
|
|
101
|
+
type TransactionUpdateContent = KeyedStateUpdate<unknown> | MoleculeCreation<any> | MoleculeDisposal<any> | StateCreation<ReadableToken<unknown>> | StateDisposal<ReadableToken<unknown>> | TransactionUpdate<Func>;
|
|
86
102
|
type TransactionUpdate<F extends Func> = {
|
|
103
|
+
type: `transaction_update`;
|
|
87
104
|
key: string;
|
|
88
105
|
id: string;
|
|
89
106
|
epoch: number;
|
|
@@ -92,20 +109,24 @@ type TransactionUpdate<F extends Func> = {
|
|
|
92
109
|
output: ReturnType<F>;
|
|
93
110
|
};
|
|
94
111
|
type Transactors = Readonly<{
|
|
95
|
-
get: <S>(state:
|
|
112
|
+
get: <S>(state: ReadableToken<S>) => S;
|
|
96
113
|
set: <S, New extends S>(state: WritableToken<S>, newValue: New | ((oldValue: S) => New)) => void;
|
|
97
114
|
find: typeof findState;
|
|
98
115
|
seek: typeof seekState;
|
|
116
|
+
json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
|
|
99
117
|
}>;
|
|
100
118
|
type TransactorsWithRunAndEnv = Readonly<{
|
|
101
119
|
get: <S>(state: ReadonlySelectorToken<S> | WritableToken<S>) => S;
|
|
102
120
|
set: <S, New extends S>(state: WritableToken<S>, newValue: New | ((oldValue: S) => New)) => void;
|
|
103
121
|
find: typeof findState;
|
|
104
122
|
seek: typeof seekState;
|
|
123
|
+
json: <T extends Transceiver<any>, J extends Json.Serializable>(state: MutableAtomToken<T, J>) => WritableSelectorToken<J>;
|
|
124
|
+
make: typeof makeMolecule;
|
|
125
|
+
dispose: typeof disposeState;
|
|
105
126
|
run: typeof runTransaction;
|
|
106
127
|
env: () => EnvironmentData;
|
|
107
128
|
}>;
|
|
108
|
-
type ReadonlyTransactors = Pick<Transactors, `find` | `get` | `seek`>;
|
|
129
|
+
type ReadonlyTransactors = Pick<Transactors, `find` | `get` | `json` | `seek`>;
|
|
109
130
|
type Read<F extends Func> = (transactors: ReadonlyTransactors, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
110
131
|
type Write<F extends Func> = (transactors: Transactors, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
111
132
|
type Transact<F extends Func> = (transactors: TransactorsWithRunAndEnv, ...parameters: Parameters<F>) => ReturnType<F>;
|
|
@@ -149,7 +170,7 @@ type WritableSelectorFamilyTokenWithCall<T, K extends Json.Serializable> = Writa
|
|
|
149
170
|
};
|
|
150
171
|
type WritableSelectorFamily<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> & {
|
|
151
172
|
(key: K): WritableSelectorToken<T>;
|
|
152
|
-
subject: Subject<WritableSelectorToken<T
|
|
173
|
+
subject: Subject<StateCreation<WritableSelectorToken<T>> | StateDisposal<WritableSelectorToken<T>>>;
|
|
153
174
|
install: (store: Store) => void;
|
|
154
175
|
};
|
|
155
176
|
type ReadonlySelectorFamilyToken<T, K extends Json.Serializable> = {
|
|
@@ -165,7 +186,7 @@ type ReadonlySelectorFamilyTokenWithCall<T, K extends Json.Serializable> = Reado
|
|
|
165
186
|
type ReadonlySelectorFamily<T, K extends Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
166
187
|
key: string;
|
|
167
188
|
type: `readonly_selector_family`;
|
|
168
|
-
subject: Subject<ReadonlySelectorToken<T
|
|
189
|
+
subject: Subject<StateCreation<ReadonlySelectorToken<T>> | StateDisposal<ReadonlySelectorToken<T>>>;
|
|
169
190
|
install: (store: Store) => void;
|
|
170
191
|
__T?: T;
|
|
171
192
|
__K?: K;
|
|
@@ -175,7 +196,7 @@ type SelectorFamilyToken<T, K extends Json.Serializable> = ReadonlySelectorFamil
|
|
|
175
196
|
declare function selectorFamily<T, K extends Json.Serializable>(options: WritableSelectorFamilyOptions<T, K>): WritableSelectorFamilyTokenWithCall<T, K>;
|
|
176
197
|
declare function selectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamilyTokenWithCall<T, K>;
|
|
177
198
|
|
|
178
|
-
declare function disposeState(token:
|
|
199
|
+
declare function disposeState(token: MoleculeToken<any, any, any> | ReadableToken<any>): void;
|
|
179
200
|
|
|
180
201
|
declare function getState<T>(token: ReadableToken<T>): T;
|
|
181
202
|
|
|
@@ -272,10 +293,11 @@ type StateUpdate<T> = {
|
|
|
272
293
|
newValue: T;
|
|
273
294
|
oldValue: T;
|
|
274
295
|
};
|
|
275
|
-
type KeyedStateUpdate<T> = StateUpdate<T> & {
|
|
296
|
+
type KeyedStateUpdate<T> = Flat<StateUpdate<T> & {
|
|
276
297
|
key: string;
|
|
298
|
+
type: `atom_update` | `selector_update`;
|
|
277
299
|
family?: FamilyMetadata;
|
|
278
|
-
}
|
|
300
|
+
}>;
|
|
279
301
|
type UpdateHandler<T> = (update: StateUpdate<T>) => void;
|
|
280
302
|
type TransactionUpdateHandler<F extends Func> = (data: TransactionUpdate<F>) => void;
|
|
281
303
|
declare function subscribe<T>(token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key?: string, store?: Store): () => void;
|
|
@@ -283,6 +305,7 @@ declare function subscribe<F extends Func>(token: TransactionToken<F>, handleUpd
|
|
|
283
305
|
declare function subscribe<M extends TimelineManageable>(token: TimelineToken<M>, handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void, key?: string, store?: Store): () => void;
|
|
284
306
|
|
|
285
307
|
type TimelineManageable = AtomFamilyToken<any, any> | AtomToken<any>;
|
|
308
|
+
type AtomOnly<M extends TimelineManageable> = M extends AtomFamilyToken<any, any> ? AtomToken<any> : M extends AtomToken<any> ? M : never;
|
|
286
309
|
type TimelineToken<M> = {
|
|
287
310
|
key: string;
|
|
288
311
|
type: `timeline`;
|
|
@@ -290,10 +313,10 @@ type TimelineToken<M> = {
|
|
|
290
313
|
};
|
|
291
314
|
type TimelineOptions<ManagedAtom extends TimelineManageable> = {
|
|
292
315
|
key: string;
|
|
293
|
-
|
|
316
|
+
scope: (ManagedAtom | MoleculeFamilyToken<any, any, any>)[];
|
|
294
317
|
shouldCapture?: (update: TimelineUpdate<ManagedAtom>, timeline: Timeline<TimelineManageable>) => boolean;
|
|
295
318
|
};
|
|
296
|
-
type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineSelectorUpdate<ManagedAtom> | TimelineTransactionUpdate;
|
|
319
|
+
type TimelineUpdate<ManagedAtom extends TimelineManageable> = TimelineAtomUpdate<ManagedAtom> | TimelineMoleculeCreation<any> | TimelineMoleculeDisposal<any> | TimelineSelectorUpdate<ManagedAtom> | TimelineStateCreation<AtomOnly<ManagedAtom>> | TimelineStateDisposal<AtomOnly<ManagedAtom>> | TimelineTransactionUpdate;
|
|
297
320
|
declare const timeline: <ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>) => TimelineToken<ManagedAtom>;
|
|
298
321
|
declare const redo: (tl: TimelineToken<any>) => void;
|
|
299
322
|
declare const undo: (tl: TimelineToken<any>) => void;
|
|
@@ -313,6 +336,11 @@ declare function belongsTo<Family extends WritableFamilyToken$1<any, any>>(famil
|
|
|
313
336
|
declare function belongsTo<Family extends ReadableFamilyToken$1<any, any>>(family: Family, unknownToken: ReadableToken$1<any>): unknownToken is ReadableToken$1<TokenType<Family>>;
|
|
314
337
|
|
|
315
338
|
type Func = (...parameters: any[]) => any;
|
|
339
|
+
type Flat<R extends {
|
|
340
|
+
[K in PropertyKey]: any;
|
|
341
|
+
}> = {
|
|
342
|
+
[K in keyof R]: R[K];
|
|
343
|
+
};
|
|
316
344
|
type RegularAtomToken<T> = {
|
|
317
345
|
key: string;
|
|
318
346
|
type: `atom`;
|
|
@@ -351,4 +379,4 @@ type FamilyMetadata = {
|
|
|
351
379
|
subKey: string;
|
|
352
380
|
};
|
|
353
381
|
|
|
354
|
-
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, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
|
382
|
+
export { type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type Effectors, type FamilyMetadata, type Flat, type Func, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeCreation, type MoleculeDisposal, 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 StateCreation, type StateDisposal, 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, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
package/dist/index.js
CHANGED
|
@@ -9,17 +9,8 @@ function atom(options) {
|
|
|
9
9
|
function atomFamily(options) {
|
|
10
10
|
return createAtomFamily(options, IMPLICIT.STORE);
|
|
11
11
|
}
|
|
12
|
-
function disposeState(token
|
|
13
|
-
|
|
14
|
-
case `atom`:
|
|
15
|
-
case `mutable_atom`:
|
|
16
|
-
Internal.disposeAtom(token, store);
|
|
17
|
-
break;
|
|
18
|
-
case `selector`:
|
|
19
|
-
case `readonly_selector`:
|
|
20
|
-
Internal.disposeSelector(token, store);
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
12
|
+
function disposeState(token) {
|
|
13
|
+
Internal.disposeFromStore(token, Internal.IMPLICIT.STORE);
|
|
23
14
|
}
|
|
24
15
|
|
|
25
16
|
// src/logger.ts
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, RegularAtomToken, WritableSelectorFamilyToken, WritableSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, WritableFamilyToken, WritableToken, ReadableFamilyToken, ReadableToken } from 'atom.io';
|
|
2
|
+
import { Transceiver } from 'atom.io/internal';
|
|
3
|
+
import { Json } from 'atom.io/json';
|
|
4
|
+
|
|
5
|
+
declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key): MutableAtomToken<T, J>;
|
|
6
|
+
declare function findState<T, K extends Json.Serializable, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key): RegularAtomToken<T>;
|
|
7
|
+
declare function findState<T, K extends Json.Serializable, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key): WritableSelectorToken<T>;
|
|
8
|
+
declare function findState<T, K extends Json.Serializable, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key): ReadonlySelectorToken<T>;
|
|
9
|
+
declare function findState<T, K extends Json.Serializable, Key extends K>(token: WritableFamilyToken<T, K>, key: Key): WritableToken<T>;
|
|
10
|
+
declare function findState<T, K extends Json.Serializable, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T>;
|
|
11
|
+
|
|
12
|
+
export { findState };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as ESTree from 'estree';
|
|
2
|
+
import * as eslint from 'eslint';
|
|
3
|
+
import { Rule } from 'eslint';
|
|
4
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
5
|
+
|
|
6
|
+
declare const explicitStateTypes: ESLintUtils.RuleModule<"noTypeArgument", [], ESLintUtils.RuleListener>;
|
|
7
|
+
|
|
8
|
+
declare const lifespan: {
|
|
9
|
+
meta: {
|
|
10
|
+
type: "problem";
|
|
11
|
+
docs: {
|
|
12
|
+
description: string;
|
|
13
|
+
category: string;
|
|
14
|
+
recommended: false;
|
|
15
|
+
url: string;
|
|
16
|
+
};
|
|
17
|
+
schema: {
|
|
18
|
+
type: "string";
|
|
19
|
+
enum: string[];
|
|
20
|
+
default: string;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
create(context: Rule.RuleContext): {
|
|
24
|
+
ImportDeclaration(node: ESTree.ImportDeclaration & Rule.NodeParentExtension): void;
|
|
25
|
+
CallExpression(node: ESTree.CallExpression & Rule.NodeParentExtension): void;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
declare const synchronousSelectorDependencies: {
|
|
30
|
+
meta: {
|
|
31
|
+
type: "problem";
|
|
32
|
+
docs: {
|
|
33
|
+
description: string;
|
|
34
|
+
category: string;
|
|
35
|
+
recommended: false;
|
|
36
|
+
url: string;
|
|
37
|
+
};
|
|
38
|
+
schema: never[];
|
|
39
|
+
};
|
|
40
|
+
create(context: Rule.RuleContext): {
|
|
41
|
+
CallExpression(node: ESTree.CallExpression & Rule.NodeParentExtension): void;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
declare const index_explicitStateTypes: typeof explicitStateTypes;
|
|
46
|
+
declare const index_lifespan: typeof lifespan;
|
|
47
|
+
declare const index_synchronousSelectorDependencies: typeof synchronousSelectorDependencies;
|
|
48
|
+
declare namespace index {
|
|
49
|
+
export { index_explicitStateTypes as explicitStateTypes, index_lifespan as lifespan, index_synchronousSelectorDependencies as synchronousSelectorDependencies };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare const _default: {
|
|
53
|
+
rules: {
|
|
54
|
+
"explicit-state-types": any;
|
|
55
|
+
"synchronous-selector-dependencies": {
|
|
56
|
+
meta: {
|
|
57
|
+
type: "problem";
|
|
58
|
+
docs: {
|
|
59
|
+
description: string;
|
|
60
|
+
category: string;
|
|
61
|
+
recommended: false;
|
|
62
|
+
url: string;
|
|
63
|
+
};
|
|
64
|
+
schema: never[];
|
|
65
|
+
};
|
|
66
|
+
create(context: eslint.Rule.RuleContext): {
|
|
67
|
+
CallExpression(node: ESTree.CallExpression & eslint.Rule.NodeParentExtension): void;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { index as Rules, _default as default };
|