atom.io 0.9.8 → 0.9.10

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 (35) hide show
  1. package/dist/index.d.mts +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/internal/dist/index.d.mts +25 -9
  4. package/internal/dist/index.d.ts +25 -9
  5. package/internal/dist/index.js +224 -223
  6. package/internal/dist/index.js.map +1 -1
  7. package/internal/dist/index.mjs +220 -222
  8. package/internal/dist/index.mjs.map +1 -1
  9. package/internal/src/atom/is-default.ts +2 -2
  10. package/internal/src/caching.ts +6 -4
  11. package/internal/src/index.ts +1 -0
  12. package/internal/src/keys.ts +30 -0
  13. package/internal/src/selector/get-selector-dependency-keys.ts +20 -0
  14. package/internal/src/selector/index.ts +1 -1
  15. package/internal/src/selector/trace-selector-atoms.ts +27 -22
  16. package/internal/src/selector/update-selector-atoms.ts +4 -4
  17. package/internal/src/store/index.ts +0 -1
  18. package/internal/src/subscribe/subscribe-to-root-atoms.ts +4 -5
  19. package/introspection/dist/index.d.mts +1 -1
  20. package/introspection/dist/index.d.ts +1 -1
  21. package/json/dist/index.d.mts +2 -6
  22. package/json/dist/index.d.ts +2 -6
  23. package/package.json +4 -4
  24. package/react-devtools/dist/index.css +281 -3
  25. package/react-devtools/dist/index.css.map +1 -1
  26. package/react-devtools/dist/index.d.mts +1 -1
  27. package/react-devtools/dist/index.d.ts +1 -1
  28. package/realtime-server/dist/index.d.mts +1 -1
  29. package/realtime-server/dist/index.d.ts +1 -1
  30. package/realtime-testing/dist/index.d.mts +1 -1
  31. package/realtime-testing/dist/index.d.ts +1 -1
  32. package/transceivers/set-rtx/dist/index.d.mts +1 -1
  33. package/transceivers/set-rtx/dist/index.d.ts +1 -1
  34. package/internal/src/selector/lookup-selector-sources.ts +0 -20
  35. package/internal/src/store/lookup.ts +0 -26
@@ -52,94 +52,6 @@ function deposit(state) {
52
52
  return token;
53
53
  }
54
54
 
