atom.io 0.25.6 → 0.27.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.d.ts +3 -3
- package/data/dist/index.js +33 -25
- package/data/package.json +1 -4
- package/data/src/dict.ts +3 -3
- package/dist/chunk-AK23DRMD.js +21 -0
- package/dist/{chunk-HYXKCFVY.js → chunk-IBTHB2PI.js} +59 -60
- package/dist/{chunk-MR5NETHW.js → chunk-IW6WYRS7.js} +4 -5
- package/dist/chunk-XWL6SNVU.js +7 -0
- package/dist/index.d.ts +32 -54
- package/dist/index.js +33 -21
- package/ephemeral/dist/index.d.ts +7 -7
- package/ephemeral/dist/index.js +1 -1
- package/ephemeral/package.json +1 -4
- package/ephemeral/src/find-state.ts +7 -7
- package/eslint-plugin/dist/index.js +7 -8
- package/eslint-plugin/package.json +1 -4
- package/immortal/dist/index.d.ts +7 -7
- package/immortal/dist/index.js +1 -1
- package/immortal/package.json +1 -4
- package/immortal/src/seek-state.ts +8 -8
- package/internal/dist/index.d.ts +56 -59
- package/internal/dist/index.js +178 -170
- package/internal/package.json +1 -4
- package/internal/src/families/create-atom-family.ts +4 -4
- package/internal/src/families/create-readonly-selector-family.ts +2 -2
- package/internal/src/families/create-regular-atom-family.ts +2 -2
- package/internal/src/families/create-selector-family.ts +4 -4
- package/internal/src/families/create-writable-selector-family.ts +2 -2
- package/internal/src/families/dispose-from-store.ts +3 -7
- package/internal/src/families/find-in-store.ts +9 -9
- package/internal/src/families/init-family-member.ts +25 -37
- package/internal/src/families/seek-in-store.ts +11 -10
- package/internal/src/get-state/get-from-store.ts +3 -3
- package/internal/src/molecule/grow-molecule-in-store.ts +9 -9
- package/internal/src/mutable/index.ts +0 -1
- package/internal/src/mutable/tracker-family.ts +2 -2
- package/internal/src/set-state/set-into-store.ts +4 -4
- package/internal/src/store/deposit.ts +3 -3
- package/internal/src/store/withdraw.ts +10 -9
- package/introspection/dist/index.js +32 -30
- package/introspection/package.json +1 -4
- package/json/dist/index.d.ts +10 -27
- package/json/dist/index.js +3 -3
- package/json/package.json +1 -4
- package/json/src/index.ts +8 -3
- package/json/src/select-json-family.ts +4 -4
- package/package.json +36 -65
- package/react/dist/index.d.ts +4 -4
- package/react/dist/index.js +2 -2
- package/react/package.json +1 -4
- package/react/src/parse-state-overloads.ts +4 -4
- package/react/src/use-i.ts +3 -3
- package/react/src/use-json.ts +3 -3
- package/react/src/use-o.ts +3 -3
- package/react-devtools/dist/index.d.ts +1 -1
- package/react-devtools/dist/index.js +90 -72
- package/react-devtools/package.json +1 -4
- package/react-devtools/src/StateIndex.tsx +5 -4
- package/realtime/dist/index.d.ts +3 -3
- package/realtime/dist/index.js +8 -9
- package/realtime/package.json +1 -4
- package/realtime/src/realtime-continuity.ts +2 -2
- package/realtime-client/dist/index.js +6 -6
- package/realtime-client/package.json +1 -4
- package/realtime-react/dist/index.d.ts +4 -4
- package/realtime-react/dist/index.js +9 -11
- package/realtime-react/package.json +1 -4
- package/realtime-react/src/use-pull-atom-family-member.ts +2 -2
- package/realtime-react/src/use-pull-mutable-family-member.ts +2 -2
- package/realtime-react/src/use-pull-selector-family-member.ts +2 -2
- package/realtime-server/dist/index.d.ts +9 -9
- package/realtime-server/dist/index.js +59 -54
- package/realtime-server/package.json +1 -4
- package/realtime-server/src/ipc-sockets/custom-socket.ts +2 -2
- package/realtime-server/src/realtime-family-provider.ts +3 -2
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
- package/realtime-testing/dist/index.js +3 -3
- package/realtime-testing/package.json +1 -4
- package/src/atom.ts +15 -42
- package/src/dispose-state.ts +2 -2
- package/src/get-state.ts +4 -4
- package/src/index.ts +5 -5
- package/src/molecule.ts +4 -3
- package/src/selector.ts +17 -39
- package/src/set-state.ts +3 -2
- package/src/silo.ts +4 -4
- package/transceivers/set-rtx/dist/index.js +11 -11
- package/transceivers/set-rtx/package.json +1 -4
- package/transceivers/set-rtx/src/set-rtx.ts +5 -5
- package/data/dist/index.cjs +0 -953
- package/dist/chunk-BF4MVQF6.js +0 -44
- package/dist/chunk-S4N6XNPH.js +0 -38
- package/dist/index.cjs +0 -215
- package/ephemeral/dist/index.cjs +0 -11
- package/eslint-plugin/dist/index.cjs +0 -388
- package/immortal/dist/index.cjs +0 -14
- package/internal/dist/index.cjs +0 -3405
- package/internal/src/mutable/is-mutable.ts +0 -16
- package/introspection/dist/index.cjs +0 -449
- package/json/dist/index.cjs +0 -128
- package/react/dist/index.cjs +0 -118
- package/react-devtools/dist/index.cjs +0 -2191
- package/realtime/dist/index.cjs +0 -120
- package/realtime-client/dist/index.cjs +0 -569
- package/realtime-react/dist/index.cjs +0 -189
- package/realtime-server/dist/index.cjs +0 -965
- package/realtime-testing/dist/index.cjs +0 -201
- package/transceivers/set-rtx/dist/index.cjs +0 -215
package/data/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as AtomIO from 'atom.io';
|
|
2
2
|
import { ReadonlySelectorFamily, MutableAtomFamily, SetterToolkit, disposeState, ReadonlySelectorToken, MutableAtomFamilyToken } from 'atom.io';
|
|
3
3
|
import { Store, Molecule } from 'atom.io/internal';
|
|
4
|
-
import {
|
|
4
|
+
import { Canonical, stringified, Json } from 'atom.io/json';
|
|
5
5
|
import { findState } from 'atom.io/ephemeral';
|
|
6
6
|
import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
|
|
7
7
|
|
|
8
|
-
declare function dict<State, Key extends
|
|
9
|
-
[K in
|
|
8
|
+
declare function dict<State, Key extends Canonical>(findState: AtomIO.ReadonlySelectorFamilyToken<State, Key> | AtomIO.RegularAtomFamilyToken<State, Key> | AtomIO.WritableSelectorFamily<State, Key>, index: AtomIO.ReadonlySelectorToken<Key[]> | AtomIO.RegularAtomToken<Key[]> | AtomIO.WritableSelectorToken<Key[]>, store?: Store): AtomIO.ReadonlySelectorToken<{
|
|
9
|
+
[K in stringified<Key>]: State;
|
|
10
10
|
}>;
|
|
11
11
|
|
|
12
12
|
type primitive = boolean | number | string | null;
|
package/data/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Junction } from '../../dist/chunk-
|
|
2
|
-
import '../../dist/chunk-
|
|
1
|
+
import { Junction } from '../../dist/chunk-IBTHB2PI.js';
|
|
2
|
+
import '../../dist/chunk-XWL6SNVU.js';
|
|
3
3
|
import { createStandaloneSelector, findInStore, IMPLICIT, getFromStore, setIntoStore, seekInStore, getJsonToken, disposeFromStore, withdraw, growMoleculeInStore, NotFoundError, initFamilyMemberInStore, createMutableAtomFamily, createRegularAtomFamily, createMoleculeFamily, newest, makeMoleculeInStore, isChildStore, createRegularAtom, createSelectorFamily, getJsonFamily } from 'atom.io/internal';
|
|
4
4
|
import { stringifyJson } from 'atom.io/json';
|
|
5
5
|
import { SetRTX } from 'atom.io/transceivers/set-rtx';
|
|
@@ -23,8 +23,37 @@ function capitalize(string) {
|
|
|
23
23
|
return string[0].toUpperCase() + string.slice(1);
|
|
24
24
|
}
|
|
25
25
|
var Join = class _Join {
|
|
26
|
+
options;
|
|
27
|
+
defaultContent;
|
|
28
|
+
toolkit;
|
|
29
|
+
retrieve;
|
|
30
|
+
molecules = /* @__PURE__ */ new Map();
|
|
31
|
+
relations;
|
|
32
|
+
states;
|
|
33
|
+
core;
|
|
34
|
+
transact(toolkit, run) {
|
|
35
|
+
const originalToolkit = this.toolkit;
|
|
36
|
+
this.toolkit = toolkit;
|
|
37
|
+
run(this);
|
|
38
|
+
this.toolkit = originalToolkit;
|
|
39
|
+
}
|
|
40
|
+
store;
|
|
41
|
+
alternates;
|
|
42
|
+
[Symbol.dispose]() {
|
|
43
|
+
this.alternates.delete(this.store.config.name);
|
|
44
|
+
}
|
|
45
|
+
in(store) {
|
|
46
|
+
const key = store.config.name;
|
|
47
|
+
const alternate = this.alternates.get(key);
|
|
48
|
+
if (alternate) {
|
|
49
|
+
return alternate;
|
|
50
|
+
}
|
|
51
|
+
const join2 = new _Join(this.options, this.defaultContent, store);
|
|
52
|
+
this.alternates.set(key, join2);
|
|
53
|
+
join2.alternates = this.alternates;
|
|
54
|
+
return join2;
|
|
55
|
+
}
|
|
26
56
|
constructor(options, defaultContent, store = IMPLICIT.STORE) {
|
|
27
|
-
this.molecules = /* @__PURE__ */ new Map();
|
|
28
57
|
this.store = store;
|
|
29
58
|
this.options = options;
|
|
30
59
|
this.defaultContent = defaultContent;
|
|
@@ -424,26 +453,6 @@ var Join = class _Join {
|
|
|
424
453
|
}
|
|
425
454
|
}
|
|
426
455
|
}
|
|
427
|
-
transact(toolkit, run) {
|
|
428
|
-
const originalToolkit = this.toolkit;
|
|
429
|
-
this.toolkit = toolkit;
|
|
430
|
-
run(this);
|
|
431
|
-
this.toolkit = originalToolkit;
|
|
432
|
-
}
|
|
433
|
-
[Symbol.dispose]() {
|
|
434
|
-
this.alternates.delete(this.store.config.name);
|
|
435
|
-
}
|
|
436
|
-
in(store) {
|
|
437
|
-
const key = store.config.name;
|
|
438
|
-
const alternate = this.alternates.get(key);
|
|
439
|
-
if (alternate) {
|
|
440
|
-
return alternate;
|
|
441
|
-
}
|
|
442
|
-
const join2 = new _Join(this.options, this.defaultContent, store);
|
|
443
|
-
this.alternates.set(key, join2);
|
|
444
|
-
join2.alternates = this.alternates;
|
|
445
|
-
return join2;
|
|
446
|
-
}
|
|
447
456
|
};
|
|
448
457
|
function join(options, defaultContent, store = IMPLICIT.STORE) {
|
|
449
458
|
const joins = getJoinMap(store);
|
|
@@ -466,12 +475,11 @@ function getJoinMap(store) {
|
|
|
466
475
|
return joins;
|
|
467
476
|
}
|
|
468
477
|
function getJoin(token, store) {
|
|
469
|
-
var _a;
|
|
470
478
|
const joinMap = getJoinMap(store);
|
|
471
479
|
let myJoin = joinMap.get(token.key);
|
|
472
480
|
if (myJoin === void 0) {
|
|
473
481
|
const rootJoinMap = getJoinMap(IMPLICIT.STORE);
|
|
474
|
-
myJoin =
|
|
482
|
+
myJoin = rootJoinMap.get(token.key)?.in(store);
|
|
475
483
|
if (myJoin === void 0) {
|
|
476
484
|
throw new Error(
|
|
477
485
|
`Join "${token.key}" not found in store "${store.config.name}"`
|
package/data/package.json
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
"name": "atom.io-data",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"private": true,
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"module": "dist/index.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
7
6
|
"types": "dist/index.d.ts",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": {
|
|
10
9
|
"import": "./dist/index.js",
|
|
11
|
-
"browser": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs",
|
|
13
10
|
"types": "./dist/index.d.ts"
|
|
14
11
|
}
|
|
15
12
|
}
|
package/data/src/dict.ts
CHANGED
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
findInStore,
|
|
6
6
|
IMPLICIT,
|
|
7
7
|
} from "atom.io/internal"
|
|
8
|
-
import type {
|
|
8
|
+
import type { Canonical, stringified } from "atom.io/json"
|
|
9
9
|
|
|
10
|
-
export function dict<State, Key extends
|
|
10
|
+
export function dict<State, Key extends Canonical>(
|
|
11
11
|
findState:
|
|
12
12
|
| AtomIO.ReadonlySelectorFamilyToken<State, Key>
|
|
13
13
|
| AtomIO.RegularAtomFamilyToken<State, Key>
|
|
@@ -17,7 +17,7 @@ export function dict<State, Key extends Json.Serializable>(
|
|
|
17
17
|
| AtomIO.RegularAtomToken<Key[]>
|
|
18
18
|
| AtomIO.WritableSelectorToken<Key[]>,
|
|
19
19
|
store: Store = IMPLICIT.STORE,
|
|
20
|
-
): AtomIO.ReadonlySelectorToken<{ [K in
|
|
20
|
+
): AtomIO.ReadonlySelectorToken<{ [K in stringified<Key>]: State }> {
|
|
21
21
|
return createStandaloneSelector(
|
|
22
22
|
{
|
|
23
23
|
key: `${findState.key}Dict`,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// ../anvl/src/json/index.ts
|
|
2
|
+
var parseJson = (str) => JSON.parse(str);
|
|
3
|
+
var stringifyJson = (json) => JSON.stringify(json);
|
|
4
|
+
var JSON_TYPE_NAMES = [
|
|
5
|
+
`array`,
|
|
6
|
+
`boolean`,
|
|
7
|
+
`null`,
|
|
8
|
+
`number`,
|
|
9
|
+
`object`,
|
|
10
|
+
`string`
|
|
11
|
+
];
|
|
12
|
+
var JSON_DEFAULTS = {
|
|
13
|
+
array: [],
|
|
14
|
+
boolean: false,
|
|
15
|
+
null: null,
|
|
16
|
+
number: 0,
|
|
17
|
+
object: {},
|
|
18
|
+
string: ``
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { JSON_DEFAULTS, JSON_TYPE_NAMES, parseJson, stringifyJson };
|
|
@@ -1,56 +1,12 @@
|
|
|
1
1
|
// ../rel8/junction/src/junction.ts
|
|
2
2
|
var Junction = class {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.cardinality = data.cardinality;
|
|
11
|
-
if (!(config == null ? void 0 : config.externalStore)) {
|
|
12
|
-
this.relations = new Map((_a = data.relations) == null ? void 0 : _a.map(([a, b]) => [a, new Set(b)]));
|
|
13
|
-
this.contents = new Map(data.contents);
|
|
14
|
-
}
|
|
15
|
-
this.isContent = (_b = config == null ? void 0 : config.isContent) != null ? _b : null;
|
|
16
|
-
if (config == null ? void 0 : config.makeContentKey) {
|
|
17
|
-
this.makeContentKey = config.makeContentKey;
|
|
18
|
-
}
|
|
19
|
-
if (config == null ? void 0 : config.externalStore) {
|
|
20
|
-
const externalStore = config.externalStore;
|
|
21
|
-
this.has = (a, b) => externalStore.has(a, b);
|
|
22
|
-
this.addRelation = (a, b) => {
|
|
23
|
-
externalStore.addRelation(a, b);
|
|
24
|
-
};
|
|
25
|
-
this.deleteRelation = (a, b) => {
|
|
26
|
-
externalStore.deleteRelation(a, b);
|
|
27
|
-
};
|
|
28
|
-
this.replaceRelationsSafely = (a, bs) => {
|
|
29
|
-
externalStore.replaceRelationsSafely(a, bs);
|
|
30
|
-
};
|
|
31
|
-
this.replaceRelationsUnsafely = (a, bs) => {
|
|
32
|
-
externalStore.replaceRelationsUnsafely(a, bs);
|
|
33
|
-
};
|
|
34
|
-
this.getRelatedKeys = (key) => externalStore.getRelatedKeys(key);
|
|
35
|
-
if (externalStore.getContent) {
|
|
36
|
-
this.getContentInternal = (contentKey) => {
|
|
37
|
-
return externalStore.getContent(contentKey);
|
|
38
|
-
};
|
|
39
|
-
this.setContent = (contentKey, content) => {
|
|
40
|
-
externalStore.setContent(contentKey, content);
|
|
41
|
-
};
|
|
42
|
-
this.deleteContent = (contentKey) => {
|
|
43
|
-
externalStore.deleteContent(contentKey);
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
for (const [x, ys] of (_c = data.relations) != null ? _c : []) {
|
|
47
|
-
for (const y of ys) this.addRelation(x, y);
|
|
48
|
-
}
|
|
49
|
-
for (const [contentKey, content] of (_d = data.contents) != null ? _d : []) {
|
|
50
|
-
this.setContent(contentKey, content);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
3
|
+
a;
|
|
4
|
+
b;
|
|
5
|
+
cardinality;
|
|
6
|
+
relations = /* @__PURE__ */ new Map();
|
|
7
|
+
contents = /* @__PURE__ */ new Map();
|
|
8
|
+
isContent;
|
|
9
|
+
makeContentKey = (a, b) => `${a}:${b}`;
|
|
54
10
|
getRelatedKeys(key) {
|
|
55
11
|
return this.relations.get(key);
|
|
56
12
|
}
|
|
@@ -128,6 +84,53 @@ var Junction = class {
|
|
|
128
84
|
deleteContent(contentKey) {
|
|
129
85
|
this.contents.delete(contentKey);
|
|
130
86
|
}
|
|
87
|
+
constructor(data, config) {
|
|
88
|
+
this.a = data.between[0];
|
|
89
|
+
this.b = data.between[1];
|
|
90
|
+
this.cardinality = data.cardinality;
|
|
91
|
+
if (!config?.externalStore) {
|
|
92
|
+
this.relations = new Map(data.relations?.map(([a, b]) => [a, new Set(b)]));
|
|
93
|
+
this.contents = new Map(data.contents);
|
|
94
|
+
}
|
|
95
|
+
this.isContent = config?.isContent ?? null;
|
|
96
|
+
if (config?.makeContentKey) {
|
|
97
|
+
this.makeContentKey = config.makeContentKey;
|
|
98
|
+
}
|
|
99
|
+
if (config?.externalStore) {
|
|
100
|
+
const externalStore = config.externalStore;
|
|
101
|
+
this.has = (a, b) => externalStore.has(a, b);
|
|
102
|
+
this.addRelation = (a, b) => {
|
|
103
|
+
externalStore.addRelation(a, b);
|
|
104
|
+
};
|
|
105
|
+
this.deleteRelation = (a, b) => {
|
|
106
|
+
externalStore.deleteRelation(a, b);
|
|
107
|
+
};
|
|
108
|
+
this.replaceRelationsSafely = (a, bs) => {
|
|
109
|
+
externalStore.replaceRelationsSafely(a, bs);
|
|
110
|
+
};
|
|
111
|
+
this.replaceRelationsUnsafely = (a, bs) => {
|
|
112
|
+
externalStore.replaceRelationsUnsafely(a, bs);
|
|
113
|
+
};
|
|
114
|
+
this.getRelatedKeys = (key) => externalStore.getRelatedKeys(key);
|
|
115
|
+
if (externalStore.getContent) {
|
|
116
|
+
this.getContentInternal = (contentKey) => {
|
|
117
|
+
return externalStore.getContent(contentKey);
|
|
118
|
+
};
|
|
119
|
+
this.setContent = (contentKey, content) => {
|
|
120
|
+
externalStore.setContent(contentKey, content);
|
|
121
|
+
};
|
|
122
|
+
this.deleteContent = (contentKey) => {
|
|
123
|
+
externalStore.deleteContent(contentKey);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
for (const [x, ys] of data.relations ?? []) {
|
|
127
|
+
for (const y of ys) this.addRelation(x, y);
|
|
128
|
+
}
|
|
129
|
+
for (const [contentKey, content] of data.contents ?? []) {
|
|
130
|
+
this.setContent(contentKey, content);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
131
134
|
toJSON() {
|
|
132
135
|
return {
|
|
133
136
|
between: [this.a, this.b],
|
|
@@ -137,9 +140,8 @@ var Junction = class {
|
|
|
137
140
|
};
|
|
138
141
|
}
|
|
139
142
|
set(a, ...rest) {
|
|
140
|
-
var _a;
|
|
141
143
|
const b = typeof rest[0] === `string` ? rest[0] : a[this.b];
|
|
142
|
-
const content =
|
|
144
|
+
const content = rest[1] ?? typeof rest[0] === `string` ? void 0 : rest[0];
|
|
143
145
|
a = typeof a === `string` ? a : a[this.a];
|
|
144
146
|
switch (this.cardinality) {
|
|
145
147
|
case `1:1`: {
|
|
@@ -202,7 +204,7 @@ var Junction = class {
|
|
|
202
204
|
replaceRelations(a, relations, config) {
|
|
203
205
|
const hasContent = !Array.isArray(relations);
|
|
204
206
|
const bs = hasContent ? Object.keys(relations) : relations;
|
|
205
|
-
if (config
|
|
207
|
+
if (config?.reckless) {
|
|
206
208
|
this.replaceRelationsUnsafely(a, bs);
|
|
207
209
|
} else {
|
|
208
210
|
this.replaceRelationsSafely(a, bs);
|
|
@@ -227,8 +229,7 @@ var Junction = class {
|
|
|
227
229
|
const aRelations = this.getRelatedKeys(a);
|
|
228
230
|
if (aRelations) {
|
|
229
231
|
return [...aRelations].map((aRelation) => {
|
|
230
|
-
|
|
231
|
-
return [aRelation, (_a = this.getContent(a, aRelation)) != null ? _a : null];
|
|
232
|
+
return [aRelation, this.getContent(a, aRelation) ?? null];
|
|
232
233
|
});
|
|
233
234
|
}
|
|
234
235
|
}
|
|
@@ -236,18 +237,16 @@ var Junction = class {
|
|
|
236
237
|
const bRelations = this.getRelatedKeys(b);
|
|
237
238
|
if (bRelations) {
|
|
238
239
|
return [...bRelations].map((bRelation) => {
|
|
239
|
-
|
|
240
|
-
return [bRelation, (_a = this.getContent(bRelation, b)) != null ? _a : null];
|
|
240
|
+
return [bRelation, this.getContent(bRelation, b) ?? null];
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
return [];
|
|
245
245
|
}
|
|
246
246
|
has(a, b) {
|
|
247
|
-
var _a;
|
|
248
247
|
if (b) {
|
|
249
248
|
const setA = this.getRelatedKeys(a);
|
|
250
|
-
return
|
|
249
|
+
return setA?.has(b) ?? false;
|
|
251
250
|
}
|
|
252
251
|
return this.relations.has(a);
|
|
253
252
|
}
|
|
@@ -55,7 +55,7 @@ var fallback = (fn, fallbackValue) => {
|
|
|
55
55
|
// ../anvl/src/nullish/index.ts
|
|
56
56
|
var isUndefined = (input) => input === void 0;
|
|
57
57
|
var ifDefined = (validate) => (input) => isUndefined(input) || validate(input);
|
|
58
|
-
var ifNullish = (alt) => (input) => input
|
|
58
|
+
var ifNullish = (alt) => (input) => input ?? alt;
|
|
59
59
|
|
|
60
60
|
// ../anvl/src/object/access.ts
|
|
61
61
|
var access = (k) => Object.assign((obj) => obj[k], {
|
|
@@ -110,20 +110,19 @@ var doesExtend = (isValue) => hasProperties(isValue, ALLOW_EXTENSION);
|
|
|
110
110
|
// ../anvl/src/object/sprawl.ts
|
|
111
111
|
var sprawl = (tree, inspector) => {
|
|
112
112
|
const walk = (path, node) => {
|
|
113
|
-
var _a;
|
|
114
113
|
const inspect = (p, n) => {
|
|
115
114
|
const result2 = inspector(p, n);
|
|
116
115
|
if (result2) return result2;
|
|
117
116
|
return null;
|
|
118
117
|
};
|
|
119
118
|
const result = inspect(path, node);
|
|
120
|
-
if (
|
|
119
|
+
if (result?.jobComplete ?? result?.pathComplete) {
|
|
121
120
|
return result;
|
|
122
121
|
}
|
|
123
122
|
const childEntries = Array.isArray(node) ? node.map((v, i) => [i, v]) : isPlainObject(node) ? Object.entries(node) : [];
|
|
124
123
|
for (const [k, v] of childEntries) {
|
|
125
124
|
const subResult = walk([...path, k], v);
|
|
126
|
-
if (subResult
|
|
125
|
+
if (subResult?.jobComplete) {
|
|
127
126
|
return subResult;
|
|
128
127
|
}
|
|
129
128
|
}
|
|
@@ -134,7 +133,7 @@ var sprawl = (tree, inspector) => {
|
|
|
134
133
|
|
|
135
134
|
// ../anvl/src/object/index.ts
|
|
136
135
|
var delve = (obj, path) => {
|
|
137
|
-
const found = path.reduce((acc, key) => acc
|
|
136
|
+
const found = path.reduce((acc, key) => acc?.[key], obj);
|
|
138
137
|
return found === void 0 ? new Error(`Not found`) : { found };
|
|
139
138
|
};
|
|
140
139
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transceiver, Subject, Store, Func, EnvironmentData, Flat, Timeline, TimelineAtomUpdate, TimelineMoleculeCreation, TimelineMoleculeDisposal, TimelineSelectorUpdate, TimelineStateCreation, TimelineStateDisposal, TimelineTransactionUpdate } from 'atom.io/internal';
|
|
2
|
-
import { Json, JsonInterface } from 'atom.io/json';
|
|
2
|
+
import { Json, JsonInterface, Canonical } from 'atom.io/json';
|
|
3
3
|
import { MoleculeConstructor as MoleculeConstructor$1, MoleculeToken as MoleculeToken$1, MoleculeFamilyToken as MoleculeFamilyToken$1, MoleculeParams as MoleculeParams$1, getState as getState$1, setState as setState$1, makeMolecule as makeMolecule$1, ActorToolkit as ActorToolkit$1, MutableAtomFamilyToken as MutableAtomFamilyToken$1, MutableAtomToken as MutableAtomToken$1, RegularAtomFamilyToken as RegularAtomFamilyToken$1, RegularAtomToken as RegularAtomToken$1, WritableSelectorFamilyToken as WritableSelectorFamilyToken$1, WritableSelectorToken as WritableSelectorToken$1, ReadonlySelectorFamilyToken as ReadonlySelectorFamilyToken$1, ReadonlySelectorToken as ReadonlySelectorToken$1, WritableFamilyToken as WritableFamilyToken$1, WritableToken as WritableToken$1, ReadableFamilyToken as ReadableFamilyToken$1, ReadableToken as ReadableToken$1, MoleculeCreation as MoleculeCreation$1, MoleculeDisposal as MoleculeDisposal$1 } from 'atom.io';
|
|
4
4
|
import { findState } from 'atom.io/ephemeral';
|
|
5
5
|
import { seekState } from 'atom.io/immortal';
|
|
@@ -40,52 +40,44 @@ declare function atom<T extends Transceiver<any>, J extends Json.Serializable>(o
|
|
|
40
40
|
* @overload Regular
|
|
41
41
|
*/
|
|
42
42
|
declare function atom<T>(options: RegularAtomOptions<T>): RegularAtomToken<T>;
|
|
43
|
-
type RegularAtomFamilyOptions<T, K extends
|
|
43
|
+
type RegularAtomFamilyOptions<T, K extends Canonical> = {
|
|
44
44
|
key: string;
|
|
45
45
|
default: T | ((key: K) => T);
|
|
46
46
|
effects?: (key: K) => AtomEffect<T>[];
|
|
47
47
|
};
|
|
48
|
-
type RegularAtomFamilyToken<T, K extends
|
|
48
|
+
type RegularAtomFamilyToken<T, K extends Canonical> = {
|
|
49
49
|
key: string;
|
|
50
50
|
type: `atom_family`;
|
|
51
51
|
__T?: T;
|
|
52
52
|
__K?: K;
|
|
53
53
|
};
|
|
54
|
-
type
|
|
55
|
-
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
56
|
-
(key: K): RegularAtomToken<T>;
|
|
57
|
-
};
|
|
58
|
-
type RegularAtomFamily<T, K extends Json.Serializable> = RegularAtomFamilyToken<T, K> & {
|
|
54
|
+
type RegularAtomFamily<T, K extends Canonical> = RegularAtomFamilyToken<T, K> & {
|
|
59
55
|
(key: K): RegularAtomToken<T>;
|
|
60
56
|
subject: Subject<StateCreation<AtomToken<T>> | StateDisposal<AtomToken<T>>>;
|
|
61
57
|
install: (store: Store) => void;
|
|
62
58
|
};
|
|
63
|
-
type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends
|
|
59
|
+
type MutableAtomFamilyOptions<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = JsonInterface<T, J> & {
|
|
64
60
|
key: string;
|
|
65
61
|
default: (key: K) => T;
|
|
66
62
|
effects?: (key: K) => AtomEffect<T>[];
|
|
67
63
|
mutable: true;
|
|
68
64
|
};
|
|
69
|
-
type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializable, K extends
|
|
65
|
+
type MutableAtomFamilyToken<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = {
|
|
70
66
|
key: string;
|
|
71
67
|
type: `mutable_atom_family`;
|
|
72
68
|
__T?: T;
|
|
73
69
|
__J?: J;
|
|
74
70
|
__K?: K;
|
|
75
71
|
};
|
|
76
|
-
type
|
|
77
|
-
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
78
|
-
(key: K): MutableAtomToken<T, J>;
|
|
79
|
-
};
|
|
80
|
-
type MutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable> = JsonInterface<T, J> & MutableAtomFamilyToken<T, J, K> & {
|
|
72
|
+
type MutableAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical> = JsonInterface<T, J> & MutableAtomFamilyToken<T, J, K> & {
|
|
81
73
|
(key: K): MutableAtomToken<T, J>;
|
|
82
74
|
subject: Subject<StateCreation<MutableAtomToken<T, J>> | StateDisposal<MutableAtomToken<T, J>>>;
|
|
83
75
|
install: (store: Store) => void;
|
|
84
76
|
};
|
|
85
|
-
type AtomFamily<T, K extends
|
|
86
|
-
type AtomFamilyToken<T, K extends
|
|
87
|
-
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends
|
|
88
|
-
declare function atomFamily<T, K extends
|
|
77
|
+
type AtomFamily<T, K extends Canonical = Canonical> = MutableAtomFamily<T extends Transceiver<any> ? T : never, any, K> | RegularAtomFamily<T, K>;
|
|
78
|
+
type AtomFamilyToken<T, K extends Canonical = Canonical> = MutableAtomFamilyToken<T extends Transceiver<any> ? T : never, any, K> | RegularAtomFamilyToken<T, K>;
|
|
79
|
+
declare function atomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyToken<T, J, K>;
|
|
80
|
+
declare function atomFamily<T, K extends Canonical>(options: RegularAtomFamilyOptions<T, K>): RegularAtomFamilyToken<T, K>;
|
|
89
81
|
|
|
90
82
|
type TransactionToken<F extends Func> = {
|
|
91
83
|
key: string;
|
|
@@ -166,41 +158,33 @@ type ReadonlySelectorOptions<T> = {
|
|
|
166
158
|
};
|
|
167
159
|
declare function selector<T>(options: WritableSelectorOptions<T>): WritableSelectorToken<T>;
|
|
168
160
|
declare function selector<T>(options: ReadonlySelectorOptions<T>): ReadonlySelectorToken<T>;
|
|
169
|
-
type WritableSelectorFamilyOptions<T, K extends
|
|
161
|
+
type WritableSelectorFamilyOptions<T, K extends Canonical> = {
|
|
170
162
|
key: string;
|
|
171
163
|
get: (key: K) => Read<() => T>;
|
|
172
164
|
set: (key: K) => Write<(newValue: T) => void>;
|
|
173
165
|
};
|
|
174
|
-
type ReadonlySelectorFamilyOptions<T, K extends
|
|
166
|
+
type ReadonlySelectorFamilyOptions<T, K extends Canonical> = {
|
|
175
167
|
key: string;
|
|
176
168
|
get: (key: K) => Read<() => T>;
|
|
177
169
|
};
|
|
178
|
-
type WritableSelectorFamilyToken<T, K extends
|
|
170
|
+
type WritableSelectorFamilyToken<T, K extends Canonical> = {
|
|
179
171
|
key: string;
|
|
180
172
|
type: `selector_family`;
|
|
181
173
|
__T?: T;
|
|
182
174
|
__K?: K;
|
|
183
175
|
};
|
|
184
|
-
type
|
|
185
|
-
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
186
|
-
(key: K): WritableSelectorToken<T>;
|
|
187
|
-
};
|
|
188
|
-
type WritableSelectorFamily<T, K extends Json.Serializable> = WritableSelectorFamilyToken<T, K> & {
|
|
176
|
+
type WritableSelectorFamily<T, K extends Canonical> = WritableSelectorFamilyToken<T, K> & {
|
|
189
177
|
(key: K): WritableSelectorToken<T>;
|
|
190
178
|
subject: Subject<StateCreation<WritableSelectorToken<T>> | StateDisposal<WritableSelectorToken<T>>>;
|
|
191
179
|
install: (store: Store) => void;
|
|
192
180
|
};
|
|
193
|
-
type ReadonlySelectorFamilyToken<T, K extends
|
|
181
|
+
type ReadonlySelectorFamilyToken<T, K extends Canonical> = {
|
|
194
182
|
key: string;
|
|
195
183
|
type: `readonly_selector_family`;
|
|
196
184
|
__T?: T;
|
|
197
185
|
__K?: K;
|
|
198
186
|
};
|
|
199
|
-
type
|
|
200
|
-
/** @deprecated In ephemeral stores, prefer the `findState`, `findInStore`, or `find` functions. In immortal stores, prefer the `seekState`, `seekInStore`, or `seek` functions. */
|
|
201
|
-
(key: K): ReadonlySelectorToken<T>;
|
|
202
|
-
};
|
|
203
|
-
type ReadonlySelectorFamily<T, K extends Json.Serializable> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
187
|
+
type ReadonlySelectorFamily<T, K extends Canonical> = ((key: K) => ReadonlySelectorToken<T>) & {
|
|
204
188
|
key: string;
|
|
205
189
|
type: `readonly_selector_family`;
|
|
206
190
|
subject: Subject<StateCreation<ReadonlySelectorToken<T>> | StateDisposal<ReadonlySelectorToken<T>>>;
|
|
@@ -208,12 +192,12 @@ type ReadonlySelectorFamily<T, K extends Json.Serializable> = ((key: K) => Reado
|
|
|
208
192
|
__T?: T;
|
|
209
193
|
__K?: K;
|
|
210
194
|
};
|
|
211
|
-
type SelectorFamily<T, K extends
|
|
212
|
-
type SelectorFamilyToken<T, K extends
|
|
213
|
-
declare function selectorFamily<T, K extends
|
|
214
|
-
declare function selectorFamily<T, K extends
|
|
195
|
+
type SelectorFamily<T, K extends Canonical> = ReadonlySelectorFamily<T, K> | WritableSelectorFamily<T, K>;
|
|
196
|
+
type SelectorFamilyToken<T, K extends Canonical> = ReadonlySelectorFamilyToken<T, K> | WritableSelectorFamilyToken<T, K>;
|
|
197
|
+
declare function selectorFamily<T, K extends Canonical>(options: WritableSelectorFamilyOptions<T, K>): WritableSelectorFamilyToken<T, K>;
|
|
198
|
+
declare function selectorFamily<T, K extends Canonical>(options: ReadonlySelectorFamilyOptions<T, K>): ReadonlySelectorFamilyToken<T, K>;
|
|
215
199
|
|
|
216
|
-
type CtorToolkit<K extends
|
|
200
|
+
type CtorToolkit<K extends Canonical> = Flat<Omit<ActorToolkit$1, `find`> & {
|
|
217
201
|
bond<T extends Transceiver<any>, J extends Json.Serializable>(family: MutableAtomFamilyToken$1<T, J, K>): MutableAtomToken$1<T, J>;
|
|
218
202
|
bond<T>(family: RegularAtomFamilyToken$1<T, K>): RegularAtomToken$1<T>;
|
|
219
203
|
bond<T>(family: WritableSelectorFamilyToken$1<T, K>): WritableSelectorToken$1<T>;
|
|
@@ -234,7 +218,7 @@ type CtorToolkit<K extends Json.Serializable> = Flat<Omit<ActorToolkit$1, `find`
|
|
|
234
218
|
claim(below: MoleculeToken<any>, options: {
|
|
235
219
|
exclusive: boolean;
|
|
236
220
|
}): void;
|
|
237
|
-
spawn<Key extends
|
|
221
|
+
spawn<Key extends Canonical, Ctor extends MoleculeConstructor>(family: MoleculeFamilyToken<Ctor>, key: Key, ...params: MoleculeParams<Ctor>): MoleculeToken<Ctor>;
|
|
238
222
|
}>;
|
|
239
223
|
type MoleculeConstructor = new (toolkit: CtorToolkit<any>, key: any, ...params: any) => any;
|
|
240
224
|
type Tail<T extends any[]> = T extends [any, ...infer Rest] ? Rest : any[];
|
|
@@ -268,13 +252,13 @@ type MoleculeKey<M extends MoleculeConstructor> = InstanceType<M>[`key`];
|
|
|
268
252
|
declare function makeRootMolecule(key: string, store?: Store): MoleculeToken<ObjectConstructor>;
|
|
269
253
|
|
|
270
254
|
declare function disposeState(token: MoleculeToken<any> | ReadableToken<any>): void;
|
|
271
|
-
declare function disposeState<K extends
|
|
255
|
+
declare function disposeState<K extends Canonical>(token: ReadableFamilyToken<any, K>, key: K): void;
|
|
272
256
|
declare function disposeState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: MoleculeKey<M>): void;
|
|
273
257
|
|
|
274
258
|
declare function getState<T>(token: ReadableToken<T>): T;
|
|
275
259
|
declare function getState<M extends MoleculeConstructor>(token: MoleculeToken<M>): InstanceType<M>;
|
|
276
|
-
declare function getState<T, K extends
|
|
277
|
-
declare function getState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key:
|
|
260
|
+
declare function getState<T, K extends Canonical>(token: ReadableFamilyToken<T, K>, key: K): T;
|
|
261
|
+
declare function getState<M extends MoleculeConstructor>(token: MoleculeFamilyToken<M>, key: Canonical): InstanceType<M>;
|
|
278
262
|
|
|
279
263
|
declare const LoggerIconDictionary: {
|
|
280
264
|
readonly "\u231B": "Timeline event fully captured";
|
|
@@ -346,12 +330,6 @@ declare class AtomIOLogger implements Logger {
|
|
|
346
330
|
warn: LogFn;
|
|
347
331
|
}
|
|
348
332
|
|
|
349
|
-
type primitive = boolean | number | string | null;
|
|
350
|
-
|
|
351
|
-
type Serializable = primitive | Readonly<{
|
|
352
|
-
[key: string]: Serializable;
|
|
353
|
-
}> | ReadonlyArray<Serializable>;
|
|
354
|
-
|
|
355
333
|
/**
|
|
356
334
|
* @public
|
|
357
335
|
* Set the value of a state into the implicit store.
|
|
@@ -369,7 +347,7 @@ declare function setState<T, New extends T>(token: WritableToken<T>, value: New
|
|
|
369
347
|
* @param value - The new value of the state.
|
|
370
348
|
* @overload Streamlined
|
|
371
349
|
*/
|
|
372
|
-
declare function setState<T, K extends
|
|
350
|
+
declare function setState<T, K extends Canonical, New extends T>(token: WritableFamilyToken<T, K>, key: K, value: New | ((oldValue: T) => New)): void;
|
|
373
351
|
|
|
374
352
|
declare class Silo {
|
|
375
353
|
store: Store;
|
|
@@ -466,13 +444,13 @@ type ReadonlySelectorToken<T> = {
|
|
|
466
444
|
type SelectorToken<T> = ReadonlySelectorToken<T> | WritableSelectorToken<T>;
|
|
467
445
|
type WritableToken<T> = AtomToken<T> | WritableSelectorToken<T>;
|
|
468
446
|
type ReadableToken<T> = AtomToken<T> | SelectorToken<T>;
|
|
469
|
-
type WritableFamily<T, K extends
|
|
470
|
-
type ReadableFamily<T, K extends
|
|
471
|
-
type WritableFamilyToken<T, K extends
|
|
472
|
-
type ReadableFamilyToken<T, K extends
|
|
447
|
+
type WritableFamily<T, K extends Canonical> = AtomFamily<T, K> | WritableSelectorFamily<T, K>;
|
|
448
|
+
type ReadableFamily<T, K extends Canonical> = AtomFamily<T, K> | SelectorFamily<T, K>;
|
|
449
|
+
type WritableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | WritableSelectorFamilyToken<T, K>;
|
|
450
|
+
type ReadableFamilyToken<T, K extends Canonical> = AtomFamilyToken<T, K> | SelectorFamilyToken<T, K>;
|
|
473
451
|
type FamilyMetadata = {
|
|
474
452
|
key: string;
|
|
475
453
|
subKey: string;
|
|
476
454
|
};
|
|
477
455
|
|
|
478
|
-
export { type ActorToolkit, type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type CtorToolkit, type Effectors, type FamilyMetadata, type GetterToolkit, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeConstructor, type MoleculeCreation, type MoleculeDisposal, type MoleculeFamily, type MoleculeFamilyOptions, type MoleculeFamilyToken, type MoleculeKey, type MoleculeParams, type MoleculeToken, type MoleculeType, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type
|
|
456
|
+
export { type ActorToolkit, type AtomEffect, type AtomFamily, type AtomFamilyToken, AtomIOLogger, type AtomOnly, type AtomToken, type CtorToolkit, type Effectors, type FamilyMetadata, type GetterToolkit, type KeyedStateUpdate, LOG_LEVELS, type LogFilter, type LogFn, type LogLevel, type Logger, type LoggerIcon, type MoleculeConstructor, type MoleculeCreation, type MoleculeDisposal, type MoleculeFamily, type MoleculeFamilyOptions, type MoleculeFamilyToken, type MoleculeKey, type MoleculeParams, type MoleculeToken, type MoleculeType, type MutableAtomFamily, type MutableAtomFamilyOptions, type MutableAtomFamilyToken, type MutableAtomOptions, type MutableAtomToken, type Read, type ReadableFamily, type ReadableFamilyToken, type ReadableToken, type ReadonlySelectorFamily, type ReadonlySelectorFamilyOptions, type ReadonlySelectorFamilyToken, type ReadonlySelectorOptions, type ReadonlySelectorToken, type RegularAtomFamily, type RegularAtomFamilyOptions, type RegularAtomFamilyToken, type RegularAtomOptions, type RegularAtomToken, type SelectorFamily, type SelectorFamilyToken, type SelectorToken, type SetterToolkit, 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 UpdateHandler, type WritableFamily, type WritableFamilyToken, type WritableSelectorFamily, type WritableSelectorFamilyOptions, type WritableSelectorFamilyToken, type WritableSelectorOptions, type WritableSelectorToken, type WritableToken, type Write, atom, atomFamily, belongsTo, disposeState, getState, isToken, makeMolecule, makeRootMolecule, moleculeFamily, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|