atom.io 0.14.4 → 0.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.cjs +47 -1416
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +8 -134
- package/data/dist/index.d.ts +8 -134
- package/data/dist/index.js +4 -6
- package/data/dist/index.js.map +1 -1
- package/dist/chunk-NYTGCPHB.js +261 -0
- package/dist/chunk-NYTGCPHB.js.map +1 -0
- package/dist/chunk-PZLG2HP3.js +36 -0
- package/dist/chunk-PZLG2HP3.js.map +1 -0
- package/dist/chunk-XACXFU3B.js +46 -0
- package/dist/chunk-XACXFU3B.js.map +1 -0
- package/dist/index.cjs +55 -2330
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +152 -1
- package/dist/index.js.map +1 -1
- package/internal/dist/index.cjs +30 -159
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +8 -211
- package/internal/dist/index.d.ts +8 -211
- package/internal/dist/index.js +2027 -1
- package/internal/dist/index.js.map +1 -1
- package/introspection/dist/index.cjs +45 -1565
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +2 -129
- package/introspection/dist/index.d.ts +2 -129
- package/introspection/dist/index.js +298 -2
- package/introspection/dist/index.js.map +1 -1
- package/json/dist/index.cjs +5 -1502
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +5 -131
- package/json/dist/index.d.ts +5 -131
- package/json/dist/index.js +37 -1
- package/json/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/react/dist/index.cjs +14 -1549
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +8 -136
- package/react/dist/index.d.ts +8 -136
- package/react/dist/index.js +62 -2
- package/react/dist/index.js.map +1 -1
- package/react-devtools/dist/index.cjs +135 -2153
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.d.cts +20 -146
- package/react-devtools/dist/index.d.ts +20 -146
- package/react-devtools/dist/index.js +5 -3
- package/react-devtools/dist/index.js.map +1 -1
- package/realtime-client/dist/index.cjs +34 -1529
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +11 -138
- package/realtime-client/dist/index.d.ts +11 -138
- package/realtime-client/dist/index.js +165 -2
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-react/dist/index.cjs +35 -1727
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.cts +7 -35
- package/realtime-react/dist/index.d.ts +7 -35
- package/realtime-react/dist/index.js +66 -4
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-server/dist/index.cjs +57 -1548
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +15 -153
- package/realtime-server/dist/index.d.ts +15 -153
- package/realtime-server/dist/index.js +21 -27
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-testing/dist/index.cjs +15 -2376
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +3 -489
- package/realtime-testing/dist/index.d.ts +3 -489
- package/realtime-testing/dist/index.js +10 -9
- package/realtime-testing/dist/index.js.map +1 -1
- package/transceivers/set-rtx/dist/index.cjs +9 -31
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.cts +7 -7
- package/transceivers/set-rtx/dist/index.d.ts +7 -7
- package/transceivers/set-rtx/dist/index.js +3 -2
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/dist/chunk-GMN5KH6A.js +0 -309
- package/dist/chunk-GMN5KH6A.js.map +0 -1
- package/dist/chunk-HQWWV67P.js +0 -62
- package/dist/chunk-HQWWV67P.js.map +0 -1
- package/dist/chunk-MK4OJD24.js +0 -67
- package/dist/chunk-MK4OJD24.js.map +0 -1
- package/dist/chunk-N7ADBQJG.js +0 -176
- package/dist/chunk-N7ADBQJG.js.map +0 -1
- package/dist/chunk-PURABO5G.js +0 -2581
- package/dist/chunk-PURABO5G.js.map +0 -1
- package/dist/index.d.cts +0 -493
- package/dist/index.d.ts +0 -493
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
|
@@ -1,2094 +1,64 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var n = Object.create(null);
|
|
11
|
-
if (e) {
|
|
12
|
-
Object.keys(e).forEach(function (k) {
|
|
13
|
-
if (k !== 'default') {
|
|
14
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: function () { return e[k]; }
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
27
|
-
|
|
28
|
-
var __defProp = Object.defineProperty;
|
|
29
|
-
var __defProps = Object.defineProperties;
|
|
30
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
31
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
32
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
33
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
34
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
35
|
-
var __spreadValues = (a2, b2) => {
|
|
36
|
-
for (var prop in b2 || (b2 = {}))
|
|
37
|
-
if (__hasOwnProp.call(b2, prop))
|
|
38
|
-
__defNormalProp(a2, prop, b2[prop]);
|
|
39
|
-
if (__getOwnPropSymbols)
|
|
40
|
-
for (var prop of __getOwnPropSymbols(b2)) {
|
|
41
|
-
if (__propIsEnum.call(b2, prop))
|
|
42
|
-
__defNormalProp(a2, prop, b2[prop]);
|
|
43
|
-
}
|
|
44
|
-
return a2;
|
|
45
|
-
};
|
|
46
|
-
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
|
|
47
|
-
var __restKey = (key) => typeof key === "symbol" ? key : key + "";
|
|
48
|
-
var __objRest = (source, exclude) => {
|
|
49
|
-
var target = {};
|
|
50
|
-
for (var prop in source)
|
|
51
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
52
|
-
target[prop] = source[prop];
|
|
53
|
-
if (source != null && __getOwnPropSymbols)
|
|
54
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
55
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
56
|
-
target[prop] = source[prop];
|
|
57
|
-
}
|
|
58
|
-
return target;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// internal/src/future.ts
|
|
62
|
-
var Future = class extends Promise {
|
|
63
|
-
constructor(executor) {
|
|
64
|
-
super((resolve, reject) => {
|
|
65
|
-
const pass2 = (value) => this.isCanceled ? reject(`canceled`) : resolve(value);
|
|
66
|
-
const fail = (reason) => this.isCanceled ? reject(`canceled`) : reject(reason);
|
|
67
|
-
if (typeof executor === `function`) {
|
|
68
|
-
executor(pass2, fail);
|
|
69
|
-
} else {
|
|
70
|
-
executor.then(pass2, fail);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
this.isCanceled = false;
|
|
74
|
-
}
|
|
75
|
-
cancel() {
|
|
76
|
-
this.isCanceled = true;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// internal/src/lineage.ts
|
|
81
|
-
function newest(scion) {
|
|
82
|
-
while (scion.child !== null) {
|
|
83
|
-
scion = scion.child;
|
|
84
|
-
}
|
|
85
|
-
return scion;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// internal/src/caching.ts
|
|
89
|
-
function cacheValue(key, value, subject, store) {
|
|
90
|
-
const target = newest(store);
|
|
91
|
-
const currentValue = target.valueMap.get(key);
|
|
92
|
-
if (currentValue instanceof Future) {
|
|
93
|
-
currentValue.cancel();
|
|
94
|
-
}
|
|
95
|
-
if (value instanceof Promise) {
|
|
96
|
-
const future = new Future(value);
|
|
97
|
-
newest(store).valueMap.set(key, future);
|
|
98
|
-
future.then((resolved) => {
|
|
99
|
-
if (future.isCanceled) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
cacheValue(key, resolved, subject, store);
|
|
103
|
-
subject.next({ newValue: resolved, oldValue: future });
|
|
104
|
-
}).catch((thrown) => {
|
|
105
|
-
if (thrown !== `canceled`) {
|
|
106
|
-
store.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
return future;
|
|
110
|
-
}
|
|
111
|
-
target.valueMap.set(key, value);
|
|
112
|
-
return value;
|
|
113
|
-
}
|
|
114
|
-
var readCachedValue = (key, store) => {
|
|
115
|
-
return newest(store).valueMap.get(key);
|
|
116
|
-
};
|
|
117
|
-
var isValueCached = (key, store) => {
|
|
118
|
-
return newest(store).valueMap.has(key);
|
|
119
|
-
};
|
|
120
|
-
var evictCachedValue = (key, store) => {
|
|
121
|
-
const core = newest(store);
|
|
122
|
-
const currentValue = core.valueMap.get(key);
|
|
123
|
-
if (currentValue instanceof Future) {
|
|
124
|
-
currentValue.cancel();
|
|
125
|
-
}
|
|
126
|
-
if (core.operation.open) {
|
|
127
|
-
core.operation.prev.set(key, currentValue);
|
|
128
|
-
}
|
|
129
|
-
core.valueMap.delete(key);
|
|
130
|
-
store.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// ../anvl/src/json/index.ts
|
|
134
|
-
var parseJson = (str) => JSON.parse(str);
|
|
135
|
-
var stringifyJson = (json) => JSON.stringify(json);
|
|
136
|
-
var JSON_TYPE_NAMES = [
|
|
137
|
-
`array`,
|
|
138
|
-
`boolean`,
|
|
139
|
-
`null`,
|
|
140
|
-
`number`,
|
|
141
|
-
`object`,
|
|
142
|
-
`string`
|
|
143
|
-
];
|
|
144
|
-
var JSON_DEFAULTS = {
|
|
145
|
-
array: [],
|
|
146
|
-
boolean: false,
|
|
147
|
-
null: null,
|
|
148
|
-
number: 0,
|
|
149
|
-
object: {},
|
|
150
|
-
string: ``
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
// ../anvl/src/primitive/index.ts
|
|
154
|
-
var isString = (input) => {
|
|
155
|
-
return typeof input === `string`;
|
|
156
|
-
};
|
|
157
|
-
var isNumber = (input) => {
|
|
158
|
-
return typeof input === `number`;
|
|
159
|
-
};
|
|
160
|
-
var isBoolean = (input) => {
|
|
161
|
-
return typeof input === `boolean`;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
// json/src/select-json.ts
|
|
165
|
-
var selectJson = (atom2, transform, store = IMPLICIT.STORE) => {
|
|
166
|
-
return createSelector(
|
|
167
|
-
{
|
|
168
|
-
key: `${atom2.key}:JSON`,
|
|
169
|
-
get: ({ get }) => transform.toJson(get(atom2)),
|
|
170
|
-
set: ({ set }, newValue) => set(atom2, transform.fromJson(newValue))
|
|
171
|
-
},
|
|
172
|
-
void 0,
|
|
173
|
-
store
|
|
174
|
-
);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
// json/src/select-json-family.ts
|
|
178
|
-
var selectJsonFamily = (atomFamily2, transform, store = IMPLICIT.STORE) => {
|
|
179
|
-
const jsonFamily = createSelectorFamily(
|
|
180
|
-
{
|
|
181
|
-
key: `${atomFamily2.key}:JSON`,
|
|
182
|
-
get: (key) => ({ get }) => transform.toJson(get(atomFamily2(key))),
|
|
183
|
-
set: (key) => ({ set }, newValue) => set(atomFamily2(key), transform.fromJson(newValue))
|
|
184
|
-
},
|
|
185
|
-
store
|
|
186
|
-
);
|
|
187
|
-
atomFamily2.subject.subscribe(
|
|
188
|
-
`store=${store.config.name}::json-selector-family`,
|
|
189
|
-
(token) => {
|
|
190
|
-
if (token.family) {
|
|
191
|
-
jsonFamily(parseJson(token.family.subKey));
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
return jsonFamily;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
// internal/src/read-or-compute-value.ts
|
|
199
|
-
var readOrComputeValue = (state, store) => {
|
|
200
|
-
if (isValueCached(state.key, store)) {
|
|
201
|
-
store.logger.info(`\u{1F4D6}`, state.type, state.key, `reading cached value`);
|
|
202
|
-
return readCachedValue(state.key, store);
|
|
203
|
-
}
|
|
204
|
-
if (state.type !== `atom`) {
|
|
205
|
-
store.logger.info(`\u{1F9EE}`, state.type, state.key, `computing value`);
|
|
206
|
-
return state.get();
|
|
207
|
-
}
|
|
208
|
-
const fallback2 = state.default instanceof Function ? state.default() : state.default;
|
|
209
|
-
store.logger.info(
|
|
210
|
-
`\u{1F481}`,
|
|
211
|
-
`atom`,
|
|
212
|
-
state.key,
|
|
213
|
-
`could not find cached value; using default`,
|
|
214
|
-
fallback2
|
|
215
|
-
);
|
|
216
|
-
return state.default instanceof Function ? state.default() : state.default;
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
// internal/src/operation.ts
|
|
220
|
-
var openOperation = (token, store) => {
|
|
221
|
-
const target = newest(store);
|
|
222
|
-
if (target.operation.open) {
|
|
223
|
-
store.logger.error(
|
|
224
|
-
`\u274C`,
|
|
225
|
-
token.type,
|
|
226
|
-
token.key,
|
|
227
|
-
`failed to setState during a setState for "${target.operation.token.key}"`
|
|
228
|
-
);
|
|
229
|
-
return `rejection`;
|
|
230
|
-
}
|
|
231
|
-
target.operation = {
|
|
232
|
-
open: true,
|
|
233
|
-
done: /* @__PURE__ */ new Set(),
|
|
234
|
-
prev: /* @__PURE__ */ new Map(),
|
|
235
|
-
time: Date.now(),
|
|
236
|
-
token
|
|
237
|
-
};
|
|
238
|
-
store.logger.info(
|
|
239
|
-
`\u2B55`,
|
|
240
|
-
token.type,
|
|
241
|
-
token.key,
|
|
242
|
-
`operation start in store "${store.config.name}"${target.transactionMeta === null ? `` : ` ${target.transactionMeta.phase} "${target.transactionMeta.update.key}"`}`
|
|
243
|
-
);
|
|
244
|
-
};
|
|
245
|
-
var closeOperation = (store) => {
|
|
246
|
-
const target = newest(store);
|
|
247
|
-
if (target.operation.open) {
|
|
248
|
-
store.logger.info(
|
|
249
|
-
`\u{1F534}`,
|
|
250
|
-
target.operation.token.type,
|
|
251
|
-
target.operation.token.key,
|
|
252
|
-
`operation done in store "${store.config.name}"`
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
target.operation = { open: false };
|
|
256
|
-
store.subject.operationStatus.next(target.operation);
|
|
257
|
-
};
|
|
258
|
-
var isDone = (key, store) => {
|
|
259
|
-
const target = newest(store);
|
|
260
|
-
if (!target.operation.open) {
|
|
261
|
-
store.logger.warn(
|
|
262
|
-
`\u{1F41E}`,
|
|
263
|
-
`unknown`,
|
|
264
|
-
key,
|
|
265
|
-
`isDone called outside of an operation. This is probably a bug.`
|
|
266
|
-
);
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
return target.operation.done.has(key);
|
|
270
|
-
};
|
|
271
|
-
var markDone = (key, store) => {
|
|
272
|
-
const target = newest(store);
|
|
273
|
-
if (!target.operation.open) {
|
|
274
|
-
store.logger.warn(
|
|
275
|
-
`\u{1F41E}`,
|
|
276
|
-
`unknown`,
|
|
277
|
-
key,
|
|
278
|
-
`markDone called outside of an operation. This is probably a bug.`
|
|
279
|
-
);
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
target.operation.done.add(key);
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
// internal/src/set-state/become.ts
|
|
286
|
-
var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
|
|
287
|
-
originalThing instanceof Function ? originalThing() : originalThing
|
|
288
|
-
) : nextVersionOfThing;
|
|
289
|
-
|
|
290
|
-
// internal/src/subject.ts
|
|
291
|
-
var Subject = class {
|
|
292
|
-
constructor() {
|
|
293
|
-
this.subscribers = /* @__PURE__ */ new Map();
|
|
294
|
-
}
|
|
295
|
-
subscribe(key, subscriber) {
|
|
296
|
-
this.subscribers.set(key, subscriber);
|
|
297
|
-
const unsubscribe = () => this.unsubscribe(key);
|
|
298
|
-
return unsubscribe;
|
|
299
|
-
}
|
|
300
|
-
unsubscribe(key) {
|
|
301
|
-
this.subscribers.delete(key);
|
|
302
|
-
}
|
|
303
|
-
next(value) {
|
|
304
|
-
const subscribers = this.subscribers.values();
|
|
305
|
-
for (const subscriber of subscribers) {
|
|
306
|
-
subscriber(value);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
var StatefulSubject = class extends Subject {
|
|
311
|
-
constructor(initialState) {
|
|
312
|
-
super();
|
|
313
|
-
this.state = initialState;
|
|
314
|
-
}
|
|
315
|
-
next(value) {
|
|
316
|
-
this.state = value;
|
|
317
|
-
super.next(value);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
322
|
-
function copyMutableIfNeeded(atom2, transform, origin, target) {
|
|
323
|
-
const originValue = origin.valueMap.get(atom2.key);
|
|
324
|
-
const targetValue = target.valueMap.get(atom2.key);
|
|
325
|
-
if (originValue === targetValue) {
|
|
326
|
-
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom2.key}`, `copying`);
|
|
327
|
-
const jsonValue = transform.toJson(originValue);
|
|
328
|
-
const copiedValue = transform.fromJson(jsonValue);
|
|
329
|
-
target.valueMap.set(atom2.key, copiedValue);
|
|
330
|
-
new Tracker(atom2, origin);
|
|
331
|
-
return copiedValue;
|
|
332
|
-
}
|
|
333
|
-
return targetValue;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// internal/src/set-state/copy-mutable-in-transaction.ts
|
|
337
|
-
function copyMutableIfWithinTransaction(oldValue, atom2, store) {
|
|
338
|
-
const target = newest(store);
|
|
339
|
-
const parent = target.parent;
|
|
340
|
-
if (parent !== null) {
|
|
341
|
-
if (`toJson` in atom2 && `fromJson` in atom2) {
|
|
342
|
-
const copiedValue = copyMutableIfNeeded(atom2, atom2, parent, target);
|
|
343
|
-
return copiedValue;
|
|
344
|
-
}
|
|
345
|
-
if (`family` in atom2) {
|
|
346
|
-
const family = parent.families.get(atom2.family.key);
|
|
347
|
-
if (family && family.type === `atom_family`) {
|
|
348
|
-
const result = copyMutableFamilyMemberWithinTransaction(
|
|
349
|
-
atom2,
|
|
350
|
-
family,
|
|
351
|
-
parent,
|
|
352
|
-
target
|
|
353
|
-
);
|
|
354
|
-
if (result) {
|
|
355
|
-
return result;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
return oldValue;
|
|
361
|
-
}
|
|
362
|
-
function copyMutableFamilyMemberWithinTransaction(atom2, family, origin, target) {
|
|
363
|
-
if (`toJson` in family && `fromJson` in family) {
|
|
364
|
-
const copyCreated = copyMutableIfNeeded(atom2, family, origin, target);
|
|
365
|
-
return copyCreated;
|
|
366
|
-
}
|
|
367
|
-
return null;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// internal/src/set-state/emit-update.ts
|
|
371
|
-
var emitUpdate = (state, update, store) => {
|
|
372
|
-
store.logger.info(
|
|
373
|
-
`\u{1F4E2}`,
|
|
374
|
-
state.type,
|
|
375
|
-
state.key,
|
|
376
|
-
`went (`,
|
|
377
|
-
update.oldValue,
|
|
378
|
-
`->`,
|
|
379
|
-
update.newValue,
|
|
380
|
-
`) subscribers:`,
|
|
381
|
-
state.subject.subscribers
|
|
382
|
-
);
|
|
383
|
-
state.subject.next(update);
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
// internal/src/set-state/evict-downstream.ts
|
|
387
|
-
var evictDownStream = (atom2, store) => {
|
|
388
|
-
const target = newest(store);
|
|
389
|
-
const downstreamKeys = target.selectorAtoms.getRelatedKeys(atom2.key);
|
|
390
|
-
store.logger.info(
|
|
391
|
-
`\u{1F9F9}`,
|
|
392
|
-
atom2.type,
|
|
393
|
-
atom2.key,
|
|
394
|
-
downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`,
|
|
395
|
-
downstreamKeys != null ? downstreamKeys : `to evict`
|
|
396
|
-
);
|
|
397
|
-
if (downstreamKeys) {
|
|
398
|
-
if (target.operation.open) {
|
|
399
|
-
store.logger.info(
|
|
400
|
-
`\u{1F9F9}`,
|
|
401
|
-
atom2.type,
|
|
402
|
-
atom2.key,
|
|
403
|
-
`[ ${[...target.operation.done].join(`, `)} ] already done`
|
|
404
|
-
);
|
|
405
|
-
}
|
|
406
|
-
for (const key of downstreamKeys) {
|
|
407
|
-
if (isDone(key, store)) {
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
evictCachedValue(key, store);
|
|
411
|
-
markDone(key, store);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
|
|
416
|
-
// internal/src/set-state/stow-update.ts
|
|
417
|
-
function shouldUpdateBeStowed(key, update) {
|
|
418
|
-
if (isTransceiver(update.newValue)) {
|
|
419
|
-
return false;
|
|
420
|
-
}
|
|
421
|
-
if (key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
422
|
-
return false;
|
|
423
|
-
}
|
|
424
|
-
return true;
|
|
425
|
-
}
|
|
426
|
-
var stowUpdate = (state, update, store) => {
|
|
427
|
-
const { key } = state;
|
|
428
|
-
const target = newest(store);
|
|
429
|
-
if (target.transactionMeta === null || target.transactionMeta.phase !== `building`) {
|
|
430
|
-
store.logger.error(
|
|
431
|
-
`\u{1F41E}`,
|
|
432
|
-
`atom`,
|
|
433
|
-
key,
|
|
434
|
-
`stowUpdate called outside of a transaction. This is probably a bug.`
|
|
435
|
-
);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
const shouldStow = shouldUpdateBeStowed(key, update);
|
|
439
|
-
if (!shouldStow) {
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
const atomUpdate = __spreadValues({ key }, update);
|
|
443
|
-
if (state.family) {
|
|
444
|
-
atomUpdate.family = state.family;
|
|
445
|
-
}
|
|
446
|
-
target.transactionMeta.update.updates.push(atomUpdate);
|
|
447
|
-
store.logger.info(
|
|
448
|
-
`\u{1F4C1}`,
|
|
449
|
-
`atom`,
|
|
450
|
-
key,
|
|
451
|
-
`stowed (`,
|
|
452
|
-
update.oldValue,
|
|
453
|
-
`->`,
|
|
454
|
-
update.newValue,
|
|
455
|
-
`)`
|
|
456
|
-
);
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
// internal/src/set-state/set-atom.ts
|
|
460
|
-
var setAtom = (atom2, next, store) => {
|
|
461
|
-
const target = newest(store);
|
|
462
|
-
const oldValue = readOrComputeValue(atom2, store);
|
|
463
|
-
let newValue = copyMutableIfWithinTransaction(oldValue, atom2, store);
|
|
464
|
-
newValue = become(next)(newValue);
|
|
465
|
-
store.logger.info(`\u{1F4DD}`, `atom`, atom2.key, `set to`, newValue);
|
|
466
|
-
newValue = cacheValue(atom2.key, newValue, atom2.subject, store);
|
|
467
|
-
if (isAtomDefault(atom2.key, store)) {
|
|
468
|
-
markAtomAsNotDefault(atom2.key, store);
|
|
469
|
-
}
|
|
470
|
-
markDone(atom2.key, store);
|
|
471
|
-
evictDownStream(atom2, store);
|
|
472
|
-
const update = { oldValue, newValue };
|
|
473
|
-
if (target.transactionMeta === null || target.transactionMeta.phase === `applying`) {
|
|
474
|
-
emitUpdate(atom2, update, store);
|
|
475
|
-
} else {
|
|
476
|
-
stowUpdate(atom2, update, store);
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
// internal/src/set-state/set-atom-or-selector.ts
|
|
481
|
-
var setAtomOrSelector = (state, value, store) => {
|
|
482
|
-
if (state.type === `selector`) {
|
|
483
|
-
state.set(value);
|
|
484
|
-
} else {
|
|
485
|
-
setAtom(state, value, store);
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
// internal/src/store/deposit.ts
|
|
490
|
-
function deposit(state) {
|
|
491
|
-
const token = {
|
|
492
|
-
key: state.key,
|
|
493
|
-
type: state.type
|
|
494
|
-
};
|
|
495
|
-
if (`family` in state) {
|
|
496
|
-
token.family = state.family;
|
|
497
|
-
}
|
|
498
|
-
return token;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
// ../rel8/junction/src/junction.ts
|
|
502
|
-
var Junction = class {
|
|
503
|
-
constructor(data, config) {
|
|
504
|
-
this.relations = /* @__PURE__ */ new Map();
|
|
505
|
-
this.contents = /* @__PURE__ */ new Map();
|
|
506
|
-
this.makeContentKey = (a2, b2) => `${a2}:${b2}`;
|
|
507
|
-
var _a2, _b, _c, _d;
|
|
508
|
-
this.a = data.between[0];
|
|
509
|
-
this.b = data.between[1];
|
|
510
|
-
this.cardinality = data.cardinality;
|
|
511
|
-
if (!(config == null ? void 0 : config.externalStore)) {
|
|
512
|
-
this.relations = new Map((_a2 = data.relations) == null ? void 0 : _a2.map(([a2, b2]) => [a2, new Set(b2)]));
|
|
513
|
-
this.contents = new Map(data.contents);
|
|
514
|
-
}
|
|
515
|
-
this.isContent = (_b = config == null ? void 0 : config.isContent) != null ? _b : null;
|
|
516
|
-
if (config == null ? void 0 : config.makeContentKey) {
|
|
517
|
-
this.makeContentKey = config.makeContentKey;
|
|
518
|
-
}
|
|
519
|
-
if (config == null ? void 0 : config.externalStore) {
|
|
520
|
-
const externalStore = config.externalStore;
|
|
521
|
-
this.has = (a2, b2) => externalStore.has(a2, b2);
|
|
522
|
-
this.addRelation = (a2, b2) => {
|
|
523
|
-
externalStore.addRelation(a2, b2);
|
|
524
|
-
};
|
|
525
|
-
this.deleteRelation = (a2, b2) => {
|
|
526
|
-
externalStore.deleteRelation(a2, b2);
|
|
527
|
-
};
|
|
528
|
-
this.replaceRelationsSafely = (a2, bs) => {
|
|
529
|
-
externalStore.replaceRelationsSafely(a2, bs);
|
|
530
|
-
};
|
|
531
|
-
this.replaceRelationsUnsafely = (a2, bs) => {
|
|
532
|
-
externalStore.replaceRelationsUnsafely(a2, bs);
|
|
533
|
-
};
|
|
534
|
-
this.getRelatedKeys = (key) => externalStore.getRelatedKeys(key);
|
|
535
|
-
if (externalStore.getContent) {
|
|
536
|
-
this.getContentInternal = (contentKey) => {
|
|
537
|
-
return externalStore.getContent(contentKey);
|
|
538
|
-
};
|
|
539
|
-
this.setContent = (contentKey, content) => {
|
|
540
|
-
externalStore.setContent(contentKey, content);
|
|
541
|
-
};
|
|
542
|
-
this.deleteContent = (contentKey) => {
|
|
543
|
-
externalStore.deleteContent(contentKey);
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
for (const [x, ys] of (_c = data.relations) != null ? _c : []) {
|
|
547
|
-
for (const y of ys)
|
|
548
|
-
this.addRelation(x, y);
|
|
549
|
-
}
|
|
550
|
-
for (const [contentKey, content] of (_d = data.contents) != null ? _d : []) {
|
|
551
|
-
this.setContent(contentKey, content);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
getRelatedKeys(key) {
|
|
556
|
-
return this.relations.get(key);
|
|
557
|
-
}
|
|
558
|
-
addRelation(a2, b2) {
|
|
559
|
-
let aRelations = this.relations.get(a2);
|
|
560
|
-
let bRelations = this.relations.get(b2);
|
|
561
|
-
if (aRelations) {
|
|
562
|
-
aRelations.add(b2);
|
|
563
|
-
} else {
|
|
564
|
-
aRelations = /* @__PURE__ */ new Set([b2]);
|
|
565
|
-
this.relations.set(a2, aRelations);
|
|
566
|
-
}
|
|
567
|
-
if (bRelations) {
|
|
568
|
-
bRelations.add(a2);
|
|
569
|
-
} else {
|
|
570
|
-
bRelations = /* @__PURE__ */ new Set([a2]);
|
|
571
|
-
this.relations.set(b2, bRelations);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
deleteRelation(a2, b2) {
|
|
575
|
-
const aRelations = this.relations.get(a2);
|
|
576
|
-
if (aRelations) {
|
|
577
|
-
aRelations.delete(b2);
|
|
578
|
-
if (aRelations.size === 0) {
|
|
579
|
-
this.relations.delete(a2);
|
|
580
|
-
}
|
|
581
|
-
const bRelations = this.relations.get(b2);
|
|
582
|
-
if (bRelations) {
|
|
583
|
-
bRelations.delete(a2);
|
|
584
|
-
if (bRelations.size === 0) {
|
|
585
|
-
this.relations.delete(b2);
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
replaceRelationsUnsafely(a2, bs) {
|
|
591
|
-
this.relations.set(a2, new Set(bs));
|
|
592
|
-
for (const b2 of bs) {
|
|
593
|
-
const bRelations = /* @__PURE__ */ new Set([a2]);
|
|
594
|
-
this.relations.set(b2, bRelations);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
replaceRelationsSafely(a2, bs) {
|
|
598
|
-
const aRelationsPrev = this.relations.get(a2);
|
|
599
|
-
if (aRelationsPrev) {
|
|
600
|
-
for (const b2 of aRelationsPrev) {
|
|
601
|
-
const bRelations = this.relations.get(b2);
|
|
602
|
-
if (bRelations) {
|
|
603
|
-
if (bRelations.size === 1) {
|
|
604
|
-
this.relations.delete(b2);
|
|
605
|
-
} else {
|
|
606
|
-
bRelations.delete(a2);
|
|
607
|
-
}
|
|
608
|
-
this.contents.delete(this.makeContentKey(a2, b2));
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
this.relations.set(a2, new Set(bs));
|
|
613
|
-
for (const b2 of bs) {
|
|
614
|
-
let bRelations = this.relations.get(b2);
|
|
615
|
-
if (bRelations) {
|
|
616
|
-
bRelations.add(a2);
|
|
617
|
-
} else {
|
|
618
|
-
bRelations = /* @__PURE__ */ new Set([a2]);
|
|
619
|
-
this.relations.set(b2, bRelations);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
getContentInternal(contentKey) {
|
|
624
|
-
return this.contents.get(contentKey);
|
|
625
|
-
}
|
|
626
|
-
setContent(contentKey, content) {
|
|
627
|
-
this.contents.set(contentKey, content);
|
|
628
|
-
}
|
|
629
|
-
deleteContent(contentKey) {
|
|
630
|
-
this.contents.delete(contentKey);
|
|
631
|
-
}
|
|
632
|
-
toJSON() {
|
|
633
|
-
return {
|
|
634
|
-
between: [this.a, this.b],
|
|
635
|
-
cardinality: this.cardinality,
|
|
636
|
-
relations: [...this.relations.entries()].map(([a2, b2]) => [a2, [...b2]]),
|
|
637
|
-
contents: [...this.contents.entries()]
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
set(a2, ...rest) {
|
|
641
|
-
var _a2;
|
|
642
|
-
const b2 = typeof rest[0] === `string` ? rest[0] : a2[this.b];
|
|
643
|
-
const content = ((_a2 = rest[1]) != null ? _a2 : typeof rest[0] === `string`) ? void 0 : rest[0];
|
|
644
|
-
a2 = typeof a2 === `string` ? a2 : a2[this.a];
|
|
645
|
-
switch (this.cardinality) {
|
|
646
|
-
case `1:1`: {
|
|
647
|
-
const bPrev = this.getRelatedKey(a2);
|
|
648
|
-
if (bPrev && bPrev !== b2)
|
|
649
|
-
this.delete(bPrev, a2);
|
|
650
|
-
}
|
|
651
|
-
case `1:n`: {
|
|
652
|
-
const aPrev = this.getRelatedKey(b2);
|
|
653
|
-
if (aPrev && aPrev !== a2)
|
|
654
|
-
this.delete(aPrev, b2);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
if (content) {
|
|
658
|
-
const contentKey = this.makeContentKey(a2, b2);
|
|
659
|
-
this.setContent(contentKey, content);
|
|
660
|
-
}
|
|
661
|
-
this.addRelation(a2, b2);
|
|
662
|
-
return this;
|
|
663
|
-
}
|
|
664
|
-
delete(x, b2) {
|
|
665
|
-
b2 = typeof b2 === `string` ? b2 : x[this.b];
|
|
666
|
-
const a2 = typeof x === `string` ? x : x[this.a];
|
|
667
|
-
if (a2 === void 0 && typeof b2 === `string`) {
|
|
668
|
-
const bRelations = this.getRelatedKeys(b2);
|
|
669
|
-
if (bRelations) {
|
|
670
|
-
for (const a3 of bRelations) {
|
|
671
|
-
this.delete(a3, b2);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
if (typeof a2 === `string` && b2 === void 0) {
|
|
676
|
-
const aRelations = this.getRelatedKeys(a2);
|
|
677
|
-
if (aRelations) {
|
|
678
|
-
for (const b3 of aRelations) {
|
|
679
|
-
this.delete(a2, b3);
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
if (typeof a2 === `string` && typeof b2 === `string`) {
|
|
684
|
-
this.deleteRelation(a2, b2);
|
|
685
|
-
const contentKey = this.makeContentKey(a2, b2);
|
|
686
|
-
this.deleteContent(contentKey);
|
|
687
|
-
}
|
|
688
|
-
return this;
|
|
689
|
-
}
|
|
690
|
-
getRelatedKey(key) {
|
|
691
|
-
const relations = this.getRelatedKeys(key);
|
|
692
|
-
if (relations) {
|
|
693
|
-
if (relations.size > 1) {
|
|
694
|
-
console.warn(
|
|
695
|
-
`${relations.size} related keys were found for key "${key}": (${[
|
|
696
|
-
...relations
|
|
697
|
-
].map((k) => `"${k}"`).join(`, `)}). Only one related key was expected.`
|
|
698
|
-
);
|
|
699
|
-
}
|
|
700
|
-
for (const relation of relations) {
|
|
701
|
-
return relation;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
replaceRelations(a2, relations, config) {
|
|
706
|
-
const hasContent = !Array.isArray(relations);
|
|
707
|
-
const bs = hasContent ? Object.keys(relations) : relations;
|
|
708
|
-
if (config == null ? void 0 : config.reckless) {
|
|
709
|
-
this.replaceRelationsUnsafely(a2, bs);
|
|
710
|
-
} else {
|
|
711
|
-
this.replaceRelationsSafely(a2, bs);
|
|
712
|
-
}
|
|
713
|
-
if (hasContent) {
|
|
714
|
-
for (const b2 of bs) {
|
|
715
|
-
const contentKey = this.makeContentKey(a2, b2);
|
|
716
|
-
const content = relations[b2];
|
|
717
|
-
this.setContent(contentKey, content);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
return this;
|
|
721
|
-
}
|
|
722
|
-
getContent(a2, b2) {
|
|
723
|
-
const contentKey = this.makeContentKey(a2, b2);
|
|
724
|
-
return this.getContentInternal(contentKey);
|
|
725
|
-
}
|
|
726
|
-
getRelationEntries(input) {
|
|
727
|
-
const a2 = input[this.a];
|
|
728
|
-
const b2 = input[this.b];
|
|
729
|
-
if (a2 !== void 0 && b2 === void 0) {
|
|
730
|
-
const aRelations = this.getRelatedKeys(a2);
|
|
731
|
-
if (aRelations) {
|
|
732
|
-
return [...aRelations].map((b3) => {
|
|
733
|
-
var _a2;
|
|
734
|
-
return [b3, (_a2 = this.getContent(a2, b3)) != null ? _a2 : null];
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
if (a2 === void 0 && b2 !== void 0) {
|
|
739
|
-
const bRelations = this.getRelatedKeys(b2);
|
|
740
|
-
if (bRelations) {
|
|
741
|
-
return [...bRelations].map((a3) => {
|
|
742
|
-
var _a2;
|
|
743
|
-
return [a3, (_a2 = this.getContent(a3, b2)) != null ? _a2 : null];
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
return [];
|
|
748
|
-
}
|
|
749
|
-
has(a2, b2) {
|
|
750
|
-
var _a2;
|
|
751
|
-
if (b2) {
|
|
752
|
-
const setA = this.getRelatedKeys(a2);
|
|
753
|
-
return (_a2 = setA == null ? void 0 : setA.has(b2)) != null ? _a2 : false;
|
|
754
|
-
}
|
|
755
|
-
return this.relations.has(a2);
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
// internal/src/store/store.ts
|
|
760
|
-
var Store = class {
|
|
761
|
-
constructor(name, store = null) {
|
|
762
|
-
this.parent = null;
|
|
763
|
-
this.child = null;
|
|
764
|
-
this.valueMap = /* @__PURE__ */ new Map();
|
|
765
|
-
this.atoms = /* @__PURE__ */ new Map();
|
|
766
|
-
this.selectors = /* @__PURE__ */ new Map();
|
|
767
|
-
this.readonlySelectors = /* @__PURE__ */ new Map();
|
|
768
|
-
this.trackers = /* @__PURE__ */ new Map();
|
|
769
|
-
this.families = /* @__PURE__ */ new Map();
|
|
770
|
-
this.timelines = /* @__PURE__ */ new Map();
|
|
771
|
-
this.transactions = /* @__PURE__ */ new Map();
|
|
772
|
-
this.atomsThatAreDefault = /* @__PURE__ */ new Set();
|
|
773
|
-
this.timelineAtoms = new Junction({
|
|
774
|
-
between: [`timelineKey`, `atomKey`],
|
|
775
|
-
cardinality: `1:n`
|
|
776
|
-
});
|
|
777
|
-
this.selectorAtoms = new Junction({
|
|
778
|
-
between: [`selectorKey`, `atomKey`],
|
|
779
|
-
cardinality: `n:n`
|
|
780
|
-
});
|
|
781
|
-
this.selectorGraph = new Junction(
|
|
782
|
-
{
|
|
783
|
-
between: [`upstreamSelectorKey`, `downstreamSelectorKey`],
|
|
784
|
-
cardinality: `n:n`
|
|
785
|
-
},
|
|
786
|
-
{
|
|
787
|
-
makeContentKey: (...keys) => keys.sort().join(`:`)
|
|
788
|
-
}
|
|
789
|
-
);
|
|
790
|
-
this.subject = {
|
|
791
|
-
atomCreation: new Subject(),
|
|
792
|
-
selectorCreation: new Subject(),
|
|
793
|
-
transactionCreation: new Subject(),
|
|
794
|
-
timelineCreation: new Subject(),
|
|
795
|
-
transactionApplying: new StatefulSubject(null),
|
|
796
|
-
operationStatus: new Subject()
|
|
797
|
-
};
|
|
798
|
-
this.operation = { open: false };
|
|
799
|
-
this.transactionMeta = null;
|
|
800
|
-
this.config = {
|
|
801
|
-
name: `IMPLICIT_STORE`
|
|
802
|
-
};
|
|
803
|
-
this.loggers = [
|
|
804
|
-
new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
|
|
805
|
-
];
|
|
806
|
-
this.logger = {
|
|
807
|
-
error: (...messages) => {
|
|
808
|
-
for (const logger of this.loggers)
|
|
809
|
-
logger.error(...messages);
|
|
810
|
-
},
|
|
811
|
-
info: (...messages) => {
|
|
812
|
-
for (const logger of this.loggers)
|
|
813
|
-
logger.info(...messages);
|
|
814
|
-
},
|
|
815
|
-
warn: (...messages) => {
|
|
816
|
-
for (const logger of this.loggers)
|
|
817
|
-
logger.warn(...messages);
|
|
818
|
-
}
|
|
819
|
-
};
|
|
820
|
-
if (store !== null) {
|
|
821
|
-
this.valueMap = new Map(store == null ? void 0 : store.valueMap);
|
|
822
|
-
this.operation = __spreadValues({}, store == null ? void 0 : store.operation);
|
|
823
|
-
this.transactionMeta = (store == null ? void 0 : store.transactionMeta) ? __spreadValues({}, store == null ? void 0 : store.transactionMeta) : null;
|
|
824
|
-
this.config = __spreadProps(__spreadValues({}, store == null ? void 0 : store.config), {
|
|
825
|
-
name
|
|
826
|
-
});
|
|
827
|
-
for (const [, atom2] of store.atoms) {
|
|
828
|
-
atom2.install(this);
|
|
829
|
-
}
|
|
830
|
-
for (const [, selector] of store.readonlySelectors) {
|
|
831
|
-
selector.install(this);
|
|
832
|
-
}
|
|
833
|
-
for (const [, selector] of store.selectors) {
|
|
834
|
-
selector.install(this);
|
|
835
|
-
}
|
|
836
|
-
for (const [, tx] of store.transactions) {
|
|
837
|
-
tx.install(this);
|
|
838
|
-
}
|
|
839
|
-
for (const [, timeline] of store.timelines) {
|
|
840
|
-
timeline.install(this);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
|
-
var IMPLICIT = {
|
|
846
|
-
STORE_INTERNAL: void 0,
|
|
847
|
-
get STORE() {
|
|
848
|
-
var _a2;
|
|
849
|
-
return (_a2 = this.STORE_INTERNAL) != null ? _a2 : this.STORE_INTERNAL = new Store(`IMPLICIT_STORE`);
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
|
|
853
|
-
// internal/src/store/withdraw.ts
|
|
854
|
-
function withdraw(token, store) {
|
|
855
|
-
var _a2, _b, _c, _d;
|
|
856
|
-
const target = newest(store);
|
|
857
|
-
const state = (_d = (_c = (_b = (_a2 = target.atoms.get(token.key)) != null ? _a2 : target.selectors.get(token.key)) != null ? _b : target.readonlySelectors.get(token.key)) != null ? _c : target.transactions.get(token.key)) != null ? _d : target.timelines.get(token.key);
|
|
858
|
-
if (state) {
|
|
859
|
-
return state;
|
|
860
|
-
}
|
|
861
|
-
return void 0;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
// internal/src/store/withdraw-new-family-member.ts
|
|
865
|
-
function withdrawNewFamilyMember(token, store) {
|
|
866
|
-
if (token.family) {
|
|
867
|
-
store.logger.info(
|
|
868
|
-
`\u{1F46A}`,
|
|
869
|
-
token.type,
|
|
870
|
-
token.key,
|
|
871
|
-
`creating new family member in store "${store.config.name}"`
|
|
872
|
-
);
|
|
873
|
-
const target = newest(store);
|
|
874
|
-
const family = target.families.get(token.family.key);
|
|
875
|
-
if (family) {
|
|
876
|
-
const jsonSubKey = JSON.parse(token.family.subKey);
|
|
877
|
-
family(jsonSubKey);
|
|
878
|
-
const state = withdraw(token, store);
|
|
879
|
-
return state;
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
return void 0;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
// internal/src/keys.ts
|
|
886
|
-
var isAtomKey = (key, store) => newest(store).atoms.has(key);
|
|
887
|
-
var isSelectorKey = (key, store) => newest(store).selectors.has(key);
|
|
888
|
-
var isReadonlySelectorKey = (key, store) => newest(store).readonlySelectors.has(key);
|
|
889
|
-
var isStateKey = (key, store) => isAtomKey(key, store) || isSelectorKey(key, store) || isReadonlySelectorKey(key, store);
|
|
890
|
-
|
|
891
|
-
// internal/src/selector/get-selector-dependency-keys.ts
|
|
892
|
-
var getSelectorDependencyKeys = (key, store) => {
|
|
893
|
-
const sources = newest(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(source, store));
|
|
894
|
-
return sources;
|
|
895
|
-
};
|
|
896
|
-
|
|
897
|
-
// internal/src/selector/trace-selector-atoms.ts
|
|
898
|
-
var traceSelectorAtoms = (selectorKey, directDependencyKey, store) => {
|
|
899
|
-
const rootKeys = [];
|
|
900
|
-
const indirectDependencyKeys = getSelectorDependencyKeys(
|
|
901
|
-
directDependencyKey,
|
|
902
|
-
store
|
|
903
|
-
);
|
|
904
|
-
let depth = 0;
|
|
905
|
-
while (indirectDependencyKeys.length > 0) {
|
|
906
|
-
const indirectDependencyKey = indirectDependencyKeys.shift();
|
|
907
|
-
++depth;
|
|
908
|
-
if (depth > 99999) {
|
|
909
|
-
throw new Error(
|
|
910
|
-
`Maximum selector dependency depth exceeded (> 99999) in selector "${selectorKey}". This is likely due to a circular dependency.`
|
|
911
|
-
);
|
|
912
|
-
}
|
|
913
|
-
if (!isAtomKey(indirectDependencyKey, store)) {
|
|
914
|
-
indirectDependencyKeys.push(
|
|
915
|
-
...getSelectorDependencyKeys(indirectDependencyKey, store)
|
|
916
|
-
);
|
|
917
|
-
} else if (!rootKeys.includes(indirectDependencyKey)) {
|
|
918
|
-
rootKeys.push(indirectDependencyKey);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
return rootKeys;
|
|
922
|
-
};
|
|
923
|
-
var traceAllSelectorAtoms = (selectorKey, store) => {
|
|
924
|
-
const directDependencyKeys = getSelectorDependencyKeys(selectorKey, store);
|
|
925
|
-
return directDependencyKeys.flatMap(
|
|
926
|
-
(depKey) => isAtomKey(depKey, store) ? depKey : traceSelectorAtoms(selectorKey, depKey, store)
|
|
927
|
-
);
|
|
928
|
-
};
|
|
929
|
-
|
|
930
|
-
// internal/src/selector/update-selector-atoms.ts
|
|
931
|
-
var updateSelectorAtoms = (selectorKey, dependency, store) => {
|
|
932
|
-
const target = newest(store);
|
|
933
|
-
if (dependency.type === `atom`) {
|
|
934
|
-
target.selectorAtoms.set({
|
|
935
|
-
selectorKey,
|
|
936
|
-
atomKey: dependency.key
|
|
937
|
-
});
|
|
938
|
-
store.logger.info(
|
|
939
|
-
`\u{1F50D}`,
|
|
940
|
-
`selector`,
|
|
941
|
-
selectorKey,
|
|
942
|
-
`discovers root atom "${dependency.key}"`
|
|
943
|
-
);
|
|
944
|
-
} else {
|
|
945
|
-
const rootKeys = traceSelectorAtoms(selectorKey, dependency.key, store);
|
|
946
|
-
store.logger.info(
|
|
947
|
-
`\u{1F50D}`,
|
|
948
|
-
`selector`,
|
|
949
|
-
selectorKey,
|
|
950
|
-
`discovers root atoms: [ ${rootKeys.map((key) => `"${key}"`).join(`, `)} ]`
|
|
951
|
-
);
|
|
952
|
-
for (const atomKey of rootKeys) {
|
|
953
|
-
target.selectorAtoms = target.selectorAtoms.set({
|
|
954
|
-
selectorKey,
|
|
955
|
-
atomKey
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
|
|
961
|
-
// internal/src/selector/register-selector.ts
|
|
962
|
-
var registerSelector = (selectorKey, store) => ({
|
|
963
|
-
get: (dependency) => {
|
|
964
|
-
const target = newest(store);
|
|
965
|
-
const alreadyRegistered = target.selectorGraph.getRelationEntries({ downstreamSelectorKey: selectorKey }).some(([_, { source }]) => source === dependency.key);
|
|
966
|
-
const dependencyState = withdraw(dependency, store);
|
|
967
|
-
if (dependencyState === void 0) {
|
|
968
|
-
throw new Error(
|
|
969
|
-
`State "${dependency.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
970
|
-
);
|
|
971
|
-
}
|
|
972
|
-
const dependencyValue = readOrComputeValue(dependencyState, store);
|
|
973
|
-
store.logger.info(
|
|
974
|
-
`\u{1F50C}`,
|
|
975
|
-
`selector`,
|
|
976
|
-
selectorKey,
|
|
977
|
-
`registers dependency ( "${dependency.key}" =`,
|
|
978
|
-
dependencyValue,
|
|
979
|
-
`)`
|
|
980
|
-
);
|
|
981
|
-
if (!alreadyRegistered) {
|
|
982
|
-
target.selectorGraph.set(
|
|
983
|
-
{
|
|
984
|
-
upstreamSelectorKey: dependency.key,
|
|
985
|
-
downstreamSelectorKey: selectorKey
|
|
986
|
-
},
|
|
987
|
-
{
|
|
988
|
-
source: dependency.key
|
|
989
|
-
}
|
|
990
|
-
);
|
|
991
|
-
}
|
|
992
|
-
updateSelectorAtoms(selectorKey, dependency, store);
|
|
993
|
-
return dependencyValue;
|
|
994
|
-
},
|
|
995
|
-
set: (stateToken, newValue) => {
|
|
996
|
-
const state = withdraw(stateToken, store);
|
|
997
|
-
if (state === void 0) {
|
|
998
|
-
throw new Error(
|
|
999
|
-
`State "${stateToken.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
1000
|
-
);
|
|
1001
|
-
}
|
|
1002
|
-
setAtomOrSelector(state, newValue, store);
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
|
|
1006
|
-
// internal/src/selector/create-read-write-selector.ts
|
|
1007
|
-
var createReadWriteSelector = (options, family, store) => {
|
|
1008
|
-
const target = newest(store);
|
|
1009
|
-
const subject = new Subject();
|
|
1010
|
-
const { get, set } = registerSelector(options.key, store);
|
|
1011
|
-
const getSelf = () => {
|
|
1012
|
-
const value = options.get({ get });
|
|
1013
|
-
cacheValue(options.key, value, subject, store);
|
|
1014
|
-
return value;
|
|
1015
|
-
};
|
|
1016
|
-
const setSelf = (next) => {
|
|
1017
|
-
const oldValue = getSelf();
|
|
1018
|
-
const newValue = become(next)(oldValue);
|
|
1019
|
-
store.logger.info(
|
|
1020
|
-
`\u{1F4DD}`,
|
|
1021
|
-
`selector`,
|
|
1022
|
-
options.key,
|
|
1023
|
-
`set (`,
|
|
1024
|
-
oldValue,
|
|
1025
|
-
`->`,
|
|
1026
|
-
newValue,
|
|
1027
|
-
`)`
|
|
1028
|
-
);
|
|
1029
|
-
cacheValue(options.key, newValue, subject, store);
|
|
1030
|
-
markDone(options.key, store);
|
|
1031
|
-
if (target.transactionMeta === null) {
|
|
1032
|
-
subject.next({ newValue, oldValue });
|
|
1033
|
-
}
|
|
1034
|
-
options.set({ get, set }, newValue);
|
|
1035
|
-
};
|
|
1036
|
-
const mySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
1037
|
-
subject,
|
|
1038
|
-
install: (s) => createSelector(options, family, s),
|
|
1039
|
-
get: getSelf,
|
|
1040
|
-
set: setSelf,
|
|
1041
|
-
type: `selector`
|
|
1042
|
-
}), family && { family });
|
|
1043
|
-
target.selectors.set(options.key, mySelector);
|
|
1044
|
-
const initialValue = getSelf();
|
|
1045
|
-
store.logger.info(`\u2728`, mySelector.type, mySelector.key, `=`, initialValue);
|
|
1046
|
-
const token = {
|
|
1047
|
-
key: options.key,
|
|
1048
|
-
type: `selector`
|
|
1049
|
-
};
|
|
1050
|
-
if (family) {
|
|
1051
|
-
token.family = family;
|
|
1052
|
-
}
|
|
1053
|
-
store.subject.selectorCreation.next(token);
|
|
1054
|
-
return token;
|
|
1055
|
-
};
|
|
1056
|
-
|
|
1057
|
-
// internal/src/selector/create-readonly-selector.ts
|
|
1058
|
-
var createReadonlySelector = (options, family, store) => {
|
|
1059
|
-
const target = newest(store);
|
|
1060
|
-
const subject = new Subject();
|
|
1061
|
-
const { get } = registerSelector(options.key, store);
|
|
1062
|
-
const getSelf = () => {
|
|
1063
|
-
const value = options.get({ get });
|
|
1064
|
-
cacheValue(options.key, value, subject, store);
|
|
1065
|
-
return value;
|
|
1066
|
-
};
|
|
1067
|
-
const readonlySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
1068
|
-
subject,
|
|
1069
|
-
install: (s) => createSelector(options, family, s),
|
|
1070
|
-
get: getSelf,
|
|
1071
|
-
type: `readonly_selector`
|
|
1072
|
-
}), family && { family });
|
|
1073
|
-
target.readonlySelectors.set(options.key, readonlySelector);
|
|
1074
|
-
const initialValue = getSelf();
|
|
1075
|
-
store.logger.info(
|
|
1076
|
-
`\u2728`,
|
|
1077
|
-
readonlySelector.type,
|
|
1078
|
-
readonlySelector.key,
|
|
1079
|
-
`=`,
|
|
1080
|
-
initialValue
|
|
1081
|
-
);
|
|
1082
|
-
const token = {
|
|
1083
|
-
key: options.key,
|
|
1084
|
-
type: `readonly_selector`
|
|
1085
|
-
};
|
|
1086
|
-
if (family) {
|
|
1087
|
-
token.family = family;
|
|
1088
|
-
}
|
|
1089
|
-
store.subject.selectorCreation.next(token);
|
|
1090
|
-
return token;
|
|
1091
|
-
};
|
|
1092
|
-
|
|
1093
|
-
// internal/src/selector/create-selector.ts
|
|
1094
|
-
function createSelector(options, family, store) {
|
|
1095
|
-
const target = newest(store);
|
|
1096
|
-
const existingWritable = target.selectors.get(options.key);
|
|
1097
|
-
const existingReadonly = target.readonlySelectors.get(options.key);
|
|
1098
|
-
if (existingWritable || existingReadonly) {
|
|
1099
|
-
store.logger.error(
|
|
1100
|
-
`\u274C`,
|
|
1101
|
-
existingReadonly ? `readonly_selector` : `selector`,
|
|
1102
|
-
options.key,
|
|
1103
|
-
`Tried to create selector, but it already exists in the store. (Ignore if you are in development using hot module replacement.)`
|
|
1104
|
-
);
|
|
1105
|
-
}
|
|
1106
|
-
if (`set` in options) {
|
|
1107
|
-
return createReadWriteSelector(options, family, store);
|
|
1108
|
-
}
|
|
1109
|
-
return createReadonlySelector(options, family, store);
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
// internal/src/subscribe/recall-state.ts
|
|
1113
|
-
var recallState = (state, store) => {
|
|
1114
|
-
const target = newest(store);
|
|
1115
|
-
if (!target.operation.open) {
|
|
1116
|
-
return target.valueMap.get(state.key);
|
|
1117
|
-
}
|
|
1118
|
-
return target.operation.prev.get(state.key);
|
|
1119
|
-
};
|
|
1120
|
-
|
|
1121
|
-
// internal/src/subscribe/subscribe-to-root-atoms.ts
|
|
1122
|
-
var subscribeToRootAtoms = (state, store) => {
|
|
1123
|
-
const dependencySubscriptions = `default` in state ? null : traceAllSelectorAtoms(state.key, store).map((atomKey) => {
|
|
1124
|
-
const atom2 = store.atoms.get(atomKey);
|
|
1125
|
-
if (atom2 === void 0) {
|
|
1126
|
-
throw new Error(
|
|
1127
|
-
`Atom "${atomKey}", a dependency of selector "${state.key}", not found in store "${store.config.name}".`
|
|
1128
|
-
);
|
|
1129
|
-
}
|
|
1130
|
-
return atom2.subject.subscribe(
|
|
1131
|
-
`${state.type}:${state.key}`,
|
|
1132
|
-
(atomChange) => {
|
|
1133
|
-
store.logger.info(
|
|
1134
|
-
`\u{1F4E2}`,
|
|
1135
|
-
state.type,
|
|
1136
|
-
state.key,
|
|
1137
|
-
`root`,
|
|
1138
|
-
atomKey,
|
|
1139
|
-
`went`,
|
|
1140
|
-
atomChange.oldValue,
|
|
1141
|
-
`->`,
|
|
1142
|
-
atomChange.newValue
|
|
1143
|
-
);
|
|
1144
|
-
const oldValue = recallState(state, store);
|
|
1145
|
-
const newValue = readOrComputeValue(state, store);
|
|
1146
|
-
store.logger.info(
|
|
1147
|
-
`\u2728`,
|
|
1148
|
-
state.type,
|
|
1149
|
-
state.key,
|
|
1150
|
-
`went`,
|
|
1151
|
-
oldValue,
|
|
1152
|
-
`->`,
|
|
1153
|
-
newValue
|
|
1154
|
-
);
|
|
1155
|
-
state.subject.next({ newValue, oldValue });
|
|
1156
|
-
}
|
|
1157
|
-
);
|
|
1158
|
-
});
|
|
1159
|
-
return dependencySubscriptions;
|
|
1160
|
-
};
|
|
1161
|
-
|
|
1162
|
-
// internal/src/subscribe/subscribe-to-state.ts
|
|
1163
|
-
function subscribeToState(token, handleUpdate, key, store) {
|
|
1164
|
-
const state = withdraw(token, store);
|
|
1165
|
-
if (state === void 0) {
|
|
1166
|
-
throw new Error(
|
|
1167
|
-
`State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
1168
|
-
);
|
|
1169
|
-
}
|
|
1170
|
-
const unsubFunction = state.subject.subscribe(key, handleUpdate);
|
|
1171
|
-
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
1172
|
-
const dependencyUnsubFunctions = state.type !== `atom` ? subscribeToRootAtoms(state, store) : null;
|
|
1173
|
-
const unsubscribe = dependencyUnsubFunctions === null ? () => {
|
|
1174
|
-
store.logger.info(
|
|
1175
|
-
`\u{1F648}`,
|
|
1176
|
-
state.type,
|
|
1177
|
-
state.key,
|
|
1178
|
-
`Removing subscription "${key}"`
|
|
1179
|
-
);
|
|
1180
|
-
unsubFunction();
|
|
1181
|
-
} : () => {
|
|
1182
|
-
store.logger.info(
|
|
1183
|
-
`\u{1F648}`,
|
|
1184
|
-
state.type,
|
|
1185
|
-
state.key,
|
|
1186
|
-
`Removing subscription "${key}"`
|
|
1187
|
-
);
|
|
1188
|
-
unsubFunction();
|
|
1189
|
-
for (const unsubFromDependency of dependencyUnsubFunctions) {
|
|
1190
|
-
unsubFromDependency();
|
|
1191
|
-
}
|
|
1192
|
-
};
|
|
1193
|
-
return unsubscribe;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
// internal/src/subscribe/subscribe-to-timeline.ts
|
|
1197
|
-
var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
1198
|
-
const tl = withdraw(token, store);
|
|
1199
|
-
if (tl === void 0) {
|
|
1200
|
-
throw new Error(
|
|
1201
|
-
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
|
|
1202
|
-
);
|
|
1203
|
-
}
|
|
1204
|
-
store.logger.info(`\u{1F440}`, `timeline`, token.key, `Adding subscription "${key}"`);
|
|
1205
|
-
const unsubscribe = tl.subject.subscribe(key, handleUpdate);
|
|
1206
|
-
return () => {
|
|
1207
|
-
store.logger.info(
|
|
1208
|
-
`\u{1F648}`,
|
|
1209
|
-
`timeline`,
|
|
1210
|
-
token.key,
|
|
1211
|
-
`Removing subscription "${key}" from timeline`
|
|
1212
|
-
);
|
|
1213
|
-
unsubscribe();
|
|
1214
|
-
};
|
|
1215
|
-
};
|
|
1216
|
-
|
|
1217
|
-
// internal/src/mutable/tracker.ts
|
|
1218
|
-
var Tracker = class {
|
|
1219
|
-
constructor(mutableState, store) {
|
|
1220
|
-
this.unsubscribeFromInnerValue = null;
|
|
1221
|
-
this.mutableState = mutableState;
|
|
1222
|
-
const target = newest(store);
|
|
1223
|
-
this.latestUpdateState = this.initializeState(mutableState, target);
|
|
1224
|
-
this.observeCore(mutableState, this.latestUpdateState, target);
|
|
1225
|
-
this.updateCore(mutableState, this.latestUpdateState, target);
|
|
1226
|
-
target.trackers.set(mutableState.key, this);
|
|
1227
|
-
}
|
|
1228
|
-
initializeState(mutableState, store) {
|
|
1229
|
-
const latestUpdateStateKey = `*${mutableState.key}`;
|
|
1230
|
-
store.atoms.delete(latestUpdateStateKey);
|
|
1231
|
-
store.valueMap.delete(latestUpdateStateKey);
|
|
1232
|
-
const familyMetaData = mutableState.family ? {
|
|
1233
|
-
key: `*${mutableState.family.key}`,
|
|
1234
|
-
subKey: mutableState.family.subKey
|
|
1235
|
-
} : void 0;
|
|
1236
|
-
const latestUpdateState = createAtom(
|
|
1237
|
-
{
|
|
1238
|
-
key: latestUpdateStateKey,
|
|
1239
|
-
default: null
|
|
1240
|
-
},
|
|
1241
|
-
familyMetaData,
|
|
1242
|
-
store
|
|
1243
|
-
);
|
|
1244
|
-
if (store.parent) {
|
|
1245
|
-
const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
|
|
1246
|
-
store.valueMap.set(latestUpdateStateKey, parentValue);
|
|
1247
|
-
}
|
|
1248
|
-
return latestUpdateState;
|
|
1249
|
-
}
|
|
1250
|
-
observeCore(mutableState, latestUpdateState, store) {
|
|
1251
|
-
const originalInnerValue = getState(mutableState, store);
|
|
1252
|
-
const target = newest(store);
|
|
1253
|
-
this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
|
|
1254
|
-
`tracker:${store.config.name}:${target.transactionMeta === null ? `main` : target.transactionMeta.update.key}`,
|
|
1255
|
-
(update) => {
|
|
1256
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1257
|
-
mutableState.key,
|
|
1258
|
-
() => {
|
|
1259
|
-
unsubscribe();
|
|
1260
|
-
setState(latestUpdateState, update, store);
|
|
1261
|
-
}
|
|
1262
|
-
);
|
|
1263
|
-
}
|
|
1264
|
-
);
|
|
1265
|
-
subscribeToState(
|
|
1266
|
-
mutableState,
|
|
1267
|
-
(update) => {
|
|
1268
|
-
var _a2;
|
|
1269
|
-
if (update.newValue !== update.oldValue) {
|
|
1270
|
-
(_a2 = this.unsubscribeFromInnerValue) == null ? void 0 : _a2.call(this);
|
|
1271
|
-
const target2 = newest(store);
|
|
1272
|
-
this.unsubscribeFromInnerValue = update.newValue.subscribe(
|
|
1273
|
-
`tracker:${store.config.name}:${target2.transactionMeta === null ? `main` : target2.transactionMeta.update.key}`,
|
|
1274
|
-
(update2) => {
|
|
1275
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1276
|
-
mutableState.key,
|
|
1277
|
-
() => {
|
|
1278
|
-
unsubscribe();
|
|
1279
|
-
setState(latestUpdateState, update2, store);
|
|
1280
|
-
}
|
|
1281
|
-
);
|
|
1282
|
-
}
|
|
1283
|
-
);
|
|
1284
|
-
}
|
|
1285
|
-
},
|
|
1286
|
-
`${store.config.name}: tracker observing inner value`,
|
|
1287
|
-
store
|
|
1288
|
-
);
|
|
1289
|
-
}
|
|
1290
|
-
updateCore(mutableState, latestUpdateState, store) {
|
|
1291
|
-
subscribeToState(
|
|
1292
|
-
latestUpdateState,
|
|
1293
|
-
({ newValue, oldValue }) => {
|
|
1294
|
-
const timelineId = store.timelineAtoms.getRelatedKey(
|
|
1295
|
-
latestUpdateState.key
|
|
1296
|
-
);
|
|
1297
|
-
if (timelineId) {
|
|
1298
|
-
const timelineData = store.timelines.get(timelineId);
|
|
1299
|
-
if (timelineData == null ? void 0 : timelineData.timeTraveling) {
|
|
1300
|
-
const unsubscribe2 = subscribeToTimeline(
|
|
1301
|
-
{ key: timelineId, type: `timeline` },
|
|
1302
|
-
(update) => {
|
|
1303
|
-
unsubscribe2();
|
|
1304
|
-
setState(
|
|
1305
|
-
mutableState,
|
|
1306
|
-
(transceiver) => {
|
|
1307
|
-
if (update === `redo` && newValue) {
|
|
1308
|
-
transceiver.do(newValue);
|
|
1309
|
-
} else if (update === `undo` && oldValue) {
|
|
1310
|
-
transceiver.undo(oldValue);
|
|
1311
|
-
}
|
|
1312
|
-
return transceiver;
|
|
1313
|
-
},
|
|
1314
|
-
store
|
|
1315
|
-
);
|
|
1316
|
-
},
|
|
1317
|
-
`${mutableState.key}: tracker observing timeline`,
|
|
1318
|
-
store
|
|
1319
|
-
);
|
|
1320
|
-
return;
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1324
|
-
latestUpdateState.key,
|
|
1325
|
-
() => {
|
|
1326
|
-
unsubscribe();
|
|
1327
|
-
const mutable = getState(mutableState, store);
|
|
1328
|
-
const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
|
|
1329
|
-
const eventOffset = updateNumber - mutable.cacheUpdateNumber;
|
|
1330
|
-
if (newValue && eventOffset === 1) {
|
|
1331
|
-
setState(
|
|
1332
|
-
mutableState,
|
|
1333
|
-
(transceiver) => (transceiver.do(newValue), transceiver),
|
|
1334
|
-
store
|
|
1335
|
-
);
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
);
|
|
1339
|
-
},
|
|
1340
|
-
`${store.config.name}: tracker observing latest update`,
|
|
1341
|
-
store
|
|
1342
|
-
);
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
|
|
1346
|
-
// internal/src/mutable/create-mutable-atom.ts
|
|
1347
|
-
function createMutableAtom(options, store) {
|
|
1348
|
-
store.logger.info(
|
|
1349
|
-
`\u{1F527}`,
|
|
1350
|
-
`atom`,
|
|
1351
|
-
options.key,
|
|
1352
|
-
`creating in store "${store.config.name}"`
|
|
1353
|
-
);
|
|
1354
|
-
const coreState = createAtom(options, void 0, store);
|
|
1355
|
-
new Tracker(coreState, store);
|
|
1356
|
-
const jsonState = selectJson(coreState, options, store);
|
|
1357
|
-
const target = newest(store);
|
|
1358
|
-
subscribeToState(
|
|
1359
|
-
jsonState,
|
|
1360
|
-
() => {
|
|
1361
|
-
const trackerHasBeenInitialized = newest(store).trackers.has(coreState.key);
|
|
1362
|
-
if (!trackerHasBeenInitialized) {
|
|
1363
|
-
new Tracker(coreState, store);
|
|
1364
|
-
}
|
|
1365
|
-
},
|
|
1366
|
-
`tracker-initializer:${store == null ? void 0 : store.config.name}:${target.transactionMeta === null ? `main` : `${target.transactionMeta.update.key}`}`,
|
|
1367
|
-
store
|
|
1368
|
-
);
|
|
1369
|
-
return coreState;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
// internal/src/families/create-atom-family.ts
|
|
1373
|
-
function createAtomFamily(options, store) {
|
|
1374
|
-
const subject = new Subject();
|
|
1375
|
-
const atomFamily2 = Object.assign(
|
|
1376
|
-
(key) => {
|
|
1377
|
-
const subKey = stringifyJson(key);
|
|
1378
|
-
const family = { key: options.key, subKey };
|
|
1379
|
-
const fullKey = `${options.key}(${subKey})`;
|
|
1380
|
-
const existing = withdraw({ key: fullKey, type: `atom` }, store);
|
|
1381
|
-
let token;
|
|
1382
|
-
if (existing) {
|
|
1383
|
-
token = deposit(existing);
|
|
1384
|
-
} else {
|
|
1385
|
-
const individualOptions = {
|
|
1386
|
-
key: fullKey,
|
|
1387
|
-
default: options.default instanceof Function ? options.default(key) : options.default
|
|
1388
|
-
};
|
|
1389
|
-
if (options.effects) {
|
|
1390
|
-
individualOptions.effects = options.effects(key);
|
|
1391
|
-
}
|
|
1392
|
-
token = createAtom(individualOptions, family, store);
|
|
1393
|
-
subject.next(token);
|
|
1394
|
-
}
|
|
1395
|
-
return token;
|
|
1396
|
-
},
|
|
1397
|
-
{
|
|
1398
|
-
key: options.key,
|
|
1399
|
-
type: `atom_family`,
|
|
1400
|
-
subject
|
|
1401
|
-
}
|
|
1402
|
-
);
|
|
1403
|
-
if (`mutable` in options && typeof options.mutable === `boolean`) {
|
|
1404
|
-
Object.assign(atomFamily2, { mutable: options.mutable });
|
|
1405
|
-
}
|
|
1406
|
-
const target = newest(store);
|
|
1407
|
-
target.families.set(options.key, atomFamily2);
|
|
1408
|
-
return atomFamily2;
|
|
1409
|
-
}
|
|
1410
|
-
|
|
1411
|
-
// internal/src/families/create-readonly-selector-family.ts
|
|
1412
|
-
function createReadonlySelectorFamily(options, store) {
|
|
1413
|
-
const subject = new Subject();
|
|
1414
|
-
return Object.assign(
|
|
1415
|
-
(key) => {
|
|
1416
|
-
const target = newest(store);
|
|
1417
|
-
const subKey = stringifyJson(key);
|
|
1418
|
-
const family = { key: options.key, subKey };
|
|
1419
|
-
const fullKey = `${options.key}(${subKey})`;
|
|
1420
|
-
const existing = target.readonlySelectors.get(fullKey);
|
|
1421
|
-
if (existing) {
|
|
1422
|
-
return deposit(existing);
|
|
1423
|
-
}
|
|
1424
|
-
return createSelector(
|
|
1425
|
-
{
|
|
1426
|
-
key: fullKey,
|
|
1427
|
-
get: options.get(key)
|
|
1428
|
-
},
|
|
1429
|
-
family,
|
|
1430
|
-
store
|
|
1431
|
-
);
|
|
1432
|
-
},
|
|
1433
|
-
{
|
|
1434
|
-
key: options.key,
|
|
1435
|
-
type: `readonly_selector_family`,
|
|
1436
|
-
subject
|
|
1437
|
-
}
|
|
1438
|
-
);
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
// internal/src/families/create-selector-family.ts
|
|
1442
|
-
function createSelectorFamily(options, store) {
|
|
1443
|
-
const isReadonly = !(`set` in options);
|
|
1444
|
-
if (isReadonly) {
|
|
1445
|
-
return createReadonlySelectorFamily(options, store);
|
|
1446
|
-
}
|
|
1447
|
-
const target = newest(store);
|
|
1448
|
-
const subject = new Subject();
|
|
1449
|
-
const selectorFamily2 = Object.assign(
|
|
1450
|
-
(key) => {
|
|
1451
|
-
const subKey = stringifyJson(key);
|
|
1452
|
-
const family = { key: options.key, subKey };
|
|
1453
|
-
const fullKey = `${options.key}(${subKey})`;
|
|
1454
|
-
const existing = target.selectors.get(fullKey);
|
|
1455
|
-
if (existing) {
|
|
1456
|
-
return deposit(existing);
|
|
1457
|
-
}
|
|
1458
|
-
const token = createSelector(
|
|
1459
|
-
{
|
|
1460
|
-
key: fullKey,
|
|
1461
|
-
get: options.get(key),
|
|
1462
|
-
set: options.set(key)
|
|
1463
|
-
},
|
|
1464
|
-
family,
|
|
1465
|
-
store
|
|
1466
|
-
);
|
|
1467
|
-
subject.next(token);
|
|
1468
|
-
return token;
|
|
1469
|
-
},
|
|
1470
|
-
{
|
|
1471
|
-
key: options.key,
|
|
1472
|
-
type: `selector_family`
|
|
1473
|
-
}
|
|
1474
|
-
);
|
|
1475
|
-
target.families.set(options.key, selectorFamily2);
|
|
1476
|
-
return selectorFamily2;
|
|
1477
|
-
}
|
|
3
|
+
var atom_io = require('atom.io');
|
|
4
|
+
var introspection = require('atom.io/introspection');
|
|
5
|
+
var react = require('atom.io/react');
|
|
6
|
+
var framerMotion = require('framer-motion');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
var react$1 = require('@floating-ui/react');
|
|
1478
10
|
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
this.findMutableState.subject.subscribe(
|
|
1491
|
-
`store=${store.config.name}::tracker-atom-family`,
|
|
1492
|
-
(atomToken) => {
|
|
1493
|
-
if (atomToken.family) {
|
|
1494
|
-
const key = parseJson(atomToken.family.subKey);
|
|
1495
|
-
this.findLatestUpdateState(key);
|
|
1496
|
-
new Tracker(atomToken, store);
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
);
|
|
1500
|
-
this.findLatestUpdateState.subject.subscribe(
|
|
1501
|
-
`store=${store.config.name}::tracker-atom-family`,
|
|
1502
|
-
(atomToken) => {
|
|
1503
|
-
if (atomToken.family) {
|
|
1504
|
-
const key = parseJson(atomToken.family.subKey);
|
|
1505
|
-
const mutableAtomToken = this.findMutableState(key);
|
|
1506
|
-
new Tracker(mutableAtomToken, store);
|
|
1507
|
-
}
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
1508
22
|
}
|
|
1509
|
-
);
|
|
23
|
+
});
|
|
1510
24
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
// internal/src/mutable/create-mutable-atom-family.ts
|
|
1514
|
-
function createMutableAtomFamily(options, store) {
|
|
1515
|
-
const coreFamily = Object.assign(
|
|
1516
|
-
createAtomFamily(options, store),
|
|
1517
|
-
options
|
|
1518
|
-
);
|
|
1519
|
-
selectJsonFamily(coreFamily, options);
|
|
1520
|
-
new FamilyTracker(coreFamily, store);
|
|
1521
|
-
return coreFamily;
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
// internal/src/mutable/transceiver.ts
|
|
1525
|
-
function isTransceiver(value) {
|
|
1526
|
-
return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
1527
27
|
}
|
|
1528
28
|
|
|
1529
|
-
|
|
1530
|
-
var isAtomDefault = (key, store) => {
|
|
1531
|
-
const core = newest(store);
|
|
1532
|
-
return core.atomsThatAreDefault.has(key);
|
|
1533
|
-
};
|
|
1534
|
-
var markAtomAsDefault = (key, store) => {
|
|
1535
|
-
const core = newest(store);
|
|
1536
|
-
core.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key);
|
|
1537
|
-
};
|
|
1538
|
-
var markAtomAsNotDefault = (key, store) => {
|
|
1539
|
-
const core = newest(store);
|
|
1540
|
-
core.atomsThatAreDefault = new Set(newest(store).atomsThatAreDefault);
|
|
1541
|
-
core.atomsThatAreDefault.delete(key);
|
|
1542
|
-
};
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
1543
30
|
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
`Tried to create atom, but it already exists in the store.`,
|
|
1560
|
-
`(Ignore if you are in development using hot module replacement.)`
|
|
1561
|
-
);
|
|
1562
|
-
return deposit(existing);
|
|
1563
|
-
}
|
|
1564
|
-
const subject = new Subject();
|
|
1565
|
-
const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
1566
|
-
type: `atom`,
|
|
1567
|
-
install: (store2) => {
|
|
1568
|
-
store2.logger.info(
|
|
1569
|
-
`\u{1F6E0}\uFE0F`,
|
|
1570
|
-
`atom`,
|
|
1571
|
-
options.key,
|
|
1572
|
-
`installing in store "${store2.config.name}"`
|
|
1573
|
-
);
|
|
1574
|
-
return `mutable` in options ? createMutableAtom(options, store2) : createAtom(options, void 0, store2);
|
|
1575
|
-
},
|
|
1576
|
-
subject
|
|
1577
|
-
}), family && { family });
|
|
1578
|
-
let initialValue = options.default;
|
|
1579
|
-
if (options.default instanceof Function) {
|
|
1580
|
-
initialValue = options.default();
|
|
1581
|
-
}
|
|
1582
|
-
target.atoms.set(newAtom.key, newAtom);
|
|
1583
|
-
markAtomAsDefault(options.key, store);
|
|
1584
|
-
cacheValue(options.key, initialValue, subject, store);
|
|
1585
|
-
const token = deposit(newAtom);
|
|
1586
|
-
if (options.effects) {
|
|
1587
|
-
let effectIndex = 0;
|
|
1588
|
-
const cleanupFunctions = [];
|
|
1589
|
-
for (const effect of options.effects) {
|
|
1590
|
-
const cleanup = effect({
|
|
1591
|
-
setSelf: (next) => setState(token, next, store),
|
|
1592
|
-
onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
|
|
1593
|
-
});
|
|
1594
|
-
if (cleanup) {
|
|
1595
|
-
cleanupFunctions.push(cleanup);
|
|
1596
|
-
}
|
|
1597
|
-
++effectIndex;
|
|
31
|
+
var __defProp = Object.defineProperty;
|
|
32
|
+
var __defProps = Object.defineProperties;
|
|
33
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
34
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
35
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
36
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
37
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
38
|
+
var __spreadValues = (a2, b2) => {
|
|
39
|
+
for (var prop in b2 || (b2 = {}))
|
|
40
|
+
if (__hasOwnProp.call(b2, prop))
|
|
41
|
+
__defNormalProp(a2, prop, b2[prop]);
|
|
42
|
+
if (__getOwnPropSymbols)
|
|
43
|
+
for (var prop of __getOwnPropSymbols(b2)) {
|
|
44
|
+
if (__propIsEnum.call(b2, prop))
|
|
45
|
+
__defNormalProp(a2, prop, b2[prop]);
|
|
1598
46
|
}
|
|
1599
|
-
|
|
1600
|
-
for (const cleanup of cleanupFunctions) {
|
|
1601
|
-
cleanup();
|
|
1602
|
-
}
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
store.subject.atomCreation.next(token);
|
|
1606
|
-
return token;
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
// internal/src/not-found-error.ts
|
|
1610
|
-
var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
1611
|
-
function prettyPrintTokenType(token) {
|
|
1612
|
-
if (token.type === `readonly_selector`) {
|
|
1613
|
-
return `Readonly Selector`;
|
|
1614
|
-
}
|
|
1615
|
-
return capitalize(token.type);
|
|
1616
|
-
}
|
|
1617
|
-
var NotFoundError = class extends Error {
|
|
1618
|
-
constructor(token, store) {
|
|
1619
|
-
super(
|
|
1620
|
-
`${prettyPrintTokenType(token)} "${token.key}" not found in store "${store.config.name}".`
|
|
1621
|
-
);
|
|
1622
|
-
}
|
|
47
|
+
return a2;
|
|
1623
48
|
};
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
var
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
if (!timelineData) {
|
|
1636
|
-
store.logger.error(
|
|
1637
|
-
`\u{1F41E}`,
|
|
1638
|
-
`timeline`,
|
|
1639
|
-
token.key,
|
|
1640
|
-
`Failed to ${action}. This timeline has not been initialized.`
|
|
1641
|
-
);
|
|
1642
|
-
return;
|
|
1643
|
-
}
|
|
1644
|
-
if (direction === `forward` && timelineData.at === timelineData.history.length || direction === `backward` && timelineData.at === 0) {
|
|
1645
|
-
store.logger.warn(
|
|
1646
|
-
`\u{1F481}`,
|
|
1647
|
-
`timeline`,
|
|
1648
|
-
token.key,
|
|
1649
|
-
`Failed to ${action} at the ${direction === `forward` ? `end` : `beginning`} of timeline "${token.key}". There is nothing to ${action}.`
|
|
1650
|
-
);
|
|
1651
|
-
return;
|
|
1652
|
-
}
|
|
1653
|
-
timelineData.timeTraveling = direction === `forward` ? `into_future` : `into_past`;
|
|
1654
|
-
if (direction === `backward`) {
|
|
1655
|
-
--timelineData.at;
|
|
1656
|
-
}
|
|
1657
|
-
const update = timelineData.history[timelineData.at];
|
|
1658
|
-
const updateValues = (atomUpdate) => {
|
|
1659
|
-
const { key, newValue, oldValue } = atomUpdate;
|
|
1660
|
-
const value = direction === `forward` ? newValue : oldValue;
|
|
1661
|
-
setState({ key, type: `atom` }, value, store);
|
|
1662
|
-
};
|
|
1663
|
-
const updateValuesFromTransactionUpdate = (transactionUpdate) => {
|
|
1664
|
-
const updates = direction === `forward` ? transactionUpdate.updates : [...transactionUpdate.updates].reverse();
|
|
1665
|
-
for (const updateFromTransaction of updates) {
|
|
1666
|
-
if (`newValue` in updateFromTransaction) {
|
|
1667
|
-
updateValues(updateFromTransaction);
|
|
1668
|
-
} else {
|
|
1669
|
-
updateValuesFromTransactionUpdate(updateFromTransaction);
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
};
|
|
1673
|
-
switch (update.type) {
|
|
1674
|
-
case `atom_update`: {
|
|
1675
|
-
updateValues(update);
|
|
1676
|
-
break;
|
|
1677
|
-
}
|
|
1678
|
-
case `selector_update`: {
|
|
1679
|
-
const updates = direction === `forward` ? update.atomUpdates : [...update.atomUpdates].reverse();
|
|
1680
|
-
for (const atomUpdate of updates) {
|
|
1681
|
-
updateValues(atomUpdate);
|
|
1682
|
-
}
|
|
1683
|
-
break;
|
|
1684
|
-
}
|
|
1685
|
-
case `transaction_update`: {
|
|
1686
|
-
updateValuesFromTransactionUpdate(update);
|
|
1687
|
-
break;
|
|
49
|
+
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
|
|
50
|
+
var __restKey = (key) => typeof key === "symbol" ? key : key + "";
|
|
51
|
+
var __objRest = (source, exclude) => {
|
|
52
|
+
var target = {};
|
|
53
|
+
for (var prop in source)
|
|
54
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
55
|
+
target[prop] = source[prop];
|
|
56
|
+
if (source != null && __getOwnPropSymbols)
|
|
57
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
58
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
59
|
+
target[prop] = source[prop];
|
|
1688
60
|
}
|
|
1689
|
-
|
|
1690
|
-
if (direction === `forward`) {
|
|
1691
|
-
++timelineData.at;
|
|
1692
|
-
}
|
|
1693
|
-
timelineData.subject.next(action);
|
|
1694
|
-
timelineData.timeTraveling = null;
|
|
1695
|
-
store.logger.info(
|
|
1696
|
-
`\u23F9\uFE0F`,
|
|
1697
|
-
`timeline`,
|
|
1698
|
-
token.key,
|
|
1699
|
-
`"${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
|
|
1700
|
-
);
|
|
1701
|
-
};
|
|
1702
|
-
|
|
1703
|
-
// src/atom.ts
|
|
1704
|
-
function atom(options) {
|
|
1705
|
-
if (`mutable` in options) {
|
|
1706
|
-
return createMutableAtom(options, IMPLICIT.STORE);
|
|
1707
|
-
}
|
|
1708
|
-
return createAtom(options, void 0, IMPLICIT.STORE);
|
|
1709
|
-
}
|
|
1710
|
-
function atomFamily(options) {
|
|
1711
|
-
if (`mutable` in options) {
|
|
1712
|
-
return createMutableAtomFamily(options, IMPLICIT.STORE);
|
|
1713
|
-
}
|
|
1714
|
-
return createAtomFamily(options, IMPLICIT.STORE);
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
|
-
// src/get-state.ts
|
|
1718
|
-
function getState(token, store = IMPLICIT.STORE) {
|
|
1719
|
-
var _a2;
|
|
1720
|
-
const state = (_a2 = withdraw(token, store)) != null ? _a2 : withdrawNewFamilyMember(token, store);
|
|
1721
|
-
if (state === void 0) {
|
|
1722
|
-
throw new NotFoundError(token, store);
|
|
1723
|
-
}
|
|
1724
|
-
return readOrComputeValue(state, store);
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
// src/logger.ts
|
|
1728
|
-
var simpleLog = (logLevel) => (icon, tokenType, tokenKey, message, ...rest) => {
|
|
1729
|
-
console[logLevel](`${icon} ${tokenType} "${tokenKey}" ${message}`, ...rest);
|
|
1730
|
-
};
|
|
1731
|
-
var simpleLogger = {
|
|
1732
|
-
error: simpleLog(`error`),
|
|
1733
|
-
info: simpleLog(`info`),
|
|
1734
|
-
warn: simpleLog(`warn`)
|
|
1735
|
-
};
|
|
1736
|
-
var AtomIOLogger = class {
|
|
1737
|
-
constructor(logLevel, filter, logger = simpleLogger) {
|
|
1738
|
-
this.logLevel = logLevel;
|
|
1739
|
-
this.filter = filter;
|
|
1740
|
-
this.logger = logger;
|
|
1741
|
-
this.error = (...args) => {
|
|
1742
|
-
var _a2, _b;
|
|
1743
|
-
if (((_b = (_a2 = this.filter) == null ? void 0 : _a2.call(this, ...args)) != null ? _b : true) && this.logLevel !== null) {
|
|
1744
|
-
this.logger.error(...args);
|
|
1745
|
-
}
|
|
1746
|
-
};
|
|
1747
|
-
this.info = (...args) => {
|
|
1748
|
-
var _a2, _b;
|
|
1749
|
-
if (((_b = (_a2 = this.filter) == null ? void 0 : _a2.call(this, ...args)) != null ? _b : true) && this.logLevel === `info`) {
|
|
1750
|
-
this.logger.info(...args);
|
|
1751
|
-
}
|
|
1752
|
-
};
|
|
1753
|
-
this.warn = (...args) => {
|
|
1754
|
-
var _a2, _b;
|
|
1755
|
-
if (((_b = (_a2 = this.filter) == null ? void 0 : _a2.call(this, ...args)) != null ? _b : true) && this.logLevel !== `error` && this.logLevel !== null) {
|
|
1756
|
-
this.logger.warn(...args);
|
|
1757
|
-
}
|
|
1758
|
-
};
|
|
1759
|
-
}
|
|
1760
|
-
};
|
|
1761
|
-
|
|
1762
|
-
// src/selector.ts
|
|
1763
|
-
function selectorFamily(options) {
|
|
1764
|
-
return createSelectorFamily(options, IMPLICIT.STORE);
|
|
1765
|
-
}
|
|
1766
|
-
|
|
1767
|
-
// src/set-state.ts
|
|
1768
|
-
function setState(token, value, store = IMPLICIT.STORE) {
|
|
1769
|
-
var _a2;
|
|
1770
|
-
const rejection = openOperation(token, store);
|
|
1771
|
-
if (rejection) {
|
|
1772
|
-
return;
|
|
1773
|
-
}
|
|
1774
|
-
const state = (_a2 = withdraw(token, store)) != null ? _a2 : withdrawNewFamilyMember(token, store);
|
|
1775
|
-
if (state === void 0) {
|
|
1776
|
-
throw new NotFoundError(token, store);
|
|
1777
|
-
}
|
|
1778
|
-
setAtomOrSelector(state, value, store);
|
|
1779
|
-
closeOperation(store);
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
// src/timeline.ts
|
|
1783
|
-
var redo = (timeline) => {
|
|
1784
|
-
timeTravel(`forward`, timeline, IMPLICIT.STORE);
|
|
1785
|
-
};
|
|
1786
|
-
var undo = (timeline) => {
|
|
1787
|
-
timeTravel(`backward`, timeline, IMPLICIT.STORE);
|
|
1788
|
-
};
|
|
1789
|
-
|
|
1790
|
-
// introspection/src/attach-atom-index.ts
|
|
1791
|
-
var attachAtomIndex = (store = IMPLICIT.STORE) => {
|
|
1792
|
-
const atomTokenIndexState__INTERNAL = createAtom(
|
|
1793
|
-
{
|
|
1794
|
-
key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
|
|
1795
|
-
default: () => {
|
|
1796
|
-
const defaultAtomIndex = [...store.atoms].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
|
|
1797
|
-
acc[key] = { key, type: `atom` };
|
|
1798
|
-
return acc;
|
|
1799
|
-
}, {});
|
|
1800
|
-
return defaultAtomIndex;
|
|
1801
|
-
},
|
|
1802
|
-
effects: [
|
|
1803
|
-
({ setSelf }) => {
|
|
1804
|
-
store.subject.atomCreation.subscribe(`introspection`, (atomToken) => {
|
|
1805
|
-
if (atomToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
1806
|
-
return;
|
|
1807
|
-
}
|
|
1808
|
-
const set = () => setSelf((state) => {
|
|
1809
|
-
const { key, family } = atomToken;
|
|
1810
|
-
if (family) {
|
|
1811
|
-
const { key: familyKey, subKey } = family;
|
|
1812
|
-
const current = state[familyKey];
|
|
1813
|
-
if (current === void 0 || `familyMembers` in current) {
|
|
1814
|
-
const familyKeyState = current || {
|
|
1815
|
-
key: familyKey,
|
|
1816
|
-
familyMembers: {}
|
|
1817
|
-
};
|
|
1818
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
1819
|
-
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
1820
|
-
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
1821
|
-
[subKey]: atomToken
|
|
1822
|
-
})
|
|
1823
|
-
})
|
|
1824
|
-
});
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
1828
|
-
[key]: atomToken
|
|
1829
|
-
});
|
|
1830
|
-
});
|
|
1831
|
-
if (newest(store).operation.open) {
|
|
1832
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1833
|
-
`introspection: waiting to update atom index`,
|
|
1834
|
-
() => {
|
|
1835
|
-
unsubscribe();
|
|
1836
|
-
set();
|
|
1837
|
-
}
|
|
1838
|
-
);
|
|
1839
|
-
} else {
|
|
1840
|
-
set();
|
|
1841
|
-
}
|
|
1842
|
-
});
|
|
1843
|
-
}
|
|
1844
|
-
]
|
|
1845
|
-
},
|
|
1846
|
-
void 0,
|
|
1847
|
-
store
|
|
1848
|
-
);
|
|
1849
|
-
return createSelector(
|
|
1850
|
-
{
|
|
1851
|
-
key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
|
|
1852
|
-
get: ({ get }) => get(atomTokenIndexState__INTERNAL)
|
|
1853
|
-
},
|
|
1854
|
-
void 0,
|
|
1855
|
-
store
|
|
1856
|
-
);
|
|
1857
|
-
};
|
|
1858
|
-
|
|
1859
|
-
// introspection/src/attach-selector-index.ts
|
|
1860
|
-
var attachSelectorIndex = (store = IMPLICIT.STORE) => {
|
|
1861
|
-
const readonlySelectorTokenIndexState__INTERNAL = createAtom(
|
|
1862
|
-
{
|
|
1863
|
-
key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
|
|
1864
|
-
default: () => Object.assign(
|
|
1865
|
-
[...store.readonlySelectors].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
|
|
1866
|
-
acc[key] = { key, type: `readonly_selector` };
|
|
1867
|
-
return acc;
|
|
1868
|
-
}, {}),
|
|
1869
|
-
[...store.selectors].reduce((acc, [key]) => {
|
|
1870
|
-
acc[key] = { key, type: `selector` };
|
|
1871
|
-
return acc;
|
|
1872
|
-
}, {})
|
|
1873
|
-
),
|
|
1874
|
-
effects: [
|
|
1875
|
-
({ setSelf }) => {
|
|
1876
|
-
store.subject.selectorCreation.subscribe(
|
|
1877
|
-
`introspection`,
|
|
1878
|
-
(selectorToken) => {
|
|
1879
|
-
if (selectorToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
1880
|
-
return;
|
|
1881
|
-
}
|
|
1882
|
-
const set = () => setSelf((state) => {
|
|
1883
|
-
const { key, family } = selectorToken;
|
|
1884
|
-
if (family) {
|
|
1885
|
-
const { key: familyKey, subKey } = family;
|
|
1886
|
-
const current = state[familyKey];
|
|
1887
|
-
if (current === void 0 || `familyMembers` in current) {
|
|
1888
|
-
const familyKeyState = current || {
|
|
1889
|
-
key: familyKey,
|
|
1890
|
-
familyMembers: {}
|
|
1891
|
-
};
|
|
1892
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
1893
|
-
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
1894
|
-
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
1895
|
-
[subKey]: selectorToken
|
|
1896
|
-
})
|
|
1897
|
-
})
|
|
1898
|
-
});
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
return __spreadProps(__spreadValues({}, state), {
|
|
1902
|
-
[key]: selectorToken
|
|
1903
|
-
});
|
|
1904
|
-
});
|
|
1905
|
-
if (newest(store).operation.open) {
|
|
1906
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1907
|
-
`introspection: waiting to update selector index`,
|
|
1908
|
-
() => {
|
|
1909
|
-
unsubscribe();
|
|
1910
|
-
set();
|
|
1911
|
-
}
|
|
1912
|
-
);
|
|
1913
|
-
} else {
|
|
1914
|
-
set();
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
);
|
|
1918
|
-
}
|
|
1919
|
-
]
|
|
1920
|
-
},
|
|
1921
|
-
void 0,
|
|
1922
|
-
store
|
|
1923
|
-
);
|
|
1924
|
-
return createSelector(
|
|
1925
|
-
{
|
|
1926
|
-
key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
|
|
1927
|
-
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
|
|
1928
|
-
},
|
|
1929
|
-
void 0,
|
|
1930
|
-
IMPLICIT.STORE
|
|
1931
|
-
);
|
|
1932
|
-
};
|
|
1933
|
-
|
|
1934
|
-
// introspection/src/attach-timeline-family.ts
|
|
1935
|
-
var attachTimelineFamily = (store = IMPLICIT.STORE) => {
|
|
1936
|
-
const findTimelineLogState__INTERNAL = createAtomFamily(
|
|
1937
|
-
{
|
|
1938
|
-
key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
|
|
1939
|
-
default: (key) => {
|
|
1940
|
-
var _a2;
|
|
1941
|
-
return (_a2 = store.timelines.get(key)) != null ? _a2 : {
|
|
1942
|
-
type: `timeline`,
|
|
1943
|
-
key: ``,
|
|
1944
|
-
at: 0,
|
|
1945
|
-
timeTraveling: null,
|
|
1946
|
-
history: [],
|
|
1947
|
-
selectorTime: null,
|
|
1948
|
-
transactionKey: null,
|
|
1949
|
-
install: () => {
|
|
1950
|
-
},
|
|
1951
|
-
subject: new Subject()
|
|
1952
|
-
};
|
|
1953
|
-
},
|
|
1954
|
-
effects: (key) => [
|
|
1955
|
-
({ setSelf }) => {
|
|
1956
|
-
const tl = store.timelines.get(key);
|
|
1957
|
-
tl == null ? void 0 : tl.subject.subscribe(`introspection`, (_) => {
|
|
1958
|
-
if (store.operation.open === true) {
|
|
1959
|
-
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1960
|
-
`introspection`,
|
|
1961
|
-
(operationStatus) => {
|
|
1962
|
-
if (operationStatus.open === false) {
|
|
1963
|
-
unsubscribe();
|
|
1964
|
-
setSelf(__spreadValues({}, tl));
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
);
|
|
1968
|
-
} else {
|
|
1969
|
-
setSelf(__spreadValues({}, tl));
|
|
1970
|
-
}
|
|
1971
|
-
});
|
|
1972
|
-
}
|
|
1973
|
-
]
|
|
1974
|
-
},
|
|
1975
|
-
store
|
|
1976
|
-
);
|
|
1977
|
-
const findTimelineLogState = createSelectorFamily(
|
|
1978
|
-
{
|
|
1979
|
-
key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
|
|
1980
|
-
get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key))
|
|
1981
|
-
},
|
|
1982
|
-
store
|
|
1983
|
-
);
|
|
1984
|
-
return findTimelineLogState;
|
|
1985
|
-
};
|
|
1986
|
-
|
|
1987
|
-
// introspection/src/attach-timeline-index.ts
|
|
1988
|
-
var attachTimelineIndex = (store = IMPLICIT.STORE) => {
|
|
1989
|
-
const timelineTokenIndexState__INTERNAL = createAtom(
|
|
1990
|
-
{
|
|
1991
|
-
key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
|
|
1992
|
-
default: () => [...store.timelines].map(([key]) => {
|
|
1993
|
-
return { key, type: `timeline` };
|
|
1994
|
-
}),
|
|
1995
|
-
effects: [
|
|
1996
|
-
({ setSelf }) => {
|
|
1997
|
-
store.subject.timelineCreation.subscribe(
|
|
1998
|
-
`introspection`,
|
|
1999
|
-
(timelineToken) => {
|
|
2000
|
-
setSelf((state) => [...state, timelineToken]);
|
|
2001
|
-
}
|
|
2002
|
-
);
|
|
2003
|
-
}
|
|
2004
|
-
]
|
|
2005
|
-
},
|
|
2006
|
-
void 0,
|
|
2007
|
-
store
|
|
2008
|
-
);
|
|
2009
|
-
const timelineTokenIndex = createSelector(
|
|
2010
|
-
{
|
|
2011
|
-
key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
|
|
2012
|
-
get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
|
|
2013
|
-
},
|
|
2014
|
-
void 0,
|
|
2015
|
-
store
|
|
2016
|
-
);
|
|
2017
|
-
return timelineTokenIndex;
|
|
2018
|
-
};
|
|
2019
|
-
|
|
2020
|
-
// introspection/src/attach-transaction-index.ts
|
|
2021
|
-
var attachTransactionIndex = (store = IMPLICIT.STORE) => {
|
|
2022
|
-
const transactionTokenIndexState__INTERNAL = createAtom(
|
|
2023
|
-
{
|
|
2024
|
-
key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
|
|
2025
|
-
default: () => [...store.transactions].map(([key]) => {
|
|
2026
|
-
return { key, type: `transaction` };
|
|
2027
|
-
}),
|
|
2028
|
-
effects: [
|
|
2029
|
-
({ setSelf }) => {
|
|
2030
|
-
store.subject.transactionCreation.subscribe(
|
|
2031
|
-
`introspection`,
|
|
2032
|
-
(transactionToken) => {
|
|
2033
|
-
setSelf((state) => [...state, transactionToken]);
|
|
2034
|
-
}
|
|
2035
|
-
);
|
|
2036
|
-
}
|
|
2037
|
-
]
|
|
2038
|
-
},
|
|
2039
|
-
void 0,
|
|
2040
|
-
store
|
|
2041
|
-
);
|
|
2042
|
-
const transactionTokenIndex = createSelector(
|
|
2043
|
-
{
|
|
2044
|
-
key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
|
|
2045
|
-
get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
|
|
2046
|
-
},
|
|
2047
|
-
void 0,
|
|
2048
|
-
store
|
|
2049
|
-
);
|
|
2050
|
-
return transactionTokenIndex;
|
|
2051
|
-
};
|
|
2052
|
-
|
|
2053
|
-
// introspection/src/attach-transaction-logs.ts
|
|
2054
|
-
var attachTransactionLogs = (store = IMPLICIT.STORE) => {
|
|
2055
|
-
const findTransactionUpdateLog = createAtomFamily(
|
|
2056
|
-
{
|
|
2057
|
-
key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
|
|
2058
|
-
default: () => [],
|
|
2059
|
-
effects: (key) => [
|
|
2060
|
-
({ setSelf }) => {
|
|
2061
|
-
const tx = store.transactions.get(key);
|
|
2062
|
-
tx == null ? void 0 : tx.subject.subscribe(`introspection`, (transactionUpdate) => {
|
|
2063
|
-
if (transactionUpdate.key === key) {
|
|
2064
|
-
setSelf((state) => [...state, transactionUpdate]);
|
|
2065
|
-
}
|
|
2066
|
-
});
|
|
2067
|
-
}
|
|
2068
|
-
]
|
|
2069
|
-
},
|
|
2070
|
-
store
|
|
2071
|
-
);
|
|
2072
|
-
const findTransactionUpdateLogState = createSelectorFamily(
|
|
2073
|
-
{
|
|
2074
|
-
key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
|
|
2075
|
-
get: (key) => ({ get }) => get(findTransactionUpdateLog(key))
|
|
2076
|
-
},
|
|
2077
|
-
store
|
|
2078
|
-
);
|
|
2079
|
-
return findTransactionUpdateLogState;
|
|
2080
|
-
};
|
|
2081
|
-
|
|
2082
|
-
// introspection/src/attach-introspection-states.ts
|
|
2083
|
-
var attachIntrospectionStates = (store = IMPLICIT.STORE) => {
|
|
2084
|
-
return {
|
|
2085
|
-
atomIndex: attachAtomIndex(store),
|
|
2086
|
-
selectorIndex: attachSelectorIndex(store),
|
|
2087
|
-
transactionIndex: attachTransactionIndex(store),
|
|
2088
|
-
findTransactionLogState: attachTransactionLogs(store),
|
|
2089
|
-
timelineIndex: attachTimelineIndex(store),
|
|
2090
|
-
findTimelineState: attachTimelineFamily(store)
|
|
2091
|
-
};
|
|
61
|
+
return target;
|
|
2092
62
|
};
|
|
2093
63
|
|
|
2094
64
|
// __unstable__/web-effects/src/storage.ts
|
|
@@ -2139,7 +109,7 @@ function pipe(a2, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
|
2139
109
|
|
|
2140
110
|
// ../anvl/src/function/index.ts
|
|
2141
111
|
var doNothing = () => void 0;
|
|
2142
|
-
var
|
|
112
|
+
var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
|
|
2143
113
|
originalThing instanceof Function ? originalThing() : originalThing
|
|
2144
114
|
) : nextVersionOfThing;
|
|
2145
115
|
var isModifier = (validate) => (sample) => {
|
|
@@ -2446,24 +416,36 @@ var Differ = class {
|
|
|
2446
416
|
};
|
|
2447
417
|
}
|
|
2448
418
|
};
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
419
|
+
|
|
420
|
+
// ../anvl/src/json/index.ts
|
|
421
|
+
var stringifyJson = (json) => JSON.stringify(json);
|
|
422
|
+
var JSON_TYPE_NAMES = [
|
|
423
|
+
`array`,
|
|
424
|
+
`boolean`,
|
|
425
|
+
`null`,
|
|
426
|
+
`number`,
|
|
427
|
+
`object`,
|
|
428
|
+
`string`
|
|
429
|
+
];
|
|
430
|
+
var JSON_DEFAULTS = {
|
|
431
|
+
array: [],
|
|
432
|
+
boolean: false,
|
|
433
|
+
null: null,
|
|
434
|
+
number: 0,
|
|
435
|
+
object: {},
|
|
436
|
+
string: ``
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
// ../anvl/src/primitive/index.ts
|
|
440
|
+
var isString = (input) => {
|
|
441
|
+
return typeof input === `string`;
|
|
442
|
+
};
|
|
443
|
+
var isNumber = (input) => {
|
|
444
|
+
return typeof input === `number`;
|
|
445
|
+
};
|
|
446
|
+
var isBoolean = (input) => {
|
|
447
|
+
return typeof input === `boolean`;
|
|
448
|
+
};
|
|
2467
449
|
|
|
2468
450
|
// ../anvl/src/refinement/refine-json.ts
|
|
2469
451
|
var JSON_PROTOTYPES = [
|
|
@@ -2854,12 +836,12 @@ var Join = class _Join {
|
|
|
2854
836
|
);
|
|
2855
837
|
}
|
|
2856
838
|
};
|
|
2857
|
-
var ElasticInput =
|
|
839
|
+
var ElasticInput = React.forwardRef(function ElasticInputFC(props, ref) {
|
|
2858
840
|
var _a2, _b, _c, _d;
|
|
2859
|
-
const inputRef =
|
|
2860
|
-
const spanRef =
|
|
2861
|
-
const [inputWidth, setInputWidth] =
|
|
2862
|
-
|
|
841
|
+
const inputRef = React.useRef(null);
|
|
842
|
+
const spanRef = React.useRef(null);
|
|
843
|
+
const [inputWidth, setInputWidth] = React.useState(`auto`);
|
|
844
|
+
React.useImperativeHandle(
|
|
2863
845
|
ref,
|
|
2864
846
|
() => ({
|
|
2865
847
|
focus: () => {
|
|
@@ -2869,7 +851,7 @@ var ElasticInput = React2.forwardRef(function ElasticInputFC(props, ref) {
|
|
|
2869
851
|
})
|
|
2870
852
|
);
|
|
2871
853
|
const extraWidth = props.type === `number` ? 15 : 0;
|
|
2872
|
-
|
|
854
|
+
React.useLayoutEffect(() => {
|
|
2873
855
|
if (spanRef.current) {
|
|
2874
856
|
setInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`);
|
|
2875
857
|
const interval = setInterval(() => {
|
|
@@ -2979,9 +961,9 @@ var NumberInput = ({
|
|
|
2979
961
|
testId,
|
|
2980
962
|
value = null
|
|
2981
963
|
}) => {
|
|
2982
|
-
const id =
|
|
2983
|
-
const [temporaryEntry, setTemporaryEntry] =
|
|
2984
|
-
const userHasMadeDeliberateChange =
|
|
964
|
+
const id = React.useId();
|
|
965
|
+
const [temporaryEntry, setTemporaryEntry] = React.useState(null);
|
|
966
|
+
const userHasMadeDeliberateChange = React.useRef(false);
|
|
2985
967
|
const refine = initRefinery({ max, min, decimalPlaces, nullable: true });
|
|
2986
968
|
const allowDecimal = decimalPlaces === void 0 || decimalPlaces > 0;
|
|
2987
969
|
const handleBlur = () => {
|
|
@@ -3155,7 +1137,7 @@ var JsonEditor_INTERNAL = ({
|
|
|
3155
1137
|
var makeElementSetters = (data, set) => data.map(
|
|
3156
1138
|
(value, index) => (newValue) => set(() => {
|
|
3157
1139
|
const newData = [...data];
|
|
3158
|
-
newData[index] =
|
|
1140
|
+
newData[index] = become(newValue)(value);
|
|
3159
1141
|
return newData;
|
|
3160
1142
|
})
|
|
3161
1143
|
);
|
|
@@ -3636,7 +1618,7 @@ var castToJson = (input) => {
|
|
|
3636
1618
|
// ../hamr/src/react-json-editor/editors-by-type/utilities/object-properties.ts
|
|
3637
1619
|
var makePropertySetters = (data, set) => mapObject(
|
|
3638
1620
|
data,
|
|
3639
|
-
(value, key) => (newValue) => set(__spreadProps(__spreadValues({}, data), { [key]:
|
|
1621
|
+
(value, key) => (newValue) => set(__spreadProps(__spreadValues({}, data), { [key]: become(newValue)(value[key]) }))
|
|
3640
1622
|
);
|
|
3641
1623
|
var makePropertyRenamers = (data, set, stableKeyMapRef) => mapObject(
|
|
3642
1624
|
data,
|
|
@@ -3695,7 +1677,7 @@ var ObjectEditor = ({
|
|
|
3695
1677
|
}) => {
|
|
3696
1678
|
var _a2;
|
|
3697
1679
|
const disabled = isReadonly(path);
|
|
3698
|
-
const stableKeyMap =
|
|
1680
|
+
const stableKeyMap = React.useRef(
|
|
3699
1681
|
Object.keys(data).reduce(
|
|
3700
1682
|
(acc, key) => {
|
|
3701
1683
|
acc[key] = key;
|
|
@@ -3861,7 +1843,7 @@ var DefaultFallback = ({ error, errorInfo }) => {
|
|
|
3861
1843
|
}
|
|
3862
1844
|
);
|
|
3863
1845
|
};
|
|
3864
|
-
var ErrorBoundary = class extends
|
|
1846
|
+
var ErrorBoundary = class extends React.Component {
|
|
3865
1847
|
constructor(props) {
|
|
3866
1848
|
super(props);
|
|
3867
1849
|
this.state = {};
|
|
@@ -4301,14 +2283,14 @@ WAYFORGE_CORE_COLOR_NAMES.reduce(
|
|
|
4301
2283
|
{}
|
|
4302
2284
|
);
|
|
4303
2285
|
var Id = ({ id }) => {
|
|
4304
|
-
const [isOpen, setIsOpen] =
|
|
4305
|
-
const { refs, floatingStyles, context } = react.useFloating({
|
|
2286
|
+
const [isOpen, setIsOpen] = React__namespace.useState(false);
|
|
2287
|
+
const { refs, floatingStyles, context } = react$1.useFloating({
|
|
4306
2288
|
open: isOpen,
|
|
4307
2289
|
onOpenChange: setIsOpen,
|
|
4308
2290
|
placement: `bottom-start`
|
|
4309
2291
|
});
|
|
4310
|
-
const click = react.useClick(context);
|
|
4311
|
-
const { getReferenceProps, getFloatingProps } = react.useInteractions([click]);
|
|
2292
|
+
const click = react$1.useClick(context);
|
|
2293
|
+
const { getReferenceProps, getFloatingProps } = react$1.useInteractions([click]);
|
|
4312
2294
|
const bgColor = stringToColor(id);
|
|
4313
2295
|
const contrastColor = pipe(bgColor, hexToSpec_default, contrastMax, specToHex_default);
|
|
4314
2296
|
const offsetColor = pipe(bgColor, hexToSpec_default, offset(0.25), specToHex_default);
|
|
@@ -4336,7 +2318,7 @@ var Id = ({ id }) => {
|
|
|
4336
2318
|
children: id.substring(0, 3)
|
|
4337
2319
|
})
|
|
4338
2320
|
),
|
|
4339
|
-
isOpen && /* @__PURE__ */ jsxRuntime.jsx(react.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2321
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsx(react$1.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4340
2322
|
"span",
|
|
4341
2323
|
__spreadProps(__spreadValues({
|
|
4342
2324
|
role: "popup",
|
|
@@ -4374,8 +2356,8 @@ var RelationEditor = (props) => {
|
|
|
4374
2356
|
] })) });
|
|
4375
2357
|
};
|
|
4376
2358
|
var StateEditor = ({ token }) => {
|
|
4377
|
-
const set = useI(token);
|
|
4378
|
-
const data = useO(token);
|
|
2359
|
+
const set = react.useI(token);
|
|
2360
|
+
const data = react.useO(token);
|
|
4379
2361
|
return isJson(data) ? /* @__PURE__ */ jsxRuntime.jsx(JsonEditor, { data, set, schema: true }) : data instanceof Join ? /* @__PURE__ */ jsxRuntime.jsx(RelationEditor, { data, set }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4380
2362
|
ElasticInput,
|
|
4381
2363
|
{
|
|
@@ -4385,7 +2367,7 @@ var StateEditor = ({ token }) => {
|
|
|
4385
2367
|
) });
|
|
4386
2368
|
};
|
|
4387
2369
|
var ReadonlySelectorViewer = ({ token }) => {
|
|
4388
|
-
const data = useO(token);
|
|
2370
|
+
const data = react.useO(token);
|
|
4389
2371
|
return isJson(data) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4390
2372
|
JsonEditor,
|
|
4391
2373
|
{
|
|
@@ -4408,7 +2390,7 @@ var StoreEditor = ({ token }) => {
|
|
|
4408
2390
|
}
|
|
4409
2391
|
return /* @__PURE__ */ jsxRuntime.jsx(StateEditor, { token });
|
|
4410
2392
|
};
|
|
4411
|
-
var findStateTypeState = selectorFamily({
|
|
2393
|
+
var findStateTypeState = atom_io.selectorFamily({
|
|
4412
2394
|
key: `\u{1F441}\u200D\u{1F5E8} State Type`,
|
|
4413
2395
|
get: (token) => ({ get }) => {
|
|
4414
2396
|
let state;
|
|
@@ -4426,10 +2408,10 @@ var findStateTypeState = selectorFamily({
|
|
|
4426
2408
|
});
|
|
4427
2409
|
var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
|
|
4428
2410
|
var _a2, _b;
|
|
4429
|
-
const setIsOpen = useI(isOpenState);
|
|
4430
|
-
const isOpen = useO(isOpenState);
|
|
4431
|
-
const state = useO(node);
|
|
4432
|
-
const stateType = useO(typeState);
|
|
2411
|
+
const setIsOpen = react.useI(isOpenState);
|
|
2412
|
+
const isOpen = react.useO(isOpenState);
|
|
2413
|
+
const state = react.useO(node);
|
|
2414
|
+
const stateType = react.useO(typeState);
|
|
4433
2415
|
const isPrimitive = Boolean(primitiveRefinery.refine(state));
|
|
4434
2416
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4435
2417
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
|
|
@@ -4444,8 +2426,8 @@ var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
|
|
|
4444
2426
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4445
2427
|
"label",
|
|
4446
2428
|
{
|
|
4447
|
-
onClick: () => console.log(node, getState(node)),
|
|
4448
|
-
onKeyUp: () => console.log(node, getState(node)),
|
|
2429
|
+
onClick: () => console.log(node, atom_io.getState(node)),
|
|
2430
|
+
onKeyUp: () => console.log(node, atom_io.getState(node)),
|
|
4449
2431
|
children: [
|
|
4450
2432
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { children: (_b = (_a2 = node.family) == null ? void 0 : _a2.subKey) != null ? _b : node.key }),
|
|
4451
2433
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "type detail", children: [
|
|
@@ -4462,8 +2444,8 @@ var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
|
|
|
4462
2444
|
] });
|
|
4463
2445
|
};
|
|
4464
2446
|
var StateIndexTreeNode = ({ node, isOpenState }) => {
|
|
4465
|
-
const setIsOpen = useI(isOpenState);
|
|
4466
|
-
const isOpen = useO(isOpenState);
|
|
2447
|
+
const setIsOpen = react.useI(isOpenState);
|
|
2448
|
+
const isOpen = react.useO(isOpenState);
|
|
4467
2449
|
for (const [key, childNode] of recordToEntries(node.familyMembers)) {
|
|
4468
2450
|
findViewIsOpenState(key);
|
|
4469
2451
|
findStateTypeState(childNode);
|
|
@@ -4501,7 +2483,7 @@ var StateIndexNode = ({ node, isOpenState, typeState }) => {
|
|
|
4501
2483
|
) : /* @__PURE__ */ jsxRuntime.jsx(StateIndexTreeNode, { node, isOpenState }) });
|
|
4502
2484
|
};
|
|
4503
2485
|
var StateIndex = ({ tokenIndex }) => {
|
|
4504
|
-
const tokenIds = useO(tokenIndex);
|
|
2486
|
+
const tokenIds = react.useO(tokenIndex);
|
|
4505
2487
|
return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "index state_index", children: Object.entries(tokenIds).filter(([key]) => !key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).sort().map(([key, node]) => {
|
|
4506
2488
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4507
2489
|
StateIndexNode,
|
|
@@ -4641,9 +2623,9 @@ var YouAreHere = () => {
|
|
|
4641
2623
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "you_are_here", children: "you are here" });
|
|
4642
2624
|
};
|
|
4643
2625
|
var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
4644
|
-
const timeline = useO(timelineState);
|
|
4645
|
-
const isOpen = useO(isOpenState);
|
|
4646
|
-
const setIsOpen = useI(isOpenState);
|
|
2626
|
+
const timeline = react.useO(timelineState);
|
|
2627
|
+
const isOpen = react.useO(isOpenState);
|
|
2628
|
+
const setIsOpen = react.useI(isOpenState);
|
|
4647
2629
|
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "node timeline_log", children: [
|
|
4648
2630
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
|
|
4649
2631
|
/* @__PURE__ */ jsxRuntime.jsx(button.OpenClose, { isOpen, setIsOpen }),
|
|
@@ -4662,7 +2644,7 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
|
4662
2644
|
"button",
|
|
4663
2645
|
{
|
|
4664
2646
|
type: "button",
|
|
4665
|
-
onClick: () => undo(token),
|
|
2647
|
+
onClick: () => atom_io.undo(token),
|
|
4666
2648
|
disabled: timeline.at === 0,
|
|
4667
2649
|
children: "undo"
|
|
4668
2650
|
}
|
|
@@ -4671,7 +2653,7 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
|
4671
2653
|
"button",
|
|
4672
2654
|
{
|
|
4673
2655
|
type: "button",
|
|
4674
|
-
onClick: () => redo(token),
|
|
2656
|
+
onClick: () => atom_io.redo(token),
|
|
4675
2657
|
disabled: timeline.at === timeline.history.length,
|
|
4676
2658
|
children: "redo"
|
|
4677
2659
|
}
|
|
@@ -4679,7 +2661,7 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
|
4679
2661
|
] })
|
|
4680
2662
|
] })
|
|
4681
2663
|
] }),
|
|
4682
|
-
isOpen ? /* @__PURE__ */ jsxRuntime.jsx("main", { children: timeline.history.map((update, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2664
|
+
isOpen ? /* @__PURE__ */ jsxRuntime.jsx("main", { children: timeline.history.map((update, index) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
4683
2665
|
index === timeline.at ? /* @__PURE__ */ jsxRuntime.jsx(YouAreHere, {}) : null,
|
|
4684
2666
|
/* @__PURE__ */ jsxRuntime.jsx(article.TimelineUpdate, { timelineUpdate: update }),
|
|
4685
2667
|
index === timeline.history.length - 1 && timeline.at === timeline.history.length ? /* @__PURE__ */ jsxRuntime.jsx(YouAreHere, {}) : null
|
|
@@ -4687,7 +2669,7 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
|
4687
2669
|
] });
|
|
4688
2670
|
};
|
|
4689
2671
|
var TimelineIndex = () => {
|
|
4690
|
-
const tokenIds = useO(timelineIndex);
|
|
2672
|
+
const tokenIds = react.useO(timelineIndex);
|
|
4691
2673
|
return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "index timeline_index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
|
|
4692
2674
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4693
2675
|
TimelineLog,
|
|
@@ -4701,9 +2683,9 @@ var TimelineIndex = () => {
|
|
|
4701
2683
|
}) });
|
|
4702
2684
|
};
|
|
4703
2685
|
var TransactionLog = ({ token, isOpenState, logState }) => {
|
|
4704
|
-
const log = useO(logState);
|
|
4705
|
-
const isOpen = useO(isOpenState);
|
|
4706
|
-
const setIsOpen = useI(isOpenState);
|
|
2686
|
+
const log = react.useO(logState);
|
|
2687
|
+
const isOpen = react.useO(isOpenState);
|
|
2688
|
+
const setIsOpen = react.useI(isOpenState);
|
|
4707
2689
|
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "node transaction_log", children: [
|
|
4708
2690
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
|
|
4709
2691
|
/* @__PURE__ */ jsxRuntime.jsx(button.OpenClose, { isOpen, setIsOpen }),
|
|
@@ -4727,7 +2709,7 @@ var TransactionLog = ({ token, isOpenState, logState }) => {
|
|
|
4727
2709
|
] });
|
|
4728
2710
|
};
|
|
4729
2711
|
var TransactionIndex = () => {
|
|
4730
|
-
const tokenIds = useO(transactionIndex);
|
|
2712
|
+
const tokenIds = react.useO(transactionIndex);
|
|
4731
2713
|
return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "index transaction_index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
|
|
4732
2714
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4733
2715
|
TransactionLog,
|
|
@@ -4741,13 +2723,13 @@ var TransactionIndex = () => {
|
|
|
4741
2723
|
}) });
|
|
4742
2724
|
};
|
|
4743
2725
|
var AtomIODevtools = () => {
|
|
4744
|
-
const constraintsRef =
|
|
4745
|
-
const setDevtoolsAreOpen = useI(devtoolsAreOpenState);
|
|
4746
|
-
const devtoolsAreOpen = useO(devtoolsAreOpenState);
|
|
4747
|
-
const setDevtoolsView = useI(devtoolsViewSelectionState);
|
|
4748
|
-
const devtoolsView = useO(devtoolsViewSelectionState);
|
|
4749
|
-
const devtoolsViewOptions = useO(devtoolsViewOptionsState);
|
|
4750
|
-
const mouseHasMoved =
|
|
2726
|
+
const constraintsRef = React.useRef(null);
|
|
2727
|
+
const setDevtoolsAreOpen = react.useI(devtoolsAreOpenState);
|
|
2728
|
+
const devtoolsAreOpen = react.useO(devtoolsAreOpenState);
|
|
2729
|
+
const setDevtoolsView = react.useI(devtoolsViewSelectionState);
|
|
2730
|
+
const devtoolsView = react.useO(devtoolsViewSelectionState);
|
|
2731
|
+
const devtoolsViewOptions = react.useO(devtoolsViewOptionsState);
|
|
2732
|
+
const mouseHasMoved = React.useRef(false);
|
|
4751
2733
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4752
2734
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4753
2735
|
framerMotion.motion.span,
|
|
@@ -4823,23 +2805,23 @@ var {
|
|
|
4823
2805
|
findTransactionLogState,
|
|
4824
2806
|
timelineIndex,
|
|
4825
2807
|
findTimelineState
|
|
4826
|
-
} = attachIntrospectionStates();
|
|
4827
|
-
var devtoolsAreOpenState = atom({
|
|
2808
|
+
} = introspection.attachIntrospectionStates();
|
|
2809
|
+
var devtoolsAreOpenState = atom_io.atom({
|
|
4828
2810
|
key: `\u{1F441}\u200D\u{1F5E8} Devtools Are Open`,
|
|
4829
2811
|
default: true,
|
|
4830
2812
|
effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools Are Open`)]
|
|
4831
2813
|
});
|
|
4832
|
-
var devtoolsViewSelectionState = atom({
|
|
2814
|
+
var devtoolsViewSelectionState = atom_io.atom({
|
|
4833
2815
|
key: `\u{1F441}\u200D\u{1F5E8} Devtools View Selection`,
|
|
4834
2816
|
default: `atoms`,
|
|
4835
2817
|
effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View`)]
|
|
4836
2818
|
});
|
|
4837
|
-
var devtoolsViewOptionsState = atom({
|
|
2819
|
+
var devtoolsViewOptionsState = atom_io.atom({
|
|
4838
2820
|
key: `\u{1F441}\u200D\u{1F5E8} Devtools View Options`,
|
|
4839
2821
|
default: [`atoms`, `selectors`, `transactions`, `timelines`],
|
|
4840
2822
|
effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View Options`)]
|
|
4841
2823
|
});
|
|
4842
|
-
var findViewIsOpenState = atomFamily({
|
|
2824
|
+
var findViewIsOpenState = atom_io.atomFamily({
|
|
4843
2825
|
key: `\u{1F441}\u200D\u{1F5E8} Devtools View Is Open`,
|
|
4844
2826
|
default: false,
|
|
4845
2827
|
effects: (key) => [lazyLocalStorageEffect(key + `:view-is-open`)]
|