atom.io 0.3.0 → 0.3.1

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/dist/index.mjs CHANGED
@@ -18,27 +18,26 @@ var __spreadValues = (a, b) => {
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  var __objRest = (source, exclude) => {
21
- var target3 = {};
21
+ var target2 = {};
22
22
  for (var prop in source)
23
23
  if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target3[prop] = source[prop];
24
+ target2[prop] = source[prop];
25
25
  if (source != null && __getOwnPropSymbols)
26
26
  for (var prop of __getOwnPropSymbols(source)) {
27
27
  if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target3[prop] = source[prop];
28
+ target2[prop] = source[prop];
29
29
  }
30
- return target3;
30
+ return target2;
31
31
  };
32
- var __export = (target3, all) => {
32
+ var __export = (target2, all) => {
33
33
  for (var name in all)
34
- __defProp(target3, name, { get: all[name], enumerable: true });
34
+ __defProp(target2, name, { get: all[name], enumerable: true });
35
35
  };
36
36
 
37
37
  // src/internal/index.ts
38
38
  var internal_exports = {};
39
39
  __export(internal_exports, {
40
40
  IMPLICIT: () => IMPLICIT,
41
- LOG_LEVELS: () => LOG_LEVELS,
42
41
  TRANSACTION_PHASES: () => TRANSACTION_PHASES,
43
42
  abortTransaction: () => abortTransaction,
44
43
  applyTransaction: () => applyTransaction,
@@ -76,7 +75,6 @@ __export(internal_exports, {
76
75
  selectorFamily__INTERNAL: () => selectorFamily__INTERNAL,
77
76
  selector__INTERNAL: () => selector__INTERNAL,
78
77
  setAtomState: () => setAtomState,
79
- setLogLevel: () => setLogLevel,
80
78
  setSelectorState: () => setSelectorState,
81
79
  setState__INTERNAL: () => setState__INTERNAL,
82
80
  storeAtom: () => storeAtom,
@@ -92,7 +90,6 @@ __export(internal_exports, {
92
90
  undoTransactionUpdate: () => undoTransactionUpdate,
93
91
  undo__INTERNAL: () => undo__INTERNAL,
94
92
  updateSelectorAtoms: () => updateSelectorAtoms,
95
- useLogger: () => useLogger,
96
93
  withdraw: () => withdraw
97
94
  });
98
95
 
@@ -124,7 +121,7 @@ var getState__INTERNAL = (state, store = IMPLICIT.STORE) => {
124
121
  (_a = store.config.logger) == null ? void 0 : _a.info(`>> read "${state.key}"`);
125
122
  return readCachedValue(state.key, store);
126
123
  }
127
- if (`get` in state) {
124
+ if (state.type !== `atom`) {
128
125
  (_b = store.config.logger) == null ? void 0 : _b.info(`-> calc "${state.key}"`);
129
126
  return computeSelectorState(state);
130
127
  }
@@ -587,21 +584,30 @@ var clearStore = (store = IMPLICIT.STORE) => {
587
584
  };
588
585
 
589
586
  // src/internal/operation.ts
590
- var openOperation = (store) => {
591
- var _a;
587
+ var openOperation = (token, store) => {
588
+ var _a, _b;
592
589
  const core = target(store);
590
+ if (core.operation.open) {
591
+ console.warn(core.operation.open);
592
+ (_a = store.config.logger) == null ? void 0 : _a.error(
593
+ `\u274C failed to setState to "${token.key}" during a setState for "${core.operation.token.key}"`
594
+ );
595
+ throw Symbol(`violation`);
596
+ }
593
597
  core.operation = {
594
598
  open: true,
595
599
  done: /* @__PURE__ */ new Set(),
596
- prev: store.valueMap
600
+ prev: store.valueMap,
601
+ time: Date.now(),
602
+ token
597
603
  };
598
- (_a = store.config.logger) == null ? void 0 : _a.info(`\u2B55`, `operation start`);
604
+ (_b = store.config.logger) == null ? void 0 : _b.info(`\u2B55 operation start from "${token.key}"`);
599
605
  };
600
606
  var closeOperation = (store) => {
601
607
  var _a;
602
608
  const core = target(store);
603
609
  core.operation = { open: false };
604
- (_a = store.config.logger) == null ? void 0 : _a.info(`\u{1F534}`, `operation done`);
610
+ (_a = store.config.logger) == null ? void 0 : _a.info(`\u{1F534} operation done`);
605
611
  };
606
612
  var isDone = (key, store = IMPLICIT.STORE) => {
607
613
  var _a;
@@ -834,7 +840,7 @@ function atomFamily__INTERNAL(options, store = IMPLICIT.STORE) {
834
840
  var _a;
835
841
  const subKey = stringifyJson(key);
836
842
  const family = { key: options.key, subKey };
837
- const fullKey = `${options.key}__${subKey}`;
843
+ const fullKey = `${options.key}(${subKey})`;
838
844
  const existing = withdraw({ key: fullKey, type: `atom` }, store);
839
845
  const token = existing ? deposit(existing) : atom__INTERNAL(
840
846
  {
@@ -862,7 +868,7 @@ function readonlySelectorFamily__INTERNAL(options, store) {
862
868
  (key) => {
863
869
  const subKey = stringifyJson(key);
864
870
  const family = { key: options.key, subKey };
865
- const fullKey = `${options.key}__${subKey}`;
871
+ const fullKey = `${options.key}(${subKey})`;
866
872
  const existing = core.readonlySelectors.get(fullKey);
867
873
  if (existing) {
868
874
  return deposit(existing);
@@ -894,7 +900,7 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
894
900
  (key) => {
895
901
  const subKey = stringifyJson(key);
896
902
  const family = { key: options.key, subKey };
897
- const fullKey = `${options.key}__${subKey}`;
903
+ const fullKey = `${options.key}(${subKey})`;
898
904
  const existing = core.selectors.get(fullKey);
899
905
  if (existing) {
900
906
  return deposit(existing);
@@ -918,39 +924,6 @@ function selectorFamily__INTERNAL(options, store = IMPLICIT.STORE) {
918
924
  );
919
925
  }
920
926
 
921
- // src/internal/logger.ts
922
- var LOG_LEVELS = [
923
- `info`,
924
- `warn`,
925
- `error`
926
- ];
927
- var setLogLevel = (preferredLevel, store = IMPLICIT.STORE) => {
928
- const { logger__INTERNAL } = store.config;
929
- if (preferredLevel === null) {
930
- store.config.logger = null;
931
- } else {
932
- store.config.logger = __spreadValues({}, console);
933
- LOG_LEVELS.forEach((logLevel) => {
934
- if (LOG_LEVELS.indexOf(logLevel) < LOG_LEVELS.indexOf(preferredLevel)) {
935
- store.config.logger[logLevel] = doNothing;
936
- } else {
937
- store.config.logger[logLevel] = logger__INTERNAL[logLevel];
938
- }
939
- });
940
- }
941
- };
942
- var useLogger = (logger, store = IMPLICIT.STORE) => {
943
- var _a;
944
- const currentLogLevel = store.config.logger === null ? null : (_a = LOG_LEVELS.find(
945
- (logLevel) => {
946
- var _a2;
947
- return ((_a2 = store.config.logger) == null ? void 0 : _a2[logLevel]) !== doNothing;
948
- }
949
- )) != null ? _a : null;
950
- store.config.logger__INTERNAL = __spreadValues({}, logger);
951
- setLogLevel(currentLogLevel, store);
952
- };
953
-
954
927
  // src/internal/selector-internal.ts
955
928
  import HAMT5 from "hamt_plus";
956
929
  import * as Rx4 from "rxjs";
@@ -1014,8 +987,9 @@ var registerSelector = (selectorKey, store = IMPLICIT.STORE) => ({
1014
987
  );
1015
988
  } else {
1016
989
  (_b = store.config.logger) == null ? void 0 : _b.info(
1017
- `\u{1F50C} registerSelector "${selectorKey}" <- "${dependency.key}" =`,
1018
- dependencyValue
990
+ `\u{1F50C} registerSelector "${selectorKey}" <- ( "${dependency.key}" =`,
991
+ dependencyValue,
992
+ `)`
1019
993
  );
1020
994
  core.selectorGraph = core.selectorGraph.set(selectorKey, dependency.key, {
1021
995
  source: dependency.key
@@ -1207,6 +1181,8 @@ var subscribeToRootAtoms = (state, store) => {
1207
1181
  // src/internal/timeline-internal.ts
1208
1182
  import HAMT7 from "hamt_plus";
1209
1183
  function timeline__INTERNAL(options, store = IMPLICIT.STORE) {
1184
+ var _a, _b;
1185
+ let incompleteSelectorTime = null;
1210
1186
  let incompleteTransactionKey = null;
1211
1187
  const timelineData = {
1212
1188
  at: 0,
@@ -1216,9 +1192,11 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE) {
1216
1192
  const subscribeToAtom = (token) => {
1217
1193
  const state = withdraw(token, store);
1218
1194
  state.subject.subscribe((update) => {
1219
- var _a, _b, _c;
1195
+ var _a2, _b2, _c, _d, _e;
1196
+ const storeCurrentSelectorKey = store.operation.open && store.operation.token.type === `selector` ? store.operation.token.key : null;
1197
+ const storeCurrentSelectorTime = store.operation.open && store.operation.token.type === `selector` ? store.operation.time : null;
1220
1198
  const storeCurrentTransactionKey = store.transactionStatus.phase === `applying` ? store.transactionStatus.key : null;
1221
- (_a = store.config.logger) == null ? void 0 : _a.info(
1199
+ (_a2 = store.config.logger) == null ? void 0 : _a2.info(
1222
1200
  `\u23F3 timeline "${options.key}" saw atom "${token.key}" go (`,
1223
1201
  update.oldValue,
1224
1202
  `->`,
@@ -1232,14 +1210,17 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE) {
1232
1210
  );
1233
1211
  if (incompleteTransactionKey !== storeCurrentTransactionKey) {
1234
1212
  if (incompleteTransactionKey) {
1235
- (_b = store.config.logger) == null ? void 0 : _b.error(
1213
+ (_b2 = store.config.logger) == null ? void 0 : _b2.error(
1236
1214
  `Timeline "${options.key}" was unable to resolve transaction "${incompleteTransactionKey}. This is probably a bug.`
1237
1215
  );
1238
1216
  }
1239
1217
  incompleteTransactionKey = storeCurrentTransactionKey;
1240
1218
  const subscription = currentTransaction.subject.subscribe((update2) => {
1241
- var _a2;
1219
+ var _a3;
1242
1220
  if (timelineData.timeTraveling === false) {
1221
+ if (timelineData.at !== timelineData.history.length) {
1222
+ timelineData.history.splice(timelineData.at);
1223
+ }
1243
1224
  timelineData.history.push(__spreadProps(__spreadValues({
1244
1225
  type: `transaction_update`
1245
1226
  }, update2), {
@@ -1251,35 +1232,95 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE) {
1251
1232
  timelineData.at = timelineData.history.length;
1252
1233
  subscription.unsubscribe();
1253
1234
  incompleteTransactionKey = null;
1254
- (_a2 = store.config.logger) == null ? void 0 : _a2.info(
1255
- `\u231B timeline "${options.key}" pushed a transaction_update from "${update2.key}"`
1235
+ (_a3 = store.config.logger) == null ? void 0 : _a3.info(
1236
+ `\u231B timeline "${options.key}" got a transaction_update "${update2.key}"`
1256
1237
  );
1257
1238
  });
1258
1239
  }
1240
+ } else if (storeCurrentSelectorKey) {
1241
+ if (timelineData.timeTraveling === false) {
1242
+ if (storeCurrentSelectorTime !== incompleteSelectorTime) {
1243
+ const newSelectorUpdate = {
1244
+ type: `selector_update`,
1245
+ key: storeCurrentSelectorKey,
1246
+ atomUpdates: []
1247
+ };
1248
+ newSelectorUpdate.atomUpdates.push(__spreadValues({
1249
+ key: token.key,
1250
+ type: `atom_update`
1251
+ }, update));
1252
+ if (timelineData.at !== timelineData.history.length) {
1253
+ timelineData.history.splice(timelineData.at);
1254
+ }
1255
+ timelineData.history.push(newSelectorUpdate);
1256
+ (_c = store.config.logger) == null ? void 0 : _c.info(
1257
+ `\u231B timeline "${options.key}" got a selector_update "${storeCurrentSelectorKey}" with`,
1258
+ newSelectorUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
1259
+ );
1260
+ timelineData.at = timelineData.history.length;
1261
+ incompleteSelectorTime = storeCurrentSelectorTime;
1262
+ } else {
1263
+ const latestUpdate = timelineData.history.at(-1);
1264
+ if ((latestUpdate == null ? void 0 : latestUpdate.type) === `selector_update`) {
1265
+ latestUpdate.atomUpdates.push(__spreadValues({
1266
+ key: token.key,
1267
+ type: `atom_update`
1268
+ }, update));
1269
+ (_d = store.config.logger) == null ? void 0 : _d.info(
1270
+ ` \u231B timeline "${options.key}" set selector_update "${storeCurrentSelectorKey}" to`,
1271
+ latestUpdate == null ? void 0 : latestUpdate.atomUpdates.map((atomUpdate) => atomUpdate.key)
1272
+ );
1273
+ }
1274
+ }
1275
+ }
1259
1276
  } else {
1260
1277
  if (timelineData.timeTraveling === false) {
1278
+ incompleteSelectorTime = null;
1279
+ if (timelineData.at !== timelineData.history.length) {
1280
+ timelineData.history.splice(timelineData.at);
1281
+ }
1261
1282
  timelineData.history.push({
1262
- type: `state_update`,
1283
+ type: `atom_update`,
1263
1284
  key: token.key,
1264
1285
  oldValue: update.oldValue,
1265
1286
  newValue: update.newValue
1266
1287
  });
1267
- (_c = store.config.logger) == null ? void 0 : _c.info(
1268
- `\u231B timeline "${options.key}" pushed a state_update to "${token.key}"`
1288
+ (_e = store.config.logger) == null ? void 0 : _e.info(
1289
+ `\u231B timeline "${options.key}" got a state_update to "${token.key}"`
1269
1290
  );
1270
1291
  timelineData.at = timelineData.history.length;
1271
1292
  }
1272
1293
  }
1273
1294
  });
1274
1295
  };
1296
+ const core = target(store);
1275
1297
  for (const tokenOrFamily of options.atoms) {
1298
+ const timelineKey = core.timelineAtoms.getRelatedId(tokenOrFamily.key);
1299
+ if (timelineKey) {
1300
+ (_a = store.config.logger) == null ? void 0 : _a.error(
1301
+ `\u274C Failed to add atom "${tokenOrFamily.key}" to timeline "${options.key}" because it belongs to timeline "${timelineKey}"`
1302
+ );
1303
+ continue;
1304
+ }
1276
1305
  if (tokenOrFamily.type === `atom_family`) {
1277
1306
  const family = tokenOrFamily;
1278
1307
  family.subject.subscribe((token) => subscribeToAtom(token));
1279
1308
  } else {
1280
1309
  const token = tokenOrFamily;
1310
+ if (`family` in token && token.family) {
1311
+ const familyTimelineKey = core.timelineAtoms.getRelatedId(
1312
+ token.family.key
1313
+ );
1314
+ if (familyTimelineKey) {
1315
+ (_b = store.config.logger) == null ? void 0 : _b.error(
1316
+ `\u274C Failed to add atom "${token.key}" to timeline "${options.key}" because its family "${token.family.key}" belongs to timeline "${familyTimelineKey}"`
1317
+ );
1318
+ continue;
1319
+ }
1320
+ }
1281
1321
  subscribeToAtom(token);
1282
1322
  }
1323
+ core.timelineAtoms = core.timelineAtoms.set(tokenOrFamily.key, options.key);
1283
1324
  }
1284
1325
  store.timelineStore = HAMT7.set(options.key, timelineData, store.timelineStore);
1285
1326
  return {
@@ -1288,28 +1329,30 @@ function timeline__INTERNAL(options, store = IMPLICIT.STORE) {
1288
1329
  };
1289
1330
  }
1290
1331
  var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1291
- var _a, _b;
1332
+ var _a, _b, _c, _d;
1333
+ (_a = store.config.logger) == null ? void 0 : _a.info(`\u23E9 redo "${token.key}"`);
1292
1334
  const timelineData = store.timelineStore.get(token.key);
1293
1335
  if (!timelineData) {
1294
- (_a = store.config.logger) == null ? void 0 : _a.error(
1295
- `Tried to redo on timeline "${token.key}" has not been initialized.`
1336
+ (_b = store.config.logger) == null ? void 0 : _b.error(
1337
+ `Failed to redo on timeline "${token.key}". This timeline has not been initialized.`
1296
1338
  );
1297
1339
  return;
1298
1340
  }
1299
1341
  if (timelineData.at === timelineData.history.length) {
1300
- (_b = store.config.logger) == null ? void 0 : _b.warn(
1301
- `Tried to redo on timeline "${token.key}" but there is nothing to redo.`
1342
+ (_c = store.config.logger) == null ? void 0 : _c.warn(
1343
+ `Failed to redo at the end of timeline "${token.key}". There is nothing to redo.`
1302
1344
  );
1303
1345
  return;
1304
1346
  }
1305
1347
  timelineData.timeTraveling = true;
1306
1348
  const update = timelineData.history[timelineData.at];
1307
1349
  switch (update.type) {
1308
- case `state_update`: {
1350
+ case `atom_update`: {
1309
1351
  const { key, newValue } = update;
1310
1352
  setState({ key, type: `atom` }, newValue);
1311
1353
  break;
1312
1354
  }
1355
+ case `selector_update`:
1313
1356
  case `transaction_update`: {
1314
1357
  for (const atomUpdate of update.atomUpdates) {
1315
1358
  const { key, newValue } = atomUpdate;
@@ -1320,19 +1363,23 @@ var redo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1320
1363
  }
1321
1364
  ++timelineData.at;
1322
1365
  timelineData.timeTraveling = false;
1366
+ (_d = store.config.logger) == null ? void 0 : _d.info(
1367
+ `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
1368
+ );
1323
1369
  };
1324
1370
  var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1325
- var _a, _b;
1371
+ var _a, _b, _c, _d;
1372
+ (_a = store.config.logger) == null ? void 0 : _a.info(`\u23EA undo "${token.key}"`);
1326
1373
  const timelineData = store.timelineStore.get(token.key);
1327
1374
  if (!timelineData) {
1328
- (_a = store.config.logger) == null ? void 0 : _a.error(
1329
- `Tried to undo on timeline "${token.key}" has not been initialized.`
1375
+ (_b = store.config.logger) == null ? void 0 : _b.error(
1376
+ `Failed to undo on timeline "${token.key}". This timeline has not been initialized.`
1330
1377
  );
1331
1378
  return;
1332
1379
  }
1333
1380
  if (timelineData.at === 0) {
1334
- (_b = store.config.logger) == null ? void 0 : _b.warn(
1335
- `Tried to undo on timeline "${token.key}" but there is nothing to undo.`
1381
+ (_c = store.config.logger) == null ? void 0 : _c.warn(
1382
+ `Failed to undo at the beginning of timeline "${token.key}". There is nothing to undo.`
1336
1383
  );
1337
1384
  return;
1338
1385
  }
@@ -1340,11 +1387,12 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1340
1387
  --timelineData.at;
1341
1388
  const update = timelineData.history[timelineData.at];
1342
1389
  switch (update.type) {
1343
- case `state_update`: {
1390
+ case `atom_update`: {
1344
1391
  const { key, oldValue } = update;
1345
1392
  setState({ key, type: `atom` }, oldValue);
1346
1393
  break;
1347
1394
  }
1395
+ case `selector_update`:
1348
1396
  case `transaction_update`: {
1349
1397
  for (const atomUpdate of update.atomUpdates) {
1350
1398
  const { key, oldValue } = atomUpdate;
@@ -1354,6 +1402,9 @@ var undo__INTERNAL = (token, store = IMPLICIT.STORE) => {
1354
1402
  }
1355
1403
  }
1356
1404
  timelineData.timeTraveling = false;
1405
+ (_d = store.config.logger) == null ? void 0 : _d.info(
1406
+ `\u23F9\uFE0F "${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
1407
+ );
1357
1408
  };
1358
1409
 
1359
1410
  // src/atom.ts
@@ -1364,6 +1415,39 @@ function atomFamily(options) {
1364
1415
  return atomFamily__INTERNAL(options);
1365
1416
  }
1366
1417
 
1418
+ // src/logger.ts
1419
+ var LOG_LEVELS = [
1420
+ `info`,
1421
+ `warn`,
1422
+ `error`
1423
+ ];
1424
+ var setLogLevel = (preferredLevel, store = IMPLICIT.STORE) => {
1425
+ const { logger__INTERNAL } = store.config;
1426
+ if (preferredLevel === null) {
1427
+ store.config.logger = null;
1428
+ } else {
1429
+ store.config.logger = __spreadValues({}, console);
1430
+ LOG_LEVELS.forEach((logLevel) => {
1431
+ if (LOG_LEVELS.indexOf(logLevel) < LOG_LEVELS.indexOf(preferredLevel)) {
1432
+ store.config.logger[logLevel] = doNothing;
1433
+ } else {
1434
+ store.config.logger[logLevel] = logger__INTERNAL[logLevel];
1435
+ }
1436
+ });
1437
+ }
1438
+ };
1439
+ var useLogger = (logger, store = IMPLICIT.STORE) => {
1440
+ var _a;
1441
+ const currentLogLevel = store.config.logger === null ? null : (_a = LOG_LEVELS.find(
1442
+ (logLevel) => {
1443
+ var _a2;
1444
+ return ((_a2 = store.config.logger) == null ? void 0 : _a2[logLevel]) !== doNothing;
1445
+ }
1446
+ )) != null ? _a : null;
1447
+ store.config.logger__INTERNAL = __spreadValues({}, logger);
1448
+ setLogLevel(currentLogLevel, store);
1449
+ };
1450
+
1367
1451
  // src/selector.ts
1368
1452
  function selector(options) {
1369
1453
  return selector__INTERNAL(options);
@@ -1372,30 +1456,13 @@ function selectorFamily(options) {
1372
1456
  return selectorFamily__INTERNAL(options);
1373
1457
  }
1374
1458
 
1375
- // src/timeline.ts
1376
- var timeline = (options) => {
1377
- return timeline__INTERNAL(options);
1378
- };
1379
- var redo = (token) => {
1380
- return redo__INTERNAL(token, IMPLICIT.STORE);
1381
- };
1382
- var undo = (token) => {
1383
- return undo__INTERNAL(token, IMPLICIT.STORE);
1384
- };
1385
-
1386
- // src/transaction.ts
1387
- function transaction(options) {
1388
- return transaction__INTERNAL(options);
1389
- }
1390
- var runTransaction = (token, store = IMPLICIT.STORE) => (...parameters) => withdraw(token, store).run(...parameters);
1391
-
1392
1459
  // src/subscribe.ts
1393
1460
  var subscribe = (token, handleUpdate, store = IMPLICIT.STORE) => {
1394
1461
  var _a;
1395
1462
  const state = withdraw(token, store);
1396
1463
  const subscription = state.subject.subscribe(handleUpdate);
1397
1464
  (_a = store.config.logger) == null ? void 0 : _a.info(`\u{1F440} subscribe to "${state.key}"`);
1398
- const dependencySubscriptions = `get` in state ? subscribeToRootAtoms(state, store) : null;
1465
+ const dependencySubscriptions = state.type !== `atom` ? subscribeToRootAtoms(state, store) : null;
1399
1466
  const unsubscribe = dependencySubscriptions === null ? () => {
1400
1467
  var _a2;
1401
1468
  (_a2 = store.config.logger) == null ? void 0 : _a2.info(`\u{1F648} unsubscribe from "${state.key}"`);
@@ -1425,19 +1492,44 @@ var subscribeToTransaction = (token, handleUpdate, store = IMPLICIT.STORE) => {
1425
1492
  return unsubscribe;
1426
1493
  };
1427
1494
 
1495
+ // src/timeline.ts
1496
+ var timeline = (options) => {
1497
+ return timeline__INTERNAL(options);
1498
+ };
1499
+ var redo = (token) => {
1500
+ return redo__INTERNAL(token, IMPLICIT.STORE);
1501
+ };
1502
+ var undo = (token) => {
1503
+ return undo__INTERNAL(token, IMPLICIT.STORE);
1504
+ };
1505
+
1506
+ // src/transaction.ts
1507
+ function transaction(options) {
1508
+ return transaction__INTERNAL(options);
1509
+ }
1510
+ var runTransaction = (token, store = IMPLICIT.STORE) => (...parameters) => withdraw(token, store).run(...parameters);
1511
+
1428
1512
  // src/index.ts
1429
1513
  var getState = (token, store = IMPLICIT.STORE) => {
1430
1514
  const state = withdraw(token, store);
1431
1515
  return getState__INTERNAL(state, store);
1432
1516
  };
1433
1517
  var setState = (token, value, store = IMPLICIT.STORE) => {
1434
- openOperation(store);
1518
+ try {
1519
+ openOperation(token, store);
1520
+ } catch (thrown) {
1521
+ if (!(typeof thrown === `symbol`)) {
1522
+ throw thrown;
1523
+ }
1524
+ return;
1525
+ }
1435
1526
  const state = withdraw(token, store);
1436
1527
  setState__INTERNAL(state, value, store);
1437
1528
  closeOperation(store);
1438
1529
  };
1439
1530
  var isDefault = (token, store = IMPLICIT.STORE) => token.type === `atom` ? isAtomDefault(token.key, store) : isSelectorDefault(token.key, store);
1440
1531
  export {
1532
+ LOG_LEVELS,
1441
1533
  internal_exports as __INTERNAL__,
1442
1534
  atom,
1443
1535
  atomFamily,