atom.io 0.14.0 → 0.14.2

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.
Files changed (133) hide show
  1. package/data/dist/index.cjs +1421 -52
  2. package/data/dist/index.cjs.map +1 -1
  3. package/data/dist/index.d.cts +317 -16
  4. package/data/dist/index.js +10 -267
  5. package/data/dist/index.js.map +1 -1
  6. package/data/package.json +5 -5
  7. package/data/src/join.ts +3 -3
  8. package/dist/chunk-C4YZZNRH.js +67 -0
  9. package/dist/chunk-C4YZZNRH.js.map +1 -0
  10. package/dist/chunk-CWKKQKVQ.js +68 -0
  11. package/dist/chunk-CWKKQKVQ.js.map +1 -0
  12. package/dist/chunk-GMN5KH6A.js +309 -0
  13. package/dist/chunk-GMN5KH6A.js.map +1 -0
  14. package/dist/chunk-N7ADBQJG.js +176 -0
  15. package/dist/chunk-N7ADBQJG.js.map +1 -0
  16. package/dist/chunk-NYCVSXQB.js +181 -0
  17. package/dist/chunk-NYCVSXQB.js.map +1 -0
  18. package/dist/chunk-PURABO5G.js +2581 -0
  19. package/dist/chunk-PURABO5G.js.map +1 -0
  20. package/dist/index.cjs +2330 -55
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +272 -22
  23. package/dist/index.js +1 -152
  24. package/dist/index.js.map +1 -1
  25. package/dist/metafile-cjs.json +1 -1
  26. package/internal/dist/index.cjs +299 -106
  27. package/internal/dist/index.cjs.map +1 -1
  28. package/internal/dist/index.d.cts +231 -30
  29. package/internal/dist/index.js +1 -2240
  30. package/internal/dist/index.js.map +1 -1
  31. package/internal/package.json +5 -5
  32. package/internal/src/atom/create-atom.ts +3 -1
  33. package/internal/src/families/create-atom-family.ts +3 -4
  34. package/internal/src/mutable/get-update-family.ts +23 -0
  35. package/internal/src/mutable/index.ts +1 -4
  36. package/internal/src/mutable/is-mutable.ts +44 -0
  37. package/internal/src/mutable/tracker.ts +9 -2
  38. package/internal/src/subject.ts +2 -1
  39. package/internal/src/timeline/add-atom-to-timeline.ts +10 -1
  40. package/internal/src/timeline/create-timeline.ts +44 -16
  41. package/introspection/dist/index.cjs +1566 -46
  42. package/introspection/dist/index.cjs.map +1 -1
  43. package/introspection/dist/index.d.cts +376 -4
  44. package/introspection/dist/index.js +2 -316
  45. package/introspection/dist/index.js.map +1 -1
  46. package/introspection/package.json +5 -5
  47. package/json/dist/index.cjs +1505 -8
  48. package/json/dist/index.cjs.map +1 -1
  49. package/json/dist/index.d.cts +373 -7
  50. package/json/dist/index.js +1 -76
  51. package/json/dist/index.js.map +1 -1
  52. package/json/package.json +5 -5
  53. package/package.json +5 -4
  54. package/react/dist/index.cjs +1549 -14
  55. package/react/dist/index.cjs.map +1 -1
  56. package/react/dist/index.d.cts +377 -4
  57. package/react/dist/index.js +2 -68
  58. package/react/dist/index.js.map +1 -1
  59. package/react/package.json +5 -5
  60. package/react-devtools/dist/index.cjs +2216 -198
  61. package/react-devtools/dist/index.cjs.map +1 -1
  62. package/react-devtools/dist/index.css +2 -2
  63. package/react-devtools/dist/index.d.cts +150 -24
  64. package/react-devtools/dist/index.js +57 -297
  65. package/react-devtools/dist/index.js.map +1 -1
  66. package/react-devtools/package.json +5 -5
  67. package/realtime-client/dist/index.cjs +1530 -35
  68. package/realtime-client/dist/index.cjs.map +1 -1
  69. package/realtime-client/dist/index.d.cts +384 -12
  70. package/realtime-client/dist/index.js +2 -165
  71. package/realtime-client/dist/index.js.map +1 -1
  72. package/realtime-client/package.json +5 -5
  73. package/realtime-react/dist/index.cjs +1727 -35
  74. package/realtime-react/dist/index.cjs.map +1 -1
  75. package/realtime-react/dist/index.d.cts +49 -9
  76. package/realtime-react/dist/index.js +4 -66
  77. package/realtime-react/dist/index.js.map +1 -1
  78. package/realtime-react/package.json +5 -5
  79. package/realtime-server/dist/index.cjs +1549 -58
  80. package/realtime-server/dist/index.cjs.map +1 -1
  81. package/realtime-server/dist/index.d.cts +394 -11
  82. package/realtime-server/dist/index.js +27 -21
  83. package/realtime-server/dist/index.js.map +1 -1
  84. package/realtime-server/package.json +6 -6
  85. package/realtime-testing/dist/index.cjs +2377 -16
  86. package/realtime-testing/dist/index.cjs.map +1 -1
  87. package/realtime-testing/dist/index.d.cts +489 -3
  88. package/realtime-testing/dist/index.js +10 -31
  89. package/realtime-testing/dist/index.js.map +1 -1
  90. package/realtime-testing/package.json +5 -5
  91. package/src/atom.ts +3 -1
  92. package/transceivers/set-rtx/dist/index.cjs +32 -10
  93. package/transceivers/set-rtx/dist/index.cjs.map +1 -1
  94. package/transceivers/set-rtx/dist/index.d.cts +29 -3
  95. package/transceivers/set-rtx/dist/index.js +2 -3
  96. package/transceivers/set-rtx/dist/index.js.map +1 -1
  97. package/transceivers/set-rtx/package.json +6 -6
  98. package/data/dist/index.d.ts +0 -158
  99. package/data/dist/metafile-cjs.json +0 -1
  100. package/data/dist/metafile-esm.json +0 -1
  101. package/dist/index.d.ts +0 -243
  102. package/dist/metafile-esm.json +0 -1
  103. package/internal/dist/index.d.ts +0 -421
  104. package/internal/dist/metafile-cjs.json +0 -1
  105. package/internal/dist/metafile-esm.json +0 -1
  106. package/internal/src/mutable/is-atom-token-mutable.ts +0 -7
  107. package/introspection/dist/index.d.ts +0 -24
  108. package/introspection/dist/metafile-cjs.json +0 -1
  109. package/introspection/dist/metafile-esm.json +0 -1
  110. package/json/dist/index.d.ts +0 -51
  111. package/json/dist/metafile-cjs.json +0 -1
  112. package/json/dist/metafile-esm.json +0 -1
  113. package/react/dist/index.d.ts +0 -23
  114. package/react/dist/metafile-cjs.json +0 -1
  115. package/react/dist/metafile-esm.json +0 -1
  116. package/react-devtools/dist/index.d.ts +0 -341
  117. package/react-devtools/dist/metafile-cjs.json +0 -1
  118. package/react-devtools/dist/metafile-esm.json +0 -1
  119. package/realtime-client/dist/index.d.ts +0 -22
  120. package/realtime-client/dist/metafile-cjs.json +0 -1
  121. package/realtime-client/dist/metafile-esm.json +0 -1
  122. package/realtime-react/dist/index.d.ts +0 -27
  123. package/realtime-react/dist/metafile-cjs.json +0 -1
  124. package/realtime-react/dist/metafile-esm.json +0 -1
  125. package/realtime-server/dist/index.d.ts +0 -25
  126. package/realtime-server/dist/metafile-cjs.json +0 -1
  127. package/realtime-server/dist/metafile-esm.json +0 -1
  128. package/realtime-testing/dist/index.d.ts +0 -49
  129. package/realtime-testing/dist/metafile-cjs.json +0 -1
  130. package/realtime-testing/dist/metafile-esm.json +0 -1
  131. package/transceivers/set-rtx/dist/index.d.ts +0 -40
  132. package/transceivers/set-rtx/dist/metafile-cjs.json +0 -1
  133. package/transceivers/set-rtx/dist/metafile-esm.json +0 -1
@@ -1,27 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var Internal = require('atom.io/internal');
4
-
5
- function _interopNamespace(e) {
6
- if (e && e.__esModule) return e;
7
- var n = Object.create(null);
8
- if (e) {
9
- Object.keys(e).forEach(function (k) {
10
- if (k !== 'default') {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () { return e[k]; }
15
- });
16
- }
17
- });
18
- }
19
- n.default = e;
20
- return Object.freeze(n);
21
- }
22
-
23
- var Internal__namespace = /*#__PURE__*/_interopNamespace(Internal);
24
-
25
3
  var __defProp = Object.defineProperty;
26
4
  var __defProps = Object.defineProperties;
27
5
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -41,8 +19,1540 @@ var __spreadValues = (a, b) => {
41
19
  return a;
42
20
  };
