tempest.games 0.2.74 → 0.2.76

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.
@@ -42,6 +42,9 @@ function getState(...params) {
42
42
  function join(options) {
43
43
  return createJoin(IMPLICIT.STORE, options);
44
44
  }
45
+ function getInternalRelations(token) {
46
+ return getInternalRelationsFromStore(token, IMPLICIT.STORE);
47
+ }
45
48
  var PRETTY_TOKEN_TYPES = {
46
49
  atom_family: `atom family`,
47
50
  atom: `atom`,
@@ -2870,6 +2873,93 @@ function findRelationsInStore(token, key, store) {
2870
2873
  }
2871
2874
  return relations;
2872
2875
  }
2876
+ function getInternalRelationsFromStore(token, store) {
2877
+ return getJoin(token, store).relatedKeysAtoms;
2878
+ }
2879
+
2880
+ // ../../packages/atom.io/dist/realtime/index.js
2881
+ var mutexAtoms = atomFamily({
2882
+ key: `mutex`,
2883
+ default: false
2884
+ });
2885
+ var InvariantMap = class extends Map {
2886
+ set(key, value) {
2887
+ if (this.has(key)) {
2888
+ console.warn(`Tried to set a key that already exists in an InvariantMap`, {
2889
+ key,
2890
+ value
2891
+ });
2892
+ return this;
2893
+ }
2894
+ return super.set(key, value);
2895
+ }
2896
+ };
2897
+ var SyncGroup = class SyncGroup2 {
2898
+ type = `continuity`;
2899
+ globals = [];
2900
+ actions = [];
2901
+ perspectives = [];
2902
+ key;
2903
+ constructor(key) {
2904
+ this.key = key;
2905
+ }
2906
+ static existing = new InvariantMap;
2907
+ static create(key, builder) {
2908
+ const { type, globals, actions, perspectives } = builder(new SyncGroup2(key));
2909
+ const token = {
2910
+ type,
2911
+ key,
2912
+ globals,
2913
+ actions,
2914
+ perspectives
2915
+ };
2916
+ SyncGroup2.existing.set(key, token);
2917
+ return token;
2918
+ }
2919
+ add(...args) {
2920
+ switch (args[0].type) {
2921
+ case `atom`:
2922
+ case `mutable_atom`:
2923
+ this.globals.push(...args);
2924
+ break;
2925
+ case `transaction`:
2926
+ this.actions.push(...args);
2927
+ break;
2928
+ case `atom_family`:
2929
+ case `mutable_atom_family`:
2930
+ {
2931
+ const [family, index] = args;
2932
+ this.perspectives.push({
2933
+ type: `realtime_perspective`,
2934
+ resourceAtoms: family,
2935
+ viewAtoms: index
2936
+ });
2937
+ }
2938
+ break;
2939
+ }
2940
+ return this;
2941
+ }
2942
+ };
2943
+ var isSocketKey = (key) => key.startsWith(`socket::`);
2944
+ var isUserKey = (key) => key.startsWith(`user::`);
2945
+ var isRoomKey = (key) => key.startsWith(`room::`);
2946
+ var roomKeysAtom = mutableAtom({
2947
+ key: `roomIndex`,
2948
+ class: UList
2949
+ });
2950
+ var usersInRooms = join({
2951
+ key: `usersInRooms`,
2952
+ between: [`room`, `user`],
2953
+ cardinality: `1:n`,
2954
+ isAType: isRoomKey,
2955
+ isBType: isUserKey
2956
+ });
2957
+ var usersInMyRoomView = selectorFamily({
2958
+ key: `usersInMyRoomView`,
2959
+ get: (myUsername) => ({ find }) => {
2960
+ return [find(getInternalRelations(usersInRooms), myUsername)];
2961
+ }
2962
+ });
2873
2963
 
2874
2964
  // ../../packages/atom.io/dist/realtime-server/index.js
2875
2965
  var redactorAtoms = atomFamily({
@@ -3217,11 +3307,11 @@ var socketAtoms = atomFamily({
3217
3307
  key: `sockets`,
3218
3308
  default: null
3219
3309
  });
3220
- var socketIndex = mutableAtom({
3310
+ var socketKeysAtom = mutableAtom({
3221
3311
  key: `socketsIndex`,
3222
3312
  class: UList
3223
3313
  });
3224
- var userIndex = mutableAtom({
3314
+ var userKeysAtom = mutableAtom({
3225
3315
  key: `usersIndex`,
3226
3316
  class: UList
3227
3317
  });
@@ -3229,15 +3319,14 @@ var usersOfSockets = join({
3229
3319
  key: `usersOfSockets`,
3230
3320
  between: [`user`, `socket`],
3231
3321
  cardinality: `1:1`,
3232
- isAType: (s) => s.startsWith(`user::`),
3233
- isBType: (s) => s.startsWith(`socket::`)
3322
+ isAType: isUserKey,
3323
+ isBType: isSocketKey
3234
3324
  });
3235
- var userMutualSituationalAwarenessIndexes = selectorFamily({
3236
- key: `userMutualSituationalAwarenessIndexes`,
3237
- get: (userId) => () => {
3238
- return [userId];
3239
- }
3325
+ var selfListSelectors = selectorFamily({
3326
+ key: `selfList`,
3327
+ get: (userId) => () => [userId]
3240
3328
  });
3329
+ var ROOMS = globalThis.ATOM_IO_REALTIME_SERVER_ROOMS ?? (globalThis.ATOM_IO_REALTIME_SERVER_ROOMS = /* @__PURE__ */ new Map);
3241
3330
 
3242
3331
  // src/backend.worker.game.bun.ts
3243
3332
  var parent = new ParentSocket(process);