atom.io 0.6.9 → 0.8.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/README.md +21 -2
- package/dist/index.d.mts +34 -421
- package/dist/index.d.ts +34 -421
- package/dist/index.js +248 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +209 -4
- package/dist/index.mjs.map +1 -1
- package/internal/dist/index.d.mts +364 -0
- package/internal/dist/index.d.ts +364 -0
- package/internal/dist/index.js +1906 -0
- package/internal/dist/index.js.map +1 -0
- package/internal/dist/index.mjs +1830 -0
- package/internal/dist/index.mjs.map +1 -0
- package/internal/package.json +15 -0
- package/internal/src/atom/create-atom.ts +75 -0
- package/internal/src/atom/delete-atom.ts +10 -0
- package/internal/src/atom/index.ts +3 -0
- package/internal/src/atom/is-default.ts +37 -0
- package/internal/src/caching.ts +38 -0
- package/internal/src/families/create-atom-family.ts +59 -0
- package/internal/src/families/create-readonly-selector-family.ts +45 -0
- package/internal/src/families/create-selector-family.ts +67 -0
- package/internal/src/families/index.ts +3 -0
- package/internal/src/future.ts +39 -0
- package/internal/src/get-state-internal.ts +23 -0
- package/internal/src/index.ts +14 -0
- package/internal/src/mutable/create-mutable-atom-family.ts +25 -0
- package/internal/src/mutable/create-mutable-atom.ts +49 -0
- package/internal/src/mutable/get-json-token.ts +22 -0
- package/internal/src/mutable/get-update-token.ts +20 -0
- package/internal/src/mutable/index.ts +17 -0
- package/internal/src/mutable/is-atom-token-mutable.ts +7 -0
- package/internal/src/mutable/tracker-family.ts +61 -0
- package/internal/src/mutable/tracker.ts +164 -0
- package/internal/src/mutable/transceiver.ts +110 -0
- package/internal/src/operation.ts +68 -0
- package/internal/src/selector/create-read-write-selector.ts +65 -0
- package/internal/src/selector/create-readonly-selector.ts +49 -0
- package/internal/src/selector/create-selector.ts +65 -0
- package/internal/src/selector/index.ts +5 -0
- package/internal/src/selector/lookup-selector-sources.ts +20 -0
- package/internal/src/selector/register-selector.ts +61 -0
- package/internal/src/selector/trace-selector-atoms.ts +45 -0
- package/internal/src/selector/update-selector-atoms.ts +34 -0
- package/internal/src/set-state/become.ts +10 -0
- package/internal/src/set-state/copy-mutable-if-needed.ts +23 -0
- package/internal/src/set-state/copy-mutable-in-transaction.ts +59 -0
- package/internal/src/set-state/copy-mutable-into-new-store.ts +34 -0
- package/internal/src/set-state/emit-update.ts +23 -0
- package/internal/src/set-state/evict-downstream.ts +39 -0
- package/internal/src/set-state/index.ts +2 -0
- package/internal/src/set-state/set-atom-state.ts +38 -0
- package/internal/src/set-state/set-selector-state.ts +19 -0
- package/internal/src/set-state/set-state-internal.ts +18 -0
- package/internal/src/set-state/stow-update.ts +42 -0
- package/internal/src/store/deposit.ts +43 -0
- package/internal/src/store/index.ts +5 -0
- package/internal/src/store/lookup.ts +26 -0
- package/internal/src/store/store.ts +154 -0
- package/internal/src/store/withdraw-new-family-member.ts +53 -0
- package/internal/src/store/withdraw.ts +113 -0
- package/internal/src/subject.ts +21 -0
- package/internal/src/subscribe/index.ts +1 -0
- package/internal/src/subscribe/recall-state.ts +19 -0
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +47 -0
- package/internal/src/timeline/add-atom-to-timeline.ts +189 -0
- package/internal/src/timeline/index.ts +3 -0
- package/internal/src/timeline/time-travel-internal.ts +91 -0
- package/internal/src/timeline/timeline-internal.ts +115 -0
- package/internal/src/transaction/abort-transaction.ts +12 -0
- package/internal/src/transaction/apply-transaction.ts +64 -0
- package/internal/src/transaction/build-transaction.ts +39 -0
- package/internal/src/transaction/index.ts +26 -0
- package/internal/src/transaction/redo-transaction.ts +22 -0
- package/internal/src/transaction/transaction-internal.ts +64 -0
- package/internal/src/transaction/undo-transaction.ts +22 -0
- package/introspection/dist/index.d.mts +3 -197
- package/introspection/dist/index.d.ts +3 -197
- package/introspection/dist/index.js +329 -4
- package/introspection/dist/index.js.map +1 -1
- package/introspection/dist/index.mjs +310 -4
- package/introspection/dist/index.mjs.map +1 -1
- package/introspection/src/attach-atom-index.ts +84 -0
- package/introspection/src/attach-introspection-states.ts +38 -0
- package/introspection/src/attach-selector-index.ts +90 -0
- package/introspection/src/attach-timeline-family.ts +59 -0
- package/introspection/src/attach-timeline-index.ts +38 -0
- package/introspection/src/attach-transaction-index.ts +40 -0
- package/introspection/src/attach-transaction-logs.ts +43 -0
- package/introspection/src/index.ts +20 -0
- package/json/dist/index.d.mts +10 -2
- package/json/dist/index.d.ts +10 -2
- package/json/dist/index.js +83 -26
- package/json/dist/index.js.map +1 -1
- package/json/dist/index.mjs +74 -3
- package/json/dist/index.mjs.map +1 -1
- package/json/src/index.ts +5 -0
- package/json/src/select-json-family.ts +35 -0
- package/json/src/select-json.ts +22 -0
- package/package.json +103 -63
- package/react/dist/index.d.mts +9 -17
- package/react/dist/index.d.ts +9 -17
- package/react/dist/index.js +44 -27
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.mjs +24 -4
- package/react/dist/index.mjs.map +1 -1
- package/react/src/index.ts +2 -0
- package/react/src/store-context.tsx +12 -0
- package/react/src/store-hooks.ts +36 -0
- package/react-devtools/dist/index.css +50 -1
- package/react-devtools/dist/index.css.map +1 -1
- package/react-devtools/dist/index.d.mts +104 -71
- package/react-devtools/dist/index.d.ts +104 -71
- package/react-devtools/dist/index.js +2821 -45
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/dist/index.mjs +2790 -11
- package/react-devtools/dist/index.mjs.map +1 -1
- package/react-devtools/src/AtomIODevtools.tsx +109 -0
- package/react-devtools/src/Button.tsx +23 -0
- package/react-devtools/src/StateEditor.tsx +75 -0
- package/react-devtools/src/StateIndex.tsx +159 -0
- package/react-devtools/src/TimelineIndex.tsx +88 -0
- package/react-devtools/src/TransactionIndex.tsx +70 -0
- package/react-devtools/src/Updates.tsx +150 -0
- package/react-devtools/src/devtools.scss +310 -0
- package/react-devtools/src/index.ts +72 -0
- package/realtime-react/dist/index.d.mts +8 -22
- package/realtime-react/dist/index.d.ts +8 -22
- package/realtime-react/dist/index.js +87 -32
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/dist/index.mjs +62 -6
- package/realtime-react/dist/index.mjs.map +1 -1
- package/realtime-react/src/index.ts +7 -0
- package/realtime-react/src/realtime-context.tsx +29 -0
- package/realtime-react/src/use-pull-family-member.ts +15 -0
- package/realtime-react/src/use-pull-mutable-family-member.ts +20 -0
- package/realtime-react/src/use-pull-mutable.ts +17 -0
- package/realtime-react/src/use-pull.ts +15 -0
- package/realtime-react/src/use-push.ts +19 -0
- package/realtime-react/src/use-server-action.ts +18 -0
- package/realtime-testing/dist/index.d.mts +49 -0
- package/realtime-testing/dist/index.d.ts +49 -0
- package/realtime-testing/dist/index.js +147 -0
- package/realtime-testing/dist/index.js.map +1 -0
- package/realtime-testing/dist/index.mjs +116 -0
- package/realtime-testing/dist/index.mjs.map +1 -0
- package/realtime-testing/src/index.ts +1 -0
- package/realtime-testing/src/setup-realtime-test.tsx +161 -0
- package/src/atom.ts +64 -9
- package/src/index.ts +29 -31
- package/src/logger.ts +3 -3
- package/src/selector.ts +3 -3
- package/src/silo.ts +29 -20
- package/src/subscribe.ts +3 -3
- package/src/timeline.ts +2 -2
- package/transceivers/set-rtx/dist/index.d.mts +39 -0
- package/transceivers/set-rtx/dist/index.d.ts +39 -0
- package/transceivers/set-rtx/dist/index.js +213 -0
- package/transceivers/set-rtx/dist/index.js.map +1 -0
- package/transceivers/set-rtx/dist/index.mjs +211 -0
- package/transceivers/set-rtx/dist/index.mjs.map +1 -0
- package/{realtime → transceivers/set-rtx}/package.json +1 -1
- package/transceivers/set-rtx/src/index.ts +1 -0
- package/transceivers/set-rtx/src/set-rtx.ts +242 -0
- package/realtime/dist/index.d.mts +0 -23
- package/realtime/dist/index.d.ts +0 -23
- package/realtime/dist/index.js +0 -32
- package/realtime/dist/index.js.map +0 -1
- package/realtime/dist/index.mjs +0 -7
- package/realtime/dist/index.mjs.map +0 -1
|
@@ -1,8 +1,314 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Subject } from 'atom.io/internal';
|
|
1
|
+
import * as __INTERNAL__ from 'atom.io/internal';
|
|
2
|
+
import { createAtom, target, createSelector, IMPLICIT, createAtomFamily, Subject, createSelectorFamily } from 'atom.io/internal';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var attachAtomIndex = (store = IMPLICIT.STORE) => {
|
|
24
|
+
const atomTokenIndexState__INTERNAL = createAtom(
|
|
25
|
+
{
|
|
26
|
+
key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
|
|
27
|
+
default: () => {
|
|
28
|
+
const defaultAtomIndex = [...store.atoms].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
|
|
29
|
+
acc[key] = { key, type: `atom` };
|
|
30
|
+
return acc;
|
|
31
|
+
}, {});
|
|
32
|
+
return defaultAtomIndex;
|
|
33
|
+
},
|
|
34
|
+
effects: [
|
|
35
|
+
({ setSelf }) => {
|
|
36
|
+
store.subject.atomCreation.subscribe(`introspection`, (atomToken) => {
|
|
37
|
+
if (atomToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const set = () => setSelf((state) => {
|
|
41
|
+
const { key, family } = atomToken;
|
|
42
|
+
if (family) {
|
|
43
|
+
const { key: familyKey, subKey } = family;
|
|
44
|
+
const current = state[familyKey];
|
|
45
|
+
if (current === void 0 || `familyMembers` in current) {
|
|
46
|
+
const familyKeyState = current || {
|
|
47
|
+
key: familyKey,
|
|
48
|
+
familyMembers: {}
|
|
49
|
+
};
|
|
50
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
51
|
+
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
52
|
+
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
53
|
+
[subKey]: atomToken
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
60
|
+
[key]: atomToken
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
if (target(store).operation.open) {
|
|
64
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
65
|
+
`introspection: waiting to update atom index`,
|
|
66
|
+
() => {
|
|
67
|
+
unsubscribe();
|
|
68
|
+
set();
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
} else {
|
|
72
|
+
set();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
void 0,
|
|
79
|
+
store
|
|
80
|
+
);
|
|
81
|
+
return createSelector(
|
|
82
|
+
{
|
|
83
|
+
key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
|
|
84
|
+
get: ({ get }) => get(atomTokenIndexState__INTERNAL)
|
|
85
|
+
},
|
|
86
|
+
void 0,
|
|
87
|
+
store
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
var attachSelectorIndex = (store = IMPLICIT.STORE) => {
|
|
91
|
+
const readonlySelectorTokenIndexState__INTERNAL = createAtom(
|
|
92
|
+
{
|
|
93
|
+
key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
|
|
94
|
+
default: () => Object.assign(
|
|
95
|
+
[...store.readonlySelectors].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
|
|
96
|
+
acc[key] = { key, type: `readonly_selector` };
|
|
97
|
+
return acc;
|
|
98
|
+
}, {}),
|
|
99
|
+
[...store.selectors].reduce((acc, [key]) => {
|
|
100
|
+
acc[key] = { key, type: `selector` };
|
|
101
|
+
return acc;
|
|
102
|
+
}, {})
|
|
103
|
+
),
|
|
104
|
+
effects: [
|
|
105
|
+
({ setSelf }) => {
|
|
106
|
+
store.subject.selectorCreation.subscribe(
|
|
107
|
+
`introspection`,
|
|
108
|
+
(selectorToken) => {
|
|
109
|
+
if (selectorToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const set = () => setSelf((state) => {
|
|
113
|
+
const { key, family } = selectorToken;
|
|
114
|
+
if (family) {
|
|
115
|
+
const { key: familyKey, subKey } = family;
|
|
116
|
+
const current = state[familyKey];
|
|
117
|
+
if (current === void 0 || `familyMembers` in current) {
|
|
118
|
+
const familyKeyState = current || {
|
|
119
|
+
key: familyKey,
|
|
120
|
+
familyMembers: {}
|
|
121
|
+
};
|
|
122
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
123
|
+
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
124
|
+
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
125
|
+
[subKey]: selectorToken
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
132
|
+
[key]: selectorToken
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
if (target(store).operation.open) {
|
|
136
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
137
|
+
`introspection: waiting to update selector index`,
|
|
138
|
+
() => {
|
|
139
|
+
unsubscribe();
|
|
140
|
+
set();
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
} else {
|
|
144
|
+
set();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
void 0,
|
|
152
|
+
store
|
|
153
|
+
);
|
|
154
|
+
return createSelector({
|
|
155
|
+
key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
|
|
156
|
+
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
var attachTimelineFamily = (store = IMPLICIT.STORE) => {
|
|
160
|
+
const findTimelineLogState__INTERNAL = createAtomFamily(
|
|
161
|
+
{
|
|
162
|
+
key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
|
|
163
|
+
default: (key) => {
|
|
164
|
+
var _a;
|
|
165
|
+
return (_a = store.timelines.get(key)) != null ? _a : {
|
|
166
|
+
type: `timeline`,
|
|
167
|
+
key: ``,
|
|
168
|
+
at: 0,
|
|
169
|
+
timeTraveling: null,
|
|
170
|
+
history: [],
|
|
171
|
+
selectorTime: null,
|
|
172
|
+
transactionKey: null,
|
|
173
|
+
install: () => {
|
|
174
|
+
},
|
|
175
|
+
subject: new Subject()
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
effects: (key) => [
|
|
179
|
+
({ setSelf }) => {
|
|
180
|
+
const tl = store.timelines.get(key);
|
|
181
|
+
tl == null ? void 0 : tl.subject.subscribe(`introspection`, (_) => {
|
|
182
|
+
if (store.operation.open === true) {
|
|
183
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
184
|
+
`introspection`,
|
|
185
|
+
(operationStatus) => {
|
|
186
|
+
if (operationStatus.open === false) {
|
|
187
|
+
unsubscribe();
|
|
188
|
+
setSelf(__spreadValues({}, tl));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
} else {
|
|
193
|
+
setSelf(__spreadValues({}, tl));
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
store
|
|
200
|
+
);
|
|
201
|
+
const findTimelineLogState = createSelectorFamily(
|
|
202
|
+
{
|
|
203
|
+
key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
|
|
204
|
+
get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key))
|
|
205
|
+
},
|
|
206
|
+
store
|
|
207
|
+
);
|
|
208
|
+
return findTimelineLogState;
|
|
209
|
+
};
|
|
210
|
+
var attachTimelineIndex = (store = IMPLICIT.STORE) => {
|
|
211
|
+
const timelineTokenIndexState__INTERNAL = createAtom(
|
|
212
|
+
{
|
|
213
|
+
key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
|
|
214
|
+
default: () => [...store.timelines].map(([key]) => {
|
|
215
|
+
return { key, type: `timeline` };
|
|
216
|
+
}),
|
|
217
|
+
effects: [
|
|
218
|
+
({ setSelf }) => {
|
|
219
|
+
store.subject.timelineCreation.subscribe(
|
|
220
|
+
`introspection`,
|
|
221
|
+
(timelineToken) => {
|
|
222
|
+
setSelf((state) => [...state, timelineToken]);
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
void 0,
|
|
229
|
+
store
|
|
230
|
+
);
|
|
231
|
+
const timelineTokenIndex = createSelector(
|
|
232
|
+
{
|
|
233
|
+
key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
|
|
234
|
+
get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
|
|
235
|
+
},
|
|
236
|
+
void 0,
|
|
237
|
+
store
|
|
238
|
+
);
|
|
239
|
+
return timelineTokenIndex;
|
|
240
|
+
};
|
|
241
|
+
var attachTransactionIndex = (store = IMPLICIT.STORE) => {
|
|
242
|
+
const transactionTokenIndexState__INTERNAL = createAtom(
|
|
243
|
+
{
|
|
244
|
+
key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
|
|
245
|
+
default: () => [...store.transactions].map(([key]) => {
|
|
246
|
+
return { key, type: `transaction` };
|
|
247
|
+
}),
|
|
248
|
+
effects: [
|
|
249
|
+
({ setSelf }) => {
|
|
250
|
+
store.subject.transactionCreation.subscribe(
|
|
251
|
+
`introspection`,
|
|
252
|
+
(transactionToken) => {
|
|
253
|
+
setSelf((state) => [...state, transactionToken]);
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
},
|
|
259
|
+
void 0,
|
|
260
|
+
store
|
|
261
|
+
);
|
|
262
|
+
const transactionTokenIndex = createSelector(
|
|
263
|
+
{
|
|
264
|
+
key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
|
|
265
|
+
get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
|
|
266
|
+
},
|
|
267
|
+
void 0,
|
|
268
|
+
store
|
|
269
|
+
);
|
|
270
|
+
return transactionTokenIndex;
|
|
271
|
+
};
|
|
272
|
+
var attachTransactionLogs = (store = IMPLICIT.STORE) => {
|
|
273
|
+
const findTransactionUpdateLog = createAtomFamily(
|
|
274
|
+
{
|
|
275
|
+
key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
|
|
276
|
+
default: () => [],
|
|
277
|
+
effects: (key) => [
|
|
278
|
+
({ setSelf }) => {
|
|
279
|
+
const tx = store.transactions.get(key);
|
|
280
|
+
tx == null ? void 0 : tx.subject.subscribe(`introspection`, (transactionUpdate) => {
|
|
281
|
+
if (transactionUpdate.key === key) {
|
|
282
|
+
setSelf((state) => [...state, transactionUpdate]);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
]
|
|
287
|
+
},
|
|
288
|
+
store
|
|
289
|
+
);
|
|
290
|
+
const findTransactionUpdateLogState = createSelectorFamily(
|
|
291
|
+
{
|
|
292
|
+
key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
|
|
293
|
+
get: (key) => ({ get }) => get(findTransactionUpdateLog(key))
|
|
294
|
+
},
|
|
295
|
+
store
|
|
296
|
+
);
|
|
297
|
+
return findTransactionUpdateLogState;
|
|
298
|
+
};
|
|
5
299
|
|
|
6
|
-
|
|
300
|
+
// src/attach-introspection-states.ts
|
|
301
|
+
var attachIntrospectionStates = (store = __INTERNAL__.IMPLICIT.STORE) => {
|
|
302
|
+
return {
|
|
303
|
+
atomIndex: attachAtomIndex(store),
|
|
304
|
+
selectorIndex: attachSelectorIndex(store),
|
|
305
|
+
transactionIndex: attachTransactionIndex(store),
|
|
306
|
+
findTransactionLogState: attachTransactionLogs(store),
|
|
307
|
+
timelineIndex: attachTimelineIndex(store),
|
|
308
|
+
findTimelineState: attachTimelineFamily(store)
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
export { attachIntrospectionStates };
|
|
7
313
|
//# sourceMappingURL=out.js.map
|
|
8
314
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/attach-introspection-states.ts","../src/attach-atom-index.ts","../src/attach-selector-index.ts","../src/attach-timeline-family.ts","../src/attach-timeline-index.ts","../src/attach-transaction-index.ts","../src/attach-transaction-logs.ts"],"names":["__INTERNAL__","attachAtomIndex","store","atomTokenIndexState__INTERNAL","key","acc","setSelf","atomToken","state","family","familyKey","subKey","current","familyKeyState","__spreadProps","__spreadValues","get","attachSelectorIndex","readonlySelectorTokenIndexState__INTERNAL","selectorToken","Subject","attachTimelineFamily","findTimelineLogState__INTERNAL","_a","tl","_","unsubscribe","operationStatus","attachTimelineIndex","timelineTokenIndexState__INTERNAL","timelineToken","attachTransactionIndex","transactionTokenIndexState__INTERNAL","transactionToken","attachTransactionLogs","findTransactionUpdateLog","tx","transactionUpdate","attachIntrospectionStates"],"mappings":"6aAAA,OAAS,gBAAAA,MAAoB,UCC7B,OAAS,gBAAAA,MAAoB,UAMtB,IAAMC,EAAkB,CAC9BC,EAA4BF,EAAa,SAAS,QACP,CAC3C,IAAMG,EACLH,EAAa,eACZ,CACC,IAAK,uDACL,QAAS,IACR,CAAC,GAAGE,EAAM,KAAK,EACb,OAAO,CAAC,CAACE,CAAG,IAAM,CAACA,EAAI,SAAS,0BAAO,CAAC,EACxC,OAAuB,CAACC,EAAK,CAACD,CAAG,KACjCC,EAAID,CAAG,EAAI,CAAE,IAAAA,EAAK,KAAM,MAAO,EACxBC,GACL,CAAC,CAAC,EACP,QAAS,CACR,CAAC,CAAE,QAAAC,CAAQ,IAAM,CAChBJ,EAAM,QAAQ,aAAa,UAC1B,gBACCK,GAAc,CACVL,EAAM,UAAU,MAGhBK,EAAU,IAAI,SAAS,0BAAO,GAGlCD,EAASE,GAAU,CAClB,GAAM,CAAE,IAAAJ,EAAK,OAAAK,CAAO,EAAIF,EACxB,GAAIE,EAAQ,CACX,GAAM,CAAE,IAAKC,EAAW,OAAAC,CAAO,EAAIF,EAC7BG,EAAUJ,EAAME,CAAS,EAC/B,GAAIE,IAAY,QAAa,kBAAmBA,EAAS,CACxD,IAAMC,EAAiBD,GAAW,CACjC,IAAKF,EACL,cAAe,CAAC,CACjB,EACA,OAAOI,EAAAC,EAAA,GACHP,GADG,CAEN,CAACE,CAAS,EAAGI,EAAAC,EAAA,GACTF,GADS,CAEZ,cAAeC,EAAAC,EAAA,GACXF,EAAe,eADJ,CAEd,CAACF,CAAM,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AAAgB,CAAI,IAAMA,EAAIgB,CAAoC,CAC3D,EACA,OACA9B,CACD,CAED,ECrCA,OAAS,gBAAAF,MAAoB,UAEtB,IAAMkC,EAAwB,CACpChC,EAA4BF,EAAa,SAAS,QACG,CACrD,IAAMmC,EAA2BnC,EAAa,qBAI7C,CACC,IAAK,6DACL,QAAS,IAAM,CAAC,EAChB,QAAUI,GAAQ,CACjB,CAAC,CAAE,QAAAE,CAAQ,IAAM,CAChB,IAAM8B,EAAKlC,EAAM,aAAa,IAAIE,CAAG,EACrCgC,GAAA,MAAAA,EAAI,QAAQ,UAAU,gBAAkBC,GAAsB,CACzDA,EAAkB,MAAQjC,GAC7BE,EAASE,GAAU,CAAC,GAAGA,EAAO6B,CAAiB,CAAC,CAElD,EACD,CACD,CACD,EACAnC,CACD,EAWA,OAVsCF,EAAa,yBAIlD,CACC,IAAK,kDACL,IAAMI,GAAQ,CAAC,CAAE,IAAAY,CAAI,IAAMA,EAAImB,EAAyB/B,CAAG,CAAC,CAC7D,EACAF,CACD,CAED,ENlBO,IAAMoC,GAA4B,CACxCpC,EAA4BF,EAAa,SAAS,SAS3C,CACN,UAAWC,EAAgBC,CAAK,EAChC,cAAee,EAAoBf,CAAK,EACxC,iBAAkB6B,EAAuB7B,CAAK,EAC9C,wBAAyBgC,EAAsBhC,CAAK,EACpD,cAAe0B,EAAoB1B,CAAK,EACxC,kBAAmBmB,EAAqBnB,CAAK,CAC9C","sourcesContent":["import { __INTERNAL__ } from \"atom.io\"\nimport type {\n\tReadonlySelectorFamily,\n\tReadonlySelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n\tTransactionUpdate,\n\tƒn,\n} from \"atom.io\"\nimport type { Timeline } from \"atom.io/internal\"\n\nimport { type AtomTokenIndex, attachAtomIndex } from \"./attach-atom-index\"\nimport type { SelectorTokenIndex } from \"./attach-selector-index\"\nimport { attachSelectorIndex } from \"./attach-selector-index\"\nimport { attachTimelineFamily } from \"./attach-timeline-family\"\nimport { attachTimelineIndex } from \"./attach-timeline-index\"\nimport { attachTransactionIndex } from \"./attach-transaction-index\"\nimport { attachTransactionLogs } from \"./attach-transaction-logs\"\n\nexport const attachIntrospectionStates = (\n\tstore: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,\n): {\n\tatomIndex: ReadonlySelectorToken<AtomTokenIndex>\n\tselectorIndex: ReadonlySelectorToken<SelectorTokenIndex>\n\ttransactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>\n\tfindTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<ƒn>[]>\n\ttimelineIndex: ReadonlySelectorToken<TimelineToken[]>\n\tfindTimelineState: ReadonlySelectorFamily<Timeline>\n} => {\n\treturn {\n\t\tatomIndex: attachAtomIndex(store),\n\t\tselectorIndex: attachSelectorIndex(store),\n\t\ttransactionIndex: attachTransactionIndex(store),\n\t\tfindTransactionLogState: attachTransactionLogs(store),\n\t\ttimelineIndex: attachTimelineIndex(store),\n\t\tfindTimelineState: attachTimelineFamily(store),\n\t}\n}\n","import type { AtomToken, ReadonlySelectorToken } from \"atom.io\"\nimport { __INTERNAL__ } from \"atom.io\"\n\nimport type { StateTokenIndex } from \".\"\n\nexport type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>\n\nexport const attachAtomIndex = (\n\tstore: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,\n): ReadonlySelectorToken<AtomTokenIndex> => {\n\tconst atomTokenIndexState__INTERNAL =\n\t\t__INTERNAL__.atom__INTERNAL<AtomTokenIndex>(\n\t\t\t{\n\t\t\t\tkey: `👁🗨 Atom Token Index (Internal)`,\n\t\t\t\tdefault: () =>\n\t\t\t\t\t[...store.atoms]\n\t\t\t\t\t\t.filter(([key]) => !key.includes(`👁🗨`))\n\t\t\t\t\t\t.reduce<AtomTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\tacc[key] = { key, type: `atom` }\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\teffects: [\n\t\t\t\t\t({ setSelf }) => {\n\t\t\t\t\t\tstore.subject.atomCreation.subscribe(\n\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t(atomToken) => {\n\t\t\t\t\t\t\t\tif (store.operation.open) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (atomToken.key.includes(`👁🗨`)) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\t\t\t\tconst { key, family } = atomToken\n\t\t\t\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[subKey]: atomToken,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t[key]: atomToken,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\treturn __INTERNAL__.selector__INTERNAL(\n\t\t{\n\t\t\tkey: `👁🗨 Atom Token Index`,\n\t\t\tget: ({ get }) => get(atomTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n}\n","import { __INTERNAL__ } from \"atom.io\"\nimport type { ReadonlySelectorToken, SelectorToken } from \"atom.io\"\n\nimport type { StateTokenIndex } from \".\"\n\nexport type SelectorTokenIndex = StateTokenIndex<\n\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n>\n\nexport const attachSelectorIndex = (\n\tstore: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,\n): ReadonlySelectorToken<SelectorTokenIndex> => {\n\tconst readonlySelectorTokenIndexState__INTERNAL =\n\t\t__INTERNAL__.atom__INTERNAL<SelectorTokenIndex>(\n\t\t\t{\n\t\t\t\tkey: `👁🗨 Selector Token Index (Internal)`,\n\t\t\t\tdefault: () =>\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t[...store.readonlySelectors]\n\t\t\t\t\t\t\t.filter(([key]) => !key.includes(`👁🗨`))\n\t\t\t\t\t\t\t.reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\t\tacc[key] = { key, type: `readonly_selector` }\n\t\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\t[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\tacc[key] = { key, type: `selector` }\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t),\n\t\t\t\teffects: [\n\t\t\t\t\t({ setSelf }) => {\n\t\t\t\t\t\tstore.subject.selectorCreation.subscribe(\n\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t(selectorToken) => {\n\t\t\t\t\t\t\t\tif (store.operation.open) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (selectorToken.key.includes(`👁🗨`)) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\t\t\t\tconst { key, family } = selectorToken\n\t\t\t\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[subKey]: selectorToken,\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t[key]: selectorToken,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\treturn __INTERNAL__.selector__INTERNAL({\n\t\tkey: `👁🗨 Selector Token Index`,\n\t\tget: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),\n\t})\n}\n","import type { ReadonlySelectorFamily, Store } from \"atom.io\"\nimport { __INTERNAL__ } from \"atom.io\"\nimport type { Timeline } from \"atom.io/internal\"\nimport { Subject } from \"atom.io/internal\"\n\nexport const attachTimelineFamily = (\n\tstore: Store = __INTERNAL__.IMPLICIT.STORE,\n): ReadonlySelectorFamily<Timeline> => {\n\tconst findTimelineLogState__INTERNAL = __INTERNAL__.atomFamily__INTERNAL<\n\t\tTimeline,\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Timeline Update Log (Internal)`,\n\t\t\tdefault: (key) =>\n\t\t\t\tstore.timelines.get(key) ?? {\n\t\t\t\t\ttype: `timeline`,\n\t\t\t\t\tkey: ``,\n\t\t\t\t\tat: 0,\n\t\t\t\t\ttimeTraveling: null,\n\t\t\t\t\thistory: [],\n\t\t\t\t\tselectorTime: null,\n\t\t\t\t\ttransactionKey: null,\n\t\t\t\t\tinstall: () => {},\n\t\t\t\t\tsubject: new Subject(),\n\t\t\t\t},\n\t\t\teffects: (key) => [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tconst tl = store.timelines.get(key)\n\t\t\t\t\ttl?.subject.subscribe(`introspection`, (_) => {\n\t\t\t\t\t\tif (store.operation.open === true) {\n\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t\t(operationStatus) => {\n\t\t\t\t\t\t\t\t\tif (operationStatus.open === false) {\n\t\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\t\tsetSelf({ ...tl })\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetSelf({ ...tl })\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tstore,\n\t)\n\tconst findTimelineLogState = __INTERNAL__.selectorFamily__INTERNAL<\n\t\tTimeline,\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Timeline Update Log`,\n\t\t\tget: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key)),\n\t\t},\n\t\tstore,\n\t)\n\treturn findTimelineLogState\n}\n","import type { ReadonlySelectorToken, Store, TimelineToken } from \"atom.io\"\nimport { __INTERNAL__ } from \"atom.io\"\n\nexport const attachTimelineIndex = (\n\tstore: Store = __INTERNAL__.IMPLICIT.STORE,\n): ReadonlySelectorToken<TimelineToken[]> => {\n\tconst timelineTokenIndexState__INTERNAL = __INTERNAL__.atom__INTERNAL<\n\t\tTimelineToken[]\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Timeline Token Index (Internal)`,\n\t\t\tdefault: () =>\n\t\t\t\t[...store.timelines].map(([key]) => {\n\t\t\t\t\treturn { key, type: `timeline` }\n\t\t\t\t}),\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.timelineCreation.subscribe(\n\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t(timelineToken) => {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, timelineToken])\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\tconst timelineTokenIndex = __INTERNAL__.selector__INTERNAL(\n\t\t{\n\t\t\tkey: `👁🗨 Timeline Token Index`,\n\t\t\tget: ({ get }) => get(timelineTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn timelineTokenIndex\n}\n","import type { ReadonlySelectorToken, TransactionToken, ƒn } from \"atom.io\"\nimport { __INTERNAL__ } from \"atom.io\"\n\nexport const attachTransactionIndex = (\n\tstore: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,\n): ReadonlySelectorToken<TransactionToken<ƒn>[]> => {\n\tconst transactionTokenIndexState__INTERNAL = __INTERNAL__.atom__INTERNAL<\n\t\tTransactionToken<ƒn>[]\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Transaction Token Index (Internal)`,\n\t\t\tdefault: () =>\n\t\t\t\t[...store.transactions].map(([key]) => {\n\t\t\t\t\treturn { key, type: `transaction` }\n\t\t\t\t}),\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.transactionCreation.subscribe(\n\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t(transactionToken) => {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, transactionToken])\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\tconst transactionTokenIndex = __INTERNAL__.selector__INTERNAL(\n\t\t{\n\t\t\tkey: `👁🗨 Transaction Token Index`,\n\t\t\tget: ({ get }) => get(transactionTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn transactionTokenIndex\n}\n","import type { ReadonlySelectorFamily, TransactionUpdate, ƒn } from \"atom.io\"\nimport { __INTERNAL__ } from \"atom.io\"\n\nexport const attachTransactionLogs = (\n\tstore: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,\n): ReadonlySelectorFamily<TransactionUpdate<ƒn>[]> => {\n\tconst findTransactionUpdateLog = __INTERNAL__.atomFamily__INTERNAL<\n\t\tTransactionUpdate<ƒn>[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Transaction Update Log (Internal)`,\n\t\t\tdefault: () => [],\n\t\t\teffects: (key) => [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tconst tx = store.transactions.get(key)\n\t\t\t\t\ttx?.subject.subscribe(`introspection`, (transactionUpdate) => {\n\t\t\t\t\t\tif (transactionUpdate.key === key) {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, transactionUpdate])\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tstore,\n\t)\n\tconst findTransactionUpdateLogState = __INTERNAL__.selectorFamily__INTERNAL<\n\t\tTransactionUpdate<ƒn>[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Transaction Update Log`,\n\t\t\tget: (key) => ({ get }) => get(findTransactionUpdateLog(key)),\n\t\t},\n\t\tstore,\n\t)\n\treturn findTransactionUpdateLogState\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/attach-introspection-states.ts","../src/attach-atom-index.ts","../src/attach-selector-index.ts","../src/attach-timeline-family.ts","../src/attach-timeline-index.ts","../src/attach-transaction-index.ts","../src/attach-transaction-logs.ts"],"names":["IMPLICIT","createAtom","createSelector","target","createAtomFamily","createSelectorFamily"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQA,YAAY,kBAAkB;;;ACN9B,SAAS,UAAU,YAAY,gBAAgB,cAAc;AAMtD,IAAM,kBAAkB,CAC9B,QAAe,SAAS,UACmB;AAC3C,QAAM,gCAAgC;AAAA,IACrC;AAAA,MACC,KAAK;AAAA,MACL,SAAS,MAAM;AACd,cAAM,mBAAmB,CAAC,GAAG,MAAM,KAAK,EACtC,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,SAAS,0BAAO,CAAC,EACxC,OAAuB,CAAC,KAAK,CAAC,GAAG,MAAM;AACvC,cAAI,GAAG,IAAI,EAAE,KAAK,MAAM,OAAO;AAC/B,iBAAO;AAAA,QACR,GAAG,CAAC,CAAC;AACN,eAAO;AAAA,MACR;AAAA,MACA,SAAS;AAAA,QACR,CAAC,E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AI,MAAM,IAAI,yBAAyB,GAAG,CAAC;AAAA,IAC7D;AAAA,IACA;AAAA,EACD;AACA,SAAO;AACR;;;ANvBO,IAAM,4BAA4B,CACxC,QAAyC,sBAAS,UAQ9C;AACJ,SAAO;AAAA,IACN,WAAW,gBAAgB,KAAK;AAAA,IAChC,eAAe,oBAAoB,KAAK;AAAA,IACxC,kBAAkB,uBAAuB,KAAK;AAAA,IAC9C,yBAAyB,sBAAsB,KAAK;AAAA,IACpD,eAAe,oBAAoB,KAAK;AAAA,IACxC,mBAAmB,qBAAqB,KAAK;AAAA,EAC9C;AACD","sourcesContent":["import type {\n\tReadonlySelectorFamily,\n\tReadonlySelectorToken,\n\tTimelineToken,\n\tTransactionToken,\n\tTransactionUpdate,\n\tƒn,\n} from \"atom.io\"\nimport * as __INTERNAL__ from \"atom.io/internal\"\nimport type { Timeline } from \"atom.io/internal\"\n\nimport { type AtomTokenIndex, attachAtomIndex } from \"./attach-atom-index\"\nimport type { SelectorTokenIndex } from \"./attach-selector-index\"\nimport { attachSelectorIndex } from \"./attach-selector-index\"\nimport { attachTimelineFamily } from \"./attach-timeline-family\"\nimport { attachTimelineIndex } from \"./attach-timeline-index\"\nimport { attachTransactionIndex } from \"./attach-transaction-index\"\nimport { attachTransactionLogs } from \"./attach-transaction-logs\"\n\nexport const attachIntrospectionStates = (\n\tstore: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,\n): {\n\tatomIndex: ReadonlySelectorToken<AtomTokenIndex>\n\tselectorIndex: ReadonlySelectorToken<SelectorTokenIndex>\n\ttransactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>\n\tfindTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<ƒn>[]>\n\ttimelineIndex: ReadonlySelectorToken<TimelineToken[]>\n\tfindTimelineState: ReadonlySelectorFamily<Timeline>\n} => {\n\treturn {\n\t\tatomIndex: attachAtomIndex(store),\n\t\tselectorIndex: attachSelectorIndex(store),\n\t\ttransactionIndex: attachTransactionIndex(store),\n\t\tfindTransactionLogState: attachTransactionLogs(store),\n\t\ttimelineIndex: attachTimelineIndex(store),\n\t\tfindTimelineState: attachTimelineFamily(store),\n\t}\n}\n","import type { AtomToken, ReadonlySelectorToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector, target } from \"atom.io/internal\"\n\nimport type { StateTokenIndex } from \".\"\n\nexport type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>\n\nexport const attachAtomIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<AtomTokenIndex> => {\n\tconst atomTokenIndexState__INTERNAL = createAtom<AtomTokenIndex>(\n\t\t{\n\t\t\tkey: `👁🗨 Atom Token Index (Internal)`,\n\t\t\tdefault: () => {\n\t\t\t\tconst defaultAtomIndex = [...store.atoms]\n\t\t\t\t\t.filter(([key]) => !key.includes(`👁🗨`))\n\t\t\t\t\t.reduce<AtomTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\tacc[key] = { key, type: `atom` }\n\t\t\t\t\t\treturn acc\n\t\t\t\t\t}, {})\n\t\t\t\treturn defaultAtomIndex\n\t\t\t},\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.atomCreation.subscribe(`introspection`, (atomToken) => {\n\t\t\t\t\t\tif (atomToken.key.includes(`👁🗨`)) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst set = () =>\n\t\t\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\t\t\tconst { key, family } = atomToken\n\t\t\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[subKey]: atomToken,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t[key]: atomToken,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\tif (target(store).operation.open) {\n\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t`introspection: waiting to update atom index`,\n\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn createSelector(\n\t\t{\n\t\t\tkey: `👁🗨 Atom Token Index`,\n\t\t\tget: ({ get }) => get(atomTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n}\n","import type { ReadonlySelectorToken, SelectorToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector, target } from \"atom.io/internal\"\n\nimport type { StateTokenIndex } from \".\"\n\nexport type SelectorTokenIndex = StateTokenIndex<\n\tReadonlySelectorToken<unknown> | SelectorToken<unknown>\n>\n\nexport const attachSelectorIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<SelectorTokenIndex> => {\n\tconst readonlySelectorTokenIndexState__INTERNAL =\n\t\tcreateAtom<SelectorTokenIndex>(\n\t\t\t{\n\t\t\t\tkey: `👁🗨 Selector Token Index (Internal)`,\n\t\t\t\tdefault: () =>\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\t[...store.readonlySelectors]\n\t\t\t\t\t\t\t.filter(([key]) => !key.includes(`👁🗨`))\n\t\t\t\t\t\t\t.reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\t\tacc[key] = { key, type: `readonly_selector` }\n\t\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\t[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {\n\t\t\t\t\t\t\tacc[key] = { key, type: `selector` }\n\t\t\t\t\t\t\treturn acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t),\n\t\t\t\teffects: [\n\t\t\t\t\t({ setSelf }) => {\n\t\t\t\t\t\tstore.subject.selectorCreation.subscribe(\n\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t(selectorToken) => {\n\t\t\t\t\t\t\t\tif (selectorToken.key.includes(`👁🗨`)) {\n\t\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst set = () =>\n\t\t\t\t\t\t\t\t\tsetSelf((state) => {\n\t\t\t\t\t\t\t\t\t\tconst { key, family } = selectorToken\n\t\t\t\t\t\t\t\t\t\tif (family) {\n\t\t\t\t\t\t\t\t\t\t\tconst { key: familyKey, subKey } = family\n\t\t\t\t\t\t\t\t\t\t\tconst current = state[familyKey]\n\t\t\t\t\t\t\t\t\t\t\tif (current === undefined || `familyMembers` in current) {\n\t\t\t\t\t\t\t\t\t\t\t\tconst familyKeyState = current || {\n\t\t\t\t\t\t\t\t\t\t\t\t\tkey: familyKey,\n\t\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {},\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[familyKey]: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfamilyMembers: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t...familyKeyState.familyMembers,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[subKey]: selectorToken,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t\t\t\t\t[key]: selectorToken,\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\tif (target(store).operation.open) {\n\t\t\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t\t\t`introspection: waiting to update selector index`,\n\t\t\t\t\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tset()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tundefined,\n\t\t\tstore,\n\t\t)\n\treturn createSelector({\n\t\tkey: `👁🗨 Selector Token Index`,\n\t\tget: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),\n\t})\n}\n","import type { ReadonlySelectorFamily } from \"atom.io\"\nimport type { Store, Timeline } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tSubject,\n\tcreateAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nexport const attachTimelineFamily = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<Timeline> => {\n\tconst findTimelineLogState__INTERNAL = createAtomFamily<Timeline, string>(\n\t\t{\n\t\t\tkey: `👁🗨 Timeline Update Log (Internal)`,\n\t\t\tdefault: (key) =>\n\t\t\t\tstore.timelines.get(key) ?? {\n\t\t\t\t\ttype: `timeline`,\n\t\t\t\t\tkey: ``,\n\t\t\t\t\tat: 0,\n\t\t\t\t\ttimeTraveling: null,\n\t\t\t\t\thistory: [],\n\t\t\t\t\tselectorTime: null,\n\t\t\t\t\ttransactionKey: null,\n\t\t\t\t\tinstall: () => {},\n\t\t\t\t\tsubject: new Subject(),\n\t\t\t\t},\n\t\t\teffects: (key) => [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tconst tl = store.timelines.get(key)\n\t\t\t\t\ttl?.subject.subscribe(`introspection`, (_) => {\n\t\t\t\t\t\tif (store.operation.open === true) {\n\t\t\t\t\t\t\tconst unsubscribe = store.subject.operationStatus.subscribe(\n\t\t\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t\t\t(operationStatus) => {\n\t\t\t\t\t\t\t\t\tif (operationStatus.open === false) {\n\t\t\t\t\t\t\t\t\t\tunsubscribe()\n\t\t\t\t\t\t\t\t\t\tsetSelf({ ...tl })\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tsetSelf({ ...tl })\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tstore,\n\t)\n\tconst findTimelineLogState = createSelectorFamily<Timeline, string>(\n\t\t{\n\t\t\tkey: `👁🗨 Timeline Update Log`,\n\t\t\tget: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key)),\n\t\t},\n\t\tstore,\n\t)\n\treturn findTimelineLogState\n}\n","import type { ReadonlySelectorToken, TimelineToken } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector } from \"atom.io/internal\"\n\nexport const attachTimelineIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<TimelineToken[]> => {\n\tconst timelineTokenIndexState__INTERNAL = createAtom<TimelineToken[]>(\n\t\t{\n\t\t\tkey: `👁🗨 Timeline Token Index (Internal)`,\n\t\t\tdefault: () =>\n\t\t\t\t[...store.timelines].map(([key]): TimelineToken => {\n\t\t\t\t\treturn { key, type: `timeline` }\n\t\t\t\t}),\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.timelineCreation.subscribe(\n\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t(timelineToken) => {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, timelineToken])\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\tconst timelineTokenIndex = createSelector(\n\t\t{\n\t\t\tkey: `👁🗨 Timeline Token Index`,\n\t\t\tget: ({ get }) => get(timelineTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn timelineTokenIndex\n}\n","import type { ReadonlySelectorToken, TransactionToken, ƒn } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport { IMPLICIT, createAtom, createSelector } from \"atom.io/internal\"\n\nexport const attachTransactionIndex = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorToken<TransactionToken<ƒn>[]> => {\n\tconst transactionTokenIndexState__INTERNAL = createAtom<\n\t\tTransactionToken<ƒn>[]\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Transaction Token Index (Internal)`,\n\t\t\tdefault: () =>\n\t\t\t\t[...store.transactions].map(([key]): TransactionToken<ƒn> => {\n\t\t\t\t\treturn { key, type: `transaction` }\n\t\t\t\t}),\n\t\t\teffects: [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tstore.subject.transactionCreation.subscribe(\n\t\t\t\t\t\t`introspection`,\n\t\t\t\t\t\t(transactionToken) => {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, transactionToken])\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\tconst transactionTokenIndex = createSelector(\n\t\t{\n\t\t\tkey: `👁🗨 Transaction Token Index`,\n\t\t\tget: ({ get }) => get(transactionTokenIndexState__INTERNAL),\n\t\t},\n\t\tundefined,\n\t\tstore,\n\t)\n\treturn transactionTokenIndex\n}\n","import type { ReadonlySelectorFamily, TransactionUpdate, ƒn } from \"atom.io\"\nimport type { Store } from \"atom.io/internal\"\nimport {\n\tIMPLICIT,\n\tcreateAtomFamily,\n\tcreateSelectorFamily,\n} from \"atom.io/internal\"\n\nexport const attachTransactionLogs = (\n\tstore: Store = IMPLICIT.STORE,\n): ReadonlySelectorFamily<TransactionUpdate<ƒn>[]> => {\n\tconst findTransactionUpdateLog = createAtomFamily<\n\t\tTransactionUpdate<ƒn>[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Transaction Update Log (Internal)`,\n\t\t\tdefault: () => [],\n\t\t\teffects: (key) => [\n\t\t\t\t({ setSelf }) => {\n\t\t\t\t\tconst tx = store.transactions.get(key)\n\t\t\t\t\ttx?.subject.subscribe(`introspection`, (transactionUpdate) => {\n\t\t\t\t\t\tif (transactionUpdate.key === key) {\n\t\t\t\t\t\t\tsetSelf((state) => [...state, transactionUpdate])\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\tstore,\n\t)\n\tconst findTransactionUpdateLogState = createSelectorFamily<\n\t\tTransactionUpdate<ƒn>[],\n\t\tstring\n\t>(\n\t\t{\n\t\t\tkey: `👁🗨 Transaction Update Log`,\n\t\t\tget: (key) => ({ get }) => get(findTransactionUpdateLog(key)),\n\t\t},\n\t\tstore,\n\t)\n\treturn findTransactionUpdateLogState\n}\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AtomToken, ReadonlySelectorToken } from "atom.io"
|
|
2
|
+
import type { Store } from "atom.io/internal"
|
|
3
|
+
import { IMPLICIT, createAtom, createSelector, target } from "atom.io/internal"
|
|
4
|
+
|
|
5
|
+
import type { StateTokenIndex } from "."
|
|
6
|
+
|
|
7
|
+
export type AtomTokenIndex = StateTokenIndex<AtomToken<unknown>>
|
|
8
|
+
|
|
9
|
+
export const attachAtomIndex = (
|
|
10
|
+
store: Store = IMPLICIT.STORE,
|
|
11
|
+
): ReadonlySelectorToken<AtomTokenIndex> => {
|
|
12
|
+
const atomTokenIndexState__INTERNAL = createAtom<AtomTokenIndex>(
|
|
13
|
+
{
|
|
14
|
+
key: `👁🗨 Atom Token Index (Internal)`,
|
|
15
|
+
default: () => {
|
|
16
|
+
const defaultAtomIndex = [...store.atoms]
|
|
17
|
+
.filter(([key]) => !key.includes(`👁🗨`))
|
|
18
|
+
.reduce<AtomTokenIndex>((acc, [key]) => {
|
|
19
|
+
acc[key] = { key, type: `atom` }
|
|
20
|
+
return acc
|
|
21
|
+
}, {})
|
|
22
|
+
return defaultAtomIndex
|
|
23
|
+
},
|
|
24
|
+
effects: [
|
|
25
|
+
({ setSelf }) => {
|
|
26
|
+
store.subject.atomCreation.subscribe(`introspection`, (atomToken) => {
|
|
27
|
+
if (atomToken.key.includes(`👁🗨`)) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
const set = () =>
|
|
31
|
+
setSelf((state) => {
|
|
32
|
+
const { key, family } = atomToken
|
|
33
|
+
if (family) {
|
|
34
|
+
const { key: familyKey, subKey } = family
|
|
35
|
+
const current = state[familyKey]
|
|
36
|
+
if (current === undefined || `familyMembers` in current) {
|
|
37
|
+
const familyKeyState = current || {
|
|
38
|
+
key: familyKey,
|
|
39
|
+
familyMembers: {},
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
...state,
|
|
43
|
+
[familyKey]: {
|
|
44
|
+
...familyKeyState,
|
|
45
|
+
familyMembers: {
|
|
46
|
+
...familyKeyState.familyMembers,
|
|
47
|
+
[subKey]: atomToken,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
...state,
|
|
55
|
+
[key]: atomToken,
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
if (target(store).operation.open) {
|
|
59
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
60
|
+
`introspection: waiting to update atom index`,
|
|
61
|
+
() => {
|
|
62
|
+
unsubscribe()
|
|
63
|
+
set()
|
|
64
|
+
},
|
|
65
|
+
)
|
|
66
|
+
} else {
|
|
67
|
+
set()
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
undefined,
|
|
74
|
+
store,
|
|
75
|
+
)
|
|
76
|
+
return createSelector(
|
|
77
|
+
{
|
|
78
|
+
key: `👁🗨 Atom Token Index`,
|
|
79
|
+
get: ({ get }) => get(atomTokenIndexState__INTERNAL),
|
|
80
|
+
},
|
|
81
|
+
undefined,
|
|
82
|
+
store,
|
|
83
|
+
)
|
|
84
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ReadonlySelectorFamily,
|
|
3
|
+
ReadonlySelectorToken,
|
|
4
|
+
TimelineToken,
|
|
5
|
+
TransactionToken,
|
|
6
|
+
TransactionUpdate,
|
|
7
|
+
ƒn,
|
|
8
|
+
} from "atom.io"
|
|
9
|
+
import * as __INTERNAL__ from "atom.io/internal"
|
|
10
|
+
import type { Timeline } from "atom.io/internal"
|
|
11
|
+
|
|
12
|
+
import { type AtomTokenIndex, attachAtomIndex } from "./attach-atom-index"
|
|
13
|
+
import type { SelectorTokenIndex } from "./attach-selector-index"
|
|
14
|
+
import { attachSelectorIndex } from "./attach-selector-index"
|
|
15
|
+
import { attachTimelineFamily } from "./attach-timeline-family"
|
|
16
|
+
import { attachTimelineIndex } from "./attach-timeline-index"
|
|
17
|
+
import { attachTransactionIndex } from "./attach-transaction-index"
|
|
18
|
+
import { attachTransactionLogs } from "./attach-transaction-logs"
|
|
19
|
+
|
|
20
|
+
export const attachIntrospectionStates = (
|
|
21
|
+
store: __INTERNAL__.Store = __INTERNAL__.IMPLICIT.STORE,
|
|
22
|
+
): {
|
|
23
|
+
atomIndex: ReadonlySelectorToken<AtomTokenIndex>
|
|
24
|
+
selectorIndex: ReadonlySelectorToken<SelectorTokenIndex>
|
|
25
|
+
transactionIndex: ReadonlySelectorToken<TransactionToken<ƒn>[]>
|
|
26
|
+
findTransactionLogState: ReadonlySelectorFamily<TransactionUpdate<ƒn>[]>
|
|
27
|
+
timelineIndex: ReadonlySelectorToken<TimelineToken[]>
|
|
28
|
+
findTimelineState: ReadonlySelectorFamily<Timeline>
|
|
29
|
+
} => {
|
|
30
|
+
return {
|
|
31
|
+
atomIndex: attachAtomIndex(store),
|
|
32
|
+
selectorIndex: attachSelectorIndex(store),
|
|
33
|
+
transactionIndex: attachTransactionIndex(store),
|
|
34
|
+
findTransactionLogState: attachTransactionLogs(store),
|
|
35
|
+
timelineIndex: attachTimelineIndex(store),
|
|
36
|
+
findTimelineState: attachTimelineFamily(store),
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { ReadonlySelectorToken, SelectorToken } from "atom.io"
|
|
2
|
+
import type { Store } from "atom.io/internal"
|
|
3
|
+
import { IMPLICIT, createAtom, createSelector, target } from "atom.io/internal"
|
|
4
|
+
|
|
5
|
+
import type { StateTokenIndex } from "."
|
|
6
|
+
|
|
7
|
+
export type SelectorTokenIndex = StateTokenIndex<
|
|
8
|
+
ReadonlySelectorToken<unknown> | SelectorToken<unknown>
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
export const attachSelectorIndex = (
|
|
12
|
+
store: Store = IMPLICIT.STORE,
|
|
13
|
+
): ReadonlySelectorToken<SelectorTokenIndex> => {
|
|
14
|
+
const readonlySelectorTokenIndexState__INTERNAL =
|
|
15
|
+
createAtom<SelectorTokenIndex>(
|
|
16
|
+
{
|
|
17
|
+
key: `👁🗨 Selector Token Index (Internal)`,
|
|
18
|
+
default: () =>
|
|
19
|
+
Object.assign(
|
|
20
|
+
[...store.readonlySelectors]
|
|
21
|
+
.filter(([key]) => !key.includes(`👁🗨`))
|
|
22
|
+
.reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
23
|
+
acc[key] = { key, type: `readonly_selector` }
|
|
24
|
+
return acc
|
|
25
|
+
}, {}),
|
|
26
|
+
[...store.selectors].reduce<SelectorTokenIndex>((acc, [key]) => {
|
|
27
|
+
acc[key] = { key, type: `selector` }
|
|
28
|
+
return acc
|
|
29
|
+
}, {}),
|
|
30
|
+
),
|
|
31
|
+
effects: [
|
|
32
|
+
({ setSelf }) => {
|
|
33
|
+
store.subject.selectorCreation.subscribe(
|
|
34
|
+
`introspection`,
|
|
35
|
+
(selectorToken) => {
|
|
36
|
+
if (selectorToken.key.includes(`👁🗨`)) {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
const set = () =>
|
|
40
|
+
setSelf((state) => {
|
|
41
|
+
const { key, family } = selectorToken
|
|
42
|
+
if (family) {
|
|
43
|
+
const { key: familyKey, subKey } = family
|
|
44
|
+
const current = state[familyKey]
|
|
45
|
+
if (current === undefined || `familyMembers` in current) {
|
|
46
|
+
const familyKeyState = current || {
|
|
47
|
+
key: familyKey,
|
|
48
|
+
familyMembers: {},
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
...state,
|
|
52
|
+
[familyKey]: {
|
|
53
|
+
...familyKeyState,
|
|
54
|
+
familyMembers: {
|
|
55
|
+
...familyKeyState.familyMembers,
|
|
56
|
+
[subKey]: selectorToken,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
...state,
|
|
64
|
+
[key]: selectorToken,
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
if (target(store).operation.open) {
|
|
68
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
69
|
+
`introspection: waiting to update selector index`,
|
|
70
|
+
() => {
|
|
71
|
+
unsubscribe()
|
|
72
|
+
set()
|
|
73
|
+
},
|
|
74
|
+
)
|
|
75
|
+
} else {
|
|
76
|
+
set()
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
)
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
undefined,
|
|
84
|
+
store,
|
|
85
|
+
)
|
|
86
|
+
return createSelector({
|
|
87
|
+
key: `👁🗨 Selector Token Index`,
|
|
88
|
+
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL),
|
|
89
|
+
})
|
|
90
|
+
}
|