43
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
44
- var attachAtomIndex = (store = Internal.IMPLICIT.STORE) => {
45
- const atomTokenIndexState__INTERNAL = Internal.createAtom(
22
+
23
+ // src/get-state.ts
24
+ function getState(token, store = IMPLICIT.STORE) {
25
+ var _a;
26
+ const state = (_a = withdraw(token, store)) != null ? _a : withdrawNewFamilyMember(token, store);
27
+ if (state === void 0) {
28
+ throw new NotFoundError(token, store);
29
+ }
30
+ return readOrComputeValue(state, store);
31
+ }
32
+
33
+ // src/logger.ts
34
+ var simpleLog = (logLevel) => (icon, tokenType, tokenKey, message, ...rest) => {
35
+ console[logLevel](`${icon} ${tokenType} "${tokenKey}" ${message}`, ...rest);
36
+ };
37
+ var simpleLogger = {
38
+ error: simpleLog(`error`),
39
+ info: simpleLog(`info`),
40
+ warn: simpleLog(`warn`)
41
+ };
42
+ var AtomIOLogger = class {
43
+ constructor(logLevel, filter, logger = simpleLogger) {
44
+ this.logLevel = logLevel;
45
+ this.filter = filter;
46
+ this.logger = logger;
47
+ this.error = (...args) => {
48
+ var _a, _b;
49
+ if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel !== null) {
50
+ this.logger.error(...args);
51
+ }
52
+ };
53
+ this.info = (...args) => {
54
+ var _a, _b;
55
+ if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel === `info`) {
56
+ this.logger.info(...args);
57
+ }
58
+ };
59
+ this.warn = (...args) => {
60
+ var _a, _b;
61
+ if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel !== `error` && this.logLevel !== null) {
62
+ this.logger.warn(...args);
63
+ }
64
+ };
65
+ }
66
+ };
67
+
68
+ // src/set-state.ts
69
+ function setState(token, value, store = IMPLICIT.STORE) {
70
+ var _a;
71
+ const rejection = openOperation(token, store);
72
+ if (rejection) {
73
+ return;
74
+ }
75
+ const state = (_a = withdraw(token, store)) != null ? _a : withdrawNewFamilyMember(token, store);
76
+ if (state === void 0) {
77
+ throw new NotFoundError(token, store);
78
+ }
79
+ setAtomOrSelector(state, value, store);
80
+ closeOperation(store);
81
+ }
82
+
83
+ // internal/src/future.ts
84
+ var Future = class extends Promise {
85
+ constructor(executor) {
86
+ super((resolve, reject) => {
87
+ const pass = (value) => this.isCanceled ? reject(`canceled`) : resolve(value);
88
+ const fail = (reason) => this.isCanceled ? reject(`canceled`) : reject(reason);
89
+ if (typeof executor === `function`) {
90
+ executor(pass, fail);
91
+ } else {
92
+ executor.then(pass, fail);
93
+ }
94
+ });
95
+ this.isCanceled = false;
96
+ }
97
+ cancel() {
98
+ this.isCanceled = true;
99
+ }
100
+ };
101
+
102
+ // internal/src/lineage.ts
103
+ function newest(scion) {
104
+ while (scion.child !== null) {
105
+ scion = scion.child;
106
+ }
107
+ return scion;
108
+ }
109
+
110
+ // internal/src/caching.ts
111
+ function cacheValue(key, value, subject, store) {
112
+ const target = newest(store);
113
+ const currentValue = target.valueMap.get(key);
114
+ if (currentValue instanceof Future) {
115
+ currentValue.cancel();
116
+ }
117
+ if (value instanceof Promise) {
118
+ const future = new Future(value);
119
+ newest(store).valueMap.set(key, future);
120
+ future.then((resolved) => {
121
+ if (future.isCanceled) {
122
+ return;
123
+ }
124
+ cacheValue(key, resolved, subject, store);
125
+ subject.next({ newValue: resolved, oldValue: future });
126
+ }).catch((thrown) => {
127
+ if (thrown !== `canceled`) {
128
+ store.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
129
+ }
130
+ });
131
+ return future;
132
+ }
133
+ target.valueMap.set(key, value);
134
+ return value;
135
+ }
136
+ var readCachedValue = (key, store) => {
137
+ return newest(store).valueMap.get(key);
138
+ };
139
+ var isValueCached = (key, store) => {
140
+ return newest(store).valueMap.has(key);
141
+ };
142
+ var evictCachedValue = (key, store) => {
143
+ const core = newest(store);
144
+ const currentValue = core.valueMap.get(key);
145
+ if (currentValue instanceof Future) {
146
+ currentValue.cancel();
147
+ }
148
+ if (core.operation.open) {
149
+ core.operation.prev.set(key, currentValue);
150
+ }
151
+ core.valueMap.delete(key);
152
+ store.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
153
+ };
154
+
155
+ // ../anvl/src/json/index.ts
156
+ var stringifyJson = (json) => JSON.stringify(json);
157
+
158
+ // json/src/select-json.ts
159
+ var selectJson = (atom, transform, store = IMPLICIT.STORE) => {
160
+ return createSelector(
161
+ {
162
+ key: `${atom.key}:JSON`,
163
+ get: ({ get }) => transform.toJson(get(atom)),
164
+ set: ({ set }, newValue) => set(atom, transform.fromJson(newValue))
165
+ },
166
+ void 0,
167
+ store
168
+ );
169
+ };
170
+
171
+ // internal/src/read-or-compute-value.ts
172
+ var readOrComputeValue = (state, store) => {
173
+ if (isValueCached(state.key, store)) {
174
+ store.logger.info(`\u{1F4D6}`, state.type, state.key, `reading cached value`);
175
+ return readCachedValue(state.key, store);
176
+ }
177
+ if (state.type !== `atom`) {
178
+ store.logger.info(`\u{1F9EE}`, state.type, state.key, `computing value`);
179
+ return state.get();
180
+ }
181
+ const fallback = state.default instanceof Function ? state.default() : state.default;
182
+ store.logger.info(
183
+ `\u{1F481}`,
184
+ `atom`,
185
+ state.key,
186
+ `could not find cached value; using default`,
187
+ fallback
188
+ );
189
+ return state.default instanceof Function ? state.default() : state.default;
190
+ };
191
+
192
+ // internal/src/operation.ts
193
+ var openOperation = (token, store) => {
194
+ const target = newest(store);
195
+ if (target.operation.open) {
196
+ store.logger.error(
197
+ `\u274C`,
198
+ token.type,
199
+ token.key,
200
+ `failed to setState during a setState for "${target.operation.token.key}"`
201
+ );
202
+ return `rejection`;
203
+ }
204
+ target.operation = {
205
+ open: true,
206
+ done: /* @__PURE__ */ new Set(),
207
+ prev: /* @__PURE__ */ new Map(),
208
+ time: Date.now(),
209
+ token
210
+ };
211
+ store.logger.info(
212
+ `\u2B55`,
213
+ token.type,
214
+ token.key,
215
+ `operation start in store "${store.config.name}"${target.transactionMeta === null ? `` : ` ${target.transactionMeta.phase} "${target.transactionMeta.update.key}"`}`
216
+ );
217
+ };
218
+ var closeOperation = (store) => {
219
+ const target = newest(store);
220
+ if (target.operation.open) {
221
+ store.logger.info(
222
+ `\u{1F534}`,
223
+ target.operation.token.type,
224
+ target.operation.token.key,
225
+ `operation done in store "${store.config.name}"`
226
+ );
227
+ }
228
+ target.operation = { open: false };
229
+ store.subject.operationStatus.next(target.operation);
230
+ };
231
+ var isDone = (key, store) => {
232
+ const target = newest(store);
233
+ if (!target.operation.open) {
234
+ store.logger.warn(
235
+ `\u{1F41E}`,
236
+ `unknown`,
237
+ key,
238
+ `isDone called outside of an operation. This is probably a bug.`
239
+ );
240
+ return true;
241
+ }
242
+ return target.operation.done.has(key);
243
+ };
244
+ var markDone = (key, store) => {
245
+ const target = newest(store);
246
+ if (!target.operation.open) {
247
+ store.logger.warn(
248
+ `\u{1F41E}`,
249
+ `unknown`,
250
+ key,
251
+ `markDone called outside of an operation. This is probably a bug.`
252
+ );
253
+ return;
254
+ }
255
+ target.operation.done.add(key);
256
+ };
257
+
258
+ // internal/src/set-state/become.ts
259
+ var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
260
+ originalThing instanceof Function ? originalThing() : originalThing
261
+ ) : nextVersionOfThing;
262
+
263
+ // internal/src/subject.ts
264
+ var Subject = class {
265
+ constructor() {
266
+ this.subscribers = /* @__PURE__ */ new Map();
267
+ }
268
+ subscribe(key, subscriber) {
269
+ this.subscribers.set(key, subscriber);
270
+ const unsubscribe = () => this.unsubscribe(key);
271
+ return unsubscribe;
272
+ }
273
+ unsubscribe(key) {
274
+ this.subscribers.delete(key);
275
+ }
276
+ next(value) {
277
+ const subscribers = this.subscribers.values();
278
+ for (const subscriber of subscribers) {
279
+ subscriber(value);
280
+ }
281
+ }
282
+ };
283
+ var StatefulSubject = class extends Subject {
284
+ constructor(initialState) {
285
+ super();
286
+ this.state = initialState;
287
+ }
288
+ next(value) {
289
+ this.state = value;
290
+ super.next(value);
291
+ }
292
+ };
293
+
294
+ // internal/src/set-state/copy-mutable-if-needed.ts
295
+ function copyMutableIfNeeded(atom, transform, origin, target) {
296
+ const originValue = origin.valueMap.get(atom.key);
297
+ const targetValue = target.valueMap.get(atom.key);
298
+ if (originValue === targetValue) {
299
+ origin.logger.info(`\u{1F4C3}`, `atom`, `${atom.key}`, `copying`);
300
+ const jsonValue = transform.toJson(originValue);
301
+ const copiedValue = transform.fromJson(jsonValue);
302
+ target.valueMap.set(atom.key, copiedValue);
303
+ new Tracker(atom, origin);
304
+ return copiedValue;
305
+ }
306
+ return targetValue;
307
+ }
308
+
309
+ // internal/src/set-state/copy-mutable-in-transaction.ts
310
+ function copyMutableIfWithinTransaction(oldValue, atom, store) {
311
+ const target = newest(store);
312
+ const parent = target.parent;
313
+ if (parent !== null) {
314
+ if (`toJson` in atom && `fromJson` in atom) {
315
+ const copiedValue = copyMutableIfNeeded(atom, atom, parent, target);
316
+ return copiedValue;
317
+ }
318
+ if (`family` in atom) {
319
+ const family = parent.families.get(atom.family.key);
320
+ if (family && family.type === `atom_family`) {
321
+ const result = copyMutableFamilyMemberWithinTransaction(
322
+ atom,
323
+ family,
324
+ parent,
325
+ target
326
+ );
327
+ if (result) {
328
+ return result;
329
+ }
330
+ }
331
+ }
332
+ }
333
+ return oldValue;
334
+ }
335
+ function copyMutableFamilyMemberWithinTransaction(atom, family, origin, target) {
336
+ if (`toJson` in family && `fromJson` in family) {
337
+ const copyCreated = copyMutableIfNeeded(atom, family, origin, target);
338
+ return copyCreated;
339
+ }
340
+ return null;
341
+ }
342
+
343
+ // internal/src/set-state/emit-update.ts
344
+ var emitUpdate = (state, update, store) => {
345
+ store.logger.info(
346
+ `\u{1F4E2}`,
347
+ state.type,
348
+ state.key,
349
+ `went (`,
350
+ update.oldValue,
351
+ `->`,
352
+ update.newValue,
353
+ `) subscribers:`,
354
+ state.subject.subscribers
355
+ );
356
+ state.subject.next(update);
357
+ };
358
+
359
+ // internal/src/set-state/evict-downstream.ts
360
+ var evictDownStream = (atom, store) => {
361
+ const target = newest(store);
362
+ const downstreamKeys = target.selectorAtoms.getRelatedKeys(atom.key);
363
+ store.logger.info(
364
+ `\u{1F9F9}`,
365
+ atom.type,
366
+ atom.key,
367
+ downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`,
368
+ downstreamKeys != null ? downstreamKeys : `to evict`
369
+ );
370
+ if (downstreamKeys) {
371
+ if (target.operation.open) {
372
+ store.logger.info(
373
+ `\u{1F9F9}`,
374
+ atom.type,
375
+ atom.key,
376
+ `[ ${[...target.operation.done].join(`, `)} ] already done`
377
+ );
378
+ }
379
+ for (const key of downstreamKeys) {
380
+ if (isDone(key, store)) {
381
+ continue;
382
+ }
383
+ evictCachedValue(key, store);
384
+ markDone(key, store);
385
+ }
386
+ }
387
+ };
388
+
389
+ // internal/src/set-state/stow-update.ts
390
+ function shouldUpdateBeStowed(key, update) {
391
+ if (isTransceiver(update.newValue)) {
392
+ return false;
393
+ }
394
+ if (key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
395
+ return false;
396
+ }
397
+ return true;
398
+ }
399
+ var stowUpdate = (state, update, store) => {
400
+ const { key } = state;
401
+ const target = newest(store);
402
+ if (target.transactionMeta === null || target.transactionMeta.phase !== `building`) {
403
+ store.logger.error(
404
+ `\u{1F41E}`,
405
+ `atom`,
406
+ key,
407
+ `stowUpdate called outside of a transaction. This is probably a bug.`
408
+ );
409
+ return;
410
+ }
411
+ const shouldStow = shouldUpdateBeStowed(key, update);
412
+ if (!shouldStow) {
413
+ return;
414
+ }
415
+ const atomUpdate = __spreadValues({ key }, update);
416
+ if (state.family) {
417
+ atomUpdate.family = state.family;
418
+ }
419
+ target.transactionMeta.update.updates.push(atomUpdate);
420
+ store.logger.info(
421
+ `\u{1F4C1}`,
422
+ `atom`,
423
+ key,
424
+ `stowed (`,
425
+ update.oldValue,
426
+ `->`,
427
+ update.newValue,
428
+ `)`
429
+ );
430
+ };
431
+
432
+ // internal/src/set-state/set-atom.ts
433
+ var setAtom = (atom, next, store) => {
434
+ const target = newest(store);
435
+ const oldValue = readOrComputeValue(atom, store);
436
+ let newValue = copyMutableIfWithinTransaction(oldValue, atom, store);
437
+ newValue = become(next)(newValue);
438
+ store.logger.info(`\u{1F4DD}`, `atom`, atom.key, `set to`, newValue);
439
+ newValue = cacheValue(atom.key, newValue, atom.subject, store);
440
+ if (isAtomDefault(atom.key, store)) {
441
+ markAtomAsNotDefault(atom.key, store);
442
+ }
443
+ markDone(atom.key, store);
444
+ evictDownStream(atom, store);
445
+ const update = { oldValue, newValue };
446
+ if (target.transactionMeta === null || target.transactionMeta.phase === `applying`) {
447
+ emitUpdate(atom, update, store);
448
+ } else {
449
+ stowUpdate(atom, update, store);
450
+ }
451
+ };
452
+
453
+ // internal/src/set-state/set-atom-or-selector.ts
454
+ var setAtomOrSelector = (state, value, store) => {
455
+ if (state.type === `selector`) {
456
+ state.set(value);
457
+ } else {
458
+ setAtom(state, value, store);
459
+ }
460
+ };
461
+
462
+ // internal/src/store/deposit.ts
463
+ function deposit(state) {
464
+ const token = {
465
+ key: state.key,
466
+ type: state.type
467
+ };
468
+ if (`family` in state) {
469
+ token.family = state.family;
470
+ }
471
+ return token;
472
+ }
473
+
474
+ // ../rel8/junction/src/junction.ts
475
+ var Junction = class {
476
+ constructor(data, config) {
477
+ this.relations = /* @__PURE__ */ new Map();
478
+ this.contents = /* @__PURE__ */ new Map();
479
+ this.makeContentKey = (a, b) => `${a}:${b}`;
480
+ var _a, _b, _c, _d;
481
+ this.a = data.between[0];
482
+ this.b = data.between[1];
483
+ this.cardinality = data.cardinality;
484
+ if (!(config == null ? void 0 : config.externalStore)) {
485
+ this.relations = new Map((_a = data.relations) == null ? void 0 : _a.map(([a, b]) => [a, new Set(b)]));
486
+ this.contents = new Map(data.contents);
487
+ }
488
+ this.isContent = (_b = config == null ? void 0 : config.isContent) != null ? _b : null;
489
+ if (config == null ? void 0 : config.makeContentKey) {
490
+ this.makeContentKey = config.makeContentKey;
491
+ }
492
+ if (config == null ? void 0 : config.externalStore) {
493
+ const externalStore = config.externalStore;
494
+ this.has = (a, b) => externalStore.has(a, b);
495
+ this.addRelation = (a, b) => {
496
+ externalStore.addRelation(a, b);
497
+ };
498
+ this.deleteRelation = (a, b) => {
499
+ externalStore.deleteRelation(a, b);
500
+ };
501
+ this.replaceRelationsSafely = (a, bs) => {
502
+ externalStore.replaceRelationsSafely(a, bs);
503
+ };
504
+ this.replaceRelationsUnsafely = (a, bs) => {
505
+ externalStore.replaceRelationsUnsafely(a, bs);
506
+ };
507
+ this.getRelatedKeys = (key) => externalStore.getRelatedKeys(key);
508
+ if (externalStore.getContent) {
509
+ this.getContentInternal = (contentKey) => {
510
+ return externalStore.getContent(contentKey);
511
+ };
512
+ this.setContent = (contentKey, content) => {
513
+ externalStore.setContent(contentKey, content);
514
+ };
515
+ this.deleteContent = (contentKey) => {
516
+ externalStore.deleteContent(contentKey);
517
+ };
518
+ }
519
+ for (const [x, ys] of (_c = data.relations) != null ? _c : []) {
520
+ for (const y of ys)
521
+ this.addRelation(x, y);
522
+ }
523
+ for (const [contentKey, content] of (_d = data.contents) != null ? _d : []) {
524
+ this.setContent(contentKey, content);
525
+ }
526
+ }
527
+ }
528
+ getRelatedKeys(key) {
529
+ return this.relations.get(key);
530
+ }
531
+ addRelation(a, b) {
532
+ let aRelations = this.relations.get(a);
533
+ let bRelations = this.relations.get(b);
534
+ if (aRelations) {
535
+ aRelations.add(b);
536
+ } else {
537
+ aRelations = /* @__PURE__ */ new Set([b]);
538
+ this.relations.set(a, aRelations);
539
+ }
540
+ if (bRelations) {
541
+ bRelations.add(a);
542
+ } else {
543
+ bRelations = /* @__PURE__ */ new Set([a]);
544
+ this.relations.set(b, bRelations);
545
+ }
546
+ }
547
+ deleteRelation(a, b) {
548
+ const aRelations = this.relations.get(a);
549
+ if (aRelations) {
550
+ aRelations.delete(b);
551
+ if (aRelations.size === 0) {
552
+ this.relations.delete(a);
553
+ }
554
+ const bRelations = this.relations.get(b);
555
+ if (bRelations) {
556
+ bRelations.delete(a);
557
+ if (bRelations.size === 0) {
558
+ this.relations.delete(b);
559
+ }
560
+ }
561
+ }
562
+ }
563
+ replaceRelationsUnsafely(a, bs) {
564
+ this.relations.set(a, new Set(bs));
565
+ for (const b of bs) {
566
+ const bRelations = /* @__PURE__ */ new Set([a]);
567
+ this.relations.set(b, bRelations);
568
+ }
569
+ }
570
+ replaceRelationsSafely(a, bs) {
571
+ const aRelationsPrev = this.relations.get(a);
572
+ if (aRelationsPrev) {
573
+ for (const b of aRelationsPrev) {
574
+ const bRelations = this.relations.get(b);
575
+ if (bRelations) {
576
+ if (bRelations.size === 1) {
577
+ this.relations.delete(b);
578
+ } else {
579
+ bRelations.delete(a);
580
+ }
581
+ this.contents.delete(this.makeContentKey(a, b));
582
+ }
583
+ }
584
+ }
585
+ this.relations.set(a, new Set(bs));
586
+ for (const b of bs) {
587
+ let bRelations = this.relations.get(b);
588
+ if (bRelations) {
589
+ bRelations.add(a);
590
+ } else {
591
+ bRelations = /* @__PURE__ */ new Set([a]);
592
+ this.relations.set(b, bRelations);
593
+ }
594
+ }
595
+ }
596
+ getContentInternal(contentKey) {
597
+ return this.contents.get(contentKey);
598
+ }
599
+ setContent(contentKey, content) {
600
+ this.contents.set(contentKey, content);
601
+ }
602
+ deleteContent(contentKey) {
603
+ this.contents.delete(contentKey);
604
+ }
605
+ toJSON() {
606
+ return {
607
+ between: [this.a, this.b],
608
+ cardinality: this.cardinality,
609
+ relations: [...this.relations.entries()].map(([a, b]) => [a, [...b]]),
610
+ contents: [...this.contents.entries()]
611
+ };
612
+ }
613
+ set(a, ...rest) {
614
+ var _a;
615
+ const b = typeof rest[0] === `string` ? rest[0] : a[this.b];
616
+ const content = ((_a = rest[1]) != null ? _a : typeof rest[0] === `string`) ? void 0 : rest[0];
617
+ a = typeof a === `string` ? a : a[this.a];
618
+ switch (this.cardinality) {
619
+ case `1:1`: {
620
+ const bPrev = this.getRelatedKey(a);
621
+ if (bPrev && bPrev !== b)
622
+ this.delete(bPrev, a);
623
+ }
624
+ case `1:n`: {
625
+ const aPrev = this.getRelatedKey(b);
626
+ if (aPrev && aPrev !== a)
627
+ this.delete(aPrev, b);
628
+ }
629
+ }
630
+ if (content) {
631
+ const contentKey = this.makeContentKey(a, b);
632
+ this.setContent(contentKey, content);
633
+ }
634
+ this.addRelation(a, b);
635
+ return this;
636
+ }
637
+ delete(x, b) {
638
+ b = typeof b === `string` ? b : x[this.b];
639
+ const a = typeof x === `string` ? x : x[this.a];
640
+ if (a === void 0 && typeof b === `string`) {
641
+ const bRelations = this.getRelatedKeys(b);
642
+ if (bRelations) {
643
+ for (const a2 of bRelations) {
644
+ this.delete(a2, b);
645
+ }
646
+ }
647
+ }
648
+ if (typeof a === `string` && b === void 0) {
649
+ const aRelations = this.getRelatedKeys(a);
650
+ if (aRelations) {
651
+ for (const b2 of aRelations) {
652
+ this.delete(a, b2);
653
+ }
654
+ }
655
+ }
656
+ if (typeof a === `string` && typeof b === `string`) {
657
+ this.deleteRelation(a, b);
658
+ const contentKey = this.makeContentKey(a, b);
659
+ this.deleteContent(contentKey);
660
+ }
661
+ return this;
662
+ }
663
+ getRelatedKey(key) {
664
+ const relations = this.getRelatedKeys(key);
665
+ if (relations) {
666
+ if (relations.size > 1) {
667
+ console.warn(
668
+ `${relations.size} related keys were found for key "${key}": (${[
669
+ ...relations
670
+ ].map((k) => `"${k}"`).join(`, `)}). Only one related key was expected.`
671
+ );
672
+ }
673
+ for (const relation of relations) {
674
+ return relation;
675
+ }
676
+ }
677
+ }
678
+ replaceRelations(a, relations, config) {
679
+ const hasContent = !Array.isArray(relations);
680
+ const bs = hasContent ? Object.keys(relations) : relations;
681
+ if (config == null ? void 0 : config.reckless) {
682
+ this.replaceRelationsUnsafely(a, bs);
683
+ } else {
684
+ this.replaceRelationsSafely(a, bs);
685
+ }
686
+ if (hasContent) {
687
+ for (const b of bs) {
688
+ const contentKey = this.makeContentKey(a, b);
689
+ const content = relations[b];
690
+ this.setContent(contentKey, content);
691
+ }
692
+ }
693
+ return this;
694
+ }
695
+ getContent(a, b) {
696
+ const contentKey = this.makeContentKey(a, b);
697
+ return this.getContentInternal(contentKey);
698
+ }
699
+ getRelationEntries(input) {
700
+ const a = input[this.a];
701
+ const b = input[this.b];
702
+ if (a !== void 0 && b === void 0) {
703
+ const aRelations = this.getRelatedKeys(a);
704
+ if (aRelations) {
705
+ return [...aRelations].map((b2) => {
706
+ var _a;
707
+ return [b2, (_a = this.getContent(a, b2)) != null ? _a : null];
708
+ });
709
+ }
710
+ }
711
+ if (a === void 0 && b !== void 0) {
712
+ const bRelations = this.getRelatedKeys(b);
713
+ if (bRelations) {
714
+ return [...bRelations].map((a2) => {
715
+ var _a;
716
+ return [a2, (_a = this.getContent(a2, b)) != null ? _a : null];
717
+ });
718
+ }
719
+ }
720
+ return [];
721
+ }
722
+ has(a, b) {
723
+ var _a;
724
+ if (b) {
725
+ const setA = this.getRelatedKeys(a);
726
+ return (_a = setA == null ? void 0 : setA.has(b)) != null ? _a : false;
727
+ }
728
+ return this.relations.has(a);
729
+ }
730
+ };
731
+
732
+ // internal/src/store/store.ts
733
+ var Store = class {
734
+ constructor(name, store = null) {
735
+ this.parent = null;
736
+ this.child = null;
737
+ this.valueMap = /* @__PURE__ */ new Map();
738
+ this.atoms = /* @__PURE__ */ new Map();
739
+ this.selectors = /* @__PURE__ */ new Map();
740
+ this.readonlySelectors = /* @__PURE__ */ new Map();
741
+ this.trackers = /* @__PURE__ */ new Map();
742
+ this.families = /* @__PURE__ */ new Map();
743
+ this.timelines = /* @__PURE__ */ new Map();
744
+ this.transactions = /* @__PURE__ */ new Map();
745
+ this.atomsThatAreDefault = /* @__PURE__ */ new Set();
746
+ this.timelineAtoms = new Junction({
747
+ between: [`timelineKey`, `atomKey`],
748
+ cardinality: `1:n`
749
+ });
750
+ this.selectorAtoms = new Junction({
751
+ between: [`selectorKey`, `atomKey`],
752
+ cardinality: `n:n`
753
+ });
754
+ this.selectorGraph = new Junction(
755
+ {
756
+ between: [`upstreamSelectorKey`, `downstreamSelectorKey`],
757
+ cardinality: `n:n`
758
+ },
759
+ {
760
+ makeContentKey: (...keys) => keys.sort().join(`:`)
761
+ }
762
+ );
763
+ this.subject = {
764
+ atomCreation: new Subject(),
765
+ selectorCreation: new Subject(),
766
+ transactionCreation: new Subject(),
767
+ timelineCreation: new Subject(),
768
+ transactionApplying: new StatefulSubject(null),
769
+ operationStatus: new Subject()
770
+ };
771
+ this.operation = { open: false };
772
+ this.transactionMeta = null;
773
+ this.config = {
774
+ name: `IMPLICIT_STORE`
775
+ };
776
+ this.loggers = [
777
+ new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
778
+ ];
779
+ this.logger = {
780
+ error: (...messages) => {
781
+ for (const logger of this.loggers)
782
+ logger.error(...messages);
783
+ },
784
+ info: (...messages) => {
785
+ for (const logger of this.loggers)
786
+ logger.info(...messages);
787
+ },
788
+ warn: (...messages) => {
789
+ for (const logger of this.loggers)
790
+ logger.warn(...messages);
791
+ }
792
+ };
793
+ if (store !== null) {
794
+ this.valueMap = new Map(store == null ? void 0 : store.valueMap);
795
+ this.operation = __spreadValues({}, store == null ? void 0 : store.operation);
796
+ this.transactionMeta = (store == null ? void 0 : store.transactionMeta) ? __spreadValues({}, store == null ? void 0 : store.transactionMeta) : null;
797
+ this.config = __spreadProps(__spreadValues({}, store == null ? void 0 : store.config), {
798
+ name
799
+ });
800
+ for (const [, atom] of store.atoms) {
801
+ atom.install(this);
802
+ }
803
+ for (const [, selector] of store.readonlySelectors) {
804
+ selector.install(this);
805
+ }
806
+ for (const [, selector] of store.selectors) {
807
+ selector.install(this);
808
+ }
809
+ for (const [, tx] of store.transactions) {
810
+ tx.install(this);
811
+ }
812
+ for (const [, timeline] of store.timelines) {
813
+ timeline.install(this);
814
+ }
815
+ }
816
+ }
817
+ };
818
+ var IMPLICIT = {
819
+ STORE_INTERNAL: void 0,
820
+ get STORE() {
821
+ var _a;
822
+ return (_a = this.STORE_INTERNAL) != null ? _a : this.STORE_INTERNAL = new Store(`IMPLICIT_STORE`);
823
+ }
824
+ };
825
+
826
+ // internal/src/store/withdraw.ts
827
+ function withdraw(token, store) {
828
+ var _a, _b, _c, _d;
829
+ const target = newest(store);
830
+ const state = (_d = (_c = (_b = (_a = target.atoms.get(token.key)) != null ? _a : 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);
831
+ if (state) {
832
+ return state;
833
+ }
834
+ return void 0;
835
+ }
836
+
837
+ // internal/src/store/withdraw-new-family-member.ts
838
+ function withdrawNewFamilyMember(token, store) {
839
+ if (token.family) {
840
+ store.logger.info(
841
+ `\u{1F46A}`,
842
+ token.type,
843
+ token.key,
844
+ `creating new family member in store "${store.config.name}"`
845
+ );
846
+ const target = newest(store);
847
+ const family = target.families.get(token.family.key);
848
+ if (family) {
849
+ const jsonSubKey = JSON.parse(token.family.subKey);
850
+ family(jsonSubKey);
851
+ const state = withdraw(token, store);
852
+ return state;
853
+ }
854
+ }
855
+ return void 0;
856
+ }
857
+
858
+ // internal/src/keys.ts
859
+ var isAtomKey = (key, store) => newest(store).atoms.has(key);
860
+ var isSelectorKey = (key, store) => newest(store).selectors.has(key);
861
+ var isReadonlySelectorKey = (key, store) => newest(store).readonlySelectors.has(key);
862
+ var isStateKey = (key, store) => isAtomKey(key, store) || isSelectorKey(key, store) || isReadonlySelectorKey(key, store);
863
+
864
+ // internal/src/selector/get-selector-dependency-keys.ts
865
+ var getSelectorDependencyKeys = (key, store) => {
866
+ const sources = newest(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(source, store));
867
+ return sources;
868
+ };
869
+
870
+ // internal/src/selector/trace-selector-atoms.ts
871
+ var traceSelectorAtoms = (selectorKey, directDependencyKey, store) => {
872
+ const rootKeys = [];
873
+ const indirectDependencyKeys = getSelectorDependencyKeys(
874
+ directDependencyKey,
875
+ store
876
+ );
877
+ let depth = 0;
878
+ while (indirectDependencyKeys.length > 0) {
879
+ const indirectDependencyKey = indirectDependencyKeys.shift();
880
+ ++depth;
881
+ if (depth > 99999) {
882
+ throw new Error(
883
+ `Maximum selector dependency depth exceeded (> 99999) in selector "${selectorKey}". This is likely due to a circular dependency.`
884
+ );
885
+ }
886
+ if (!isAtomKey(indirectDependencyKey, store)) {
887
+ indirectDependencyKeys.push(
888
+ ...getSelectorDependencyKeys(indirectDependencyKey, store)
889
+ );
890
+ } else if (!rootKeys.includes(indirectDependencyKey)) {
891
+ rootKeys.push(indirectDependencyKey);
892
+ }
893
+ }
894
+ return rootKeys;
895
+ };
896
+ var traceAllSelectorAtoms = (selectorKey, store) => {
897
+ const directDependencyKeys = getSelectorDependencyKeys(selectorKey, store);
898
+ return directDependencyKeys.flatMap(
899
+ (depKey) => isAtomKey(depKey, store) ? depKey : traceSelectorAtoms(selectorKey, depKey, store)
900
+ );
901
+ };
902
+
903
+ // internal/src/selector/update-selector-atoms.ts
904
+ var updateSelectorAtoms = (selectorKey, dependency, store) => {
905
+ const target = newest(store);
906
+ if (dependency.type === `atom`) {
907
+ target.selectorAtoms.set({
908
+ selectorKey,
909
+ atomKey: dependency.key
910
+ });
911
+ store.logger.info(
912
+ `\u{1F50D}`,
913
+ `selector`,
914
+ selectorKey,
915
+ `discovers root atom "${dependency.key}"`
916
+ );
917
+ } else {
918
+ const rootKeys = traceSelectorAtoms(selectorKey, dependency.key, store);
919
+ store.logger.info(
920
+ `\u{1F50D}`,
921
+ `selector`,
922
+ selectorKey,
923
+ `discovers root atoms: [ ${rootKeys.map((key) => `"${key}"`).join(`, `)} ]`
924
+ );
925
+ for (const atomKey of rootKeys) {
926
+ target.selectorAtoms = target.selectorAtoms.set({
927
+ selectorKey,
928
+ atomKey
929
+ });
930
+ }
931
+ }
932
+ };
933
+
934
+ // internal/src/selector/register-selector.ts
935
+ var registerSelector = (selectorKey, store) => ({
936
+ get: (dependency) => {
937
+ const target = newest(store);
938
+ const alreadyRegistered = target.selectorGraph.getRelationEntries({ downstreamSelectorKey: selectorKey }).some(([_, { source }]) => source === dependency.key);
939
+ const dependencyState = withdraw(dependency, store);
940
+ if (dependencyState === void 0) {
941
+ throw new Error(
942
+ `State "${dependency.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
943
+ );
944
+ }
945
+ const dependencyValue = readOrComputeValue(dependencyState, store);
946
+ store.logger.info(
947
+ `\u{1F50C}`,
948
+ `selector`,
949
+ selectorKey,
950
+ `registers dependency ( "${dependency.key}" =`,
951
+ dependencyValue,
952
+ `)`
953
+ );
954
+ if (!alreadyRegistered) {
955
+ target.selectorGraph.set(
956
+ {
957
+ upstreamSelectorKey: dependency.key,
958
+ downstreamSelectorKey: selectorKey
959
+ },
960
+ {
961
+ source: dependency.key
962
+ }
963
+ );
964
+ }
965
+ updateSelectorAtoms(selectorKey, dependency, store);
966
+ return dependencyValue;
967
+ },
968
+ set: (stateToken, newValue) => {
969
+ const state = withdraw(stateToken, store);
970
+ if (state === void 0) {
971
+ throw new Error(
972
+ `State "${stateToken.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
973
+ );
974
+ }
975
+ setAtomOrSelector(state, newValue, store);
976
+ }
977
+ });
978
+
979
+ // internal/src/selector/create-read-write-selector.ts
980
+ var createReadWriteSelector = (options, family, store) => {
981
+ const target = newest(store);
982
+ const subject = new Subject();
983
+ const { get, set } = registerSelector(options.key, store);
984
+ const getSelf = () => {
985
+ const value = options.get({ get });
986
+ cacheValue(options.key, value, subject, store);
987
+ return value;
988
+ };
989
+ const setSelf = (next) => {
990
+ const oldValue = getSelf();
991
+ const newValue = become(next)(oldValue);
992
+ store.logger.info(
993
+ `\u{1F4DD}`,
994
+ `selector`,
995
+ options.key,
996
+ `set (`,
997
+ oldValue,
998
+ `->`,
999
+ newValue,
1000
+ `)`
1001
+ );
1002
+ cacheValue(options.key, newValue, subject, store);
1003
+ markDone(options.key, store);
1004
+ if (target.transactionMeta === null) {
1005
+ subject.next({ newValue, oldValue });
1006
+ }
1007
+ options.set({ get, set }, newValue);
1008
+ };
1009
+ const mySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
1010
+ subject,
1011
+ install: (s) => createSelector(options, family, s),
1012
+ get: getSelf,
1013
+ set: setSelf,
1014
+ type: `selector`
1015
+ }), family && { family });
1016
+ target.selectors.set(options.key, mySelector);
1017
+ const initialValue = getSelf();
1018
+ store.logger.info(`\u2728`, mySelector.type, mySelector.key, `=`, initialValue);
1019
+ const token = {
1020
+ key: options.key,
1021
+ type: `selector`
1022
+ };
1023
+ if (family) {
1024
+ token.family = family;
1025
+ }
1026
+ store.subject.selectorCreation.next(token);
1027
+ return token;
1028
+ };
1029
+
1030
+ // internal/src/selector/create-readonly-selector.ts
1031
+ var createReadonlySelector = (options, family, store) => {
1032
+ const target = newest(store);
1033
+ const subject = new Subject();
1034
+ const { get } = registerSelector(options.key, store);
1035
+ const getSelf = () => {
1036
+ const value = options.get({ get });
1037
+ cacheValue(options.key, value, subject, store);
1038
+ return value;
1039
+ };
1040
+ const readonlySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
1041
+ subject,
1042
+ install: (s) => createSelector(options, family, s),
1043
+ get: getSelf,
1044
+ type: `readonly_selector`
1045
+ }), family && { family });
1046
+ target.readonlySelectors.set(options.key, readonlySelector);
1047
+ const initialValue = getSelf();
1048
+ store.logger.info(
1049
+ `\u2728`,
1050
+ readonlySelector.type,
1051
+ readonlySelector.key,
1052
+ `=`,
1053
+ initialValue
1054
+ );
1055
+ const token = {
1056
+ key: options.key,
1057
+ type: `readonly_selector`
1058
+ };
1059
+ if (family) {
1060
+ token.family = family;
1061
+ }
1062
+ store.subject.selectorCreation.next(token);
1063
+ return token;
1064
+ };
1065
+
1066
+ // internal/src/selector/create-selector.ts
1067
+ function createSelector(options, family, store) {
1068
+ const target = newest(store);
1069
+ const existingWritable = target.selectors.get(options.key);
1070
+ const existingReadonly = target.readonlySelectors.get(options.key);
1071
+ if (existingWritable || existingReadonly) {
1072
+ store.logger.error(
1073
+ `\u274C`,
1074
+ existingReadonly ? `readonly_selector` : `selector`,
1075
+ options.key,
1076
+ `Tried to create selector, but it already exists in the store. (Ignore if you are in development using hot module replacement.)`
1077
+ );
1078
+ }
1079
+ if (`set` in options) {
1080
+ return createReadWriteSelector(options, family, store);
1081
+ }
1082
+ return createReadonlySelector(options, family, store);
1083
+ }
1084
+
1085
+ // internal/src/subscribe/recall-state.ts
1086
+ var recallState = (state, store) => {
1087
+ const target = newest(store);
1088
+ if (!target.operation.open) {
1089
+ return target.valueMap.get(state.key);
1090
+ }
1091
+ return target.operation.prev.get(state.key);
1092
+ };
1093
+
1094
+ // internal/src/subscribe/subscribe-to-root-atoms.ts
1095
+ var subscribeToRootAtoms = (state, store) => {
1096
+ const dependencySubscriptions = `default` in state ? null : traceAllSelectorAtoms(state.key, store).map((atomKey) => {
1097
+ const atom = store.atoms.get(atomKey);
1098
+ if (atom === void 0) {
1099
+ throw new Error(
1100
+ `Atom "${atomKey}", a dependency of selector "${state.key}", not found in store "${store.config.name}".`
1101
+ );
1102
+ }
1103
+ return atom.subject.subscribe(
1104
+ `${state.type}:${state.key}`,
1105
+ (atomChange) => {
1106
+ store.logger.info(
1107
+ `\u{1F4E2}`,
1108
+ state.type,
1109
+ state.key,
1110
+ `root`,
1111
+ atomKey,
1112
+ `went`,
1113
+ atomChange.oldValue,
1114
+ `->`,
1115
+ atomChange.newValue
1116
+ );
1117
+ const oldValue = recallState(state, store);
1118
+ const newValue = readOrComputeValue(state, store);
1119
+ store.logger.info(
1120
+ `\u2728`,
1121
+ state.type,
1122
+ state.key,
1123
+ `went`,
1124
+ oldValue,
1125
+ `->`,
1126
+ newValue
1127
+ );
1128
+ state.subject.next({ newValue, oldValue });
1129
+ }
1130
+ );
1131
+ });
1132
+ return dependencySubscriptions;
1133
+ };
1134
+
1135
+ // internal/src/subscribe/subscribe-to-state.ts
1136
+ function subscribeToState(token, handleUpdate, key, store) {
1137
+ const state = withdraw(token, store);
1138
+ if (state === void 0) {
1139
+ throw new Error(
1140
+ `State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
1141
+ );
1142
+ }
1143
+ const unsubFunction = state.subject.subscribe(key, handleUpdate);
1144
+ store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
1145
+ const dependencyUnsubFunctions = state.type !== `atom` ? subscribeToRootAtoms(state, store) : null;
1146
+ const unsubscribe = dependencyUnsubFunctions === null ? () => {
1147
+ store.logger.info(
1148
+ `\u{1F648}`,
1149
+ state.type,
1150
+ state.key,
1151
+ `Removing subscription "${key}"`
1152
+ );
1153
+ unsubFunction();
1154
+ } : () => {
1155
+ store.logger.info(
1156
+ `\u{1F648}`,
1157
+ state.type,
1158
+ state.key,
1159
+ `Removing subscription "${key}"`
1160
+ );
1161
+ unsubFunction();
1162
+ for (const unsubFromDependency of dependencyUnsubFunctions) {
1163
+ unsubFromDependency();
1164
+ }
1165
+ };
1166
+ return unsubscribe;
1167
+ }
1168
+
1169
+ // internal/src/subscribe/subscribe-to-timeline.ts
1170
+ var subscribeToTimeline = (token, handleUpdate, key, store) => {
1171
+ const tl = withdraw(token, store);
1172
+ if (tl === void 0) {
1173
+ throw new Error(
1174
+ `Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
1175
+ );
1176
+ }
1177
+ store.logger.info(`\u{1F440}`, `timeline`, token.key, `Adding subscription "${key}"`);
1178
+ const unsubscribe = tl.subject.subscribe(key, handleUpdate);
1179
+ return () => {
1180
+ store.logger.info(
1181
+ `\u{1F648}`,
1182
+ `timeline`,
1183
+ token.key,
1184
+ `Removing subscription "${key}" from timeline`
1185
+ );
1186
+ unsubscribe();
1187
+ };
1188
+ };
1189
+
1190
+ // internal/src/mutable/tracker.ts
1191
+ var Tracker = class {
1192
+ constructor(mutableState, store) {
1193
+ this.unsubscribeFromInnerValue = null;
1194
+ this.mutableState = mutableState;
1195
+ const target = newest(store);
1196
+ this.latestUpdateState = this.initializeState(mutableState, target);
1197
+ this.observeCore(mutableState, this.latestUpdateState, target);
1198
+ this.updateCore(mutableState, this.latestUpdateState, target);
1199
+ target.trackers.set(mutableState.key, this);
1200
+ }
1201
+ initializeState(mutableState, store) {
1202
+ const latestUpdateStateKey = `*${mutableState.key}`;
1203
+ store.atoms.delete(latestUpdateStateKey);
1204
+ store.valueMap.delete(latestUpdateStateKey);
1205
+ const familyMetaData = mutableState.family ? {
1206
+ key: `*${mutableState.family.key}`,
1207
+ subKey: mutableState.family.subKey
1208
+ } : void 0;
1209
+ const latestUpdateState = createAtom(
1210
+ {
1211
+ key: latestUpdateStateKey,
1212
+ default: null
1213
+ },
1214
+ familyMetaData,
1215
+ store
1216
+ );
1217
+ if (store.parent) {
1218
+ const parentValue = store.parent.valueMap.get(latestUpdateStateKey);
1219
+ store.valueMap.set(latestUpdateStateKey, parentValue);
1220
+ }
1221
+ return latestUpdateState;
1222
+ }
1223
+ observeCore(mutableState, latestUpdateState, store) {
1224
+ const originalInnerValue = getState(mutableState, store);
1225
+ const target = newest(store);
1226
+ this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
1227
+ `tracker:${store.config.name}:${target.transactionMeta === null ? `main` : target.transactionMeta.update.key}`,
1228
+ (update) => {
1229
+ const unsubscribe = store.subject.operationStatus.subscribe(
1230
+ mutableState.key,
1231
+ () => {
1232
+ unsubscribe();
1233
+ setState(latestUpdateState, update, store);
1234
+ }
1235
+ );
1236
+ }
1237
+ );
1238
+ subscribeToState(
1239
+ mutableState,
1240
+ (update) => {
1241
+ var _a;
1242
+ if (update.newValue !== update.oldValue) {
1243
+ (_a = this.unsubscribeFromInnerValue) == null ? void 0 : _a.call(this);
1244
+ const target2 = newest(store);
1245
+ this.unsubscribeFromInnerValue = update.newValue.subscribe(
1246
+ `tracker:${store.config.name}:${target2.transactionMeta === null ? `main` : target2.transactionMeta.update.key}`,
1247
+ (update2) => {
1248
+ const unsubscribe = store.subject.operationStatus.subscribe(
1249
+ mutableState.key,
1250
+ () => {
1251
+ unsubscribe();
1252
+ setState(latestUpdateState, update2, store);
1253
+ }
1254
+ );
1255
+ }
1256
+ );
1257
+ }
1258
+ },
1259
+ `${store.config.name}: tracker observing inner value`,
1260
+ store
1261
+ );
1262
+ }
1263
+ updateCore(mutableState, latestUpdateState, store) {
1264
+ subscribeToState(
1265
+ latestUpdateState,
1266
+ ({ newValue, oldValue }) => {
1267
+ const timelineId = store.timelineAtoms.getRelatedKey(
1268
+ latestUpdateState.key
1269
+ );
1270
+ if (timelineId) {
1271
+ const timelineData = store.timelines.get(timelineId);
1272
+ if (timelineData == null ? void 0 : timelineData.timeTraveling) {
1273
+ const unsubscribe2 = subscribeToTimeline(
1274
+ { key: timelineId, type: `timeline` },
1275
+ (update) => {
1276
+ unsubscribe2();
1277
+ setState(
1278
+ mutableState,
1279
+ (transceiver) => {
1280
+ if (update === `redo` && newValue) {
1281
+ transceiver.do(newValue);
1282
+ } else if (update === `undo` && oldValue) {
1283
+ transceiver.undo(oldValue);
1284
+ }
1285
+ return transceiver;
1286
+ },
1287
+ store
1288
+ );
1289
+ },
1290
+ `${mutableState.key}: tracker observing timeline`,
1291
+ store
1292
+ );
1293
+ return;
1294
+ }
1295
+ }
1296
+ const unsubscribe = store.subject.operationStatus.subscribe(
1297
+ latestUpdateState.key,
1298
+ () => {
1299
+ unsubscribe();
1300
+ const mutable = getState(mutableState, store);
1301
+ const updateNumber = newValue === null ? -1 : mutable.getUpdateNumber(newValue);
1302
+ const eventOffset = updateNumber - mutable.cacheUpdateNumber;
1303
+ if (newValue && eventOffset === 1) {
1304
+ setState(
1305
+ mutableState,
1306
+ (transceiver) => (transceiver.do(newValue), transceiver),
1307
+ store
1308
+ );
1309
+ }
1310
+ }
1311
+ );
1312
+ },
1313
+ `${store.config.name}: tracker observing latest update`,
1314
+ store
1315
+ );
1316
+ }
1317
+ };
1318
+
1319
+ // internal/src/mutable/create-mutable-atom.ts
1320
+ function createMutableAtom(options, store) {
1321
+ store.logger.info(
1322
+ `\u{1F527}`,
1323
+ `atom`,
1324
+ options.key,
1325
+ `creating in store "${store.config.name}"`
1326
+ );
1327
+ const coreState = createAtom(options, void 0, store);
1328
+ new Tracker(coreState, store);
1329
+ const jsonState = selectJson(coreState, options, store);
1330
+ const target = newest(store);
1331
+ subscribeToState(
1332
+ jsonState,
1333
+ () => {
1334
+ const trackerHasBeenInitialized = newest(store).trackers.has(coreState.key);
1335
+ if (!trackerHasBeenInitialized) {
1336
+ new Tracker(coreState, store);
1337
+ }
1338
+ },
1339
+ `tracker-initializer:${store == null ? void 0 : store.config.name}:${target.transactionMeta === null ? `main` : `${target.transactionMeta.update.key}`}`,
1340
+ store
1341
+ );
1342
+ return coreState;
1343
+ }
1344
+
1345
+ // internal/src/families/create-atom-family.ts
1346
+ function createAtomFamily(options, store) {
1347
+ const subject = new Subject();
1348
+ const atomFamily = Object.assign(
1349
+ (key) => {
1350
+ const subKey = stringifyJson(key);
1351
+ const family = { key: options.key, subKey };
1352
+ const fullKey = `${options.key}(${subKey})`;
1353
+ const existing = withdraw({ key: fullKey, type: `atom` }, store);
1354
+ let token;
1355
+ if (existing) {
1356
+ token = deposit(existing);
1357
+ } else {
1358
+ const individualOptions = {
1359
+ key: fullKey,
1360
+ default: options.default instanceof Function ? options.default(key) : options.default
1361
+ };
1362
+ if (options.effects) {
1363
+ individualOptions.effects = options.effects(key);
1364
+ }
1365
+ token = createAtom(individualOptions, family, store);
1366
+ subject.next(token);
1367
+ }
1368
+ return token;
1369
+ },
1370
+ {
1371
+ key: options.key,
1372
+ type: `atom_family`,
1373
+ subject
1374
+ }
1375
+ );
1376
+ if (`mutable` in options && typeof options.mutable === `boolean`) {
1377
+ Object.assign(atomFamily, { mutable: options.mutable });
1378
+ }
1379
+ const target = newest(store);
1380
+ target.families.set(options.key, atomFamily);
1381
+ return atomFamily;
1382
+ }
1383
+
1384
+ // internal/src/families/create-readonly-selector-family.ts
1385
+ function createReadonlySelectorFamily(options, store) {
1386
+ const subject = new Subject();
1387
+ return Object.assign(
1388
+ (key) => {
1389
+ const target = newest(store);
1390
+ const subKey = stringifyJson(key);
1391
+ const family = { key: options.key, subKey };
1392
+ const fullKey = `${options.key}(${subKey})`;
1393
+ const existing = target.readonlySelectors.get(fullKey);
1394
+ if (existing) {
1395
+ return deposit(existing);
1396
+ }
1397
+ return createSelector(
1398
+ {
1399
+ key: fullKey,
1400
+ get: options.get(key)
1401
+ },
1402
+ family,
1403
+ store
1404
+ );
1405
+ },
1406
+ {
1407
+ key: options.key,
1408
+ type: `readonly_selector_family`,
1409
+ subject
1410
+ }
1411
+ );
1412
+ }
1413
+
1414
+ // internal/src/families/create-selector-family.ts
1415
+ function createSelectorFamily(options, store) {
1416
+ const isReadonly = !(`set` in options);
1417
+ if (isReadonly) {
1418
+ return createReadonlySelectorFamily(options, store);
1419
+ }
1420
+ const target = newest(store);
1421
+ const subject = new Subject();
1422
+ const selectorFamily = Object.assign(
1423
+ (key) => {
1424
+ const subKey = stringifyJson(key);
1425
+ const family = { key: options.key, subKey };
1426
+ const fullKey = `${options.key}(${subKey})`;
1427
+ const existing = target.selectors.get(fullKey);
1428
+ if (existing) {
1429
+ return deposit(existing);
1430
+ }
1431
+ const token = createSelector(
1432
+ {
1433
+ key: fullKey,
1434
+ get: options.get(key),
1435
+ set: options.set(key)
1436
+ },
1437
+ family,
1438
+ store
1439
+ );
1440
+ subject.next(token);
1441
+ return token;
1442
+ },
1443
+ {
1444
+ key: options.key,
1445
+ type: `selector_family`
1446
+ }
1447
+ );
1448
+ target.families.set(options.key, selectorFamily);
1449
+ return selectorFamily;
1450
+ }
1451
+
1452
+ // internal/src/mutable/transceiver.ts
1453
+ function isTransceiver(value) {
1454
+ return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
1455
+ }
1456
+
1457
+ // internal/src/atom/is-default.ts
1458
+ var isAtomDefault = (key, store) => {
1459
+ const core = newest(store);
1460
+ return core.atomsThatAreDefault.has(key);
1461
+ };
1462
+ var markAtomAsDefault = (key, store) => {
1463
+ const core = newest(store);
1464
+ core.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key);
1465
+ };
1466
+ var markAtomAsNotDefault = (key, store) => {
1467
+ const core = newest(store);
1468
+ core.atomsThatAreDefault = new Set(newest(store).atomsThatAreDefault);
1469
+ core.atomsThatAreDefault.delete(key);
1470
+ };
1471
+
1472
+ // internal/src/atom/create-atom.ts
1473
+ function createAtom(options, family, store) {
1474
+ store.logger.info(
1475
+ `\u{1F528}`,
1476
+ `atom`,
1477
+ options.key,
1478
+ `creating in store "${store.config.name}"`
1479
+ );
1480
+ const target = newest(store);
1481
+ const existing = target.atoms.get(options.key);
1482
+ if (existing) {
1483
+ store.logger.error(
1484
+ `\u274C`,
1485
+ `atom`,
1486
+ options.key,
1487
+ `Tried to create atom, but it already exists in the store.`,
1488
+ `(Ignore if you are in development using hot module replacement.)`
1489
+ );
1490
+ return deposit(existing);
1491
+ }
1492
+ const subject = new Subject();
1493
+ const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
1494
+ type: `atom`,
1495
+ install: (store2) => {
1496
+ store2.logger.info(
1497
+ `\u{1F6E0}\uFE0F`,
1498
+ `atom`,
1499
+ options.key,
1500
+ `installing in store "${store2.config.name}"`
1501
+ );
1502
+ return `mutable` in options ? createMutableAtom(options, store2) : createAtom(options, void 0, store2);
1503
+ },
1504
+ subject
1505
+ }), family && { family });
1506
+ let initialValue = options.default;
1507
+ if (options.default instanceof Function) {
1508
+ initialValue = options.default();
1509
+ }
1510
+ target.atoms.set(newAtom.key, newAtom);
1511
+ markAtomAsDefault(options.key, store);
1512
+ cacheValue(options.key, initialValue, subject, store);
1513
+ const token = deposit(newAtom);
1514
+ if (options.effects) {
1515
+ let effectIndex = 0;
1516
+ const cleanupFunctions = [];
1517
+ for (const effect of options.effects) {
1518
+ const cleanup = effect({
1519
+ setSelf: (next) => setState(token, next, store),
1520
+ onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
1521
+ });
1522
+ if (cleanup) {
1523
+ cleanupFunctions.push(cleanup);
1524
+ }
1525
+ ++effectIndex;
1526
+ }
1527
+ newAtom.cleanup = () => {
1528
+ for (const cleanup of cleanupFunctions) {
1529
+ cleanup();
1530
+ }
1531
+ };
1532
+ }
1533
+ store.subject.atomCreation.next(token);
1534
+ return token;
1535
+ }
1536
+
1537
+ // internal/src/not-found-error.ts
1538
+ var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
1539
+ function prettyPrintTokenType(token) {
1540
+ if (token.type === `readonly_selector`) {
1541
+ return `Readonly Selector`;
1542
+ }
1543
+ return capitalize(token.type);
1544
+ }
1545
+ var NotFoundError = class extends Error {
1546
+ constructor(token, store) {
1547
+ super(
1548
+ `${prettyPrintTokenType(token)} "${token.key}" not found in store "${store.config.name}".`
1549
+ );
1550
+ }
1551
+ };
1552
+
1553
+ // introspection/src/attach-atom-index.ts
1554
+ var attachAtomIndex = (store = IMPLICIT.STORE) => {
1555
+ const atomTokenIndexState__INTERNAL = createAtom(
46
1556
  {
47
1557
  key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
48
1558
  default: () => {
@@ -81,7 +1591,7 @@ var attachAtomIndex = (store = Internal.IMPLICIT.STORE) => {
81
1591
  [key]: atomToken
82
1592
  });
83
1593
  });
84
- if (Internal.newest(store).operation.open) {
1594
+ if (newest(store).operation.open) {
85
1595
  const unsubscribe = store.subject.operationStatus.subscribe(
86
1596
  `introspection: waiting to update atom index`,
87
1597
  () => {
@@ -99,7 +1609,7 @@ var attachAtomIndex = (store = Internal.IMPLICIT.STORE) => {
99
1609
  void 0,
100
1610
  store
101
1611
  );
102
- return Internal.createSelector(
1612
+ return createSelector(
103
1613
  {
104
1614
  key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
105
1615
  get: ({ get }) => get(atomTokenIndexState__INTERNAL)
@@ -108,8 +1618,10 @@ var attachAtomIndex = (store = Internal.IMPLICIT.STORE) => {
108
1618
  store
109
1619
  );
110
1620
  };
111
- var attachSelectorIndex = (store = Internal.IMPLICIT.STORE) => {
112
- const readonlySelectorTokenIndexState__INTERNAL = Internal.createAtom(
1621
+
1622
+ // introspection/src/attach-selector-index.ts
1623
+ var attachSelectorIndex = (store = IMPLICIT.STORE) => {
1624
+ const readonlySelectorTokenIndexState__INTERNAL = createAtom(
113
1625
  {
114
1626
  key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
115
1627
  default: () => Object.assign(
@@ -153,7 +1665,7 @@ var attachSelectorIndex = (store = Internal.IMPLICIT.STORE) => {
153
1665
  [key]: selectorToken
154
1666
  });
155
1667
  });
156
- if (Internal.newest(store).operation.open) {
1668
+ if (newest(store).operation.open) {
157
1669
  const unsubscribe = store.subject.operationStatus.subscribe(
158
1670
  `introspection: waiting to update selector index`,
159
1671
  () => {
@@ -172,17 +1684,19 @@ var attachSelectorIndex = (store = Internal.IMPLICIT.STORE) => {
172
1684
  void 0,
173
1685
  store
174
1686
  );
175
- return Internal.createSelector(
1687
+ return createSelector(
176
1688
  {
177
1689
  key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
178
1690
  get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
179
1691
  },
180
1692
  void 0,
181
- Internal.IMPLICIT.STORE
1693
+ IMPLICIT.STORE
182
1694
  );
183
1695
  };
184
- var attachTimelineFamily = (store = Internal.IMPLICIT.STORE) => {
185
- const findTimelineLogState__INTERNAL = Internal.createAtomFamily(
1696
+
1697
+ // introspection/src/attach-timeline-family.ts
1698
+ var attachTimelineFamily = (store = IMPLICIT.STORE) => {
1699
+ const findTimelineLogState__INTERNAL = createAtomFamily(
186
1700
  {
187
1701
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
188
1702
  default: (key) => {
@@ -197,7 +1711,7 @@ var attachTimelineFamily = (store = Internal.IMPLICIT.STORE) => {
197
1711
  transactionKey: null,
198
1712
  install: () => {
199
1713
  },
200
- subject: new Internal.Subject()
1714
+ subject: new Subject()
201
1715
  };
202
1716
  },
203
1717
  effects: (key) => [
@@ -223,7 +1737,7 @@ var attachTimelineFamily = (store = Internal.IMPLICIT.STORE) => {
223
1737
  },
224
1738
  store
225
1739
  );
226
- const findTimelineLogState = Internal.createSelectorFamily(
1740
+ const findTimelineLogState = createSelectorFamily(
227
1741
  {
228
1742
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
229
1743
  get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key))
@@ -232,8 +1746,10 @@ var attachTimelineFamily = (store = Internal.IMPLICIT.STORE) => {
232
1746
  );
233
1747
  return findTimelineLogState;
234
1748
  };
235
- var attachTimelineIndex = (store = Internal.IMPLICIT.STORE) => {
236
- const timelineTokenIndexState__INTERNAL = Internal.createAtom(
1749
+
1750
+ // introspection/src/attach-timeline-index.ts
1751
+ var attachTimelineIndex = (store = IMPLICIT.STORE) => {
1752
+ const timelineTokenIndexState__INTERNAL = createAtom(
237
1753
  {
238
1754
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
239
1755
  default: () => [...store.timelines].map(([key]) => {
@@ -253,7 +1769,7 @@ var attachTimelineIndex = (store = Internal.IMPLICIT.STORE) => {
253
1769
  void 0,
254
1770
  store
255
1771
  );
256
- const timelineTokenIndex = Internal.createSelector(
1772
+ const timelineTokenIndex = createSelector(
257
1773
  {
258
1774
  key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
259
1775
  get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
@@ -263,8 +1779,10 @@ var attachTimelineIndex = (store = Internal.IMPLICIT.STORE) => {
263
1779
  );
264
1780
  return timelineTokenIndex;
265
1781
  };
266
- var attachTransactionIndex = (store = Internal.IMPLICIT.STORE) => {
267
- const transactionTokenIndexState__INTERNAL = Internal.createAtom(
1782
+
1783
+ // introspection/src/attach-transaction-index.ts
1784
+ var attachTransactionIndex = (store = IMPLICIT.STORE) => {
1785
+ const transactionTokenIndexState__INTERNAL = createAtom(
268
1786
  {
269
1787
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
270
1788
  default: () => [...store.transactions].map(([key]) => {
@@ -284,7 +1802,7 @@ var attachTransactionIndex = (store = Internal.IMPLICIT.STORE) => {
284
1802
  void 0,
285
1803
  store
286
1804
  );
287
- const transactionTokenIndex = Internal.createSelector(
1805
+ const transactionTokenIndex = createSelector(
288
1806
  {
289
1807
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
290
1808
  get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
@@ -294,8 +1812,10 @@ var attachTransactionIndex = (store = Internal.IMPLICIT.STORE) => {
294
1812
  );
295
1813
  return transactionTokenIndex;
296
1814
  };
297
- var attachTransactionLogs = (store = Internal.IMPLICIT.STORE) => {
298
- const findTransactionUpdateLog = Internal.createAtomFamily(
1815
+
1816
+ // introspection/src/attach-transaction-logs.ts
1817
+ var attachTransactionLogs = (store = IMPLICIT.STORE) => {
1818
+ const findTransactionUpdateLog = createAtomFamily(
299
1819
  {
300
1820
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
301
1821
  default: () => [],
@@ -312,7 +1832,7 @@ var attachTransactionLogs = (store = Internal.IMPLICIT.STORE) => {
312
1832
  },
313
1833
  store
314
1834
  );
315
- const findTransactionUpdateLogState = Internal.createSelectorFamily(
1835
+ const findTransactionUpdateLogState = createSelectorFamily(
316
1836
  {
317
1837
  key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
318
1838
  get: (key) => ({ get }) => get(findTransactionUpdateLog(key))
@@ -322,8 +1842,8 @@ var attachTransactionLogs = (store = Internal.IMPLICIT.STORE) => {
322
1842
  return findTransactionUpdateLogState;
323
1843
  };
324
1844
 
325
- // src/attach-introspection-states.ts
326
- var attachIntrospectionStates = (store = Internal__namespace.IMPLICIT.STORE) => {
1845
+ // introspection/src/attach-introspection-states.ts
1846
+ var attachIntrospectionStates = (store = IMPLICIT.STORE) => {
327
1847
  return {
328
1848
  atomIndex: attachAtomIndex(store),
329
1849
  selectorIndex: attachSelectorIndex(store),