tempest.games 0.2.102 → 0.2.103

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/app/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>TEMPEST</title>
8
- <script type="module" crossorigin src="/assets/index-DgtNKk2k.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-D3X4KPAg.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DZ_4vJcE.css">
10
10
  </head>
11
11
  <body>
@@ -50111,23 +50111,23 @@ var Store = class {
50111
50111
  family.install(this);
50112
50112
  }
50113
50113
  const mutableHelpers = /* @__PURE__ */ new Set;
50114
- for (const [, atom] of store.atoms) {
50115
- if (mutableHelpers.has(atom.key))
50114
+ for (const [, atom$1] of store.atoms) {
50115
+ if (mutableHelpers.has(atom$1.key))
50116
50116
  continue;
50117
- atom.install(this);
50118
- if (atom.type === `mutable_atom`) {
50119
- const originalJsonToken = getJsonToken(store, atom);
50120
- const originalUpdateToken = getUpdateToken(atom);
50117
+ atom$1.install(this);
50118
+ if (atom$1.type === `mutable_atom`) {
50119
+ const originalJsonToken = getJsonToken(store, atom$1);
50120
+ const originalUpdateToken = getUpdateToken(atom$1);
50121
50121
  mutableHelpers.add(originalJsonToken.key);
50122
50122
  mutableHelpers.add(originalUpdateToken.key);
50123
50123
  }
50124
50124
  }
50125
- for (const [, selector] of store.readonlySelectors)
50126
- selector.install(this);
50127
- for (const [, selector] of store.writableSelectors) {
50128
- if (mutableHelpers.has(selector.key))
50125
+ for (const [, selector$1] of store.readonlySelectors)
50126
+ selector$1.install(this);
50127
+ for (const [, selector$1] of store.writableSelectors) {
50128
+ if (mutableHelpers.has(selector$1.key))
50129
50129
  continue;
50130
- selector.install(this);
50130
+ selector$1.install(this);
50131
50131
  }
50132
50132
  for (const [, tx] of store.transactions)
50133
50133
  tx.install(this);
@@ -50805,26 +50805,26 @@ function dispatchOrDeferStateUpdate(target, state, proto, stateIsNewlyCreated, f
50805
50805
  }
50806
50806
  }
50807
50807
  var UNSET = Symbol(`UNSET`);
50808
- var setAtom = (target, atom, next) => {
50808
+ var setAtom = (target, atom$1, next) => {
50809
50809
  let oldValue;
50810
50810
  let newValue;
50811
50811
  if (isFn(next)) {
50812
- const prev = readOrComputeValue(target, atom, `mut`);
50812
+ const prev = readOrComputeValue(target, atom$1, `mut`);
50813
50813
  oldValue = prev;
50814
50814
  newValue = next(prev);
50815
50815
  } else {
50816
- if (target.valueMap.has(atom.key))
50817
- oldValue = readFromCache(target, atom, `mut`);
50818
- else if (atom.type === `atom` && !isFn(atom.default))
50819
- oldValue = atom.default;
50816
+ if (target.valueMap.has(atom$1.key))
50817
+ oldValue = readFromCache(target, atom$1, `mut`);
50818
+ else if (atom$1.type === `atom` && !isFn(atom$1.default))
50819
+ oldValue = atom$1.default;
50820
50820
  else
50821
50821
  oldValue = UNSET;
50822
50822
  newValue = next;
50823
50823
  }
50824
- target.logger.info(`\u2B50`, `atom`, atom.key, `setting value`, newValue);
50825
- newValue = writeToCache(target, atom, newValue);
50826
- markDone(target, atom.key);
50827
- evictDownstreamFromAtom(target, atom);
50824
+ target.logger.info(`\u2B50`, `atom`, atom$1.key, `setting value`, newValue);
50825
+ newValue = writeToCache(target, atom$1, newValue);
50826
+ markDone(target, atom$1.key);
50827
+ evictDownstreamFromAtom(target, atom$1);
50828
50828
  if (oldValue === UNSET)
50829
50829
  return { newValue };
50830
50830
  return {
@@ -50832,17 +50832,17 @@ var setAtom = (target, atom, next) => {
50832
50832
  newValue
50833
50833
  };
50834
50834
  };
50835
- function resetAtom(target, atom) {
50836
- switch (atom.type) {
50835
+ function resetAtom(target, atom$1) {
50836
+ switch (atom$1.type) {
50837
50837
  case `mutable_atom`:
50838
- return setAtom(target, atom, new atom.class);
50838
+ return setAtom(target, atom$1, new atom$1.class);
50839
50839
  case `atom`: {
50840
50840
  let def;
50841
- if (isFn(atom.default))
50842
- def = safeCompute(target, atom);
50841
+ if (isFn(atom$1.default))
50842
+ def = safeCompute(target, atom$1);
50843
50843
  else
50844
- def = atom.default;
50845
- return setAtom(target, atom, def);
50844
+ def = atom$1.default;
50845
+ return setAtom(target, atom$1, def);
50846
50846
  }
50847
50847
  }
50848
50848
  }
@@ -50856,8 +50856,8 @@ function resetAtomOrSelector(target, state) {
50856
50856
  case `writable_held_selector`:
50857
50857
  {
50858
50858
  const atoms = traceRootSelectorAtoms(target, state.key);
50859
- for (const atom of atoms.values())
50860
- dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
50859
+ for (const atom$1 of atoms.values())
50860
+ dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom$1), false);
50861
50861
  const value = state.getFrom(target);
50862
50862
  protoUpdate = {
50863
50863
  oldValue: value,
@@ -50869,8 +50869,8 @@ function resetAtomOrSelector(target, state) {
50869
50869
  {
50870
50870
  const oldValue = safeCompute(target, state);
50871
50871
  const atoms = traceRootSelectorAtoms(target, state.key);
50872
- for (const atom of atoms.values())
50873
- dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
50872
+ for (const atom$1 of atoms.values())
50873
+ dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom$1), false);
50874
50874
  protoUpdate = {
50875
50875
  oldValue,
50876
50876
  newValue: safeCompute(target, state)
@@ -50887,26 +50887,26 @@ var RESET_STATE = Symbol(`RESET`);
50887
50887
  function resetInStore(store, ...params) {
50888
50888
  setIntoStore(store, ...[...params, RESET_STATE]);
50889
50889
  }
50890
- function setSelector(target, selector, next) {
50890
+ function setSelector(target, selector$1, next) {
50891
50891
  let oldValue;
50892
50892
  let newValue;
50893
50893
  let constant;
50894
- const { type, key } = selector;
50895
- switch (selector.type) {
50894
+ const { type, key } = selector$1;
50895
+ switch (selector$1.type) {
50896
50896
  case `writable_pure_selector`:
50897
- oldValue = readOrComputeValue(target, selector, `mut`);
50897
+ oldValue = readOrComputeValue(target, selector$1, `mut`);
50898
50898
  newValue = become(next, oldValue);
50899
- newValue = writeToCache(target, selector, newValue);
50899
+ newValue = writeToCache(target, selector$1, newValue);
50900
50900
  break;
50901
50901
  case `writable_held_selector`:
50902
- constant = selector.const;
50902
+ constant = selector$1.const;
50903
50903
  become(next, constant);
50904
50904
  oldValue = constant;
50905
50905
  newValue = constant;
50906
50906
  }
50907
50907
  target.logger.info(`\u2B50`, type, key, `setting to`, newValue);
50908
50908
  markDone(target, key);
50909
- selector.setSelf(newValue);
50909
+ selector$1.setSelf(newValue);
50910
50910
  return {
50911
50911
  oldValue,
50912
50912
  newValue
@@ -51005,8 +51005,8 @@ function traceRootSelectorAtoms(store, selectorKey, covered = /* @__PURE__ */ ne
51005
51005
  continue;
51006
51006
  covered.add(dependencyKey);
51007
51007
  if (isAtomKey(store, dependencyKey)) {
51008
- const atom = store.atoms.get(dependencyKey);
51009
- roots.set(atom.key, atom);
51008
+ const atom$1 = store.atoms.get(dependencyKey);
51009
+ roots.set(atom$1.key, atom$1);
51010
51010
  } else
51011
51011
  dependencies.push(...getSelectorDependencyKeys(store, dependencyKey));
51012
51012
  }
@@ -51264,13 +51264,13 @@ var recallState = (store, state) => {
51264
51264
  return target.operation.prev.get(state.key);
51265
51265
  return target.valueMap.get(state.key);
51266
51266
  };
51267
- var subscribeToRootDependency = (target, selector, atom) => {
51268
- return atom.subject.subscribe(`${selector.type}:${selector.key}`, (atomChange) => {
51269
- target.logger.info(`\uD83D\uDCE2`, selector.type, selector.key, `root`, atom.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
51270
- const oldValue = recallState(target, selector);
51271
- const newValue = readOrComputeValue(target, selector);
51272
- target.logger.info(`\u2728`, selector.type, selector.key, `went`, oldValue, `->`, newValue);
51273
- selector.subject.next({
51267
+ var subscribeToRootDependency = (target, selector$1, atom$1) => {
51268
+ return atom$1.subject.subscribe(`${selector$1.type}:${selector$1.key}`, (atomChange) => {
51269
+ target.logger.info(`\uD83D\uDCE2`, selector$1.type, selector$1.key, `root`, atom$1.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
51270
+ const oldValue = recallState(target, selector$1);
51271
+ const newValue = readOrComputeValue(target, selector$1);
51272
+ target.logger.info(`\u2728`, selector$1.type, selector$1.key, `went`, oldValue, `->`, newValue);
51273
+ selector$1.subject.next({
51274
51274
  newValue,
51275
51275
  oldValue
51276
51276
  });
@@ -51290,8 +51290,8 @@ function subscribeToState(store, token, key, handleUpdate) {
51290
51290
  let updateHandler = safelyHandleUpdate;
51291
51291
  if (isSelector) {
51292
51292
  readOrComputeValue(store, state);
51293
- for (const [atomKey, atom] of traceRootSelectorAtoms(store, state.key))
51294
- rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
51293
+ for (const [atomKey, atom$1] of traceRootSelectorAtoms(store, state.key))
51294
+ rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom$1));
51295
51295
  updateHandler = function updateRootsBeforeHandlingUpdate(update) {
51296
51296
  const dependencies = traceRootSelectorAtoms(store, state.key);
51297
51297
  for (const [previousRootKey, unsub] of rootSubs)
@@ -51301,8 +51301,8 @@ function subscribeToState(store, token, key, handleUpdate) {
51301
51301
  unsub();
51302
51302
  rootSubs.delete(previousRootKey);
51303
51303
  }
51304
- for (const [atomKey, atom] of dependencies)
51305
- rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
51304
+ for (const [atomKey, atom$1] of dependencies)
51305
+ rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom$1));
51306
51306
  safelyHandleUpdate(update);
51307
51307
  };
51308
51308
  }
@@ -51637,9 +51637,9 @@ function evictCachedValue(target, key) {
51637
51637
  target.valueMap.delete(key);
51638
51638
  target.logger.info(`\uD83D\uDDD1`, `state`, key, `evicted`);
51639
51639
  }
51640
- function evictDownstreamFromAtom(store, atom) {
51640
+ function evictDownstreamFromAtom(store, atom$1) {
51641
51641
  const target = newest(store);
51642
- const { key, type } = atom;
51642
+ const { key, type } = atom$1;
51643
51643
  const downstreamKeys = target.selectorAtoms.getRelatedKeys(key);
51644
51644
  target.logger.info(`\uD83E\uDDF9`, type, key, downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`, downstreamKeys ?? `to evict`);
51645
51645
  if (downstreamKeys) {
@@ -51717,10 +51717,10 @@ function createRegularAtom(store, options, family, internalRoles) {
51717
51717
  store.on.atomCreation.next(token);
51718
51718
  return token;
51719
51719
  }
51720
- function hasRole(atom, role) {
51721
- if (`internalRoles` in atom === false)
51720
+ function hasRole(atom$1, role) {
51721
+ if (`internalRoles` in atom$1 === false)
51722
51722
  return false;
51723
- return atom.internalRoles.includes(role);
51723
+ return atom$1.internalRoles.includes(role);
51724
51724
  }
51725
51725
  function capitalize(string) {
51726
51726
  return string[0].toUpperCase() + string.slice(1);
@@ -60631,7 +60631,7 @@ var SubjectSocket = class extends CustomSocket {
60631
60631
  in;
60632
60632
  out;
60633
60633
  id = `no_id_retrieved`;
60634
- disposalFunctions = [];
60634
+ disposalEffects = [];
60635
60635
  constructor(id) {
60636
60636
  super((...args2) => {
60637
60637
  this.out.next(args2);
@@ -60645,7 +60645,7 @@ var SubjectSocket = class extends CustomSocket {
60645
60645
  });
60646
60646
  }
60647
60647
  dispose() {
60648
- for (const dispose of this.disposalFunctions)
60648
+ for (const dispose of this.disposalEffects)
60649
60649
  dispose();
60650
60650
  }
60651
60651
  };
@@ -60737,18 +60737,30 @@ var ParentSocket = class extends CustomSocket {
60737
60737
  this.id = this.proc.pid?.toString();
60738
60738
  this.on(`user-joins`, (userKey) => {
60739
60739
  this.logger.info(`\uD83D\uDC64`, userKey, `joined`);
60740
- if (this.relays.get(userKey))
60740
+ const existingRelay = this.relays.get(userKey);
60741
+ if (existingRelay) {
60742
+ this.logger.info(`\uD83D\uDD17`, `reattaching relay services for`, userKey);
60743
+ const cleanupRelay$1 = this.initRelay(existingRelay, userKey);
60744
+ if (cleanupRelay$1)
60745
+ existingRelay.disposalEffects.push(cleanupRelay$1);
60746
+ this.on(userKey, (...data) => {
60747
+ relay.in.next(data);
60748
+ });
60749
+ existingRelay.disposalEffects.push(existingRelay.out.subscribe(`socket`, (data) => {
60750
+ this.emit(userKey, ...data);
60751
+ }));
60741
60752
  return;
60753
+ }
60742
60754
  const relay = new SubjectSocket(userKey);
60743
60755
  this.relays.set(userKey, relay);
60744
60756
  this.logger.info(`\uD83D\uDD17`, `attaching relay services for`, userKey);
60745
60757
  const cleanupRelay = this.initRelay(relay, userKey);
60746
60758
  if (cleanupRelay)
60747
- relay.disposalFunctions.push(cleanupRelay);
60759
+ relay.disposalEffects.push(cleanupRelay);
60748
60760
  this.on(userKey, (...data) => {
60749
60761
  relay.in.next(data);
60750
60762
  });
60751
- relay.disposalFunctions.push(relay.out.subscribe(`socket`, (data) => {
60763
+ relay.disposalEffects.push(relay.out.subscribe(`socket`, (data) => {
60752
60764
  this.emit(userKey, ...data);
60753
60765
  }));
60754
60766
  });
@@ -981,23 +981,23 @@ var Store = class {
981
981
  family.install(this);
982
982
  }
983
983
  const mutableHelpers = /* @__PURE__ */ new Set;
984
- for (const [, atom] of store.atoms) {
985
- if (mutableHelpers.has(atom.key))
984
+ for (const [, atom$1] of store.atoms) {
985
+ if (mutableHelpers.has(atom$1.key))
986
986
  continue;
987
- atom.install(this);
988
- if (atom.type === `mutable_atom`) {
989
- const originalJsonToken = getJsonToken(store, atom);
990
- const originalUpdateToken = getUpdateToken(atom);
987
+ atom$1.install(this);
988
+ if (atom$1.type === `mutable_atom`) {
989
+ const originalJsonToken = getJsonToken(store, atom$1);
990
+ const originalUpdateToken = getUpdateToken(atom$1);
991
991
  mutableHelpers.add(originalJsonToken.key);
992
992
  mutableHelpers.add(originalUpdateToken.key);
993
993
  }
994
994
  }
995
- for (const [, selector] of store.readonlySelectors)
996
- selector.install(this);
997
- for (const [, selector] of store.writableSelectors) {
998
- if (mutableHelpers.has(selector.key))
995
+ for (const [, selector$1] of store.readonlySelectors)
996
+ selector$1.install(this);
997
+ for (const [, selector$1] of store.writableSelectors) {
998
+ if (mutableHelpers.has(selector$1.key))
999
999
  continue;
1000
- selector.install(this);
1000
+ selector$1.install(this);
1001
1001
  }
1002
1002
  for (const [, tx] of store.transactions)
1003
1003
  tx.install(this);
@@ -1675,26 +1675,26 @@ function dispatchOrDeferStateUpdate(target, state, proto, stateIsNewlyCreated, f
1675
1675
  }
1676
1676
  }
1677
1677
  var UNSET = Symbol(`UNSET`);
1678
- var setAtom = (target, atom, next) => {
1678
+ var setAtom = (target, atom$1, next) => {
1679
1679
  let oldValue;
1680
1680
  let newValue;
1681
1681
  if (isFn(next)) {
1682
- const prev = readOrComputeValue(target, atom, `mut`);
1682
+ const prev = readOrComputeValue(target, atom$1, `mut`);
1683
1683
  oldValue = prev;
1684
1684
  newValue = next(prev);
1685
1685
  } else {
1686
- if (target.valueMap.has(atom.key))
1687
- oldValue = readFromCache(target, atom, `mut`);
1688
- else if (atom.type === `atom` && !isFn(atom.default))
1689
- oldValue = atom.default;
1686
+ if (target.valueMap.has(atom$1.key))
1687
+ oldValue = readFromCache(target, atom$1, `mut`);
1688
+ else if (atom$1.type === `atom` && !isFn(atom$1.default))
1689
+ oldValue = atom$1.default;
1690
1690
  else
1691
1691
  oldValue = UNSET;
1692
1692
  newValue = next;
1693
1693
  }
1694
- target.logger.info(`\u2B50`, `atom`, atom.key, `setting value`, newValue);
1695
- newValue = writeToCache(target, atom, newValue);
1696
- markDone(target, atom.key);
1697
- evictDownstreamFromAtom(target, atom);
1694
+ target.logger.info(`\u2B50`, `atom`, atom$1.key, `setting value`, newValue);
1695
+ newValue = writeToCache(target, atom$1, newValue);
1696
+ markDone(target, atom$1.key);
1697
+ evictDownstreamFromAtom(target, atom$1);
1698
1698
  if (oldValue === UNSET)
1699
1699
  return { newValue };
1700
1700
  return {
@@ -1702,17 +1702,17 @@ var setAtom = (target, atom, next) => {
1702
1702
  newValue
1703
1703
  };
1704
1704
  };
1705
- function resetAtom(target, atom) {
1706
- switch (atom.type) {
1705
+ function resetAtom(target, atom$1) {
1706
+ switch (atom$1.type) {
1707
1707
  case `mutable_atom`:
1708
- return setAtom(target, atom, new atom.class);
1708
+ return setAtom(target, atom$1, new atom$1.class);
1709
1709
  case `atom`: {
1710
1710
  let def;
1711
- if (isFn(atom.default))
1712
- def = safeCompute(target, atom);
1711
+ if (isFn(atom$1.default))
1712
+ def = safeCompute(target, atom$1);
1713
1713
  else
1714
- def = atom.default;
1715
- return setAtom(target, atom, def);
1714
+ def = atom$1.default;
1715
+ return setAtom(target, atom$1, def);
1716
1716
  }
1717
1717
  }
1718
1718
  }
@@ -1726,8 +1726,8 @@ function resetAtomOrSelector(target, state) {
1726
1726
  case `writable_held_selector`:
1727
1727
  {
1728
1728
  const atoms = traceRootSelectorAtoms(target, state.key);
1729
- for (const atom of atoms.values())
1730
- dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
1729
+ for (const atom$1 of atoms.values())
1730
+ dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom$1), false);
1731
1731
  const value = state.getFrom(target);
1732
1732
  protoUpdate = {
1733
1733
  oldValue: value,
@@ -1739,8 +1739,8 @@ function resetAtomOrSelector(target, state) {
1739
1739
  {
1740
1740
  const oldValue = safeCompute(target, state);
1741
1741
  const atoms = traceRootSelectorAtoms(target, state.key);
1742
- for (const atom of atoms.values())
1743
- dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
1742
+ for (const atom$1 of atoms.values())
1743
+ dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom$1), false);
1744
1744
  protoUpdate = {
1745
1745
  oldValue,
1746
1746
  newValue: safeCompute(target, state)
@@ -1757,26 +1757,26 @@ var RESET_STATE = Symbol(`RESET`);
1757
1757
  function resetInStore(store, ...params) {
1758
1758
  setIntoStore(store, ...[...params, RESET_STATE]);
1759
1759
  }
1760
- function setSelector(target, selector, next) {
1760
+ function setSelector(target, selector$1, next) {
1761
1761
  let oldValue;
1762
1762
  let newValue;
1763
1763
  let constant;
1764
- const { type, key } = selector;
1765
- switch (selector.type) {
1764
+ const { type, key } = selector$1;
1765
+ switch (selector$1.type) {
1766
1766
  case `writable_pure_selector`:
1767
- oldValue = readOrComputeValue(target, selector, `mut`);
1767
+ oldValue = readOrComputeValue(target, selector$1, `mut`);
1768
1768
  newValue = become(next, oldValue);
1769
- newValue = writeToCache(target, selector, newValue);
1769
+ newValue = writeToCache(target, selector$1, newValue);
1770
1770
  break;
1771
1771
  case `writable_held_selector`:
1772
- constant = selector.const;
1772
+ constant = selector$1.const;
1773
1773
  become(next, constant);
1774
1774
  oldValue = constant;
1775
1775
  newValue = constant;
1776
1776
  }
1777
1777
  target.logger.info(`\u2B50`, type, key, `setting to`, newValue);
1778
1778
  markDone(target, key);
1779
- selector.setSelf(newValue);
1779
+ selector$1.setSelf(newValue);
1780
1780
  return {
1781
1781
  oldValue,
1782
1782
  newValue
@@ -1875,8 +1875,8 @@ function traceRootSelectorAtoms(store, selectorKey, covered = /* @__PURE__ */ ne
1875
1875
  continue;
1876
1876
  covered.add(dependencyKey);
1877
1877
  if (isAtomKey(store, dependencyKey)) {
1878
- const atom = store.atoms.get(dependencyKey);
1879
- roots.set(atom.key, atom);
1878
+ const atom$1 = store.atoms.get(dependencyKey);
1879
+ roots.set(atom$1.key, atom$1);
1880
1880
  } else
1881
1881
  dependencies.push(...getSelectorDependencyKeys(store, dependencyKey));
1882
1882
  }
@@ -2134,13 +2134,13 @@ var recallState = (store, state) => {
2134
2134
  return target.operation.prev.get(state.key);
2135
2135
  return target.valueMap.get(state.key);
2136
2136
  };
2137
- var subscribeToRootDependency = (target, selector, atom) => {
2138
- return atom.subject.subscribe(`${selector.type}:${selector.key}`, (atomChange) => {
2139
- target.logger.info(`\uD83D\uDCE2`, selector.type, selector.key, `root`, atom.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
2140
- const oldValue = recallState(target, selector);
2141
- const newValue = readOrComputeValue(target, selector);
2142
- target.logger.info(`\u2728`, selector.type, selector.key, `went`, oldValue, `->`, newValue);
2143
- selector.subject.next({
2137
+ var subscribeToRootDependency = (target, selector$1, atom$1) => {
2138
+ return atom$1.subject.subscribe(`${selector$1.type}:${selector$1.key}`, (atomChange) => {
2139
+ target.logger.info(`\uD83D\uDCE2`, selector$1.type, selector$1.key, `root`, atom$1.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
2140
+ const oldValue = recallState(target, selector$1);
2141
+ const newValue = readOrComputeValue(target, selector$1);
2142
+ target.logger.info(`\u2728`, selector$1.type, selector$1.key, `went`, oldValue, `->`, newValue);
2143
+ selector$1.subject.next({
2144
2144
  newValue,
2145
2145
  oldValue
2146
2146
  });
@@ -2160,8 +2160,8 @@ function subscribeToState(store, token, key, handleUpdate) {
2160
2160
  let updateHandler = safelyHandleUpdate;
2161
2161
  if (isSelector) {
2162
2162
  readOrComputeValue(store, state);
2163
- for (const [atomKey, atom] of traceRootSelectorAtoms(store, state.key))
2164
- rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
2163
+ for (const [atomKey, atom$1] of traceRootSelectorAtoms(store, state.key))
2164
+ rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom$1));
2165
2165
  updateHandler = function updateRootsBeforeHandlingUpdate(update) {
2166
2166
  const dependencies = traceRootSelectorAtoms(store, state.key);
2167
2167
  for (const [previousRootKey, unsub] of rootSubs)
@@ -2171,8 +2171,8 @@ function subscribeToState(store, token, key, handleUpdate) {
2171
2171
  unsub();
2172
2172
  rootSubs.delete(previousRootKey);
2173
2173
  }
2174
- for (const [atomKey, atom] of dependencies)
2175
- rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
2174
+ for (const [atomKey, atom$1] of dependencies)
2175
+ rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom$1));
2176
2176
  safelyHandleUpdate(update);
2177
2177
  };
2178
2178
  }
@@ -2507,9 +2507,9 @@ function evictCachedValue(target, key) {
2507
2507
  target.valueMap.delete(key);
2508
2508
  target.logger.info(`\uD83D\uDDD1`, `state`, key, `evicted`);
2509
2509
  }
2510
- function evictDownstreamFromAtom(store, atom) {
2510
+ function evictDownstreamFromAtom(store, atom$1) {
2511
2511
  const target = newest(store);
2512
- const { key, type } = atom;
2512
+ const { key, type } = atom$1;
2513
2513
  const downstreamKeys = target.selectorAtoms.getRelatedKeys(key);
2514
2514
  target.logger.info(`\uD83E\uDDF9`, type, key, downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`, downstreamKeys ?? `to evict`);
2515
2515
  if (downstreamKeys) {
@@ -2587,10 +2587,10 @@ function createRegularAtom(store, options, family, internalRoles) {
2587
2587
  store.on.atomCreation.next(token);
2588
2588
  return token;
2589
2589
  }
2590
- function hasRole(atom, role) {
2591
- if (`internalRoles` in atom === false)
2590
+ function hasRole(atom$1, role) {
2591
+ if (`internalRoles` in atom$1 === false)
2592
2592
  return false;
2593
- return atom.internalRoles.includes(role);
2593
+ return atom$1.internalRoles.includes(role);
2594
2594
  }
2595
2595
  function capitalize(string) {
2596
2596
  return string[0].toUpperCase() + string.slice(1);
@@ -3051,7 +3051,7 @@ var SubjectSocket = class extends CustomSocket {
3051
3051
  in;
3052
3052
  out;
3053
3053
  id = `no_id_retrieved`;
3054
- disposalFunctions = [];
3054
+ disposalEffects = [];
3055
3055
  constructor(id) {
3056
3056
  super((...args) => {
3057
3057
  this.out.next(args);
@@ -3065,7 +3065,7 @@ var SubjectSocket = class extends CustomSocket {
3065
3065
  });
3066
3066
  }
3067
3067
  dispose() {
3068
- for (const dispose of this.disposalFunctions)
3068
+ for (const dispose of this.disposalEffects)
3069
3069
  dispose();
3070
3070
  }
3071
3071
  };
@@ -3157,18 +3157,30 @@ var ParentSocket = class extends CustomSocket {
3157
3157
  this.id = this.proc.pid?.toString();
3158
3158
  this.on(`user-joins`, (userKey) => {
3159
3159
  this.logger.info(`\uD83D\uDC64`, userKey, `joined`);
3160
- if (this.relays.get(userKey))
3160
+ const existingRelay = this.relays.get(userKey);
3161
+ if (existingRelay) {
3162
+ this.logger.info(`\uD83D\uDD17`, `reattaching relay services for`, userKey);
3163
+ const cleanupRelay$1 = this.initRelay(existingRelay, userKey);
3164
+ if (cleanupRelay$1)
3165
+ existingRelay.disposalEffects.push(cleanupRelay$1);
3166
+ this.on(userKey, (...data) => {
3167
+ relay.in.next(data);
3168
+ });
3169
+ existingRelay.disposalEffects.push(existingRelay.out.subscribe(`socket`, (data) => {
3170
+ this.emit(userKey, ...data);
3171
+ }));
3161
3172
  return;
3173
+ }
3162
3174
  const relay = new SubjectSocket(userKey);
3163
3175
  this.relays.set(userKey, relay);
3164
3176
  this.logger.info(`\uD83D\uDD17`, `attaching relay services for`, userKey);
3165
3177
  const cleanupRelay = this.initRelay(relay, userKey);
3166
3178
  if (cleanupRelay)
3167
- relay.disposalFunctions.push(cleanupRelay);
3179
+ relay.disposalEffects.push(cleanupRelay);
3168
3180
  this.on(userKey, (...data) => {
3169
3181
  relay.in.next(data);
3170
3182
  });
3171
- relay.disposalFunctions.push(relay.out.subscribe(`socket`, (data) => {
3183
+ relay.disposalEffects.push(relay.out.subscribe(`socket`, (data) => {
3172
3184
  this.emit(userKey, ...data);
3173
3185
  }));
3174
3186
  });