55
- // src/subject.ts
56
- var Subject = class {
57
- constructor() {
58
- this.subscribers = /* @__PURE__ */ new Map();
59
- }
60
- subscribe(key, subscriber) {
61
- this.subscribers.set(key, subscriber);
62
- const unsubscribe = () => this.unsubscribe(key);
63
- return unsubscribe;
64
- }
65
- unsubscribe(key) {
66
- this.subscribers.delete(key);
67
- }
68
- next(value) {
69
- for (const subscriber of this.subscribers.values()) {
70
- subscriber(value);
71
- }
72
- }
73
- };
74
-
75
- // src/transaction/abort-transaction.ts
76
- var abortTransaction = (store) => {
77
- var _a, _b;
78
- if (store.transactionStatus.phase === `idle`) {
79
- (_a = store.config.logger) == null ? void 0 : _a.warn(
80
- `abortTransaction called outside of a transaction. This is probably a bug.`
81
- );
82
- return;
83
- }
84
- store.transactionStatus = { phase: `idle` };
85
- (_b = store.config.logger) == null ? void 0 : _b.info(`\u{1FA82}`, `transaction fail`);
86
- };
87
- var applyTransaction = (output, store) => {
88
- var _a, _b, _c, _d, _e;
89
- if (store.transactionStatus.phase !== `building`) {
90
- (_a = store.config.logger) == null ? void 0 : _a.warn(
91
- `abortTransaction called outside of a transaction. This is probably a bug.`
92
- );
93
- return;
94
- }
95
- store.transactionStatus.phase = `applying`;
96
- store.transactionStatus.output = output;
97
- const { atomUpdates } = store.transactionStatus;
98
- (_b = store.config.logger) == null ? void 0 : _b.info(
99
- `\u{1F6C3} applying transaction "${store.transactionStatus.key}" with ${atomUpdates.length} updates.`
100
- );
101
- (_c = store.config.logger) == null ? void 0 : _c.info(`\u{1F6C3} the updates are:`, atomUpdates);
102
- for (const { key, newValue } of atomUpdates) {
103
- const token = { key, type: `atom` };
104
- if (!store.valueMap.has(token.key)) {
105
- if (token.family) {
106
- const family = store.families.get(token.family.key);
107
- if (family) {
108
- family(token.family.subKey);
109
- }
110
- } else {
111
- const newAtom = store.transactionStatus.core.atoms.get(token.key);
112
- if (!newAtom) {
113
- throw new Error(
114
- `Absurd Error: Atom "${token.key}" not found while copying updates from transaction "${store.transactionStatus.key}" to store "${store.config.name}"`
115
- );
116
- }
117
- store.atoms.set(newAtom.key, newAtom);
118
- store.valueMap.set(newAtom.key, newAtom.default);
119
- (_d = store.config.logger) == null ? void 0 : _d.info(`\u{1F527}`, `add atom "${newAtom.key}"`);
120
- }
121
- }
122
- setState(token, newValue, store);
123
- }
124
- const myTransaction = withdraw(
125
- { key: store.transactionStatus.key, type: `transaction` },
126
- store
127
- );
128
- if (myTransaction === void 0) {
129
- throw new Error(
130
- `Transaction "${store.transactionStatus.key}" not found. Absurd. How is this running?`
131
- );
132
- }
133
- myTransaction.subject.next({
134
- key: store.transactionStatus.key,
135
- atomUpdates,
136
- output,
137
- params: store.transactionStatus.params
138
- });
139
- store.transactionStatus = { phase: `idle` };
140
- (_e = store.config.logger) == null ? void 0 : _e.info(`\u{1F6EC}`, `transaction "${myTransaction.key}" applied`);
141
- };
142
-
143
55
  // ../../rel8/junction/src/junction.ts
