@liveblocks/client 0.14.2 → 0.14.5

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.
@@ -6,6 +6,7 @@ export declare type ApplyResult = {
6
6
  modified: false;
7
7
  };
8
8
  export interface Doc {
9
+ roomId: string;
9
10
  generateId: () => string;
10
11
  generateOpId: () => string;
11
12
  getItem: (id: string) => AbstractCrdt | undefined;
@@ -19,6 +20,7 @@ export declare abstract class AbstractCrdt {
19
20
  * INTERNAL
20
21
  */
21
22
  protected get _doc(): Doc | undefined;
23
+ get roomId(): string | null;
22
24
  /**
23
25
  * INTERNAL
24
26
  */
@@ -27,6 +27,9 @@ class AbstractCrdt {
27
27
  get _doc() {
28
28
  return __classPrivateFieldGet(this, _AbstractCrdt_doc, "f");
29
29
  }
30
+ get roomId() {
31
+ return __classPrivateFieldGet(this, _AbstractCrdt_doc, "f") ? __classPrivateFieldGet(this, _AbstractCrdt_doc, "f").roomId : null;
32
+ }
30
33
  /**
31
34
  * INTERNAL
32
35
  */
package/lib/cjs/room.js CHANGED
@@ -169,6 +169,7 @@ function makeStateMachine(state, context, mockedEffects) {
169
169
  generateId,
170
170
  generateOpId,
171
171
  dispatch: storageDispatch,
172
+ roomId: context.room,
172
173
  });
173
174
  }
174
175
  function addItem(id, item) {
@@ -664,6 +665,11 @@ See v0.13 release notes for more information.
664
665
  if (state.connection.state === "connecting") {
665
666
  updateConnection(Object.assign(Object.assign({}, state.connection), { state: "open" }));
666
667
  state.numberOfRetry = 0;
668
+ // Re-broadcast the user presence during a reconnect.
669
+ if (state.lastConnectionId !== undefined) {
670
+ state.buffer.presence = state.me;
671
+ tryFlushing();
672
+ }
667
673
  state.lastConnectionId = state.connection.id;
668
674
  if (state.root) {
669
675
  state.buffer.messages.push({ type: live_1.ClientMessageType.FetchStorage });
@@ -1025,6 +1031,7 @@ function createRoom(options, context) {
1025
1031
  const state = defaultState(options.defaultPresence, options.defaultStorageRoot);
1026
1032
  const machine = makeStateMachine(state, context);
1027
1033
  const room = {
1034
+ id: context.room,
1028
1035
  /////////////
1029
1036
  // Core //
1030
1037
  /////////////
@@ -167,6 +167,10 @@ export declare type OthersEvent<T extends Presence = Presence> = {
167
167
  type: "reset";
168
168
  };
169
169
  export declare type Room = {
170
+ /**
171
+ * The id of the room.
172
+ */
173
+ readonly id: string;
170
174
  getConnectionState(): ConnectionState;
171
175
  subscribe: {
172
176
  /**
@@ -6,6 +6,7 @@ export declare type ApplyResult = {
6
6
  modified: false;
7
7
  };
8
8
  export interface Doc {
9
+ roomId: string;
9
10
  generateId: () => string;
10
11
  generateOpId: () => string;
11
12
  getItem: (id: string) => AbstractCrdt | undefined;
@@ -19,6 +20,7 @@ export declare abstract class AbstractCrdt {
19
20
  * INTERNAL
20
21
  */
21
22
  protected get _doc(): Doc | undefined;
23
+ get roomId(): string | null;
22
24
  /**
23
25
  * INTERNAL
24
26
  */
@@ -24,6 +24,9 @@ export class AbstractCrdt {
24
24
  get _doc() {
25
25
  return __classPrivateFieldGet(this, _AbstractCrdt_doc, "f");
26
26
  }
27
+ get roomId() {
28
+ return __classPrivateFieldGet(this, _AbstractCrdt_doc, "f") ? __classPrivateFieldGet(this, _AbstractCrdt_doc, "f").roomId : null;
29
+ }
27
30
  /**
28
31
  * INTERNAL
29
32
  */
package/lib/esm/room.js CHANGED
@@ -166,6 +166,7 @@ export function makeStateMachine(state, context, mockedEffects) {
166
166
  generateId,
167
167
  generateOpId,
168
168
  dispatch: storageDispatch,
169
+ roomId: context.room,
169
170
  });
170
171
  }
171
172
  function addItem(id, item) {
@@ -661,6 +662,11 @@ See v0.13 release notes for more information.
661
662
  if (state.connection.state === "connecting") {
662
663
  updateConnection(Object.assign(Object.assign({}, state.connection), { state: "open" }));
663
664
  state.numberOfRetry = 0;
665
+ // Re-broadcast the user presence during a reconnect.
666
+ if (state.lastConnectionId !== undefined) {
667
+ state.buffer.presence = state.me;
668
+ tryFlushing();
669
+ }
664
670
  state.lastConnectionId = state.connection.id;
665
671
  if (state.root) {
666
672
  state.buffer.messages.push({ type: ClientMessageType.FetchStorage });
@@ -1020,6 +1026,7 @@ export function createRoom(options, context) {
1020
1026
  const state = defaultState(options.defaultPresence, options.defaultStorageRoot);
1021
1027
  const machine = makeStateMachine(state, context);
1022
1028
  const room = {
1029
+ id: context.room,
1023
1030
  /////////////
1024
1031
  // Core //
1025
1032
  /////////////
@@ -167,6 +167,10 @@ export declare type OthersEvent<T extends Presence = Presence> = {
167
167
  type: "reset";
168
168
  };
169
169
  export declare type Room = {
170
+ /**
171
+ * The id of the room.
172
+ */
173
+ readonly id: string;
170
174
  getConnectionState(): ConnectionState;
171
175
  subscribe: {
172
176
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/client",
3
- "version": "0.14.2",
3
+ "version": "0.14.5",
4
4
  "description": "",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",