atom.io 0.6.4 → 0.6.6
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/README.md +32 -78
- package/dist/index.d.mts +4 -35
- package/dist/index.d.ts +4 -35
- package/dist/index.js +17 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -129
- package/dist/index.mjs.map +1 -1
- package/introspection/dist/index.js +312 -0
- package/introspection/dist/index.js.map +1 -0
- package/introspection/dist/index.mjs +289 -0
- package/introspection/dist/index.mjs.map +1 -0
- package/introspection/package.json +15 -0
- package/package.json +17 -8
- package/react-devtools/dist/index.css +22 -5
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +347 -8
- package/react-devtools/dist/index.d.ts +347 -8
- package/react-devtools/dist/index.js +2722 -674
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +2669 -630
- package/react-devtools/dist/index.mjs.map +1 -1
- package/src/internal/index.ts +0 -1
- package/src/internal/operation.ts +1 -0
- package/src/internal/store.ts +3 -2
- package/src/internal/time-travel-internal.ts +2 -0
- package/src/internal/timeline/add-atom-to-timeline.ts +11 -12
- package/src/internal/timeline-internal.ts +5 -1
- package/src/introspection/attach-atom-index.ts +73 -0
- package/src/introspection/attach-introspection-states.ts +42 -0
- package/src/introspection/attach-selector-index.ts +77 -0
- package/src/introspection/attach-timeline-family.ts +49 -0
- package/src/introspection/attach-timeline-index.ts +36 -0
- package/src/introspection/attach-transaction-index.ts +38 -0
- package/src/introspection/attach-transaction-logs.ts +40 -0
- package/src/introspection/index.ts +20 -0
- package/src/react-devtools/AtomIODevtools.tsx +97 -96
- package/src/react-devtools/Button.tsx +24 -0
- package/src/react-devtools/StateEditor.tsx +14 -16
- package/src/react-devtools/StateIndex.tsx +153 -0
- package/src/react-devtools/TimelineIndex.tsx +92 -0
- package/src/react-devtools/TransactionIndex.tsx +70 -0
- package/src/react-devtools/Updates.tsx +145 -0
- package/src/react-devtools/devtools.scss +196 -15
- package/src/react-devtools/index.ts +71 -0
- package/src/react-explorer/AtomIOExplorer.tsx +0 -1
- package/src/react-explorer/explorer-effects.ts +3 -3
- package/src/react-explorer/explorer-states.ts +1 -1
- package/src/react-explorer/space-states.ts +6 -4
- package/src/react-explorer/view-states.ts +0 -2
- package/realtime-testing/dist/index.d.mts +0 -49
- package/realtime-testing/dist/index.d.ts +0 -49
- package/realtime-testing/dist/index.js +0 -165
- package/realtime-testing/dist/index.js.map +0 -1
- package/realtime-testing/dist/index.mjs +0 -129
- package/realtime-testing/dist/index.mjs.map +0 -1
- package/src/internal/meta/attach-meta.ts +0 -17
- package/src/internal/meta/index.ts +0 -4
- package/src/internal/meta/meta-state.ts +0 -135
- package/src/internal/meta/meta-timelines.ts +0 -1
- package/src/internal/meta/meta-transactions.ts +0 -1
- package/src/react-devtools/TokenList.tsx +0 -61
package/README.md
CHANGED
|
@@ -1,78 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
- [x] subscribe to creation of atom tokens
|
|
34
|
-
- [x] subscribe to creation of selector tokens
|
|
35
|
-
- [x] subscribe to creation of readonly selector tokens
|
|
36
|
-
- [ ] reimplement state indices as selectors
|
|
37
|
-
- [ ] subscribe to creation of transaction tokens
|
|
38
|
-
- [ ] subscribe to creation of timeline tokens
|
|
39
|
-
- [ ] subscribe to changes in store configuration
|
|
40
|
-
|
|
41
|
-
# /react-devtools
|
|
42
|
-
- [ ]
|
|
43
|
-
|
|
44
|
-
# /react
|
|
45
|
-
## features
|
|
46
|
-
- [x] useStore
|
|
47
|
-
- [x] useI, useO, useIO
|
|
48
|
-
- [ ] useTimeline
|
|
49
|
-
- [ ] useStoreIndex
|
|
50
|
-
- [ ] useTransactionIO
|
|
51
|
-
|
|
52
|
-
# /realtime
|
|
53
|
-
- [x] expose single atom and selector
|
|
54
|
-
- [x] expose atom family and selector family
|
|
55
|
-
- [ ] receive single atom and selector
|
|
56
|
-
- [ ] receive atom family and selector family
|
|
57
|
-
- [x] receive transaction params, run transaction
|
|
58
|
-
- [ ] assess transaction impact (active subscriptions influenced by transaction)
|
|
59
|
-
- [ ] return transaction impact as timeline event
|
|
60
|
-
- [ ] identity-based exposure and receipt
|
|
61
|
-
- [ ] expose selector as atom
|
|
62
|
-
|
|
63
|
-
# /react-realtime
|
|
64
|
-
example: what's in the box? (options: green apple, green banana, red apple, red banana)
|
|
65
|
-
- no player gets to see what's in the box
|
|
66
|
-
- player 1 can see the color of the item in the box
|
|
67
|
-
- a register must be kept allocating "subscription permissions" per player
|
|
68
|
-
- sometimes permissions may refer to "true" or "global" state; sometimes to state that is "virtual" or "local" to the player
|
|
69
|
-
- player 2 can see the type of the item in the box
|
|
70
|
-
- atom<`${string}____${string}`> boxItem
|
|
71
|
-
- selector boxItemColor
|
|
72
|
-
- selector boxItemType
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
# /web-fx
|
|
77
|
-
## features
|
|
78
|
-
- [ ] localStorage and sessionStorage effects
|
|
1
|
+
<hr>
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img alt="corners logo" src="https://raw.githubusercontent.com/jeremybanka/wayforge/main/packages/atom.io/assets/logo.png"/>
|
|
5
|
+
</div>
|
|
6
|
+
|
|
7
|
+
<br>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://bundlephobia.com/result?p=atom.io">
|
|
11
|
+
<img alt="Bundlephobia" src="https://img.shields.io/bundlephobia/minzip/atom.io?style=for-the-badge&labelColor=333">
|
|
12
|
+
</a>
|
|
13
|
+
<a aria-label="Types" href="https://www.npmjs.com/package/atom.io">
|
|
14
|
+
<img alt="Types" src="https://img.shields.io/npm/types/atom.io?style=for-the-badge&labelColor=333">
|
|
15
|
+
</a>
|
|
16
|
+
<a aria-label="Build status" href="https://github.com/jeremybanka/wayforge/actions/workflows/integration.yml">
|
|
17
|
+
<img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/jeremybanka/wayforge/integration.yml?branch=main&style=for-the-badge&labelColor=333">
|
|
18
|
+
</a>
|
|
19
|
+
<a aria-label="NPM version" href="https://www.npmjs.com/package/atom.io">
|
|
20
|
+
<img alt="NPM Version" src="https://img.shields.io/npm/v/atom.io?style=for-the-badge&labelColor=333">
|
|
21
|
+
</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
npm i atom.io
|
|
26
|
+
```
|
|
27
|
+
```shell
|
|
28
|
+
pnpm add atom.io
|
|
29
|
+
```
|
|
30
|
+
<hr>
|
|
31
|
+
|
|
32
|
+
Reactive state graph for node and the browser inspired by [Recoil](https://recoiljs.org/).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hamt } from 'hamt_plus';
|
|
2
|
-
import { Refinement } from 'fp-ts/
|
|
2
|
+
import { Refinement } from 'fp-ts/Refinement';
|
|
3
3
|
|
|
4
4
|
type ƒn = (...parameters: any[]) => any;
|
|
5
5
|
|
|
@@ -86,8 +86,9 @@ interface Store {
|
|
|
86
86
|
subject: {
|
|
87
87
|
atomCreation: Subject<AtomToken<unknown>>;
|
|
88
88
|
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
89
|
-
transactionCreation: Subject<TransactionToken
|
|
89
|
+
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
90
90
|
timelineCreation: Subject<TimelineToken>;
|
|
91
|
+
operationStatus: Subject<OperationProgress>;
|
|
91
92
|
};
|
|
92
93
|
operation: OperationProgress;
|
|
93
94
|
transactionStatus: TransactionStatus<ƒn>;
|
|
@@ -169,37 +170,6 @@ declare const markAtomAsDefault: (key: string, store?: Store) => void;
|
|
|
169
170
|
declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
|
|
170
171
|
declare const isSelectorDefault: (key: string, store?: Store) => boolean;
|
|
171
172
|
|
|
172
|
-
type StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = Record<string, Token | {
|
|
173
|
-
key: string;
|
|
174
|
-
familyMembers: Record<string, Token>;
|
|
175
|
-
}>;
|
|
176
|
-
type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
|
|
177
|
-
type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
178
|
-
declare const attachMetaAtoms: (store?: Store) => ReadonlySelectorToken<AtomTokenIndex>;
|
|
179
|
-
declare const attachMetaSelectors: (store?: Store) => ReadonlySelectorToken<SelectorTokenIndex>;
|
|
180
|
-
|
|
181
|
-
declare const attachMetaState: (store?: Store) => {
|
|
182
|
-
atomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>;
|
|
183
|
-
selectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
type index$1_AtomTokenIndex = AtomTokenIndex;
|
|
187
|
-
type index$1_SelectorTokenIndex = SelectorTokenIndex;
|
|
188
|
-
type index$1_StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = StateTokenIndex<Token>;
|
|
189
|
-
declare const index$1_attachMetaAtoms: typeof attachMetaAtoms;
|
|
190
|
-
declare const index$1_attachMetaSelectors: typeof attachMetaSelectors;
|
|
191
|
-
declare const index$1_attachMetaState: typeof attachMetaState;
|
|
192
|
-
declare namespace index$1 {
|
|
193
|
-
export {
|
|
194
|
-
index$1_AtomTokenIndex as AtomTokenIndex,
|
|
195
|
-
index$1_SelectorTokenIndex as SelectorTokenIndex,
|
|
196
|
-
index$1_StateTokenIndex as StateTokenIndex,
|
|
197
|
-
index$1_attachMetaAtoms as attachMetaAtoms,
|
|
198
|
-
index$1_attachMetaSelectors as attachMetaSelectors,
|
|
199
|
-
index$1_attachMetaState as attachMetaState,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
173
|
type OperationProgress = {
|
|
204
174
|
open: false;
|
|
205
175
|
} | {
|
|
@@ -333,7 +303,7 @@ type Timeline = {
|
|
|
333
303
|
selectorTime: number | null;
|
|
334
304
|
transactionKey: string | null;
|
|
335
305
|
install: (store: Store) => void;
|
|
336
|
-
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate
|
|
306
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
337
307
|
};
|
|
338
308
|
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
339
309
|
|
|
@@ -444,7 +414,6 @@ declare namespace index {
|
|
|
444
414
|
export {
|
|
445
415
|
index_Atom as Atom,
|
|
446
416
|
index_IMPLICIT as IMPLICIT,
|
|
447
|
-
index$1 as META,
|
|
448
417
|
index_OperationProgress as OperationProgress,
|
|
449
418
|
index_ReadonlySelector as ReadonlySelector,
|
|
450
419
|
index_Selector as Selector,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hamt } from 'hamt_plus';
|
|
2
|
-
import { Refinement } from 'fp-ts/
|
|
2
|
+
import { Refinement } from 'fp-ts/Refinement';
|
|
3
3
|
|
|
4
4
|
type ƒn = (...parameters: any[]) => any;
|
|
5
5
|
|
|
@@ -86,8 +86,9 @@ interface Store {
|
|
|
86
86
|
subject: {
|
|
87
87
|
atomCreation: Subject<AtomToken<unknown>>;
|
|
88
88
|
selectorCreation: Subject<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
89
|
-
transactionCreation: Subject<TransactionToken
|
|
89
|
+
transactionCreation: Subject<TransactionToken<ƒn>>;
|
|
90
90
|
timelineCreation: Subject<TimelineToken>;
|
|
91
|
+
operationStatus: Subject<OperationProgress>;
|
|
91
92
|
};
|
|
92
93
|
operation: OperationProgress;
|
|
93
94
|
transactionStatus: TransactionStatus<ƒn>;
|
|
@@ -169,37 +170,6 @@ declare const markAtomAsDefault: (key: string, store?: Store) => void;
|
|
|
169
170
|
declare const markAtomAsNotDefault: (key: string, store?: Store) => void;
|
|
170
171
|
declare const isSelectorDefault: (key: string, store?: Store) => boolean;
|
|
171
172
|
|
|
172
|
-
type StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = Record<string, Token | {
|
|
173
|
-
key: string;
|
|
174
|
-
familyMembers: Record<string, Token>;
|
|
175
|
-
}>;
|
|
176
|
-
type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>;
|
|
177
|
-
type SelectorTokenIndex = StateTokenIndex<ReadonlySelectorToken<unknown> | SelectorToken<unknown>>;
|
|
178
|
-
declare const attachMetaAtoms: (store?: Store) => ReadonlySelectorToken<AtomTokenIndex>;
|
|
179
|
-
declare const attachMetaSelectors: (store?: Store) => ReadonlySelectorToken<SelectorTokenIndex>;
|
|
180
|
-
|
|
181
|
-
declare const attachMetaState: (store?: Store) => {
|
|
182
|
-
atomTokenIndexState: ReadonlySelectorToken<AtomTokenIndex>;
|
|
183
|
-
selectorTokenIndexState: ReadonlySelectorToken<SelectorTokenIndex>;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
type index$1_AtomTokenIndex = AtomTokenIndex;
|
|
187
|
-
type index$1_SelectorTokenIndex = SelectorTokenIndex;
|
|
188
|
-
type index$1_StateTokenIndex<Token extends AtomToken<unknown> | ReadonlySelectorToken<unknown> | SelectorToken<unknown>> = StateTokenIndex<Token>;
|
|
189
|
-
declare const index$1_attachMetaAtoms: typeof attachMetaAtoms;
|
|
190
|
-
declare const index$1_attachMetaSelectors: typeof attachMetaSelectors;
|
|
191
|
-
declare const index$1_attachMetaState: typeof attachMetaState;
|
|
192
|
-
declare namespace index$1 {
|
|
193
|
-
export {
|
|
194
|
-
index$1_AtomTokenIndex as AtomTokenIndex,
|
|
195
|
-
index$1_SelectorTokenIndex as SelectorTokenIndex,
|
|
196
|
-
index$1_StateTokenIndex as StateTokenIndex,
|
|
197
|
-
index$1_attachMetaAtoms as attachMetaAtoms,
|
|
198
|
-
index$1_attachMetaSelectors as attachMetaSelectors,
|
|
199
|
-
index$1_attachMetaState as attachMetaState,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
173
|
type OperationProgress = {
|
|
204
174
|
open: false;
|
|
205
175
|
} | {
|
|
@@ -333,7 +303,7 @@ type Timeline = {
|
|
|
333
303
|
selectorTime: number | null;
|
|
334
304
|
transactionKey: string | null;
|
|
335
305
|
install: (store: Store) => void;
|
|
336
|
-
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate
|
|
306
|
+
subject: Subject<TimelineAtomUpdate | TimelineSelectorUpdate | TimelineTransactionUpdate | `redo` | `undo`>;
|
|
337
307
|
};
|
|
338
308
|
declare function timeline__INTERNAL(options: TimelineOptions, store?: Store, data?: Timeline | null): TimelineToken;
|
|
339
309
|
|
|
@@ -444,7 +414,6 @@ declare namespace index {
|
|
|
444
414
|
export {
|
|
445
415
|
index_Atom as Atom,
|
|
446
416
|
index_IMPLICIT as IMPLICIT,
|
|
447
|
-
index$1 as META,
|
|
448
417
|
index_OperationProgress as OperationProgress,
|
|
449
418
|
index_ReadonlySelector as ReadonlySelector,
|
|
450
419
|
index_Selector as Selector,
|
package/dist/index.js
CHANGED
|
@@ -88,7 +88,6 @@ var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
|
88
88
|
var internal_exports = {};
|
|
89
89
|
__export(internal_exports, {
|
|
90
90
|
IMPLICIT: () => IMPLICIT,
|
|
91
|
-
META: () => meta_exports,
|
|
92
91
|
Subject: () => Subject,
|
|
93
92
|
TRANSACTION_PHASES: () => TRANSACTION_PHASES,
|
|
94
93
|
abortTransaction: () => abortTransaction,
|
|
@@ -672,12 +671,13 @@ var createStore = (name, store = null) => {
|
|
|
672
671
|
transactions: import_hamt_plus2.default.make(),
|
|
673
672
|
timelines: import_hamt_plus2.default.make(),
|
|
674
673
|
timelineAtoms: new Join({ relationType: `1:n` }).from(`timelineKey`).to(`atomKey`),
|
|
675
|
-
subject:
|
|
674
|
+
subject: {
|
|
676
675
|
atomCreation: new Subject(),
|
|
677
676
|
selectorCreation: new Subject(),
|
|
678
677
|
transactionCreation: new Subject(),
|
|
679
|
-
timelineCreation: new Subject()
|
|
680
|
-
|
|
678
|
+
timelineCreation: new Subject(),
|
|
679
|
+
operationStatus: new Subject()
|
|
680
|
+
},
|
|
681
681
|
operation: __spreadValues({
|
|
682
682
|
open: false
|
|
683
683
|
}, store == null ? void 0 : store.operation),
|
|
@@ -750,6 +750,7 @@ var closeOperation = (store) => {
|
|
|
750
750
|
const core = target(store);
|
|
751
751
|
core.operation = { open: false };
|
|
752
752
|
(_a = store.config.logger) == null ? void 0 : _a.info(`\u{1F534} operation done`);
|
|
753
|
+
store.subject.operationStatus.next(core.operation);
|
|
753
754
|
};
|
|
754
755
|
var isDone = (key, store = IMPLICIT.STORE) => {
|
|
755
756
|
var _a;
|
|
@@ -982,120 +983,6 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
|
|
|
982
983
|
);
|
|
983
984
|
}
|
|
984
985
|
|
|
985
|
-
// src/internal/meta/index.ts
|
|
986
|
-
var meta_exports = {};
|
|
987
|
-
__export(meta_exports, {
|
|
988
|
-
attachMetaAtoms: () => attachMetaAtoms,
|
|
989
|
-
attachMetaSelectors: () => attachMetaSelectors,
|
|
990
|
-
attachMetaState: () => attachMetaState
|
|
991
|
-
});
|
|
992
|
-
|
|
993
|
-
// src/internal/meta/meta-state.ts
|
|
994
|
-
var attachMetaAtoms = (store = IMPLICIT.STORE) => {
|
|
995
|
-
const atomTokenIndexState__INTERNAL = atom({
|
|
996
|
-
key: `\u{1F441}\u200D\u{1F5E8}_atom_token_index__INTERNAL`,
|
|
997
|
-
default: () => [...store.atoms].reduce((acc, [key]) => {
|
|
998
|
-
acc[key] = { key, type: `atom` };
|
|
999
|
-
return acc;
|
|
1000
|
-
}, {}),
|
|
1001
|
-
effects: [
|
|
1002
|
-
({ setSelf }) => {
|
|
1003
|
-
store.subject.atomCreation.subscribe((atomToken) => {
|
|
1004
|
-
if (store.operation.open) {
|
|
1005
|
-
return;
|
|
1006
|
-
}
|
|
1007
|
-
setSelf((state) => {
|
|
1008
|
-
const { key, family } = atomToken;
|
|
1009
|
-
if (family) {
|
|
1010
|
-
const { key: familyKey, subKey } = family;
|
|
1011
|
-
const current = state[familyKey];
|
|
1012
|
-
if (current === void 0 || `familyMembers` in current) {
|
|
1013
|
-
const familyKeyState = current || {
|
|
1014
|
-
key: familyKey,
|
|
1015
|
-
familyMembers: {}
|
|
1016
|
-
};
|
|
1017
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
1018
|
-
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
1019
|
-
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
1020
|
-
[subKey]: atomToken
|
|
1021
|
-
})
|
|
1022
|
-
})
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
1027
|
-
[key]: atomToken
|
|
1028
|
-
});
|
|
1029
|
-
});
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
]
|
|
1033
|
-
});
|
|
1034
|
-
return selector({
|
|
1035
|
-
key: `\u{1F441}\u200D\u{1F5E8}_atom_token_index`,
|
|
1036
|
-
get: ({ get }) => get(atomTokenIndexState__INTERNAL)
|
|
1037
|
-
});
|
|
1038
|
-
};
|
|
1039
|
-
var attachMetaSelectors = (store = IMPLICIT.STORE) => {
|
|
1040
|
-
const readonlySelectorTokenIndexState__INTERNAL = atom({
|
|
1041
|
-
key: `\u{1F441}\u200D\u{1F5E8}_selector_token_index__INTERNAL`,
|
|
1042
|
-
default: () => Object.assign(
|
|
1043
|
-
[...store.readonlySelectors].reduce((acc, [key]) => {
|
|
1044
|
-
acc[key] = { key, type: `readonly_selector` };
|
|
1045
|
-
return acc;
|
|
1046
|
-
}, {}),
|
|
1047
|
-
[...store.selectors].reduce((acc, [key]) => {
|
|
1048
|
-
acc[key] = { key, type: `selector` };
|
|
1049
|
-
return acc;
|
|
1050
|
-
}, {})
|
|
1051
|
-
),
|
|
1052
|
-
effects: [
|
|
1053
|
-
({ setSelf }) => {
|
|
1054
|
-
store.subject.selectorCreation.subscribe((selectorToken) => {
|
|
1055
|
-
if (store.operation.open) {
|
|
1056
|
-
return;
|
|
1057
|
-
}
|
|
1058
|
-
setSelf((state) => {
|
|
1059
|
-
const { key, family } = selectorToken;
|
|
1060
|
-
if (family) {
|
|
1061
|
-
const { key: familyKey, subKey } = family;
|
|
1062
|
-
const current = state[familyKey];
|
|
1063
|
-
if (current === void 0 || `familyMembers` in current) {
|
|
1064
|
-
const familyKeyState = current || {
|
|
1065
|
-
key: familyKey,
|
|
1066
|
-
familyMembers: {}
|
|
1067
|
-
};
|
|
1068
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
1069
|
-
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
1070
|
-
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
1071
|
-
[subKey]: selectorToken
|
|
1072
|
-
})
|
|
1073
|
-
})
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
1078
|
-
[key]: selectorToken
|
|
1079
|
-
});
|
|
1080
|
-
});
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
]
|
|
1084
|
-
});
|
|
1085
|
-
return selector({
|
|
1086
|
-
key: `\u{1F441}\u200D\u{1F5E8}_selector_token_index`,
|
|
1087
|
-
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
|
|
1088
|
-
});
|
|
1089
|
-
};
|
|
1090
|
-
|
|
1091
|
-
// src/internal/meta/attach-meta.ts
|
|
1092
|
-
var attachMetaState = (store = IMPLICIT.STORE) => {
|
|
1093
|
-
return {
|
|
1094
|
-
atomTokenIndexState: attachMetaAtoms(store),
|
|
1095
|
-
selectorTokenIndexState: attachMetaSelectors(store)
|
|
1096
|
-
};
|
|
1097
|
-
};
|
|
1098
|
-
|
|
1099
986
|
// src/internal/selector-internal.ts
|
|
1100
987
|
var import_hamt_plus9 = __toESM(require("hamt_plus"));
|
|
1101
988
|
|
|
@@ -1478,6 +1365,7 @@ var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
|
|
|
1478
1365
|
}
|
|
1479
1366
|
}
|
|
1480
1367
|
++timelineData.at;
|
|
1368
|
+
timelineData.subject.next(`redo`);
|
|
1481
1369
|
timelineData.timeTraveling = false;
|
|
1482
1370
|
(_d = store.config.logger) == null ? void 0 : _d.info(
|
|
1483
1371
|
`\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
|
|
@@ -1517,6 +1405,7 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
|
|
|
1517
1405
|
break;
|
|
1518
1406
|
}
|
|
1519
1407
|
}
|
|
1408
|
+
timelineData.subject.next(`undo`);
|
|
1520
1409
|
timelineData.timeTraveling = false;
|
|
1521
1410
|
(_d = store.config.logger) == null ? void 0 : _d.info(
|
|
1522
1411
|
`\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
|
|
@@ -1555,9 +1444,6 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
|
1555
1444
|
`Timeline "${tl.key}" has a selectorTime, but no history. This is most likely a bug in AtomIO.`
|
|
1556
1445
|
);
|
|
1557
1446
|
}
|
|
1558
|
-
if (mostRecentUpdate.type === `selector_update`) {
|
|
1559
|
-
tl.subject.next(mostRecentUpdate);
|
|
1560
|
-
}
|
|
1561
1447
|
}
|
|
1562
1448
|
if (currentTransactionKey && store.transactionStatus.phase === `applying`) {
|
|
1563
1449
|
const currentTransaction = withdraw(
|
|
@@ -1578,6 +1464,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
|
1578
1464
|
tl.transactionKey = currentTransactionKey;
|
|
1579
1465
|
const subscription = currentTransaction.subject.subscribe((update2) => {
|
|
1580
1466
|
var _a2;
|
|
1467
|
+
subscription.unsubscribe();
|
|
1581
1468
|
if (tl.timeTraveling === false && currentTransactionTime) {
|
|
1582
1469
|
if (tl.at !== tl.history.length) {
|
|
1583
1470
|
tl.history.splice(tl.at);
|
|
@@ -1591,10 +1478,9 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
|
1591
1478
|
)
|
|
1592
1479
|
});
|
|
1593
1480
|
tl.history.push(timelineTransactionUpdate);
|
|
1481
|
+
tl.at = tl.history.length;
|
|
1594
1482
|
tl.subject.next(timelineTransactionUpdate);
|
|
1595
1483
|
}
|
|
1596
|
-
tl.at = tl.history.length;
|
|
1597
|
-
subscription.unsubscribe();
|
|
1598
1484
|
tl.transactionKey = null;
|
|
1599
1485
|
(_a2 = store.config.logger) == null ? void 0 : _a2.info(
|
|
1600
1486
|
`\u231B timeline "${tl.key}" got a transaction_update "${update2.key}"`
|
|
@@ -1602,29 +1488,29 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
|
1602
1488
|
});
|
|
1603
1489
|
}
|
|
1604
1490
|
} else if (currentSelectorKey && currentSelectorTime) {
|
|
1491
|
+
let latestUpdate = tl.history.at(-1);
|
|
1605
1492
|
if (currentSelectorTime !== tl.selectorTime) {
|
|
1606
|
-
|
|
1493
|
+
latestUpdate = {
|
|
1607
1494
|
type: `selector_update`,
|
|
1608
1495
|
timestamp: currentSelectorTime,
|
|
1609
1496
|
key: currentSelectorKey,
|
|
1610
1497
|
atomUpdates: []
|
|
1611
1498
|
};
|
|
1612
|
-
|
|
1499
|
+
latestUpdate.atomUpdates.push(__spreadValues({
|
|
1613
1500
|
key: atom2.key,
|
|
1614
1501
|
type: `atom_update`
|
|
1615
1502
|
}, update));
|
|
1616
1503
|
if (tl.at !== tl.history.length) {
|
|
1617
1504
|
tl.history.splice(tl.at);
|
|
1618
1505
|
}
|
|
1619
|
-
tl.history.push(
|
|
1506
|
+
tl.history.push(latestUpdate);
|
|
1620
1507
|
(_c = store.config.logger) == null ? void 0 : _c.info(
|
|
1621
1508
|
`\u231B timeline "${tl.key}" got a selector_update "${currentSelectorKey}" with`,
|
|
1622
|
-
|
|
1509
|
+
latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
|
|
1623
1510
|
);
|
|
1624
1511
|
tl.at = tl.history.length;
|
|
1625
1512
|
tl.selectorTime = currentSelectorTime;
|
|
1626
1513
|
} else {
|
|
1627
|
-
const latestUpdate = tl.history.at(-1);
|
|
1628
1514
|
if ((latestUpdate == null ? void 0 : latestUpdate.type) === `selector_update`) {
|
|
1629
1515
|
latestUpdate.atomUpdates.push(__spreadValues({
|
|
1630
1516
|
key: atom2.key,
|
|
@@ -1636,6 +1522,8 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
|
1636
1522
|
);
|
|
1637
1523
|
}
|
|
1638
1524
|
}
|
|
1525
|
+
if (latestUpdate)
|
|
1526
|
+
tl.subject.next(latestUpdate);
|
|
1639
1527
|
} else {
|
|
1640
1528
|
const timestamp = Date.now();
|
|
1641
1529
|
tl.selectorTime = null;
|
|
@@ -1652,7 +1540,7 @@ var addAtomToTimeline = (atomToken, atoms, tl, store = IMPLICIT.STORE) => {
|
|
|
1652
1540
|
tl.history.push(atomUpdate);
|
|
1653
1541
|
tl.subject.next(atomUpdate);
|
|
1654
1542
|
(_e = store.config.logger) == null ? void 0 : _e.info(
|
|
1655
|
-
`\u231B timeline "${tl.key}" got
|
|
1543
|
+
`\u231B timeline "${tl.key}" got an atom_update to "${atom2.key}"`
|
|
1656
1544
|
);
|
|
1657
1545
|
tl.at = tl.history.length;
|
|
1658
1546
|
}
|