144
56
  var Junction = class {
145
57
  constructor(data, config) {
@@ -338,6 +250,180 @@ var Junction = class {
338
250
  }
339
251
  };
340
252
 
253
+ // src/subject.ts
254
+ var Subject = class {
255
+ constructor() {
256
+ this.subscribers = /* @__PURE__ */ new Map();
257
+ }
258
+ subscribe(key, subscriber) {
259
+ this.subscribers.set(key, subscriber);
260
+ const unsubscribe = () => this.unsubscribe(key);
261
+ return unsubscribe;
262
+ }
263
+ unsubscribe(key) {
264
+ this.subscribers.delete(key);
265
+ }
266
+ next(value) {
267
+ for (const subscriber of this.subscribers.values()) {
268
+ subscriber(value);
269
+ }
270
+ }
271
+ };
272
+
273
+ // src/store/store.ts
274
+ var Store = class {
275
+ constructor(name, store = null) {
276
+ this.valueMap = /* @__PURE__ */ new Map();
277
+ this.atoms = /* @__PURE__ */ new Map();
278
+ this.selectors = /* @__PURE__ */ new Map();
279
+ this.readonlySelectors = /* @__PURE__ */ new Map();
280
+ this.trackers = /* @__PURE__ */ new Map();
281
+ this.families = /* @__PURE__ */ new Map();
282
+ this.timelines = /* @__PURE__ */ new Map();
283
+ this.transactions = /* @__PURE__ */ new Map();
284
+ this.atomsThatAreDefault = /* @__PURE__ */ new Set();
285
+ this.timelineAtoms = new Junction({
286
+ between: [`timelineKey`, `atomKey`],
287
+ cardinality: `1:n`
288
+ });
289
+ this.selectorAtoms = new Junction({
290
+ between: [`selectorKey`, `atomKey`],
291
+ cardinality: `n:n`
292
+ });
293
+ this.selectorGraph = new Junction(
294
+ {
295
+ between: [`upstreamSelectorKey`, `downstreamSelectorKey`],
296
+ cardinality: `n:n`
297
+ },
298
+ {
299
+ makeContentKey: (...keys) => keys.sort().join(`:`)
300
+ }
301
+ );
302
+ this.subject = {
303
+ atomCreation: new Subject(),
304
+ selectorCreation: new Subject(),
305
+ transactionCreation: new Subject(),
306
+ timelineCreation: new Subject(),
307
+ operationStatus: new Subject()
308
+ };
309
+ this.operation = { open: false };
310
+ this.transactionStatus = { phase: `idle` };
311
+ this.config = {
312
+ name: `IMPLICIT_STORE`,
313
+ logger: __spreadProps(__spreadValues({}, console), { info: () => void 0 }),
314
+ logger__INTERNAL: console
315
+ };
316
+ var _a;
317
+ if (store !== null) {
318
+ this.valueMap = new Map(store == null ? void 0 : store.valueMap);
319
+ this.operation = __spreadValues({}, store == null ? void 0 : store.operation);
320
+ this.transactionStatus = __spreadValues({}, store == null ? void 0 : store.transactionStatus);
321
+ this.config = __spreadProps(__spreadValues({}, store == null ? void 0 : store.config), {
322
+ logger__INTERNAL: console,
323
+ logger: __spreadValues(__spreadProps(__spreadValues({}, console), {
324
+ info: () => void 0
325
+ }), (_a = store == null ? void 0 : store.config) == null ? void 0 : _a.logger),
326
+ name
327
+ });
328
+ for (const [, atom] of store.atoms) {
329
+ atom.install(this);
330
+ }
331
+ for (const [, selector] of store.readonlySelectors) {
332
+ selector.install(this);
333
+ }
334
+ for (const [, selector] of store.selectors) {
335
+ selector.install(this);
336
+ }
337
+ for (const [, tx] of store.transactions) {
338
+ tx.install(this);
339
+ }
340
+ for (const [, timeline] of store.timelines) {
341
+ timeline.install(this);
342
+ }
343
+ }
344
+ }
345
+ };
346
+ var IMPLICIT = {
347
+ STORE_INTERNAL: void 0,
348
+ get STORE() {
349
+ var _a;
350
+ return (_a = this.STORE_INTERNAL) != null ? _a : this.STORE_INTERNAL = new Store(`IMPLICIT_STORE`);
351
+ }
352
+ };
353
+ var clearStore = (store = IMPLICIT.STORE) => {
354
+ const { config } = store;
355
+ Object.assign(store, new Store(config.name));
356
+ store.config = config;
357
+ };
358
+
359
+ // src/transaction/abort-transaction.ts
360
+ var abortTransaction = (store) => {
361
+ var _a, _b;
362
+ if (store.transactionStatus.phase === `idle`) {
363
+ (_a = store.config.logger) == null ? void 0 : _a.warn(
364
+ `abortTransaction called outside of a transaction. This is probably a bug.`
365
+ );
366
+ return;
367
+ }
368
+ store.transactionStatus = { phase: `idle` };
369
+ (_b = store.config.logger) == null ? void 0 : _b.info(`\u{1FA82}`, `transaction fail`);
370
+ };
371
+ var applyTransaction = (output, store) => {
372
+ var _a, _b, _c, _d, _e;
373
+ if (store.transactionStatus.phase !== `building`) {
374
+ (_a = store.config.logger) == null ? void 0 : _a.warn(
375
+ `abortTransaction called outside of a transaction. This is probably a bug.`
376
+ );
377
+ return;
378
+ }
379
+ store.transactionStatus.phase = `applying`;
380
+ store.transactionStatus.output = output;
381
+ const { atomUpdates } = store.transactionStatus;
382
+ (_b = store.config.logger) == null ? void 0 : _b.info(
383
+ `\u{1F6C3} applying transaction "${store.transactionStatus.key}" with ${atomUpdates.length} updates.`
384
+ );
385
+ (_c = store.config.logger) == null ? void 0 : _c.info(`\u{1F6C3} the updates are:`, atomUpdates);
386
+ for (const { key, newValue } of atomUpdates) {
387
+ const token = { key, type: `atom` };
388
+ if (!store.valueMap.has(token.key)) {
389
+ if (token.family) {
390
+ const family = store.families.get(token.family.key);
391
+ if (family) {
392
+ family(token.family.subKey);
393
+ }
394
+ } else {
395
+ const newAtom = store.transactionStatus.core.atoms.get(token.key);
396
+ if (!newAtom) {
397
+ throw new Error(
398
+ `Absurd Error: Atom "${token.key}" not found while copying updates from transaction "${store.transactionStatus.key}" to store "${store.config.name}"`
399
+ );
400
+ }
401
+ store.atoms.set(newAtom.key, newAtom);
402
+ store.valueMap.set(newAtom.key, newAtom.default);
403
+ (_d = store.config.logger) == null ? void 0 : _d.info(`\u{1F527}`, `add atom "${newAtom.key}"`);
404
+ }
405
+ }
406
+ setState(token, newValue, store);
407
+ }
408
+ const myTransaction = withdraw(
409
+ { key: store.transactionStatus.key, type: `transaction` },
410
+ store
411
+ );
412
+ if (myTransaction === void 0) {
413
+ throw new Error(
414
+ `Transaction "${store.transactionStatus.key}" not found. Absurd. How is this running?`
415
+ );
416
+ }
417
+ myTransaction.subject.next({
418
+ key: store.transactionStatus.key,
419
+ atomUpdates,
420
+ output,
421
+ params: store.transactionStatus.params
422
+ });
423
+ store.transactionStatus = { phase: `idle` };
424
+ (_e = store.config.logger) == null ? void 0 : _e.info(`\u{1F6EC}`, `transaction "${myTransaction.key}" applied`);
425
+ };
426
+
341
427
  // src/transaction/build-transaction.ts
342
428
  var buildTransaction = (key, params, store) => {
343
429
  var _a;
@@ -441,107 +527,6 @@ var undoTransactionUpdate = (update, store) => {
441
527
  // src/transaction/index.ts
442
528
  var TRANSACTION_PHASES = [`idle`, `building`, `applying`];
443
529
 
444
- // src/store/lookup.ts
445
- function lookup(key, store) {
446
- var _a;
447
- const core = target(store);
448
- let type = core.atoms.has(key) ? `atom` : core.selectors.has(key) ? `selector` : core.readonlySelectors.has(key) ? `readonly_selector` : ``;
449
- if (!type) {
450
- const errorId = Math.random().toString(36);
451
- type = `\u{1F6A8} This state could not be found by lookup! Check the console for "${errorId}"`;
452
- (_a = store.config.logger) == null ? void 0 : _a.error(
453
- `${errorId}: Key "${key}" does not exist in the store.`
454
- );
455
- }
456
- return { key, type };
457
- }
458
-
459
- // src/store/store.ts
460
- var Store = class {
461
- constructor(name, store = null) {
462
- this.valueMap = /* @__PURE__ */ new Map();
463
- this.atoms = /* @__PURE__ */ new Map();
464
- this.selectors = /* @__PURE__ */ new Map();
465
- this.readonlySelectors = /* @__PURE__ */ new Map();
466
- this.trackers = /* @__PURE__ */ new Map();
467
- this.families = /* @__PURE__ */ new Map();
468
- this.timelines = /* @__PURE__ */ new Map();
469
- this.transactions = /* @__PURE__ */ new Map();
470
- this.atomsThatAreDefault = /* @__PURE__ */ new Set();
471
- this.timelineAtoms = new Junction({
472
- between: [`timelineKey`, `atomKey`],
473
- cardinality: `1:n`
474
- });
475
- this.selectorAtoms = new Junction({
476
- between: [`selectorKey`, `atomKey`],
477
- cardinality: `n:n`
478
- });
479
- this.selectorGraph = new Junction(
480
- {
481
- between: [`upstreamSelectorKey`, `downstreamSelectorKey`],
482
- cardinality: `n:n`
483
- },
484
- {
485
- makeContentKey: (...keys) => keys.sort().join(`:`)
486
- }
487
- );
488
- this.subject = {
489
- atomCreation: new Subject(),
490
- selectorCreation: new Subject(),
491
- transactionCreation: new Subject(),
492
- timelineCreation: new Subject(),
493
- operationStatus: new Subject()
494
- };
495
- this.operation = { open: false };
496
- this.transactionStatus = { phase: `idle` };
497
- this.config = {
498
- name: `IMPLICIT_STORE`,
499
- logger: __spreadProps(__spreadValues({}, console), { info: () => void 0 }),
500
- logger__INTERNAL: console
501
- };
502
- var _a;
503
- if (store !== null) {
504
- this.valueMap = new Map(store == null ? void 0 : store.valueMap);
505
- this.operation = __spreadValues({}, store == null ? void 0 : store.operation);
506
- this.transactionStatus = __spreadValues({}, store == null ? void 0 : store.transactionStatus);
507
- this.config = __spreadProps(__spreadValues({}, store == null ? void 0 : store.config), {
508
- logger__INTERNAL: console,
509
- logger: __spreadValues(__spreadProps(__spreadValues({}, console), {
510
- info: () => void 0
511
- }), (_a = store == null ? void 0 : store.config) == null ? void 0 : _a.logger),
512
- name
513
- });
514
- for (const [, atom] of store.atoms) {
515
- atom.install(this);
516
- }
517
- for (const [, selector] of store.readonlySelectors) {
518
- selector.install(this);
519
- }
520
- for (const [, selector] of store.selectors) {
521
- selector.install(this);
522
- }
523
- for (const [, tx] of store.transactions) {
524
- tx.install(this);
525
- }
526
- for (const [, timeline] of store.timelines) {
527
- timeline.install(this);
528
- }
529
- }
530
- }
531
- };
532
- var IMPLICIT = {
533
- STORE_INTERNAL: void 0,
534
- get STORE() {
535
- var _a;
536
- return (_a = this.STORE_INTERNAL) != null ? _a : this.STORE_INTERNAL = new Store(`IMPLICIT_STORE`);
537
- }
538
- };
539
- var clearStore = (store = IMPLICIT.STORE) => {
540
- const { config } = store;
541
- Object.assign(store, new Store(config.name));
542
- store.config = config;
543
- };
544
-
545
530
  // src/timeline/add-atom-to-timeline.ts
546
531
  var addAtomToTimeline = (atomToken, tl, store = IMPLICIT.STORE) => {
547
532
  const atom = withdraw(atomToken, store);
@@ -934,10 +919,12 @@ var cacheValue = (key, value, subject, store = IMPLICIT.STORE) => {
934
919
  subject.next({ newValue: value2, oldValue: value2 });
935
920
  }).catch((error) => {
936
921
  var _a;
937
- (_a = store.config.logger) == null ? void 0 : _a.error(
938
- `Promised value for "${key}" rejected:`,
939
- error
940
- );
922
+ if (error !== `canceled`) {
923
+ (_a = store.config.logger) == null ? void 0 : _a.error(
924
+ `Promised value for "${key}" rejected:`,
925
+ error
926
+ );
927
+ }
941
928
  });
942
929
  } else {
943
930
  target(store).valueMap.set(key, value);
@@ -1132,9 +1119,15 @@ function createAtomFamily(options, store = IMPLICIT.STORE) {
1132
1119
  return atomFamily;
1133
1120
  }
1134
1121
 
1135
- // src/selector/lookup-selector-sources.ts
1136
- var lookupSelectorSources = (key, store) => {
1137
- const sources = target(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => lookup(source, store));
1122
+ // src/keys.ts
1123
+ var isAtomKey = (key, store) => target(store).atoms.has(key);
1124
+ var isSelectorKey = (key, store) => target(store).selectors.has(key);
1125
+ var isReadonlySelectorKey = (key, store) => target(store).readonlySelectors.has(key);
1126
+ var isStateKey = (key, store) => isAtomKey(key, store) || isSelectorKey(key, store) || isReadonlySelectorKey(key, store);
1127
+
1128
+ // src/selector/get-selector-dependency-keys.ts
1129
+ var getSelectorDependencyKeys = (key, store) => {
1130
+ const sources = target(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(source, store));
1138
1131
  return sources;
1139
1132
  };
1140
1133
 
@@ -1379,30 +1372,35 @@ var setState__INTERNAL = (state, value, store = IMPLICIT.STORE) => {
1379
1372
  };
1380
1373
 
1381
1374
  // src/selector/trace-selector-atoms.ts
1382
- var traceSelectorAtoms = (selectorKey, dependency, store) => {
1383
- const roots = [];
1384
- const sources = lookupSelectorSources(dependency.key, store);
1375
+ var traceSelectorAtoms = (selectorKey, directDependencyKey, store) => {
1376
+ const rootKeys = [];
1377
+ const indirectDependencyKeys = getSelectorDependencyKeys(
1378
+ directDependencyKey,
1379
+ store
1380
+ );
1385
1381
  let depth = 0;
1386
- while (sources.length > 0) {
1387
- const source = sources.shift();
1382
+ while (indirectDependencyKeys.length > 0) {
1383
+ const indirectDependencyKey = indirectDependencyKeys.shift();
1388
1384
  ++depth;
1389
- if (depth > 999) {
1385
+ if (depth > 99999) {
1390
1386
  throw new Error(
1391
- `Maximum selector dependency depth exceeded in selector "${selectorKey}".`
1387
+ `Maximum selector dependency depth exceeded (> 99999) in selector "${selectorKey}". This is likely due to a circular dependency.`
1392
1388
  );
1393
1389
  }
1394
- if (source.type !== `atom`) {
1395
- sources.push(...lookupSelectorSources(source.key, store));
1396
- } else {
1397
- roots.push(source);
1390
+ if (!isAtomKey(indirectDependencyKey, store)) {
1391
+ indirectDependencyKeys.push(
1392
+ ...getSelectorDependencyKeys(indirectDependencyKey, store)
1393
+ );
1394
+ } else if (!rootKeys.includes(indirectDependencyKey)) {
1395
+ rootKeys.push(indirectDependencyKey);
1398
1396
  }
1399
1397
  }
1400
- return roots;
1398
+ return rootKeys;
1401
1399
  };
1402
1400
  var traceAllSelectorAtoms = (selectorKey, store) => {
1403
- const sources = lookupSelectorSources(selectorKey, store);
1404
- return sources.flatMap(
1405
- (source) => source.type === `atom` ? source : traceSelectorAtoms(selectorKey, source, store)
1401
+ const directDependencyKeys = getSelectorDependencyKeys(selectorKey, store);
1402
+ return directDependencyKeys.flatMap(
1403
+ (depKey) => isAtomKey(depKey, store) ? depKey : traceSelectorAtoms(selectorKey, depKey, store)
1406
1404
  );
1407
1405
  };
1408
1406
 
@@ -1420,15 +1418,15 @@ var updateSelectorAtoms = (selectorKey, dependency, store) => {
1420
1418
  );
1421
1419
  return;
1422
1420
  }
1423
- const roots = traceSelectorAtoms(selectorKey, dependency, store);
1421
+ const rootKeys = traceSelectorAtoms(selectorKey, dependency.key, store);
1424
1422
  (_b = store.config.logger) == null ? void 0 : _b.info(
1425
1423
  ` || adding roots for "${selectorKey}":`,
1426
- roots.map((r) => r.key)
1424
+ rootKeys.map((r) => r)
1427
1425
  );
1428
- for (const root of roots) {
1426
+ for (const atomKey of rootKeys) {
1429
1427
  core.selectorAtoms = core.selectorAtoms.set({
1430
1428
  selectorKey,
1431
- atomKey: root.key
1429
+ atomKey
1432
1430
  });
1433
1431
  }
1434
1432
  };
@@ -1745,8 +1743,8 @@ var markAtomAsNotDefault = (key, store = IMPLICIT.STORE) => {
1745
1743
  core.atomsThatAreDefault.delete(key);
1746
1744
  };
1747
1745
  var isSelectorDefault = (key, store = IMPLICIT.STORE) => {
1748
- const roots = traceAllSelectorAtoms(key, store);
1749
- return roots.every((root) => isAtomDefault(root.key, store));
1746
+ const rootKeys = traceAllSelectorAtoms(key, store);
1747
+ return rootKeys.every((rootKey) => isAtomDefault(rootKey, store));
1750
1748
  };
1751
1749
 
1752
1750
  // src/atom/create-atom.ts
@@ -1819,11 +1817,11 @@ var recallState = (state, store = IMPLICIT.STORE) => {
1819
1817
 
1820
1818
  // src/subscribe/subscribe-to-root-atoms.ts
1821
1819
  var subscribeToRootAtoms = (state, store) => {
1822
- const dependencySubscriptions = `default` in state ? null : traceAllSelectorAtoms(state.key, store).map((atomToken) => {
1823
- const atom = withdraw(atomToken, store);
1820
+ const dependencySubscriptions = `default` in state ? null : traceAllSelectorAtoms(state.key, store).map((atomKey) => {
1821
+ const atom = store.atoms.get(atomKey);
1824
1822
  if (atom === void 0) {
1825
1823
  throw new Error(
1826
- `Atom "${atomToken.key}", a dependency of selector "${state.key}", not found in store "${store.config.name}".`
1824
+ `Atom "${atomKey}", a dependency of selector "${state.key}", not found in store "${store.config.name}".`
1827
1825
  );
1828
1826
  }
1829
1827
  return atom.subject.subscribe(
@@ -1831,7 +1829,7 @@ var subscribeToRootAtoms = (state, store) => {
1831
1829
  (atomChange) => {
1832
1830
  var _a, _b;
1833
1831
  (_a = store.config.logger) == null ? void 0 : _a.info(
1834
- `\u{1F4E2} selector "${state.key}" saw root "${atomToken.key}" go (`,
1832
+ `\u{1F4E2} selector "${state.key}" saw root "${atomKey}" go (`,
1835
1833
  atomChange.oldValue,
1836
1834
  `->`,
1837
1835
  atomChange.newValue,
@@ -1853,6 +1851,6 @@ var subscribeToRootAtoms = (state, store) => {
1853
1851
  return dependencySubscriptions;
1854
1852
  };
1855
1853
 
1856
- export { FamilyTracker, Future, IMPLICIT, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, deleteAtom, deposit, evictCachedValue, getJsonToken, getState__INTERNAL, getUpdateToken, isAtomDefault, isAtomMutable, isAtomTokenMutable, isDone, isSelectorDefault, isTransceiver, isValueCached, lookup, lookupSelectorSources, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, redoTransactionUpdate, redo__INTERNAL, registerSelector, setState__INTERNAL, subscribeToRootAtoms, target, timeline__INTERNAL, traceAllSelectorAtoms, traceSelectorAtoms, transaction__INTERNAL, undoTransactionUpdate, undo__INTERNAL, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
1854
+ export { FamilyTracker, Future, IMPLICIT, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, addAtomToTimeline, applyTransaction, become, buildTransaction, cacheValue, clearStore, closeOperation, createAtom, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelectorFamily, createSelector, createSelectorFamily, deleteAtom, deposit, evictCachedValue, getJsonToken, getSelectorDependencyKeys, getState__INTERNAL, getUpdateToken, isAtomDefault, isAtomKey, isAtomMutable, isAtomTokenMutable, isDone, isReadonlySelectorKey, isSelectorDefault, isSelectorKey, isStateKey, isTransceiver, isValueCached, markAtomAsDefault, markAtomAsNotDefault, markDone, openOperation, readCachedValue, redoTransactionUpdate, redo__INTERNAL, registerSelector, setState__INTERNAL, subscribeToRootAtoms, target, timeline__INTERNAL, traceAllSelectorAtoms, traceSelectorAtoms, transaction__INTERNAL, undoTransactionUpdate, undo__INTERNAL, updateSelectorAtoms, withdraw, withdrawNewFamilyMember };
1857
1855
  //# sourceMappingURL=out.js.map
1858
1856
  //# sourceMappingURL=index.mjs.map