atom.io 0.31.0 → 0.32.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 +867 -101
- package/data/dist/index.js +10 -558
- package/data/src/index.ts +0 -2
- package/data/src/struct-family.ts +1 -1
- package/data/src/struct.ts +1 -2
- package/dist/chunk-354XQWHH.js +153 -0
- package/dist/chunk-4LWKCEW3.js +14 -0
- package/dist/chunk-5F2V7S3B.js +83 -0
- package/dist/chunk-ECOMOMUN.js +631 -0
- package/dist/{chunk-42UH5F5Q.js → chunk-GY2XQYZY.js} +2051 -755
- package/dist/chunk-NF7FJKJD.js +107 -0
- package/dist/chunk-R3ZUK5EH.js +1024 -0
- package/dist/chunk-Z2UJW4NQ.js +523 -0
- package/dist/index.d.ts +855 -127
- package/dist/index.js +1 -143
- package/eslint-plugin/dist/index.d.ts +1 -30
- package/eslint-plugin/dist/index.js +0 -146
- package/eslint-plugin/src/index.ts +0 -1
- package/eslint-plugin/src/rules/index.ts +0 -1
- package/internal/dist/index.d.ts +794 -70
- package/internal/dist/index.js +1 -2
- package/internal/src/atom/create-regular-atom.ts +3 -3
- package/internal/src/atom/dispose-atom.ts +4 -13
- package/internal/src/atom/is-default.ts +3 -3
- package/internal/src/caching.ts +5 -5
- package/internal/src/capitalize.ts +3 -0
- package/internal/src/families/create-readonly-selector-family.ts +5 -6
- package/internal/src/families/create-writable-selector-family.ts +1 -4
- package/internal/src/families/dispose-from-store.ts +3 -13
- package/internal/src/families/find-in-store.ts +1 -6
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/get-state/read-or-compute-value.ts +1 -1
- package/internal/src/index.ts +19 -9
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +2 -3
- package/internal/src/install-into-store.ts +48 -0
- package/internal/src/join/edit-relations-in-store.ts +32 -0
- package/internal/src/join/find-relations-in-store.ts +124 -0
- package/internal/src/join/get-internal-relations-from-store.ts +14 -0
- package/internal/src/join/get-join.ts +31 -0
- package/internal/src/join/index.ts +5 -0
- package/{data/src/join.ts → internal/src/join/join-internal.ts} +20 -429
- package/internal/src/keys.ts +7 -7
- package/internal/src/molecule.ts +299 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-json-token.ts +1 -1
- package/internal/src/mutable/tracker-family.ts +19 -17
- package/internal/src/mutable/tracker.ts +8 -8
- package/internal/src/not-found-error.ts +8 -30
- package/internal/src/pretty-print.ts +2 -13
- package/internal/src/selector/create-readonly-selector.ts +3 -7
- package/internal/src/selector/create-writable-selector.ts +4 -4
- package/internal/src/selector/dispose-selector.ts +20 -11
- package/internal/src/selector/get-selector-dependency-keys.ts +1 -1
- package/internal/src/selector/register-selector.ts +7 -17
- package/internal/src/selector/trace-selector-atoms.ts +2 -2
- package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
- package/internal/src/set-state/emit-update.ts +1 -1
- package/internal/src/set-state/evict-downstream.ts +1 -1
- package/internal/src/set-state/set-atom-or-selector.ts +1 -1
- package/internal/src/set-state/set-atom.ts +10 -10
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/set-state/stow-update.ts +1 -1
- package/internal/src/store/deposit.ts +10 -8
- package/internal/src/store/store.ts +1 -1
- package/internal/src/store/withdraw.ts +34 -53
- package/internal/src/subscribe/recall-state.ts +1 -1
- package/internal/src/subscribe/subscribe-in-store.ts +3 -3
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
- package/internal/src/subscribe/subscribe-to-state.ts +5 -5
- package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
- package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
- package/internal/src/timeline/create-timeline.ts +17 -37
- package/internal/src/transaction/act-upon-store.ts +2 -2
- package/internal/src/transaction/apply-transaction.ts +5 -5
- package/internal/src/transaction/assign-transaction-to-continuity.ts +1 -1
- package/internal/src/transaction/build-transaction.ts +5 -8
- package/internal/src/transaction/create-transaction.ts +3 -3
- package/internal/src/transaction/get-epoch-number.ts +3 -3
- package/internal/src/transaction/set-epoch-number.ts +2 -2
- package/introspection/dist/index.d.ts +922 -6
- package/introspection/dist/index.js +2 -620
- package/json/dist/index.d.ts +899 -5
- package/json/dist/index.js +1 -81
- package/json/src/select-json-family.ts +3 -14
- package/package.json +27 -45
- package/react/dist/index.d.ts +921 -3
- package/react/dist/index.js +2 -82
- package/react/src/use-o.ts +1 -1
- package/react/src/use-tl.ts +2 -2
- package/react-devtools/dist/index.css +16 -14
- package/react-devtools/dist/index.d.ts +26 -1
- package/react-devtools/dist/index.js +6 -6
- package/react-devtools/src/devtools.scss +16 -14
- package/realtime/dist/index.d.ts +202 -8
- package/realtime/dist/index.js +2 -107
- package/realtime/src/realtime-continuity.ts +2 -2
- package/realtime/src/shared-room-store.ts +1 -2
- package/realtime-client/dist/index.d.ts +960 -22
- package/realtime-client/dist/index.js +3 -509
- package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
- package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
- package/realtime-client/src/pull-atom-family-member.ts +2 -2
- package/realtime-client/src/pull-atom.ts +2 -2
- package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
- package/realtime-client/src/pull-mutable-atom.ts +2 -2
- package/realtime-client/src/pull-selector-family-member.ts +4 -4
- package/realtime-client/src/pull-selector.ts +4 -4
- package/realtime-client/src/push-state.ts +5 -10
- package/realtime-client/src/server-action.ts +4 -4
- package/realtime-client/src/sync-continuity.ts +6 -6
- package/realtime-react/dist/index.d.ts +166 -12
- package/realtime-react/dist/index.js +5 -154
- package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
- package/realtime-react/src/use-pull-atom.ts +1 -1
- package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
- package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector.ts +1 -1
- package/realtime-react/src/use-push.ts +1 -1
- package/realtime-react/src/use-server-action.ts +2 -2
- package/realtime-react/src/use-sync-continuity.ts +1 -1
- package/realtime-server/dist/index.d.ts +971 -28
- package/realtime-server/dist/index.js +3 -1001
- package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
- package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
- package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
- package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
- package/realtime-server/src/ipc-sockets/child-socket.ts +0 -1
- package/realtime-server/src/realtime-action-receiver.ts +1 -1
- package/realtime-server/src/realtime-family-provider.ts +2 -2
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
- package/realtime-server/src/realtime-mutable-provider.ts +2 -2
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
- package/realtime-server/src/realtime-state-provider.ts +2 -2
- package/realtime-testing/dist/index.d.ts +1091 -3
- package/realtime-testing/dist/index.js +23 -26
- package/realtime-testing/src/setup-realtime-test.tsx +6 -5
- package/src/atom.ts +53 -29
- package/src/dispose-state.ts +12 -2
- package/{ephemeral/src → src}/find-state.ts +35 -25
- package/src/get-state.ts +16 -0
- package/src/index.ts +77 -3
- package/src/join.ts +218 -0
- package/src/realm.ts +169 -0
- package/src/selector.ts +20 -0
- package/src/set-state.ts +16 -8
- package/src/silo.ts +13 -7
- package/src/timeline.ts +1 -1
- package/src/transaction.ts +4 -8
- package/transceivers/set-rtx/dist/index.d.ts +37 -2
- package/transceivers/set-rtx/dist/index.js +1 -212
- package/transceivers/set-rtx/src/set-rtx.ts +4 -1
- package/web/dist/index.d.ts +30 -1
- package/web/dist/index.js +1 -15
- package/data/src/until.ts +0 -15
- package/dist/chunk-ICGFFQ3H.js +0 -272
- package/ephemeral/dist/index.d.ts +0 -57
- package/ephemeral/dist/index.js +0 -9
- package/ephemeral/package.json +0 -13
- package/ephemeral/src/index.ts +0 -1
- package/eslint-plugin/src/rules/lifespan.ts +0 -203
- package/immortal/dist/index.d.ts +0 -12
- package/immortal/dist/index.js +0 -9
- package/immortal/package.json +0 -13
- package/immortal/src/index.ts +0 -1
- package/immortal/src/seek-state.ts +0 -60
- package/src/allocate.ts +0 -443
- package/src/molecule.ts +0 -16
|
@@ -1,213 +1,2 @@
|
|
|
1
|
+
export { SetRTX } from '../../../dist/chunk-GY2XQYZY.js';
|
|
1
2
|
import '../../../dist/chunk-XWL6SNVU.js';
|
|
2
|
-
import { Subject } from 'atom.io/internal';
|
|
3
|
-
import { stringifyJson } from 'atom.io/json';
|
|
4
|
-
|
|
5
|
-
var SetRTX = class _SetRTX extends Set {
|
|
6
|
-
mode = `record`;
|
|
7
|
-
subject = new Subject();
|
|
8
|
-
cacheLimit = 0;
|
|
9
|
-
cache = [];
|
|
10
|
-
cacheIdx = -1;
|
|
11
|
-
cacheUpdateNumber = -1;
|
|
12
|
-
constructor(values, cacheLimit = 0) {
|
|
13
|
-
super(values);
|
|
14
|
-
if (values instanceof _SetRTX) {
|
|
15
|
-
this.parent = values;
|
|
16
|
-
this.cacheUpdateNumber = values.cacheUpdateNumber;
|
|
17
|
-
}
|
|
18
|
-
if (cacheLimit) {
|
|
19
|
-
this.cacheLimit = cacheLimit;
|
|
20
|
-
this.cache = new Array(cacheLimit);
|
|
21
|
-
this.subscribe(`auto cache`, (update) => {
|
|
22
|
-
this.cacheIdx++;
|
|
23
|
-
this.cacheIdx %= this.cacheLimit;
|
|
24
|
-
this.cache[this.cacheIdx] = update;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
toJSON() {
|
|
29
|
-
return {
|
|
30
|
-
members: [...this],
|
|
31
|
-
cache: this.cache,
|
|
32
|
-
cacheLimit: this.cacheLimit,
|
|
33
|
-
cacheIdx: this.cacheIdx,
|
|
34
|
-
cacheUpdateNumber: this.cacheUpdateNumber
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
static fromJSON(json) {
|
|
38
|
-
const set = new _SetRTX(json.members, json.cacheLimit);
|
|
39
|
-
set.cache = json.cache;
|
|
40
|
-
set.cacheIdx = json.cacheIdx;
|
|
41
|
-
set.cacheUpdateNumber = json.cacheUpdateNumber;
|
|
42
|
-
return set;
|
|
43
|
-
}
|
|
44
|
-
add(value) {
|
|
45
|
-
const result = super.add(value);
|
|
46
|
-
if (this.mode === `record`) {
|
|
47
|
-
this.cacheUpdateNumber++;
|
|
48
|
-
this.emit(`add:${stringifyJson(value)}`);
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
clear() {
|
|
53
|
-
const capturedContents = this.mode === `record` ? [...this] : null;
|
|
54
|
-
super.clear();
|
|
55
|
-
if (capturedContents) {
|
|
56
|
-
this.cacheUpdateNumber++;
|
|
57
|
-
this.emit(`clear:${JSON.stringify(capturedContents)}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
delete(value) {
|
|
61
|
-
const result = super.delete(value);
|
|
62
|
-
if (this.mode === `record`) {
|
|
63
|
-
this.cacheUpdateNumber++;
|
|
64
|
-
this.emit(`del:${stringifyJson(value)}`);
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
parent;
|
|
69
|
-
child = null;
|
|
70
|
-
transactionUpdates = null;
|
|
71
|
-
transaction(run) {
|
|
72
|
-
this.mode = `transaction`;
|
|
73
|
-
this.transactionUpdates = [];
|
|
74
|
-
this.child = new _SetRTX(this);
|
|
75
|
-
const unsubscribe = this.child._subscribe(`transaction`, (update) => {
|
|
76
|
-
this.transactionUpdates?.push(update);
|
|
77
|
-
});
|
|
78
|
-
try {
|
|
79
|
-
const shouldCommit = run(this.child);
|
|
80
|
-
if (shouldCommit) {
|
|
81
|
-
for (const update of this.transactionUpdates) {
|
|
82
|
-
this.doStep(update);
|
|
83
|
-
}
|
|
84
|
-
this.cacheUpdateNumber++;
|
|
85
|
-
this.emit(`tx:${this.transactionUpdates.join(`;`)}`);
|
|
86
|
-
}
|
|
87
|
-
} catch (thrown) {
|
|
88
|
-
console.error(`Failed to apply transaction to SetRTX:`, thrown);
|
|
89
|
-
throw thrown;
|
|
90
|
-
} finally {
|
|
91
|
-
unsubscribe();
|
|
92
|
-
this.child = null;
|
|
93
|
-
this.transactionUpdates = null;
|
|
94
|
-
this.mode = `record`;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
_subscribe(key, fn) {
|
|
98
|
-
return this.subject.subscribe(key, fn);
|
|
99
|
-
}
|
|
100
|
-
subscribe(key, fn) {
|
|
101
|
-
return this.subject.subscribe(key, (update) => {
|
|
102
|
-
fn(`${this.cacheUpdateNumber}=${update}`);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
emit(update) {
|
|
106
|
-
this.subject.next(update);
|
|
107
|
-
}
|
|
108
|
-
doStep(update) {
|
|
109
|
-
const typeValueBreak = update.indexOf(`:`);
|
|
110
|
-
const type = update.substring(0, typeValueBreak);
|
|
111
|
-
const value = update.substring(typeValueBreak + 1);
|
|
112
|
-
switch (type) {
|
|
113
|
-
case `add`:
|
|
114
|
-
this.add(JSON.parse(value));
|
|
115
|
-
break;
|
|
116
|
-
case `clear`:
|
|
117
|
-
this.clear();
|
|
118
|
-
break;
|
|
119
|
-
case `del`:
|
|
120
|
-
this.delete(JSON.parse(value));
|
|
121
|
-
break;
|
|
122
|
-
case `tx`:
|
|
123
|
-
for (const subUpdate of value.split(`;`)) {
|
|
124
|
-
this.doStep(subUpdate);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
getUpdateNumber(update) {
|
|
129
|
-
const breakpoint = update.indexOf(`=`);
|
|
130
|
-
return Number(update.substring(0, breakpoint));
|
|
131
|
-
}
|
|
132
|
-
do(update) {
|
|
133
|
-
const breakpoint = update.indexOf(`=`);
|
|
134
|
-
const updateNumber = Number(update.substring(0, breakpoint));
|
|
135
|
-
const eventOffset = updateNumber - this.cacheUpdateNumber;
|
|
136
|
-
const isFuture = eventOffset > 0;
|
|
137
|
-
if (isFuture) {
|
|
138
|
-
if (eventOffset === 1) {
|
|
139
|
-
this.mode = `playback`;
|
|
140
|
-
const innerUpdate = update.substring(breakpoint + 1);
|
|
141
|
-
this.doStep(innerUpdate);
|
|
142
|
-
this.mode = `record`;
|
|
143
|
-
this.cacheUpdateNumber = updateNumber;
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
return this.cacheUpdateNumber + 1;
|
|
147
|
-
}
|
|
148
|
-
if (Math.abs(eventOffset) < this.cacheLimit) {
|
|
149
|
-
const eventIdx = this.cacheIdx + eventOffset;
|
|
150
|
-
const cachedUpdate = this.cache[eventIdx];
|
|
151
|
-
if (cachedUpdate === update) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
this.mode = `playback`;
|
|
155
|
-
let done = false;
|
|
156
|
-
while (!done) {
|
|
157
|
-
this.cacheIdx %= this.cacheLimit;
|
|
158
|
-
const u = this.cache[this.cacheIdx];
|
|
159
|
-
this.cacheIdx--;
|
|
160
|
-
if (!u) {
|
|
161
|
-
return `OUT_OF_RANGE`;
|
|
162
|
-
}
|
|
163
|
-
this.undo(u);
|
|
164
|
-
done = this.cacheIdx === eventIdx - 1;
|
|
165
|
-
}
|
|
166
|
-
const innerUpdate = update.substring(breakpoint + 1);
|
|
167
|
-
this.doStep(innerUpdate);
|
|
168
|
-
this.mode = `record`;
|
|
169
|
-
this.cacheUpdateNumber = updateNumber;
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
return `OUT_OF_RANGE`;
|
|
173
|
-
}
|
|
174
|
-
undoStep(update) {
|
|
175
|
-
const breakpoint = update.indexOf(`:`);
|
|
176
|
-
const type = update.substring(0, breakpoint);
|
|
177
|
-
const value = update.substring(breakpoint + 1);
|
|
178
|
-
switch (type) {
|
|
179
|
-
case `add`:
|
|
180
|
-
this.delete(JSON.parse(value));
|
|
181
|
-
break;
|
|
182
|
-
case `del`:
|
|
183
|
-
this.add(JSON.parse(value));
|
|
184
|
-
break;
|
|
185
|
-
case `clear`: {
|
|
186
|
-
const values = JSON.parse(value);
|
|
187
|
-
for (const v of values) this.add(v);
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
case `tx`: {
|
|
191
|
-
const updates = value.split(`;`);
|
|
192
|
-
for (let i = updates.length - 1; i >= 0; i--) {
|
|
193
|
-
this.undoStep(updates[i]);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
undo(update) {
|
|
199
|
-
const breakpoint = update.indexOf(`=`);
|
|
200
|
-
const updateNumber = Number(update.substring(0, breakpoint));
|
|
201
|
-
if (updateNumber === this.cacheUpdateNumber) {
|
|
202
|
-
this.mode = `playback`;
|
|
203
|
-
const innerUpdate = update.substring(breakpoint + 1);
|
|
204
|
-
this.undoStep(innerUpdate);
|
|
205
|
-
this.mode = `record`;
|
|
206
|
-
this.cacheUpdateNumber--;
|
|
207
|
-
return null;
|
|
208
|
-
}
|
|
209
|
-
return this.cacheUpdateNumber;
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
export { SetRTX };
|
|
@@ -111,7 +111,10 @@ export class SetRTX<P extends primitive>
|
|
|
111
111
|
}
|
|
112
112
|
} catch (thrown) {
|
|
113
113
|
/* eslint-disable-next-line no-console */
|
|
114
|
-
console.
|
|
114
|
+
console.warn(
|
|
115
|
+
`Did not apply transaction to SetRTX; this error was thrown:`,
|
|
116
|
+
thrown,
|
|
117
|
+
)
|
|
115
118
|
throw thrown
|
|
116
119
|
} finally {
|
|
117
120
|
unsubscribe()
|
package/web/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
/** @public */
|
|
2
|
+
type Effectors<T> = {
|
|
3
|
+
/**
|
|
4
|
+
* Set the value of the atom
|
|
5
|
+
* @param next - The new value of the atom, or a setter function
|
|
6
|
+
*/
|
|
7
|
+
setSelf: <New extends T>(next: New | Setter<T, New>) => void;
|
|
8
|
+
/** Subscribe to changes to the atom */
|
|
9
|
+
onSet: (callback: (options: {
|
|
10
|
+
newValue: T;
|
|
11
|
+
oldValue: T;
|
|
12
|
+
}) => void) => void;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @public
|
|
16
|
+
* A function that runs side effects when the atom is set
|
|
17
|
+
* @param tools - {@link Effectors} that can be used to run side effects
|
|
18
|
+
* @returns
|
|
19
|
+
* Optionally, a cleanup function that will be called when the atom is disposed
|
|
20
|
+
*/
|
|
21
|
+
type AtomEffect<T> = (tools: Effectors<T>) => (() => void) | void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @public
|
|
25
|
+
* A function that sets the value of a state.
|
|
26
|
+
* @param oldValue - The current value of the state.
|
|
27
|
+
* @returns
|
|
28
|
+
* The new value of the state.
|
|
29
|
+
*/
|
|
30
|
+
type Setter<T, New extends T> = (oldValue: T) => New;
|
|
2
31
|
|
|
3
32
|
type StringInterface<T> = {
|
|
4
33
|
stringify: (t: T) => string;
|
package/web/dist/index.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
+
export { persistSync } from '../../dist/chunk-4LWKCEW3.js';
|
|
1
2
|
import '../../dist/chunk-XWL6SNVU.js';
|
|
2
|
-
|
|
3
|
-
// web/src/persist-sync.ts
|
|
4
|
-
var persistSync = (storage, { stringify, parse }, key) => ({ setSelf, onSet }) => {
|
|
5
|
-
const savedValue = storage.getItem(key);
|
|
6
|
-
if (savedValue != null) setSelf(parse(savedValue));
|
|
7
|
-
onSet(({ newValue }) => {
|
|
8
|
-
if (newValue == null) {
|
|
9
|
-
storage.removeItem(key);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
storage.setItem(key, stringify(newValue));
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { persistSync };
|
package/data/src/until.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type Loadable<T> = Promise<T> | T
|
|
2
|
-
export type Fated<T, E extends Error = Error> = Loadable<E | T>
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Utility for handling loadable values
|
|
6
|
-
* @param loadable Loadable value
|
|
7
|
-
* @param fallback Fallback value until Loadable is resolved
|
|
8
|
-
* @returns Fallback value if your loadable is a promise, otherwise the loadable's resolved value
|
|
9
|
-
*/
|
|
10
|
-
export function until<T>(loadable: Loadable<T>, fallback: T): T {
|
|
11
|
-
if (loadable instanceof Promise) {
|
|
12
|
-
return fallback
|
|
13
|
-
}
|
|
14
|
-
return loadable
|
|
15
|
-
}
|
package/dist/chunk-ICGFFQ3H.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { IMPLICIT, newest, isChildStore, findInStore, disposeFromStore, getTrace } from 'atom.io/internal';
|
|
2
|
-
import { stringifyJson, parseJson } from 'atom.io/json';
|
|
3
|
-
|
|
4
|
-
// src/molecule.ts
|
|
5
|
-
function makeRootMoleculeInStore(key, store = IMPLICIT.STORE) {
|
|
6
|
-
const molecule = {
|
|
7
|
-
key,
|
|
8
|
-
stringKey: stringifyJson(key),
|
|
9
|
-
dependsOn: `any`
|
|
10
|
-
};
|
|
11
|
-
store.molecules.set(stringifyJson(key), molecule);
|
|
12
|
-
return key;
|
|
13
|
-
}
|
|
14
|
-
var $claim = Symbol(`claim`);
|
|
15
|
-
function allocateIntoStore(store, provenance, key, dependsOn = `any`) {
|
|
16
|
-
const origin = provenance;
|
|
17
|
-
const stringKey = stringifyJson(key);
|
|
18
|
-
const invalidKeys = [];
|
|
19
|
-
const target = newest(store);
|
|
20
|
-
if (Array.isArray(origin)) {
|
|
21
|
-
for (const formerClaim of origin) {
|
|
22
|
-
const claimString = stringifyJson(formerClaim);
|
|
23
|
-
const claim = target.molecules.get(claimString);
|
|
24
|
-
if (claim) {
|
|
25
|
-
store.moleculeGraph.set(claimString, stringKey, { source: claimString });
|
|
26
|
-
} else {
|
|
27
|
-
invalidKeys.push(claimString);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
const claimString = stringifyJson(origin);
|
|
32
|
-
const claim = target.molecules.get(claimString);
|
|
33
|
-
if (claim) {
|
|
34
|
-
store.moleculeGraph.set(claimString, stringKey, { source: claimString });
|
|
35
|
-
} else {
|
|
36
|
-
invalidKeys.push(claimString);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (invalidKeys.length === 0) {
|
|
40
|
-
target.molecules.set(stringKey, { key, stringKey, dependsOn });
|
|
41
|
-
}
|
|
42
|
-
const creationEvent = {
|
|
43
|
-
type: `molecule_creation`,
|
|
44
|
-
key,
|
|
45
|
-
provenance: origin
|
|
46
|
-
};
|
|
47
|
-
const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
|
|
48
|
-
if (isTransaction) {
|
|
49
|
-
target.transactionMeta.update.updates.push(creationEvent);
|
|
50
|
-
} else {
|
|
51
|
-
target.on.moleculeCreation.next(creationEvent);
|
|
52
|
-
}
|
|
53
|
-
for (const claim of invalidKeys) {
|
|
54
|
-
const disposal = store.disposalTraces.buffer.find(
|
|
55
|
-
(item) => item?.key === claim
|
|
56
|
-
);
|
|
57
|
-
store.logger.error(
|
|
58
|
-
`\u274C`,
|
|
59
|
-
`molecule`,
|
|
60
|
-
key,
|
|
61
|
-
`allocation failed:`,
|
|
62
|
-
`Could not allocate to ${claim} in store "${store.config.name}".`,
|
|
63
|
-
disposal ? `
|
|
64
|
-
${claim} was most recently disposed
|
|
65
|
-
${disposal.trace}` : `No previous disposal trace for ${claim} was found.`
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
return key;
|
|
69
|
-
}
|
|
70
|
-
function fuseWithinStore(store, type, sideA, sideB) {
|
|
71
|
-
const compoundKey = `T$--${type}==${sideA}++${sideB}`;
|
|
72
|
-
const above = [sideA, sideB];
|
|
73
|
-
allocateIntoStore(
|
|
74
|
-
store,
|
|
75
|
-
above,
|
|
76
|
-
compoundKey,
|
|
77
|
-
`all`
|
|
78
|
-
);
|
|
79
|
-
return compoundKey;
|
|
80
|
-
}
|
|
81
|
-
function deallocateFromStore(store, claim) {
|
|
82
|
-
const stringKey = stringifyJson(claim);
|
|
83
|
-
const molecule = store.molecules.get(stringKey);
|
|
84
|
-
if (!molecule) {
|
|
85
|
-
const disposal = store.disposalTraces.buffer.find(
|
|
86
|
-
(item) => item?.key === stringKey
|
|
87
|
-
);
|
|
88
|
-
store.logger.error(
|
|
89
|
-
`\u274C`,
|
|
90
|
-
`molecule`,
|
|
91
|
-
claim,
|
|
92
|
-
`deallocation failed:`,
|
|
93
|
-
`Could not find allocation for ${stringKey} in store "${store.config.name}".`,
|
|
94
|
-
disposal ? `
|
|
95
|
-
This state was most recently deallocated
|
|
96
|
-
${disposal.trace}` : `No previous disposal trace for ${stringKey} was found.`
|
|
97
|
-
);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const joinKeys = store.moleculeJoins.getRelatedKeys(
|
|
101
|
-
molecule.key
|
|
102
|
-
);
|
|
103
|
-
if (joinKeys) {
|
|
104
|
-
for (const joinKey of joinKeys) {
|
|
105
|
-
const join = store.joins.get(joinKey);
|
|
106
|
-
if (join) {
|
|
107
|
-
join.relations.delete(molecule.key);
|
|
108
|
-
join.molecules.delete(molecule.stringKey);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
store.moleculeJoins.delete(molecule.stringKey);
|
|
113
|
-
const provenance = [];
|
|
114
|
-
const values = [];
|
|
115
|
-
const disposalEvent = {
|
|
116
|
-
type: `molecule_disposal`,
|
|
117
|
-
key: molecule.key,
|
|
118
|
-
values,
|
|
119
|
-
provenance
|
|
120
|
-
};
|
|
121
|
-
const target = newest(store);
|
|
122
|
-
target.molecules.delete(stringKey);
|
|
123
|
-
const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
|
|
124
|
-
if (isTransaction) {
|
|
125
|
-
target.transactionMeta.update.updates.push(disposalEvent);
|
|
126
|
-
}
|
|
127
|
-
const relatedMolecules = store.moleculeGraph.getRelationEntries({
|
|
128
|
-
downstreamMoleculeKey: molecule.stringKey
|
|
129
|
-
});
|
|
130
|
-
if (relatedMolecules) {
|
|
131
|
-
for (const [relatedStringKey, { source }] of relatedMolecules) {
|
|
132
|
-
if (source === molecule.stringKey) {
|
|
133
|
-
const relatedKey = parseJson(relatedStringKey);
|
|
134
|
-
deallocateFromStore(store, relatedKey);
|
|
135
|
-
} else {
|
|
136
|
-
provenance.push(source);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const familyKeys = target.moleculeData.getRelatedKeys(molecule.stringKey);
|
|
141
|
-
if (familyKeys) {
|
|
142
|
-
for (const familyKey of familyKeys) {
|
|
143
|
-
const family = target.families.get(familyKey);
|
|
144
|
-
const token = findInStore(store, family, molecule.key);
|
|
145
|
-
values.push([family.key, token]);
|
|
146
|
-
disposeFromStore(store, token);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
target.moleculeGraph.delete(molecule.stringKey);
|
|
150
|
-
target.moleculeJoins.delete(molecule.stringKey);
|
|
151
|
-
target.moleculeData.delete(molecule.stringKey);
|
|
152
|
-
if (!isTransaction) {
|
|
153
|
-
target.on.moleculeDisposal.next(disposalEvent);
|
|
154
|
-
}
|
|
155
|
-
target.molecules.delete(molecule.stringKey);
|
|
156
|
-
const trace = getTrace(new Error());
|
|
157
|
-
store.disposalTraces.add({ key: stringKey, trace });
|
|
158
|
-
}
|
|
159
|
-
function claimWithinStore(store, newProvenance, claim, exclusive) {
|
|
160
|
-
const stringKey = stringifyJson(claim);
|
|
161
|
-
const target = newest(store);
|
|
162
|
-
const molecule = target.molecules.get(stringKey);
|
|
163
|
-
if (!molecule) {
|
|
164
|
-
const disposal = store.disposalTraces.buffer.find(
|
|
165
|
-
(item) => item?.key === stringKey
|
|
166
|
-
);
|
|
167
|
-
store.logger.error(
|
|
168
|
-
`\u274C`,
|
|
169
|
-
`molecule`,
|
|
170
|
-
claim,
|
|
171
|
-
`claim failed:`,
|
|
172
|
-
`Could not allocate to ${stringKey} in store "${store.config.name}".`,
|
|
173
|
-
disposal ? `
|
|
174
|
-
${stringKey} was most recently disposed
|
|
175
|
-
${disposal.trace}` : `No previous disposal trace for ${stringKey} was found.`
|
|
176
|
-
);
|
|
177
|
-
return claim;
|
|
178
|
-
}
|
|
179
|
-
const newProvenanceKey = stringifyJson(newProvenance);
|
|
180
|
-
const newProvenanceMolecule = target.molecules.get(newProvenanceKey);
|
|
181
|
-
if (!newProvenanceMolecule) {
|
|
182
|
-
const disposal = store.disposalTraces.buffer.find(
|
|
183
|
-
(item) => item?.key === newProvenanceKey
|
|
184
|
-
);
|
|
185
|
-
store.logger.error(
|
|
186
|
-
`\u274C`,
|
|
187
|
-
`molecule`,
|
|
188
|
-
claim,
|
|
189
|
-
`claim failed:`,
|
|
190
|
-
`Could not allocate to ${newProvenanceKey} in store "${store.config.name}".`,
|
|
191
|
-
disposal ? `
|
|
192
|
-
${newProvenanceKey} was most recently disposed
|
|
193
|
-
${disposal.trace}` : `No previous disposal trace for ${newProvenanceKey} was found.`
|
|
194
|
-
);
|
|
195
|
-
return claim;
|
|
196
|
-
}
|
|
197
|
-
const priorProvenance = store.moleculeGraph.getRelationEntries({
|
|
198
|
-
downstreamMoleculeKey: molecule.stringKey
|
|
199
|
-
}).filter(([, { source }]) => source !== stringKey).map(([key]) => parseJson(key));
|
|
200
|
-
if (exclusive) {
|
|
201
|
-
target.moleculeGraph.delete(stringKey);
|
|
202
|
-
}
|
|
203
|
-
target.moleculeGraph.set(
|
|
204
|
-
{
|
|
205
|
-
upstreamMoleculeKey: newProvenanceMolecule.stringKey,
|
|
206
|
-
downstreamMoleculeKey: molecule.stringKey
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
source: newProvenanceMolecule.stringKey
|
|
210
|
-
}
|
|
211
|
-
);
|
|
212
|
-
const transferEvent = {
|
|
213
|
-
type: `molecule_transfer`,
|
|
214
|
-
key: molecule.key,
|
|
215
|
-
from: priorProvenance,
|
|
216
|
-
to: [newProvenanceMolecule.key]
|
|
217
|
-
};
|
|
218
|
-
const isTransaction = isChildStore(target) && target.transactionMeta.phase === `building`;
|
|
219
|
-
if (isTransaction) {
|
|
220
|
-
target.transactionMeta.update.updates.push(transferEvent);
|
|
221
|
-
}
|
|
222
|
-
return claim;
|
|
223
|
-
}
|
|
224
|
-
var Realm = class {
|
|
225
|
-
store;
|
|
226
|
-
constructor(store = IMPLICIT.STORE) {
|
|
227
|
-
this.store = store;
|
|
228
|
-
makeRootMoleculeInStore(`root`, store);
|
|
229
|
-
}
|
|
230
|
-
allocate(provenance, key, attachmentStyle) {
|
|
231
|
-
return allocateIntoStore(
|
|
232
|
-
this.store,
|
|
233
|
-
provenance,
|
|
234
|
-
key,
|
|
235
|
-
attachmentStyle
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
fuse(type, reagentA, reagentB) {
|
|
239
|
-
return fuseWithinStore(this.store, type, reagentA, reagentB);
|
|
240
|
-
}
|
|
241
|
-
deallocate(claim) {
|
|
242
|
-
deallocateFromStore(this.store, claim);
|
|
243
|
-
}
|
|
244
|
-
claim(newProvenance, claim, exclusive) {
|
|
245
|
-
return claimWithinStore(this.store, newProvenance, claim, exclusive);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
var T$ = `T$`;
|
|
249
|
-
var Anarchy = class {
|
|
250
|
-
store;
|
|
251
|
-
realm;
|
|
252
|
-
constructor(store = IMPLICIT.STORE) {
|
|
253
|
-
this.store = store;
|
|
254
|
-
this.realm = new Realm(store);
|
|
255
|
-
}
|
|
256
|
-
allocate(provenance, key, attachmentStyle) {
|
|
257
|
-
allocateIntoStore(
|
|
258
|
-
this.store,
|
|
259
|
-
provenance,
|
|
260
|
-
key,
|
|
261
|
-
attachmentStyle
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
deallocate(key) {
|
|
265
|
-
deallocateFromStore(this.store, key);
|
|
266
|
-
}
|
|
267
|
-
claim(newProvenance, key, exclusive) {
|
|
268
|
-
claimWithinStore(this.store, newProvenance, key, exclusive);
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
export { $claim, Anarchy, Realm, T$, allocateIntoStore, claimWithinStore, deallocateFromStore, fuseWithinStore, makeRootMoleculeInStore };
|
|
@@ -1,57 +0,0 @@
|
|
|
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, Canonical } from 'atom.io/json';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @overload Mutable Atom
|
|
7
|
-
* Finds a {@link MutableAtomToken} in the store.
|
|
8
|
-
* @param token - A {@link MutableAtomFamilyToken}.
|
|
9
|
-
* @param key - The key of the state.
|
|
10
|
-
* @returns
|
|
11
|
-
* The current value of the state.
|
|
12
|
-
*/
|
|
13
|
-
declare function findState<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical, Key extends K>(token: MutableAtomFamilyToken<T, J, K>, key: Key): MutableAtomToken<T, J, K>;
|
|
14
|
-
/**
|
|
15
|
-
* Finds a state in the store.
|
|
16
|
-
* @param token - The token of the state family.
|
|
17
|
-
* @param key - The key of the state.
|
|
18
|
-
* @returns
|
|
19
|
-
* The current value of the state.
|
|
20
|
-
*/
|
|
21
|
-
declare function findState<T, K extends Canonical, Key extends K>(token: RegularAtomFamilyToken<T, K>, key: Key): RegularAtomToken<T, K>;
|
|
22
|
-
/**
|
|
23
|
-
* Finds a state in the store.
|
|
24
|
-
* @param token - The token of the state family.
|
|
25
|
-
* @param key - The key of the state.
|
|
26
|
-
* @returns
|
|
27
|
-
* The current value of the state.
|
|
28
|
-
*/
|
|
29
|
-
declare function findState<T, K extends Canonical, Key extends K>(token: WritableSelectorFamilyToken<T, K>, key: Key): WritableSelectorToken<T, K>;
|
|
30
|
-
/**
|
|
31
|
-
* Finds a state in the store.
|
|
32
|
-
* @param token - The token of the state family.
|
|
33
|
-
* @param key - The key of the state.
|
|
34
|
-
* @returns
|
|
35
|
-
* The current value of the state.
|
|
36
|
-
*/
|
|
37
|
-
declare function findState<T, K extends Canonical, Key extends K>(token: ReadonlySelectorFamilyToken<T, K>, key: Key): ReadonlySelectorToken<T, K>;
|
|
38
|
-
/**
|
|
39
|
-
* Finds a state in the store.
|
|
40
|
-
* @param token - The token of the state family.
|
|
41
|
-
* @param key - The key of the state.
|
|
42
|
-
* @returns
|
|
43
|
-
* The current value of the state.
|
|
44
|
-
*/
|
|
45
|
-
declare function findState<T, K extends Canonical, Key extends K>(token: WritableFamilyToken<T, K>, key: Key): WritableToken<T, K>;
|
|
46
|
-
/**
|
|
47
|
-
* @public
|
|
48
|
-
* Finds a {@link ReadableToken} in the store.
|
|
49
|
-
* @param token - A {@link ReadableFamilyToken}.
|
|
50
|
-
* @param key - The key of the state.
|
|
51
|
-
* @returns
|
|
52
|
-
* The current value of the state.
|
|
53
|
-
* @overload Unknown
|
|
54
|
-
*/
|
|
55
|
-
declare function findState<T, K extends Canonical, Key extends K>(token: ReadableFamilyToken<T, K>, key: Key): ReadableToken<T, K>;
|
|
56
|
-
|
|
57
|
-
export { findState };
|
package/ephemeral/dist/index.js
DELETED
package/ephemeral/package.json
DELETED
package/ephemeral/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./find-state"
|