@inditextech/weave-store-azure-web-pubsub 0.62.3 → 0.62.4
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.cjs +12 -4
- package/dist/client.d.cts +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +12 -4
- package/dist/server.cjs +39 -18
- package/dist/server.d.cts +2 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +39 -18
- package/package.json +2 -2
package/dist/client.cjs
CHANGED
|
@@ -1535,7 +1535,7 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1535
1535
|
const u8 = toUint8Array(encoder);
|
|
1536
1536
|
sendToControlGroup(this, this.topic, MessageDataType.Awareness, u8);
|
|
1537
1537
|
this._initialized = false;
|
|
1538
|
-
this._ws.close();
|
|
1538
|
+
if (this._ws.readyState === WebSocket.OPEN) this._ws.close();
|
|
1539
1539
|
}
|
|
1540
1540
|
}
|
|
1541
1541
|
setFetchClient(fetchClient = window.fetch) {
|
|
@@ -1552,8 +1552,7 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1552
1552
|
throw new Error(`Failed to fetch connection url from: ${this._url}`);
|
|
1553
1553
|
}
|
|
1554
1554
|
}
|
|
1555
|
-
async
|
|
1556
|
-
if (this._wsConnected || this._ws) return;
|
|
1555
|
+
async createWebSocket() {
|
|
1557
1556
|
const websocket = new reconnecting_websocket.default(async () => {
|
|
1558
1557
|
let url = "https://error";
|
|
1559
1558
|
let error = null;
|
|
@@ -1598,7 +1597,7 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1598
1597
|
const encoder = readMessage(this, buf, true, messageData.f);
|
|
1599
1598
|
if (length$1(encoder) > 1) sendToControlGroup(this, this.topic, MessageDataType.Sync, toUint8Array(encoder));
|
|
1600
1599
|
};
|
|
1601
|
-
websocket.onclose = () => {
|
|
1600
|
+
websocket.onclose = (ev) => {
|
|
1602
1601
|
this._status = "disconnected";
|
|
1603
1602
|
this.emit("status", this._status);
|
|
1604
1603
|
if (this._wsConnected) {
|
|
@@ -1608,6 +1607,10 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1608
1607
|
this.synced = false;
|
|
1609
1608
|
removeAwarenessStates(this.awareness, Array.from(this.awareness.getStates().keys()).filter((x) => x !== this.doc.clientID), this);
|
|
1610
1609
|
}
|
|
1610
|
+
if (ev.code === 1008 && websocket.readyState === WebSocket.OPEN) {
|
|
1611
|
+
websocket.close();
|
|
1612
|
+
this.createWebSocket();
|
|
1613
|
+
}
|
|
1611
1614
|
};
|
|
1612
1615
|
websocket.onopen = () => {
|
|
1613
1616
|
this._status = "connected";
|
|
@@ -1630,6 +1633,11 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1630
1633
|
sendToControlGroup(this, this.topic, MessageDataType.Awareness, u8$1);
|
|
1631
1634
|
}
|
|
1632
1635
|
};
|
|
1636
|
+
return websocket;
|
|
1637
|
+
}
|
|
1638
|
+
async start() {
|
|
1639
|
+
if (this._wsConnected || this._ws) return;
|
|
1640
|
+
await this.createWebSocket();
|
|
1633
1641
|
}
|
|
1634
1642
|
};
|
|
1635
1643
|
function joinGroup(client, group) {
|
package/dist/client.d.cts
CHANGED
|
@@ -92,6 +92,7 @@ declare class WeaveStoreAzureWebPubSubSyncClient extends Emittery {
|
|
|
92
92
|
stop(): void;
|
|
93
93
|
setFetchClient(fetchClient?: FetchClient): void;
|
|
94
94
|
fetchConnectionUrl(): Promise<string>;
|
|
95
|
+
createWebSocket(): Promise<ReconnectingWebSocket>;
|
|
95
96
|
start(): Promise<void>;
|
|
96
97
|
} //#endregion
|
|
97
98
|
//#region src/store-azure-web-pubsub.d.ts
|
package/dist/client.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ declare class WeaveStoreAzureWebPubSubSyncClient extends Emittery {
|
|
|
92
92
|
stop(): void;
|
|
93
93
|
setFetchClient(fetchClient?: FetchClient): void;
|
|
94
94
|
fetchConnectionUrl(): Promise<string>;
|
|
95
|
+
createWebSocket(): Promise<ReconnectingWebSocket>;
|
|
95
96
|
start(): Promise<void>;
|
|
96
97
|
} //#endregion
|
|
97
98
|
//#region src/store-azure-web-pubsub.d.ts
|
package/dist/client.js
CHANGED
|
@@ -1512,7 +1512,7 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1512
1512
|
const u8 = toUint8Array(encoder);
|
|
1513
1513
|
sendToControlGroup(this, this.topic, MessageDataType.Awareness, u8);
|
|
1514
1514
|
this._initialized = false;
|
|
1515
|
-
this._ws.close();
|
|
1515
|
+
if (this._ws.readyState === WebSocket.OPEN) this._ws.close();
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
1518
|
setFetchClient(fetchClient = window.fetch) {
|
|
@@ -1529,8 +1529,7 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1529
1529
|
throw new Error(`Failed to fetch connection url from: ${this._url}`);
|
|
1530
1530
|
}
|
|
1531
1531
|
}
|
|
1532
|
-
async
|
|
1533
|
-
if (this._wsConnected || this._ws) return;
|
|
1532
|
+
async createWebSocket() {
|
|
1534
1533
|
const websocket = new ReconnectingWebSocket(async () => {
|
|
1535
1534
|
let url = "https://error";
|
|
1536
1535
|
let error = null;
|
|
@@ -1575,7 +1574,7 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1575
1574
|
const encoder = readMessage(this, buf, true, messageData.f);
|
|
1576
1575
|
if (length$1(encoder) > 1) sendToControlGroup(this, this.topic, MessageDataType.Sync, toUint8Array(encoder));
|
|
1577
1576
|
};
|
|
1578
|
-
websocket.onclose = () => {
|
|
1577
|
+
websocket.onclose = (ev) => {
|
|
1579
1578
|
this._status = "disconnected";
|
|
1580
1579
|
this.emit("status", this._status);
|
|
1581
1580
|
if (this._wsConnected) {
|
|
@@ -1585,6 +1584,10 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1585
1584
|
this.synced = false;
|
|
1586
1585
|
removeAwarenessStates(this.awareness, Array.from(this.awareness.getStates().keys()).filter((x) => x !== this.doc.clientID), this);
|
|
1587
1586
|
}
|
|
1587
|
+
if (ev.code === 1008 && websocket.readyState === WebSocket.OPEN) {
|
|
1588
|
+
websocket.close();
|
|
1589
|
+
this.createWebSocket();
|
|
1590
|
+
}
|
|
1588
1591
|
};
|
|
1589
1592
|
websocket.onopen = () => {
|
|
1590
1593
|
this._status = "connected";
|
|
@@ -1607,6 +1610,11 @@ var WeaveStoreAzureWebPubSubSyncClient = class extends Emittery {
|
|
|
1607
1610
|
sendToControlGroup(this, this.topic, MessageDataType.Awareness, u8$1);
|
|
1608
1611
|
}
|
|
1609
1612
|
};
|
|
1613
|
+
return websocket;
|
|
1614
|
+
}
|
|
1615
|
+
async start() {
|
|
1616
|
+
if (this._wsConnected || this._ws) return;
|
|
1617
|
+
await this.createWebSocket();
|
|
1610
1618
|
}
|
|
1611
1619
|
};
|
|
1612
1620
|
function joinGroup(client, group) {
|
package/dist/server.cjs
CHANGED
|
@@ -30650,6 +30650,7 @@ const applyAwarenessUpdate = (awareness, update, origin) => {
|
|
|
30650
30650
|
|
|
30651
30651
|
//#endregion
|
|
30652
30652
|
//#region src/server/azure-web-pubsub-host.ts
|
|
30653
|
+
const expirationTimeInMinutes = 60;
|
|
30653
30654
|
const messageSync = 0;
|
|
30654
30655
|
const messageAwareness = 1;
|
|
30655
30656
|
const AzureWebPubSubJsonProtocol = "json.webpubsub.azure.v1";
|
|
@@ -30705,11 +30706,24 @@ var WeaveStoreAzureWebPubSubSyncHost = class extends Emittery {
|
|
|
30705
30706
|
const u8 = toUint8Array(encoderAwarenessState);
|
|
30706
30707
|
this.broadcast(this.topic, origin, u8);
|
|
30707
30708
|
}
|
|
30708
|
-
async
|
|
30709
|
-
const url$1 = await this.negotiate(this.topic);
|
|
30710
|
-
const conn = new reconnecting_websocket.default(url$1, AzureWebPubSubJsonProtocol, { WebSocket: this._polyfill });
|
|
30709
|
+
async createWebSocket() {
|
|
30711
30710
|
const group = this.topic;
|
|
30712
|
-
|
|
30711
|
+
const { url: url$1 } = await this.negotiate(this.topic);
|
|
30712
|
+
const ws$1 = new reconnecting_websocket.default(url$1, AzureWebPubSubJsonProtocol, {
|
|
30713
|
+
WebSocket: this._polyfill,
|
|
30714
|
+
connectionTimeout: 4e3,
|
|
30715
|
+
maxRetries: Infinity,
|
|
30716
|
+
maxReconnectionDelay: 8e3,
|
|
30717
|
+
minReconnectionDelay: 1e3
|
|
30718
|
+
});
|
|
30719
|
+
ws$1.addEventListener("open", () => {
|
|
30720
|
+
this.emit("connected");
|
|
30721
|
+
ws$1.send(JSON.stringify({
|
|
30722
|
+
type: MessageType.JoinGroup,
|
|
30723
|
+
group: `${group}.host`
|
|
30724
|
+
}));
|
|
30725
|
+
});
|
|
30726
|
+
ws$1.addEventListener("message", (e) => {
|
|
30713
30727
|
const event = JSON.parse(e.data.toString());
|
|
30714
30728
|
if (event.type === "message" && event.from === "group") switch (event.data.t) {
|
|
30715
30729
|
case MessageDataType.Init:
|
|
@@ -30724,21 +30738,27 @@ var WeaveStoreAzureWebPubSubSyncHost = class extends Emittery {
|
|
|
30724
30738
|
this.onAwareness(group, event.data);
|
|
30725
30739
|
return;
|
|
30726
30740
|
}
|
|
30727
|
-
};
|
|
30728
|
-
|
|
30741
|
+
});
|
|
30742
|
+
ws$1.addEventListener("close", (ev) => {
|
|
30743
|
+
if (ev.code === 1008 && ws$1.readyState === ws.WebSocket.OPEN) {
|
|
30744
|
+
ws$1.close();
|
|
30745
|
+
this._conn = this.createWebSocket();
|
|
30746
|
+
}
|
|
30747
|
+
});
|
|
30748
|
+
ws$1.addEventListener("error", (error) => {
|
|
30729
30749
|
this.emit("error", error);
|
|
30730
30750
|
});
|
|
30731
|
-
|
|
30732
|
-
|
|
30733
|
-
|
|
30734
|
-
|
|
30735
|
-
|
|
30736
|
-
|
|
30737
|
-
|
|
30738
|
-
|
|
30739
|
-
|
|
30740
|
-
|
|
30741
|
-
this._conn =
|
|
30751
|
+
setTimeout(() => {
|
|
30752
|
+
if (ws$1.readyState === ws.WebSocket.OPEN) {
|
|
30753
|
+
ws$1.close();
|
|
30754
|
+
this._conn = this.createWebSocket();
|
|
30755
|
+
}
|
|
30756
|
+
}, expirationTimeInMinutes * .75 * 60 * 1e3);
|
|
30757
|
+
this._conn = ws$1;
|
|
30758
|
+
return ws$1;
|
|
30759
|
+
}
|
|
30760
|
+
async start() {
|
|
30761
|
+
this._conn = await this.createWebSocket();
|
|
30742
30762
|
}
|
|
30743
30763
|
broadcast(group, from$1, u8) {
|
|
30744
30764
|
this._conn?.send(JSON.stringify({
|
|
@@ -30804,10 +30824,11 @@ var WeaveStoreAzureWebPubSubSyncHost = class extends Emittery {
|
|
|
30804
30824
|
`webpubsub.joinLeaveGroup.${group}.host`
|
|
30805
30825
|
];
|
|
30806
30826
|
const res = await this._client.getClientAccessToken({
|
|
30827
|
+
expirationTimeInMinutes,
|
|
30807
30828
|
userId: HostUserId,
|
|
30808
30829
|
roles
|
|
30809
30830
|
});
|
|
30810
|
-
return res
|
|
30831
|
+
return res;
|
|
30811
30832
|
}
|
|
30812
30833
|
};
|
|
30813
30834
|
|
package/dist/server.d.cts
CHANGED
|
@@ -5,6 +5,7 @@ import * as Y$1 from "yjs";
|
|
|
5
5
|
import * as Y from "yjs";
|
|
6
6
|
import { RequestHandler } from "express-serve-static-core";
|
|
7
7
|
import * as awarenessProtocol from "y-protocols/awareness";
|
|
8
|
+
import ReconnectingWebSocket from "reconnecting-websocket";
|
|
8
9
|
import { WebPubSubServiceClient } from "@azure/web-pubsub";
|
|
9
10
|
|
|
10
11
|
//#region src/types.d.ts
|
|
@@ -573,6 +574,7 @@ declare class WeaveStoreAzureWebPubSubSyncHost extends Emittery {
|
|
|
573
574
|
}: WebPubSubHostOptions);
|
|
574
575
|
get awareness(): awarenessProtocol.Awareness;
|
|
575
576
|
sendInitAwarenessInfo(origin: string): void;
|
|
577
|
+
createWebSocket(): Promise<ReconnectingWebSocket>;
|
|
576
578
|
start(): Promise<void>;
|
|
577
579
|
private broadcast;
|
|
578
580
|
private send;
|
package/dist/server.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { WebPubSubServiceClient } from "@azure/web-pubsub";
|
|
|
2
2
|
import { TokenCredential } from "@azure/identity";
|
|
3
3
|
import * as Y$1 from "yjs";
|
|
4
4
|
import * as Y from "yjs";
|
|
5
|
+
import ReconnectingWebSocket from "reconnecting-websocket";
|
|
5
6
|
import koa from "koa";
|
|
6
7
|
import Emittery from "emittery";
|
|
7
8
|
import { RequestHandler } from "express-serve-static-core";
|
|
@@ -573,6 +574,7 @@ declare class WeaveStoreAzureWebPubSubSyncHost extends Emittery {
|
|
|
573
574
|
}: WebPubSubHostOptions);
|
|
574
575
|
get awareness(): awarenessProtocol.Awareness;
|
|
575
576
|
sendInitAwarenessInfo(origin: string): void;
|
|
577
|
+
createWebSocket(): Promise<ReconnectingWebSocket>;
|
|
576
578
|
start(): Promise<void>;
|
|
577
579
|
private broadcast;
|
|
578
580
|
private send;
|
package/dist/server.js
CHANGED
|
@@ -30654,6 +30654,7 @@ const applyAwarenessUpdate = (awareness, update, origin) => {
|
|
|
30654
30654
|
|
|
30655
30655
|
//#endregion
|
|
30656
30656
|
//#region src/server/azure-web-pubsub-host.ts
|
|
30657
|
+
const expirationTimeInMinutes = 60;
|
|
30657
30658
|
const messageSync = 0;
|
|
30658
30659
|
const messageAwareness = 1;
|
|
30659
30660
|
const AzureWebPubSubJsonProtocol = "json.webpubsub.azure.v1";
|
|
@@ -30709,11 +30710,24 @@ var WeaveStoreAzureWebPubSubSyncHost = class extends Emittery {
|
|
|
30709
30710
|
const u8 = toUint8Array(encoderAwarenessState);
|
|
30710
30711
|
this.broadcast(this.topic, origin, u8);
|
|
30711
30712
|
}
|
|
30712
|
-
async
|
|
30713
|
-
const url$1 = await this.negotiate(this.topic);
|
|
30714
|
-
const conn = new ReconnectingWebSocket(url$1, AzureWebPubSubJsonProtocol, { WebSocket: this._polyfill });
|
|
30713
|
+
async createWebSocket() {
|
|
30715
30714
|
const group = this.topic;
|
|
30716
|
-
|
|
30715
|
+
const { url: url$1 } = await this.negotiate(this.topic);
|
|
30716
|
+
const ws = new ReconnectingWebSocket(url$1, AzureWebPubSubJsonProtocol, {
|
|
30717
|
+
WebSocket: this._polyfill,
|
|
30718
|
+
connectionTimeout: 4e3,
|
|
30719
|
+
maxRetries: Infinity,
|
|
30720
|
+
maxReconnectionDelay: 8e3,
|
|
30721
|
+
minReconnectionDelay: 1e3
|
|
30722
|
+
});
|
|
30723
|
+
ws.addEventListener("open", () => {
|
|
30724
|
+
this.emit("connected");
|
|
30725
|
+
ws.send(JSON.stringify({
|
|
30726
|
+
type: MessageType.JoinGroup,
|
|
30727
|
+
group: `${group}.host`
|
|
30728
|
+
}));
|
|
30729
|
+
});
|
|
30730
|
+
ws.addEventListener("message", (e) => {
|
|
30717
30731
|
const event = JSON.parse(e.data.toString());
|
|
30718
30732
|
if (event.type === "message" && event.from === "group") switch (event.data.t) {
|
|
30719
30733
|
case MessageDataType.Init:
|
|
@@ -30728,21 +30742,27 @@ var WeaveStoreAzureWebPubSubSyncHost = class extends Emittery {
|
|
|
30728
30742
|
this.onAwareness(group, event.data);
|
|
30729
30743
|
return;
|
|
30730
30744
|
}
|
|
30731
|
-
};
|
|
30732
|
-
|
|
30745
|
+
});
|
|
30746
|
+
ws.addEventListener("close", (ev) => {
|
|
30747
|
+
if (ev.code === 1008 && ws.readyState === WebSocket.OPEN) {
|
|
30748
|
+
ws.close();
|
|
30749
|
+
this._conn = this.createWebSocket();
|
|
30750
|
+
}
|
|
30751
|
+
});
|
|
30752
|
+
ws.addEventListener("error", (error) => {
|
|
30733
30753
|
this.emit("error", error);
|
|
30734
30754
|
});
|
|
30735
|
-
|
|
30736
|
-
|
|
30737
|
-
|
|
30738
|
-
|
|
30739
|
-
|
|
30740
|
-
|
|
30741
|
-
|
|
30742
|
-
|
|
30743
|
-
|
|
30744
|
-
|
|
30745
|
-
this._conn =
|
|
30755
|
+
setTimeout(() => {
|
|
30756
|
+
if (ws.readyState === WebSocket.OPEN) {
|
|
30757
|
+
ws.close();
|
|
30758
|
+
this._conn = this.createWebSocket();
|
|
30759
|
+
}
|
|
30760
|
+
}, expirationTimeInMinutes * .75 * 60 * 1e3);
|
|
30761
|
+
this._conn = ws;
|
|
30762
|
+
return ws;
|
|
30763
|
+
}
|
|
30764
|
+
async start() {
|
|
30765
|
+
this._conn = await this.createWebSocket();
|
|
30746
30766
|
}
|
|
30747
30767
|
broadcast(group, from$1, u8) {
|
|
30748
30768
|
this._conn?.send(JSON.stringify({
|
|
@@ -30808,10 +30828,11 @@ var WeaveStoreAzureWebPubSubSyncHost = class extends Emittery {
|
|
|
30808
30828
|
`webpubsub.joinLeaveGroup.${group}.host`
|
|
30809
30829
|
];
|
|
30810
30830
|
const res = await this._client.getClientAccessToken({
|
|
30831
|
+
expirationTimeInMinutes,
|
|
30811
30832
|
userId: HostUserId,
|
|
30812
30833
|
roles
|
|
30813
30834
|
});
|
|
30814
|
-
return res
|
|
30835
|
+
return res;
|
|
30815
30836
|
}
|
|
30816
30837
|
};
|
|
30817
30838
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inditextech/weave-store-azure-web-pubsub",
|
|
3
|
-
"version": "0.62.
|
|
3
|
+
"version": "0.62.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"yjs": "13.6.27"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@inditextech/weave-sdk": "0.62.
|
|
64
|
+
"@inditextech/weave-sdk": "0.62.4",
|
|
65
65
|
"@koa/cors": "^5.0.0",
|
|
66
66
|
"@types/express": "^5.0.1",
|
|
67
67
|
"@types/ioredis": "^4.28.10",
|