@inditextech/weave-store-azure-web-pubsub 3.4.0-SNAPSHOT.85.1 → 3.4.0
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 +2 -6
- package/dist/client.js +9 -24
- package/dist/server.d.ts +3 -7
- package/dist/server.js +8053 -247
- package/package.json +3 -3
package/dist/client.d.ts
CHANGED
|
@@ -134,7 +134,6 @@ type FetchClient = (input: string | URL | globalThis.Request, init?: RequestInit
|
|
|
134
134
|
type FetchInitialState = (doc: Doc) => void;
|
|
135
135
|
type PersistRoom = (roomId: string, actualState: Uint8Array<ArrayBufferLike>) => Promise<void>;
|
|
136
136
|
type FetchRoom = (roomId: string) => Promise<Uint8Array | null>;
|
|
137
|
-
type WeaveRoomData = Uint8Array | FetchInitialState;
|
|
138
137
|
type WeaveStoreAzureWebPubsubEvents = {
|
|
139
138
|
onConnect: WeaveStoreAzureWebPubsubOnConnectEvent;
|
|
140
139
|
onConnected: WeaveStoreAzureWebPubsubOnConnectedEvent;
|
|
@@ -230,7 +229,6 @@ type WeaveStoreAzureWebPubsubSyncHostOptions = {
|
|
|
230
229
|
attemptsLimit: number;
|
|
231
230
|
};
|
|
232
231
|
};
|
|
233
|
-
|
|
234
232
|
//#endregion
|
|
235
233
|
//#region src/client.d.ts
|
|
236
234
|
declare class WeaveStoreAzureWebPubSubSyncClient extends Emittery {
|
|
@@ -287,18 +285,16 @@ declare class WeaveStoreAzureWebPubsub extends WeaveStore {
|
|
|
287
285
|
private roomId;
|
|
288
286
|
private started;
|
|
289
287
|
private initialRoomData;
|
|
290
|
-
private actualStatus;
|
|
291
288
|
protected provider: WeaveStoreAzureWebPubSubSyncClient;
|
|
292
289
|
protected name: string;
|
|
293
290
|
protected supportsUndoManager: boolean;
|
|
294
291
|
protected awarenessCallback: (changes: any) => void;
|
|
295
|
-
constructor(initialRoomData:
|
|
292
|
+
constructor(initialRoomData: Uint8Array | FetchInitialState | undefined, storeOptions: WeaveStoreOptions, azureWebPubsubOptions: Pick<WeaveStoreAzureWebPubsubOptions, "roomId" | "url"> & Partial<Omit<WeaveStoreAzureWebPubsubOptions, "roomId" | "url">>);
|
|
296
293
|
setup(): void;
|
|
297
294
|
private loadRoomInitialData;
|
|
298
295
|
private init;
|
|
299
296
|
emitEvent<T>(name: string, payload?: T): void;
|
|
300
297
|
getClientId(): string | null;
|
|
301
|
-
switchToRoom(roomId: string, roomData: Uint8Array | FetchInitialState | undefined): Promise<void>;
|
|
302
298
|
connect(extraParams?: Record<string, string>): Promise<void>;
|
|
303
299
|
disconnect(): void;
|
|
304
300
|
simulateWebsocketError(): void;
|
|
@@ -308,4 +304,4 @@ declare class WeaveStoreAzureWebPubsub extends WeaveStore {
|
|
|
308
304
|
}
|
|
309
305
|
|
|
310
306
|
//#endregion
|
|
311
|
-
export { FetchClient, FetchInitialState, FetchRoom, Message, MessageData, MessageDataType, MessageHandler, MessageType, PersistRoom, WEAVE_STORE_AZURE_WEB_PUBSUB, WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_DESTROY_ROOM_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_CLIENT_DEFAULT_OPTIONS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_HOST_DEFAULT_OPTIONS, WEAVE_STORE_HORIZONTAL_SYNC_HANDLER_CLIENT_TYPE, WeaveAzureWebPubsubSyncHandlerOptions,
|
|
307
|
+
export { FetchClient, FetchInitialState, FetchRoom, Message, MessageData, MessageDataType, MessageHandler, MessageType, PersistRoom, WEAVE_STORE_AZURE_WEB_PUBSUB, WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_DESTROY_ROOM_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_CLIENT_DEFAULT_OPTIONS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_HOST_DEFAULT_OPTIONS, WEAVE_STORE_HORIZONTAL_SYNC_HANDLER_CLIENT_TYPE, WeaveAzureWebPubsubSyncHandlerOptions, WeaveStoreAzureWebPubSubSyncClientConnectionStatus, WeaveStoreAzureWebPubSubSyncClientConnectionStatusKeys, WeaveStoreAzureWebPubSubSyncClientOptions, WeaveStoreAzureWebPubSubSyncHostClientConnectOptions, WeaveStoreAzureWebPubsub, WeaveStoreAzureWebPubsubConfig, WeaveStoreAzureWebPubsubEvents, WeaveStoreAzureWebPubsubOnConnectEvent, WeaveStoreAzureWebPubsubOnConnectedEvent, WeaveStoreAzureWebPubsubOnDisconnectedEvent, WeaveStoreAzureWebPubsubOnStoreFetchConnectionUrlEvent, WeaveStoreAzureWebPubsubOnWebsocketCloseEvent, WeaveStoreAzureWebPubsubOnWebsocketErrorEvent, WeaveStoreAzureWebPubsubOnWebsocketJoinGroupEvent, WeaveStoreAzureWebPubsubOnWebsocketMessageEvent, WeaveStoreAzureWebPubsubOnWebsocketOpenEvent, WeaveStoreAzureWebPubsubOnWebsocketReconnectEvent, WeaveStoreAzureWebPubsubOptions, WeaveStoreAzureWebPubsubSyncHandlerDestroyRoomStatus, WeaveStoreAzureWebPubsubSyncHandlerDestroyRoomStatusKeys, WeaveStoreAzureWebPubsubSyncHostOptions };
|
package/dist/client.js
CHANGED
|
@@ -2560,10 +2560,12 @@ var Emittery = class Emittery {
|
|
|
2560
2560
|
});
|
|
2561
2561
|
}
|
|
2562
2562
|
}
|
|
2563
|
-
once(eventNames) {
|
|
2563
|
+
once(eventNames, predicate) {
|
|
2564
|
+
if (predicate !== void 0 && typeof predicate !== "function") throw new TypeError("predicate must be a function");
|
|
2564
2565
|
let off_;
|
|
2565
2566
|
const promise = new Promise((resolve) => {
|
|
2566
2567
|
off_ = this.on(eventNames, (data) => {
|
|
2568
|
+
if (predicate && !predicate(data)) return;
|
|
2567
2569
|
off_();
|
|
2568
2570
|
resolve(data);
|
|
2569
2571
|
});
|
|
@@ -2596,10 +2598,11 @@ var Emittery = class Emittery {
|
|
|
2596
2598
|
assertEventName(eventName);
|
|
2597
2599
|
if (isMetaEvent(eventName) && !canEmitMetaEvents) throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
|
|
2598
2600
|
this.logIfDebugEnabled("emitSerial", eventName, eventData);
|
|
2601
|
+
enqueueProducers(this, eventName, eventData);
|
|
2599
2602
|
const listeners = getListeners(this, eventName) ?? new Set();
|
|
2600
2603
|
const anyListeners = anyMap.get(this);
|
|
2601
2604
|
const staticListeners = [...listeners];
|
|
2602
|
-
const staticAnyListeners = [...anyListeners];
|
|
2605
|
+
const staticAnyListeners = isMetaEvent(eventName) ? [] : [...anyListeners];
|
|
2603
2606
|
await resolvedPromise;
|
|
2604
2607
|
for (const listener of staticListeners) if (listeners.has(listener)) await listener(eventData);
|
|
2605
2608
|
for (const listener of staticAnyListeners) if (anyListeners.has(listener)) await listener(eventName, eventData);
|
|
@@ -3971,6 +3974,7 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
3971
3974
|
if (message.type === MessageType.System) return;
|
|
3972
3975
|
const messageData = message.data;
|
|
3973
3976
|
if (messageData.type === "heartbeat") {
|
|
3977
|
+
console.log("[Azure Web PubSub] received heartbeat, updating last heartbeat time.");
|
|
3974
3978
|
this._lastHeartbeatTime = Date.now();
|
|
3975
3979
|
return;
|
|
3976
3980
|
}
|
|
@@ -4041,6 +4045,7 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
4041
4045
|
this._checkHeartbeatId = setInterval(() => {
|
|
4042
4046
|
const now = Date.now();
|
|
4043
4047
|
if (now - this._lastHeartbeatTime > this._synClientOptions.heartbeat.checkWindowTimeMs) {
|
|
4048
|
+
console.log(`[Azure Web PubSub] heartbeat not received in ${this._synClientOptions.heartbeat.checkWindowTimeMs}ms window, handling it...`);
|
|
4044
4049
|
this.disconnect();
|
|
4045
4050
|
this.createWebSocket();
|
|
4046
4051
|
}
|
|
@@ -4142,7 +4147,6 @@ var WeaveStoreAzureWebPubsub = class extends WeaveStore {
|
|
|
4142
4147
|
this.roomId = roomId;
|
|
4143
4148
|
this.initialRoomData = initialRoomData;
|
|
4144
4149
|
this.started = false;
|
|
4145
|
-
this.actualStatus = WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED;
|
|
4146
4150
|
this.init();
|
|
4147
4151
|
}
|
|
4148
4152
|
setup() {
|
|
@@ -4156,8 +4160,7 @@ var WeaveStoreAzureWebPubsub = class extends WeaveStore {
|
|
|
4156
4160
|
}
|
|
4157
4161
|
init() {
|
|
4158
4162
|
const { url } = this.azureWebPubsubOptions;
|
|
4159
|
-
|
|
4160
|
-
this.provider = new WeaveStoreAzureWebPubSubSyncClient(this, patchedUrl, this.roomId, this.getDocument(), this.azureWebPubsubOptions.syncClientOptions);
|
|
4163
|
+
this.provider = new WeaveStoreAzureWebPubSubSyncClient(this, url, this.roomId, this.getDocument(), this.azureWebPubsubOptions.syncClientOptions);
|
|
4161
4164
|
const awareness = this.provider.awareness;
|
|
4162
4165
|
awareness.on("update", this.handleAwarenessChange.bind(this));
|
|
4163
4166
|
awareness.on("change", this.handleAwarenessChange.bind(this));
|
|
@@ -4169,11 +4172,7 @@ var WeaveStoreAzureWebPubsub = class extends WeaveStore {
|
|
|
4169
4172
|
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED);
|
|
4170
4173
|
});
|
|
4171
4174
|
this.provider.on("status", (status) => {
|
|
4172
|
-
|
|
4173
|
-
this.handleConnectionStatusChange(status);
|
|
4174
|
-
if (this.actualStatus === WEAVE_STORE_CONNECTION_STATUS.SWITCHING_ROOM && status === WEAVE_STORE_CONNECTION_STATUS.CONNECTED) this.instance.emitEvent("onRoomSwitchingEnd", { room: this.roomId });
|
|
4175
|
-
this.actualStatus = status;
|
|
4176
|
-
}
|
|
4175
|
+
this.handleConnectionStatusChange(status);
|
|
4177
4176
|
if (status === WEAVE_STORE_CONNECTION_STATUS.CONNECTED && !this.started) {
|
|
4178
4177
|
this.loadRoomInitialData();
|
|
4179
4178
|
this.started = true;
|
|
@@ -4187,23 +4186,9 @@ var WeaveStoreAzureWebPubsub = class extends WeaveStore {
|
|
|
4187
4186
|
if (this.provider) return this.provider.getClientId();
|
|
4188
4187
|
return null;
|
|
4189
4188
|
}
|
|
4190
|
-
async switchToRoom(roomId, roomData) {
|
|
4191
|
-
this.instance.emitEvent("onRoomSwitchingStart", { room: roomId });
|
|
4192
|
-
this.actualStatus = WEAVE_STORE_CONNECTION_STATUS.SWITCHING_ROOM;
|
|
4193
|
-
this.disconnect();
|
|
4194
|
-
this.restartDocument();
|
|
4195
|
-
await this.instance.switchRoom();
|
|
4196
|
-
this.roomId = roomId;
|
|
4197
|
-
this.initialRoomData = roomData;
|
|
4198
|
-
this.started = false;
|
|
4199
|
-
this.init();
|
|
4200
|
-
this.setup();
|
|
4201
|
-
this.connect();
|
|
4202
|
-
}
|
|
4203
4189
|
async connect(extraParams) {
|
|
4204
4190
|
const { fetchClient } = this.azureWebPubsubOptions;
|
|
4205
4191
|
this.provider.setFetchClient(fetchClient ?? window.fetch);
|
|
4206
|
-
this.instance.emitEvent("onStoreRoomChanged", { room: this.roomId });
|
|
4207
4192
|
await this.provider.connect(extraParams);
|
|
4208
4193
|
}
|
|
4209
4194
|
disconnect() {
|
package/dist/server.d.ts
CHANGED
|
@@ -42,18 +42,16 @@ declare class WeaveStoreAzureWebPubsub extends WeaveStore {
|
|
|
42
42
|
private roomId;
|
|
43
43
|
private started;
|
|
44
44
|
private initialRoomData;
|
|
45
|
-
private actualStatus;
|
|
46
45
|
protected provider: WeaveStoreAzureWebPubSubSyncClient;
|
|
47
46
|
protected name: string;
|
|
48
47
|
protected supportsUndoManager: boolean;
|
|
49
48
|
protected awarenessCallback: (changes: any) => void;
|
|
50
|
-
constructor(initialRoomData:
|
|
49
|
+
constructor(initialRoomData: Uint8Array | FetchInitialState | undefined, storeOptions: WeaveStoreOptions, azureWebPubsubOptions: Pick<WeaveStoreAzureWebPubsubOptions, "roomId" | "url"> & Partial<Omit<WeaveStoreAzureWebPubsubOptions, "roomId" | "url">>);
|
|
51
50
|
setup(): void;
|
|
52
51
|
private loadRoomInitialData;
|
|
53
52
|
private init;
|
|
54
53
|
emitEvent<T>(name: string, payload?: T): void;
|
|
55
54
|
getClientId(): string | null;
|
|
56
|
-
switchToRoom(roomId: string, roomData: Uint8Array | FetchInitialState | undefined): Promise<void>;
|
|
57
55
|
connect(extraParams?: Record<string, string>): Promise<void>;
|
|
58
56
|
disconnect(): void;
|
|
59
57
|
simulateWebsocketError(): void;
|
|
@@ -145,7 +143,6 @@ type FetchClient = (input: string | URL | globalThis.Request, init?: RequestInit
|
|
|
145
143
|
type FetchInitialState = (doc: Doc) => void;
|
|
146
144
|
type PersistRoom = (roomId: string, actualState: Uint8Array<ArrayBufferLike>) => Promise<void>;
|
|
147
145
|
type FetchRoom = (roomId: string) => Promise<Uint8Array | null>;
|
|
148
|
-
type WeaveRoomData = Uint8Array | FetchInitialState;
|
|
149
146
|
type WeaveStoreAzureWebPubsubEvents = {
|
|
150
147
|
onConnect: WeaveStoreAzureWebPubsubOnConnectEvent;
|
|
151
148
|
onConnected: WeaveStoreAzureWebPubsubOnConnectedEvent;
|
|
@@ -422,8 +419,7 @@ declare enum MqttDisconnectReasonCode {
|
|
|
422
419
|
* Description: The Server does not support Wildcard Subscriptions; the subscription is not accepted.
|
|
423
420
|
*/
|
|
424
421
|
WildcardSubscriptionsNotSupported = 162,
|
|
425
|
-
}
|
|
426
|
-
//#endregion
|
|
422
|
+
} //#endregion
|
|
427
423
|
//#region src/server/event-handler/enum/mqtt-error-codes/mqtt-v311-connect-return-code.d.ts
|
|
428
424
|
/**
|
|
429
425
|
* MQTT 3.1.1 Connect Return Codes.
|
|
@@ -1138,4 +1134,4 @@ declare class WeaveAzureWebPubsubServer extends Emittery {
|
|
|
1138
1134
|
}
|
|
1139
1135
|
|
|
1140
1136
|
//#endregion
|
|
1141
|
-
export { Certificate, ConnectErrorResponse, ConnectRequest, ConnectResponse, ConnectResponseHandler, ConnectedRequest, ConnectionContext, DisconnectedRequest, FetchClient, FetchInitialState, FetchRoom, Message, MessageData, MessageDataType, MessageHandler, MessageType, MqttConnectErrorResponse, MqttConnectErrorResponseProperties, MqttConnectProperties, MqttConnectRequest, MqttConnectResponse, MqttConnectResponseProperties, MqttConnectionContextProperties, MqttDisconnectPacket, MqttDisconnectReasonCode, MqttDisconnectedProperties, MqttDisconnectedRequest, MqttUserProperty, MqttV311ConnectReturnCode, MqttV500ConnectReasonCode, PersistRoom, UserEventRequest, UserEventResponseHandler, WEAVE_STORE_AZURE_WEB_PUBSUB, WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_DESTROY_ROOM_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_CLIENT_DEFAULT_OPTIONS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_HOST_DEFAULT_OPTIONS, WEAVE_STORE_HORIZONTAL_SYNC_HANDLER_CLIENT_TYPE, WeaveAzureWebPubsubServer, WeaveAzureWebPubsubSyncHandlerOptions,
|
|
1137
|
+
export { Certificate, ConnectErrorResponse, ConnectRequest, ConnectResponse, ConnectResponseHandler, ConnectedRequest, ConnectionContext, DisconnectedRequest, FetchClient, FetchInitialState, FetchRoom, Message, MessageData, MessageDataType, MessageHandler, MessageType, MqttConnectErrorResponse, MqttConnectErrorResponseProperties, MqttConnectProperties, MqttConnectRequest, MqttConnectResponse, MqttConnectResponseProperties, MqttConnectionContextProperties, MqttDisconnectPacket, MqttDisconnectReasonCode, MqttDisconnectedProperties, MqttDisconnectedRequest, MqttUserProperty, MqttV311ConnectReturnCode, MqttV500ConnectReasonCode, PersistRoom, UserEventRequest, UserEventResponseHandler, WEAVE_STORE_AZURE_WEB_PUBSUB, WEAVE_STORE_AZURE_WEB_PUBSUB_CONNECTION_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_DESTROY_ROOM_STATUS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_CLIENT_DEFAULT_OPTIONS, WEAVE_STORE_AZURE_WEB_PUBSUB_SYNC_HOST_DEFAULT_OPTIONS, WEAVE_STORE_HORIZONTAL_SYNC_HANDLER_CLIENT_TYPE, WeaveAzureWebPubsubServer, WeaveAzureWebPubsubSyncHandlerOptions, WeaveStoreAzureWebPubSubSyncClientConnectionStatus, WeaveStoreAzureWebPubSubSyncClientConnectionStatusKeys, WeaveStoreAzureWebPubSubSyncClientOptions, WeaveStoreAzureWebPubSubSyncHost, WeaveStoreAzureWebPubSubSyncHostClientConnectOptions, WeaveStoreAzureWebPubsubConfig, WeaveStoreAzureWebPubsubEvents, WeaveStoreAzureWebPubsubOnConnectEvent, WeaveStoreAzureWebPubsubOnConnectedEvent, WeaveStoreAzureWebPubsubOnDisconnectedEvent, WeaveStoreAzureWebPubsubOnStoreFetchConnectionUrlEvent, WeaveStoreAzureWebPubsubOnWebsocketCloseEvent, WeaveStoreAzureWebPubsubOnWebsocketErrorEvent, WeaveStoreAzureWebPubsubOnWebsocketJoinGroupEvent, WeaveStoreAzureWebPubsubOnWebsocketMessageEvent, WeaveStoreAzureWebPubsubOnWebsocketOpenEvent, WeaveStoreAzureWebPubsubOnWebsocketReconnectEvent, WeaveStoreAzureWebPubsubOptions, WeaveStoreAzureWebPubsubSyncHandlerDestroyRoomStatus, WeaveStoreAzureWebPubsubSyncHandlerDestroyRoomStatusKeys, WeaveStoreAzureWebPubsubSyncHostOptions, WebPubSubClientProtocol, WebPubSubEventHandler, WebPubSubEventHandlerOptions };
|