@inditextech/weave-store-azure-web-pubsub 3.2.5 → 3.4.0-SNAPSHOT.38.1

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/dist/client.d.ts CHANGED
@@ -250,6 +250,7 @@ declare class WeaveStoreAzureWebPubsub extends WeaveStore {
250
250
  private roomId;
251
251
  private started;
252
252
  private initialRoomData;
253
+ private actualStatus;
253
254
  protected provider: WeaveStoreAzureWebPubSubSyncClient;
254
255
  protected name: string;
255
256
  protected supportsUndoManager: boolean;
@@ -260,6 +261,7 @@ declare class WeaveStoreAzureWebPubsub extends WeaveStore {
260
261
  private init;
261
262
  emitEvent<T>(name: string, payload?: T): void;
262
263
  getClientId(): string | null;
264
+ switchToRoom(roomId: string, roomData: Uint8Array | FetchInitialState | undefined): Promise<void>;
263
265
  connect(extraParams?: Record<string, string>): Promise<void>;
264
266
  disconnect(): void;
265
267
  simulateWebsocketError(): void;
package/dist/client.js CHANGED
@@ -4085,6 +4085,7 @@ var WeaveStoreAzureWebPubsub = class extends WeaveStore {
4085
4085
  this.roomId = roomId;
4086
4086
  this.initialRoomData = initialRoomData;
4087
4087
  this.started = false;
4088
+ this.actualStatus = WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED;
4088
4089
  this.init();
4089
4090
  }
4090
4091
  setup() {
@@ -4098,7 +4099,8 @@ var WeaveStoreAzureWebPubsub = class extends WeaveStore {
4098
4099
  }
4099
4100
  init() {
4100
4101
  const { url } = this.azureWebPubsubOptions;
4101
- this.provider = new WeaveStoreAzureWebPubSubSyncClient(this, url, this.roomId, this.getDocument());
4102
+ const patchedUrl = url.replace("[roomId]", this.roomId);
4103
+ this.provider = new WeaveStoreAzureWebPubSubSyncClient(this, patchedUrl, this.roomId, this.getDocument());
4102
4104
  const awareness = this.provider.awareness;
4103
4105
  awareness.on("update", this.handleAwarenessChange.bind(this));
4104
4106
  awareness.on("change", this.handleAwarenessChange.bind(this));
@@ -4111,7 +4113,11 @@ var WeaveStoreAzureWebPubsub = class extends WeaveStore {
4111
4113
  this.disconnect();
4112
4114
  });
4113
4115
  this.provider.on("status", (status) => {
4114
- this.handleConnectionStatusChange(status);
4116
+ if (this.actualStatus !== WEAVE_STORE_CONNECTION_STATUS.SWITCHING_ROOM || this.actualStatus === WEAVE_STORE_CONNECTION_STATUS.SWITCHING_ROOM && status === WEAVE_STORE_CONNECTION_STATUS.CONNECTED) {
4117
+ this.handleConnectionStatusChange(status);
4118
+ if (this.actualStatus === WEAVE_STORE_CONNECTION_STATUS.SWITCHING_ROOM && status === WEAVE_STORE_CONNECTION_STATUS.CONNECTED) this.instance.emitEvent("onRoomSwitchingEnd", { room: this.roomId });
4119
+ this.actualStatus = status;
4120
+ }
4115
4121
  if (status === WEAVE_STORE_CONNECTION_STATUS.CONNECTED && !this.started) {
4116
4122
  this.loadRoomInitialData();
4117
4123
  this.started = true;
@@ -4125,9 +4131,23 @@ var WeaveStoreAzureWebPubsub = class extends WeaveStore {
4125
4131
  if (this.provider) return this.provider.getClientId();
4126
4132
  return null;
4127
4133
  }
4134
+ async switchToRoom(roomId, roomData) {
4135
+ this.instance.emitEvent("onRoomSwitchingStart", { room: roomId });
4136
+ this.actualStatus = WEAVE_STORE_CONNECTION_STATUS.SWITCHING_ROOM;
4137
+ this.disconnect();
4138
+ this.restartDocument();
4139
+ await this.instance.switchRoom();
4140
+ this.roomId = roomId;
4141
+ this.initialRoomData = roomData;
4142
+ this.started = false;
4143
+ this.init();
4144
+ this.setup();
4145
+ this.connect();
4146
+ }
4128
4147
  async connect(extraParams) {
4129
4148
  const { fetchClient } = this.azureWebPubsubOptions;
4130
4149
  this.provider.setFetchClient(fetchClient ?? window.fetch);
4150
+ this.instance.emitEvent("onStoreRoomChanged", { room: this.roomId });
4131
4151
  await this.provider.connect(extraParams);
4132
4152
  }
4133
4153
  disconnect() {
package/dist/server.d.ts CHANGED
@@ -35,6 +35,7 @@ declare class WeaveStoreAzureWebPubsub extends WeaveStore {
35
35
  private roomId;
36
36
  private started;
37
37
  private initialRoomData;
38
+ private actualStatus;
38
39
  protected provider: WeaveStoreAzureWebPubSubSyncClient;
39
40
  protected name: string;
40
41
  protected supportsUndoManager: boolean;
@@ -45,6 +46,7 @@ declare class WeaveStoreAzureWebPubsub extends WeaveStore {
45
46
  private init;
46
47
  emitEvent<T>(name: string, payload?: T): void;
47
48
  getClientId(): string | null;
49
+ switchToRoom(roomId: string, roomData: Uint8Array | FetchInitialState | undefined): Promise<void>;
48
50
  connect(extraParams?: Record<string, string>): Promise<void>;
49
51
  disconnect(): void;
50
52
  simulateWebsocketError(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inditextech/weave-store-azure-web-pubsub",
3
- "version": "3.2.5",
3
+ "version": "3.4.0-SNAPSHOT.38.1",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
@@ -57,8 +57,8 @@
57
57
  "dependencies": {
58
58
  "@azure/identity": "4.10.2",
59
59
  "@azure/web-pubsub": "1.2.0",
60
- "@inditextech/weave-types": "3.2.5",
61
- "@inditextech/weave-sdk": "3.2.5",
60
+ "@inditextech/weave-types": "3.4.0-SNAPSHOT.38.1",
61
+ "@inditextech/weave-sdk": "3.4.0-SNAPSHOT.38.1",
62
62
  "@syncedstore/core": "0.6.0",
63
63
  "buffer": "6.0.3",
64
64
  "reconnecting-websocket": "4.4.0",