tempest.games 0.2.101 → 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.
@@ -9191,23 +9191,23 @@ var Store = class {
9191
9191
  family.install(this);
9192
9192
  }
9193
9193
  const mutableHelpers = /* @__PURE__ */ new Set;
9194
- for (const [, atom] of store.atoms) {
9195
- if (mutableHelpers.has(atom.key))
9194
+ for (const [, atom$1] of store.atoms) {
9195
+ if (mutableHelpers.has(atom$1.key))
9196
9196
  continue;
9197
- atom.install(this);
9198
- if (atom.type === `mutable_atom`) {
9199
- const originalJsonToken = getJsonToken(store, atom);
9200
- const originalUpdateToken = getUpdateToken(atom);
9197
+ atom$1.install(this);
9198
+ if (atom$1.type === `mutable_atom`) {
9199
+ const originalJsonToken = getJsonToken(store, atom$1);
9200
+ const originalUpdateToken = getUpdateToken(atom$1);
9201
9201
  mutableHelpers.add(originalJsonToken.key);
9202
9202
  mutableHelpers.add(originalUpdateToken.key);
9203
9203
  }
9204
9204
  }
9205
- for (const [, selector] of store.readonlySelectors)
9206
- selector.install(this);
9207
- for (const [, selector] of store.writableSelectors) {
9208
- if (mutableHelpers.has(selector.key))
9205
+ for (const [, selector$1] of store.readonlySelectors)
9206
+ selector$1.install(this);
9207
+ for (const [, selector$1] of store.writableSelectors) {
9208
+ if (mutableHelpers.has(selector$1.key))
9209
9209
  continue;
9210
- selector.install(this);
9210
+ selector$1.install(this);
9211
9211
  }
9212
9212
  for (const [, tx] of store.transactions)
9213
9213
  tx.install(this);
@@ -9885,26 +9885,26 @@ function dispatchOrDeferStateUpdate(target, state, proto2, stateIsNewlyCreated,
9885
9885
  }
9886
9886
  }
9887
9887
  var UNSET = Symbol(`UNSET`);
9888
- var setAtom = (target, atom, next2) => {
9888
+ var setAtom = (target, atom$1, next2) => {
9889
9889
  let oldValue;
9890
9890
  let newValue;
9891
9891
  if (isFn(next2)) {
9892
- const prev = readOrComputeValue(target, atom, `mut`);
9892
+ const prev = readOrComputeValue(target, atom$1, `mut`);
9893
9893
  oldValue = prev;
9894
9894
  newValue = next2(prev);
9895
9895
  } else {
9896
- if (target.valueMap.has(atom.key))
9897
- oldValue = readFromCache(target, atom, `mut`);
9898
- else if (atom.type === `atom` && !isFn(atom.default))
9899
- oldValue = atom.default;
9896
+ if (target.valueMap.has(atom$1.key))
9897
+ oldValue = readFromCache(target, atom$1, `mut`);
9898
+ else if (atom$1.type === `atom` && !isFn(atom$1.default))
9899
+ oldValue = atom$1.default;
9900
9900
  else
9901
9901
  oldValue = UNSET;
9902
9902
  newValue = next2;
9903
9903
  }
9904
- target.logger.info(`\u2B50`, `atom`, atom.key, `setting value`, newValue);
9905
- newValue = writeToCache(target, atom, newValue);
9906
- markDone(target, atom.key);
9907
- evictDownstreamFromAtom(target, atom);
9904
+ target.logger.info(`\u2B50`, `atom`, atom$1.key, `setting value`, newValue);
9905
+ newValue = writeToCache(target, atom$1, newValue);
9906
+ markDone(target, atom$1.key);
9907
+ evictDownstreamFromAtom(target, atom$1);
9908
9908
  if (oldValue === UNSET)
9909
9909
  return { newValue };
9910
9910
  return {
@@ -9912,17 +9912,17 @@ var setAtom = (target, atom, next2) => {
9912
9912
  newValue
9913
9913
  };
9914
9914
  };
9915
- function resetAtom(target, atom) {
9916
- switch (atom.type) {
9915
+ function resetAtom(target, atom$1) {
9916
+ switch (atom$1.type) {
9917
9917
  case `mutable_atom`:
9918
- return setAtom(target, atom, new atom.class);
9918
+ return setAtom(target, atom$1, new atom$1.class);
9919
9919
  case `atom`: {
9920
9920
  let def;
9921
- if (isFn(atom.default))
9922
- def = safeCompute(target, atom);
9921
+ if (isFn(atom$1.default))
9922
+ def = safeCompute(target, atom$1);
9923
9923
  else
9924
- def = atom.default;
9925
- return setAtom(target, atom, def);
9924
+ def = atom$1.default;
9925
+ return setAtom(target, atom$1, def);
9926
9926
  }
9927
9927
  }
9928
9928
  }
@@ -9936,8 +9936,8 @@ function resetAtomOrSelector(target, state) {
9936
9936
  case `writable_held_selector`:
9937
9937
  {
9938
9938
  const atoms = traceRootSelectorAtoms(target, state.key);
9939
- for (const atom of atoms.values())
9940
- dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
9939
+ for (const atom$1 of atoms.values())
9940
+ dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom$1), false);
9941
9941
  const value2 = state.getFrom(target);
9942
9942
  protoUpdate = {
9943
9943
  oldValue: value2,
@@ -9949,8 +9949,8 @@ function resetAtomOrSelector(target, state) {
9949
9949
  {
9950
9950
  const oldValue = safeCompute(target, state);
9951
9951
  const atoms = traceRootSelectorAtoms(target, state.key);
9952
- for (const atom of atoms.values())
9953
- dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom), false);
9952
+ for (const atom$1 of atoms.values())
9953
+ dispatchOrDeferStateUpdate(target, state, resetAtom(target, atom$1), false);
9954
9954
  protoUpdate = {
9955
9955
  oldValue,
9956
9956
  newValue: safeCompute(target, state)
@@ -9967,26 +9967,26 @@ var RESET_STATE = Symbol(`RESET`);
9967
9967
  function resetInStore(store, ...params) {
9968
9968
  setIntoStore(store, ...[...params, RESET_STATE]);
9969
9969
  }
9970
- function setSelector(target, selector, next2) {
9970
+ function setSelector(target, selector$1, next2) {
9971
9971
  let oldValue;
9972
9972
  let newValue;
9973
9973
  let constant;
9974
- const { type: type2, key } = selector;
9975
- switch (selector.type) {
9974
+ const { type: type2, key } = selector$1;
9975
+ switch (selector$1.type) {
9976
9976
  case `writable_pure_selector`:
9977
- oldValue = readOrComputeValue(target, selector, `mut`);
9977
+ oldValue = readOrComputeValue(target, selector$1, `mut`);
9978
9978
  newValue = become(next2, oldValue);
9979
- newValue = writeToCache(target, selector, newValue);
9979
+ newValue = writeToCache(target, selector$1, newValue);
9980
9980
  break;
9981
9981
  case `writable_held_selector`:
9982
- constant = selector.const;
9982
+ constant = selector$1.const;
9983
9983
  become(next2, constant);
9984
9984
  oldValue = constant;
9985
9985
  newValue = constant;
9986
9986
  }
9987
9987
  target.logger.info(`\u2B50`, type2, key, `setting to`, newValue);
9988
9988
  markDone(target, key);
9989
- selector.setSelf(newValue);
9989
+ selector$1.setSelf(newValue);
9990
9990
  return {
9991
9991
  oldValue,
9992
9992
  newValue
@@ -10085,8 +10085,8 @@ function traceRootSelectorAtoms(store, selectorKey, covered = /* @__PURE__ */ ne
10085
10085
  continue;
10086
10086
  covered.add(dependencyKey);
10087
10087
  if (isAtomKey(store, dependencyKey)) {
10088
- const atom = store.atoms.get(dependencyKey);
10089
- roots.set(atom.key, atom);
10088
+ const atom$1 = store.atoms.get(dependencyKey);
10089
+ roots.set(atom$1.key, atom$1);
10090
10090
  } else
10091
10091
  dependencies.push(...getSelectorDependencyKeys(store, dependencyKey));
10092
10092
  }
@@ -10344,13 +10344,13 @@ var recallState = (store, state) => {
10344
10344
  return target.operation.prev.get(state.key);
10345
10345
  return target.valueMap.get(state.key);
10346
10346
  };
10347
- var subscribeToRootDependency = (target, selector, atom) => {
10348
- return atom.subject.subscribe(`${selector.type}:${selector.key}`, (atomChange) => {
10349
- target.logger.info(`\uD83D\uDCE2`, selector.type, selector.key, `root`, atom.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
10350
- const oldValue = recallState(target, selector);
10351
- const newValue = readOrComputeValue(target, selector);
10352
- target.logger.info(`\u2728`, selector.type, selector.key, `went`, oldValue, `->`, newValue);
10353
- selector.subject.next({
10347
+ var subscribeToRootDependency = (target, selector$1, atom$1) => {
10348
+ return atom$1.subject.subscribe(`${selector$1.type}:${selector$1.key}`, (atomChange) => {
10349
+ target.logger.info(`\uD83D\uDCE2`, selector$1.type, selector$1.key, `root`, atom$1.key, `went`, atomChange.oldValue, `->`, atomChange.newValue);
10350
+ const oldValue = recallState(target, selector$1);
10351
+ const newValue = readOrComputeValue(target, selector$1);
10352
+ target.logger.info(`\u2728`, selector$1.type, selector$1.key, `went`, oldValue, `->`, newValue);
10353
+ selector$1.subject.next({
10354
10354
  newValue,
10355
10355
  oldValue
10356
10356
  });
@@ -10370,8 +10370,8 @@ function subscribeToState(store, token, key, handleUpdate) {
10370
10370
  let updateHandler = safelyHandleUpdate;
10371
10371
  if (isSelector) {
10372
10372
  readOrComputeValue(store, state);
10373
- for (const [atomKey, atom] of traceRootSelectorAtoms(store, state.key))
10374
- rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
10373
+ for (const [atomKey, atom$1] of traceRootSelectorAtoms(store, state.key))
10374
+ rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom$1));
10375
10375
  updateHandler = function updateRootsBeforeHandlingUpdate(update) {
10376
10376
  const dependencies = traceRootSelectorAtoms(store, state.key);
10377
10377
  for (const [previousRootKey, unsub] of rootSubs)
@@ -10381,8 +10381,8 @@ function subscribeToState(store, token, key, handleUpdate) {
10381
10381
  unsub();
10382
10382
  rootSubs.delete(previousRootKey);
10383
10383
  }
10384
- for (const [atomKey, atom] of dependencies)
10385
- rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom));
10384
+ for (const [atomKey, atom$1] of dependencies)
10385
+ rootSubs.set(atomKey, subscribeToRootDependency(store, state, atom$1));
10386
10386
  safelyHandleUpdate(update);
10387
10387
  };
10388
10388
  }
@@ -10717,9 +10717,9 @@ function evictCachedValue(target, key) {
10717
10717
  target.valueMap.delete(key);
10718
10718
  target.logger.info(`\uD83D\uDDD1`, `state`, key, `evicted`);
10719
10719
  }
10720
- function evictDownstreamFromAtom(store, atom) {
10720
+ function evictDownstreamFromAtom(store, atom$1) {
10721
10721
  const target = newest(store);
10722
- const { key, type: type2 } = atom;
10722
+ const { key, type: type2 } = atom$1;
10723
10723
  const downstreamKeys = target.selectorAtoms.getRelatedKeys(key);
10724
10724
  target.logger.info(`\uD83E\uDDF9`, type2, key, downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`, downstreamKeys ?? `to evict`);
10725
10725
  if (downstreamKeys) {
@@ -10797,10 +10797,10 @@ function createRegularAtom(store, options, family, internalRoles) {
10797
10797
  store.on.atomCreation.next(token);
10798
10798
  return token;
10799
10799
  }
10800
- function hasRole(atom, role) {
10801
- if (`internalRoles` in atom === false)
10800
+ function hasRole(atom$1, role) {
10801
+ if (`internalRoles` in atom$1 === false)
10802
10802
  return false;
10803
- return atom.internalRoles.includes(role);
10803
+ return atom$1.internalRoles.includes(role);
10804
10804
  }
10805
10805
  function capitalize3(string2) {
10806
10806
  return string2[0].toUpperCase() + string2.slice(1);
@@ -11620,7 +11620,7 @@ var SubjectSocket = class extends CustomSocket {
11620
11620
  in;
11621
11621
  out;
11622
11622
  id = `no_id_retrieved`;
11623
- disposalFunctions = [];
11623
+ disposalEffects = [];
11624
11624
  constructor(id) {
11625
11625
  super((...args2) => {
11626
11626
  this.out.next(args2);
@@ -11634,7 +11634,7 @@ var SubjectSocket = class extends CustomSocket {
11634
11634
  });
11635
11635
  }
11636
11636
  dispose() {
11637
- for (const dispose of this.disposalFunctions)
11637
+ for (const dispose of this.disposalEffects)
11638
11638
  dispose();
11639
11639
  }
11640
11640
  };
@@ -11726,18 +11726,30 @@ var ParentSocket = class extends CustomSocket {
11726
11726
  this.id = this.proc.pid?.toString();
11727
11727
  this.on(`user-joins`, (userKey) => {
11728
11728
  this.logger.info(`\uD83D\uDC64`, userKey, `joined`);
11729
- if (this.relays.get(userKey))
11729
+ const existingRelay = this.relays.get(userKey);
11730
+ if (existingRelay) {
11731
+ this.logger.info(`\uD83D\uDD17`, `reattaching relay services for`, userKey);
11732
+ const cleanupRelay$1 = this.initRelay(existingRelay, userKey);
11733
+ if (cleanupRelay$1)
11734
+ existingRelay.disposalEffects.push(cleanupRelay$1);
11735
+ this.on(userKey, (...data) => {
11736
+ relay.in.next(data);
11737
+ });
11738
+ existingRelay.disposalEffects.push(existingRelay.out.subscribe(`socket`, (data) => {
11739
+ this.emit(userKey, ...data);
11740
+ }));
11730
11741
  return;
11742
+ }
11731
11743
  const relay = new SubjectSocket(userKey);
11732
11744
  this.relays.set(userKey, relay);
11733
11745
  this.logger.info(`\uD83D\uDD17`, `attaching relay services for`, userKey);
11734
11746
  const cleanupRelay = this.initRelay(relay, userKey);
11735
11747
  if (cleanupRelay)
11736
- relay.disposalFunctions.push(cleanupRelay);
11748
+ relay.disposalEffects.push(cleanupRelay);
11737
11749
  this.on(userKey, (...data) => {
11738
11750
  relay.in.next(data);
11739
11751
  });
11740
- relay.disposalFunctions.push(relay.out.subscribe(`socket`, (data) => {
11752
+ relay.disposalEffects.push(relay.out.subscribe(`socket`, (data) => {
11741
11753
  this.emit(userKey, ...data);
11742
11754
  }));
11743
11755
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tempest.games",
3
- "version": "0.2.101",
3
+ "version": "0.2.103",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -43,9 +43,9 @@
43
43
  "react-email": "5.1.0",
44
44
  "resend": "6.6.0",
45
45
  "safegen": "0.8.3",
46
- "socket.io": "4.8.1",
47
- "socket.io-client": "4.8.1",
48
- "atom.io": "0.46.9",
46
+ "socket.io": "4.8.3",
47
+ "socket.io-client": "4.8.3",
48
+ "atom.io": "0.46.11",
49
49
  "safedeposit": "0.1.2",
50
50
  "treetrunks": "0.1.5"
51
51
  },
@@ -69,7 +69,7 @@
69
69
  "sass-embedded": "1.97.1",
70
70
  "vite": "7.3.0",
71
71
  "vitest": "4.0.16",
72
- "flightdeck": "0.3.29",
72
+ "flightdeck": "0.3.31",
73
73
  "varmint": "0.5.11"
74
74
  },
75
75
  "scripts": {