@kokimoki/app 1.3.0 → 1.3.2

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.
@@ -8,10 +8,10 @@ export declare class KokimokiAwareness<Data extends S.Generic<unknown>> extends
8
8
  data: Data;
9
9
  }>>> {
10
10
  readonly dataSchema: Data;
11
- data: Data["defaultValue"];
11
+ private _data;
12
12
  private _pingInterval;
13
13
  private _kmClients;
14
- constructor(roomName: string, dataSchema: Data, data: Data["defaultValue"], mode?: RoomSubscriptionMode, pingTimeout?: number);
14
+ constructor(roomName: string, dataSchema: Data, _data: Data["defaultValue"], mode?: RoomSubscriptionMode, pingTimeout?: number);
15
15
  onJoin(client: KokimokiClient<any>): Promise<void>;
16
16
  onBeforeLeave(client: KokimokiClient<any>): Promise<void>;
17
17
  onLeave(client: KokimokiClient<any>): Promise<void>;
@@ -3,17 +3,17 @@ import { KokimokiSchema as S } from "./kokimoki-schema";
3
3
  import { RoomSubscriptionMode } from "./room-subscription-mode";
4
4
  export class KokimokiAwareness extends KokimokiStore {
5
5
  dataSchema;
6
- data;
6
+ _data;
7
7
  _pingInterval = null;
8
8
  _kmClients = new Set();
9
- constructor(roomName, dataSchema, data, mode = RoomSubscriptionMode.ReadWrite, pingTimeout = 3000) {
9
+ constructor(roomName, dataSchema, _data, mode = RoomSubscriptionMode.ReadWrite, pingTimeout = 3000) {
10
10
  super(`/a/${roomName}`, S.dict(S.struct({
11
11
  clientId: S.string(),
12
12
  lastPing: S.number(),
13
13
  data: dataSchema,
14
14
  })), mode);
15
15
  this.dataSchema = dataSchema;
16
- this.data = data;
16
+ this._data = _data;
17
17
  this._pingInterval = setInterval(async () => {
18
18
  const kmClients = Array.from(this._kmClients);
19
19
  await Promise.all(kmClients.map(async (client) => {
@@ -28,7 +28,7 @@ export class KokimokiAwareness extends KokimokiStore {
28
28
  t.set(this.root[client.connectionId], {
29
29
  clientId: client.id,
30
30
  lastPing: timestamp,
31
- data: this.data,
31
+ data: this._data,
32
32
  });
33
33
  }
34
34
  // Delete clients that haven't pinged in a while
@@ -50,7 +50,7 @@ export class KokimokiAwareness extends KokimokiStore {
50
50
  t.set(this.root[client.connectionId], {
51
51
  clientId: client.id,
52
52
  lastPing: client.serverTimestamp(),
53
- data: this.data,
53
+ data: this._data,
54
54
  });
55
55
  });
56
56
  }
@@ -64,17 +64,18 @@ export class KokimokiAwareness extends KokimokiStore {
64
64
  }
65
65
  getClients() {
66
66
  const clients = {};
67
- for (const clientId in this.proxy) {
68
- clients[clientId] = this.proxy[clientId].data;
67
+ for (const connectionId in this.proxy) {
68
+ clients[this.proxy[connectionId].clientId] =
69
+ this.proxy[connectionId].data;
69
70
  }
70
71
  return clients;
71
72
  }
72
73
  async setData(data) {
73
- this.data = data;
74
+ this._data = data;
74
75
  const kmClients = Array.from(this._kmClients);
75
76
  await Promise.all(kmClients.map(async (client) => {
76
77
  await client.transact((t) => {
77
- t.set(this.root[client.connectionId].data, this.data);
78
+ t.set(this.root[client.connectionId].data, this._data);
78
79
  });
79
80
  }));
80
81
  }
@@ -370,10 +370,10 @@ declare class KokimokiAwareness<Data extends KokimokiSchema.Generic<unknown>> ex
370
370
  data: Data;
371
371
  }>>> {
372
372
  readonly dataSchema: Data;
373
- data: Data["defaultValue"];
373
+ private _data;
374
374
  private _pingInterval;
375
375
  private _kmClients;
376
- constructor(roomName: string, dataSchema: Data, data: Data["defaultValue"], mode?: RoomSubscriptionMode, pingTimeout?: number);
376
+ constructor(roomName: string, dataSchema: Data, _data: Data["defaultValue"], mode?: RoomSubscriptionMode, pingTimeout?: number);
377
377
  onJoin(client: KokimokiClient<any>): Promise<void>;
378
378
  onBeforeLeave(client: KokimokiClient<any>): Promise<void>;
379
379
  onLeave(client: KokimokiClient<any>): Promise<void>;
@@ -634,7 +634,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
634
634
  var eventsExports = events.exports;
635
635
  var EventEmitter$1 = /*@__PURE__*/getDefaultExportFromCjs(eventsExports);
636
636
 
637
- const KOKIMOKI_APP_VERSION = "1.3.0";
637
+ const KOKIMOKI_APP_VERSION = "1.3.2";
638
638
 
639
639
  /**
640
640
  * Utility module to work with key-value stores.
@@ -12494,17 +12494,17 @@ class KokimokiQueue extends KokimokiStore {
12494
12494
 
12495
12495
  class KokimokiAwareness extends KokimokiStore {
12496
12496
  dataSchema;
12497
- data;
12497
+ _data;
12498
12498
  _pingInterval = null;
12499
12499
  _kmClients = new Set();
12500
- constructor(roomName, dataSchema, data, mode = RoomSubscriptionMode.ReadWrite, pingTimeout = 3000) {
12500
+ constructor(roomName, dataSchema, _data, mode = RoomSubscriptionMode.ReadWrite, pingTimeout = 3000) {
12501
12501
  super(`/a/${roomName}`, KokimokiSchema.dict(KokimokiSchema.struct({
12502
12502
  clientId: KokimokiSchema.string(),
12503
12503
  lastPing: KokimokiSchema.number(),
12504
12504
  data: dataSchema,
12505
12505
  })), mode);
12506
12506
  this.dataSchema = dataSchema;
12507
- this.data = data;
12507
+ this._data = _data;
12508
12508
  this._pingInterval = setInterval(async () => {
12509
12509
  const kmClients = Array.from(this._kmClients);
12510
12510
  await Promise.all(kmClients.map(async (client) => {
@@ -12519,7 +12519,7 @@ class KokimokiAwareness extends KokimokiStore {
12519
12519
  t.set(this.root[client.connectionId], {
12520
12520
  clientId: client.id,
12521
12521
  lastPing: timestamp,
12522
- data: this.data,
12522
+ data: this._data,
12523
12523
  });
12524
12524
  }
12525
12525
  // Delete clients that haven't pinged in a while
@@ -12541,7 +12541,7 @@ class KokimokiAwareness extends KokimokiStore {
12541
12541
  t.set(this.root[client.connectionId], {
12542
12542
  clientId: client.id,
12543
12543
  lastPing: client.serverTimestamp(),
12544
- data: this.data,
12544
+ data: this._data,
12545
12545
  });
12546
12546
  });
12547
12547
  }
@@ -12555,17 +12555,18 @@ class KokimokiAwareness extends KokimokiStore {
12555
12555
  }
12556
12556
  getClients() {
12557
12557
  const clients = {};
12558
- for (const clientId in this.proxy) {
12559
- clients[clientId] = this.proxy[clientId].data;
12558
+ for (const connectionId in this.proxy) {
12559
+ clients[this.proxy[connectionId].clientId] =
12560
+ this.proxy[connectionId].data;
12560
12561
  }
12561
12562
  return clients;
12562
12563
  }
12563
12564
  async setData(data) {
12564
- this.data = data;
12565
+ this._data = data;
12565
12566
  const kmClients = Array.from(this._kmClients);
12566
12567
  await Promise.all(kmClients.map(async (client) => {
12567
12568
  await client.transact((t) => {
12568
- t.set(this.root[client.connectionId].data, this.data);
12569
+ t.set(this.root[client.connectionId].data, this._data);
12569
12570
  });
12570
12571
  }));
12571
12572
  }