@inditextech/weave-store-websockets 0.24.1 → 0.26.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.cjs +24 -18
- package/dist/client.d.cts +6 -16
- package/dist/client.d.ts +6 -16
- package/dist/client.js +25 -18
- package/dist/server.cjs +502 -21
- package/dist/server.d.cts +45 -17
- package/dist/server.d.ts +45 -17
- package/dist/server.js +503 -21
- package/package.json +11 -4
package/dist/client.cjs
CHANGED
|
@@ -40,16 +40,17 @@ const WEAVE_TRANSFORMER_ANCHORS = {
|
|
|
40
40
|
["BOTTOM_RIGHT"]: "bottom-right"
|
|
41
41
|
};
|
|
42
42
|
const WEAVE_DEFAULT_ENABLED_ANCHORS = Object.values(WEAVE_TRANSFORMER_ANCHORS);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//#region src/constants.ts
|
|
46
|
-
const WEAVE_STORE_WEBSOCKETS = "store-websockets";
|
|
47
|
-
const WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS = {
|
|
43
|
+
const WEAVE_STORE_CONNECTION_STATUS = {
|
|
44
|
+
["ERROR"]: "error",
|
|
48
45
|
["CONNECTING"]: "connecting",
|
|
49
46
|
["CONNECTED"]: "connected",
|
|
50
47
|
["DISCONNECTED"]: "disconnected"
|
|
51
48
|
};
|
|
52
49
|
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/constants.ts
|
|
52
|
+
const WEAVE_STORE_WEBSOCKETS = "store-websockets";
|
|
53
|
+
|
|
53
54
|
//#endregion
|
|
54
55
|
//#region src/store-websockets.ts
|
|
55
56
|
var WeaveStoreWebsockets = class extends __inditextech_weave_sdk.WeaveStore {
|
|
@@ -64,28 +65,34 @@ var WeaveStoreWebsockets = class extends __inditextech_weave_sdk.WeaveStore {
|
|
|
64
65
|
}
|
|
65
66
|
init() {
|
|
66
67
|
const { wsOptions: { serverUrl } } = this.websocketOptions;
|
|
68
|
+
this.initialized = false;
|
|
67
69
|
this.provider = new y_websocket.WebsocketProvider(serverUrl, this.roomId, this.getDocument(), {
|
|
68
70
|
connect: false,
|
|
69
71
|
disableBc: true
|
|
70
72
|
});
|
|
71
73
|
this.provider.on("status", ({ status }) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
this.handleConnectionStatusChange(status);
|
|
75
|
+
if (!this.initialized && status === "connected") this.initialized = true;
|
|
76
|
+
});
|
|
77
|
+
this.provider.on("connection-close", () => {
|
|
78
|
+
if (this.initialized) {
|
|
79
|
+
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.CONNECTING);
|
|
80
|
+
return;
|
|
77
81
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED);
|
|
83
|
+
});
|
|
84
|
+
this.provider.on("connection-error", () => {
|
|
85
|
+
if (this.initialized) {
|
|
86
|
+
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED);
|
|
87
|
+
return;
|
|
83
88
|
}
|
|
84
|
-
this.
|
|
85
|
-
this.instance.emitEvent("onConnectionStatusChange", status);
|
|
89
|
+
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.ERROR);
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
connect() {
|
|
93
|
+
const awareness = this.provider.awareness;
|
|
94
|
+
awareness.on("update", this.handleAwarenessChange.bind(this));
|
|
95
|
+
awareness.on("change", this.handleAwarenessChange.bind(this));
|
|
89
96
|
this.provider.connect();
|
|
90
97
|
}
|
|
91
98
|
disconnect() {
|
|
@@ -109,5 +116,4 @@ var WeaveStoreWebsockets = class extends __inditextech_weave_sdk.WeaveStore {
|
|
|
109
116
|
|
|
110
117
|
//#endregion
|
|
111
118
|
exports.WEAVE_STORE_WEBSOCKETS = WEAVE_STORE_WEBSOCKETS
|
|
112
|
-
exports.WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS = WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS
|
|
113
119
|
exports.WeaveStoreWebsockets = WeaveStoreWebsockets
|
package/dist/client.d.cts
CHANGED
|
@@ -22,27 +22,12 @@ type WeaveUndoManagerOptions = {
|
|
|
22
22
|
captureTimeout?: number;
|
|
23
23
|
trackedOrigins?: Set<any>;
|
|
24
24
|
}; //#endregion
|
|
25
|
-
//#region src/constants.d.ts
|
|
26
|
-
declare const WEAVE_STORE_WEBSOCKETS = "store-websockets";
|
|
27
|
-
declare const WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS: {
|
|
28
|
-
readonly "CONNECTING": "connecting";
|
|
29
|
-
readonly "CONNECTED": "connected";
|
|
30
|
-
readonly "DISCONNECTED": "disconnected";
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
25
|
//#region src/types.d.ts
|
|
35
|
-
type WeaveStoreWebsocketsConnectionStatusKeys = keyof typeof WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS;
|
|
36
|
-
type WeaveStoreWebsocketsConnectionStatus = (typeof WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS)[WeaveStoreWebsocketsConnectionStatusKeys];
|
|
37
26
|
type WeaveStoreWebsocketsOptions = {
|
|
38
27
|
roomId: string;
|
|
39
28
|
wsOptions: {
|
|
40
29
|
serverUrl: string;
|
|
41
30
|
};
|
|
42
|
-
callbacks?: WeaveStoreWebsocketsCallbacks;
|
|
43
|
-
};
|
|
44
|
-
type WeaveStoreWebsocketsCallbacks = {
|
|
45
|
-
onConnectionStatusChange?: (status: WeaveStoreWebsocketsConnectionStatus) => void;
|
|
46
31
|
};
|
|
47
32
|
type PerformUpgrade = (req: IncomingMessage) => Promise<boolean>;
|
|
48
33
|
type ExtractRoomId = (req: IncomingMessage) => string | undefined;
|
|
@@ -55,6 +40,7 @@ type FetchRoom = (roomId: string) => Promise<Uint8Array | null>;
|
|
|
55
40
|
declare class WeaveStoreWebsockets extends WeaveStore {
|
|
56
41
|
private websocketOptions;
|
|
57
42
|
private roomId;
|
|
43
|
+
private initialized;
|
|
58
44
|
protected provider: WebsocketProvider;
|
|
59
45
|
protected name: string;
|
|
60
46
|
protected supportsUndoManager: boolean;
|
|
@@ -67,4 +53,8 @@ declare class WeaveStoreWebsockets extends WeaveStore {
|
|
|
67
53
|
}
|
|
68
54
|
|
|
69
55
|
//#endregion
|
|
70
|
-
|
|
56
|
+
//#region src/constants.d.ts
|
|
57
|
+
declare const WEAVE_STORE_WEBSOCKETS = "store-websockets";
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { ExtractRoomId, FetchInitialState, FetchRoom, PerformUpgrade, PersistRoom, WEAVE_STORE_WEBSOCKETS, WeaveStoreWebsockets, WeaveStoreWebsocketsOptions };
|
package/dist/client.d.ts
CHANGED
|
@@ -22,27 +22,12 @@ type WeaveUndoManagerOptions = {
|
|
|
22
22
|
captureTimeout?: number;
|
|
23
23
|
trackedOrigins?: Set<any>;
|
|
24
24
|
}; //#endregion
|
|
25
|
-
//#region src/constants.d.ts
|
|
26
|
-
declare const WEAVE_STORE_WEBSOCKETS = "store-websockets";
|
|
27
|
-
declare const WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS: {
|
|
28
|
-
readonly "CONNECTING": "connecting";
|
|
29
|
-
readonly "CONNECTED": "connected";
|
|
30
|
-
readonly "DISCONNECTED": "disconnected";
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
25
|
//#region src/types.d.ts
|
|
35
|
-
type WeaveStoreWebsocketsConnectionStatusKeys = keyof typeof WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS;
|
|
36
|
-
type WeaveStoreWebsocketsConnectionStatus = (typeof WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS)[WeaveStoreWebsocketsConnectionStatusKeys];
|
|
37
26
|
type WeaveStoreWebsocketsOptions = {
|
|
38
27
|
roomId: string;
|
|
39
28
|
wsOptions: {
|
|
40
29
|
serverUrl: string;
|
|
41
30
|
};
|
|
42
|
-
callbacks?: WeaveStoreWebsocketsCallbacks;
|
|
43
|
-
};
|
|
44
|
-
type WeaveStoreWebsocketsCallbacks = {
|
|
45
|
-
onConnectionStatusChange?: (status: WeaveStoreWebsocketsConnectionStatus) => void;
|
|
46
31
|
};
|
|
47
32
|
type PerformUpgrade = (req: IncomingMessage) => Promise<boolean>;
|
|
48
33
|
type ExtractRoomId = (req: IncomingMessage) => string | undefined;
|
|
@@ -55,6 +40,7 @@ type FetchRoom = (roomId: string) => Promise<Uint8Array | null>;
|
|
|
55
40
|
declare class WeaveStoreWebsockets extends WeaveStore {
|
|
56
41
|
private websocketOptions;
|
|
57
42
|
private roomId;
|
|
43
|
+
private initialized;
|
|
58
44
|
protected provider: WebsocketProvider;
|
|
59
45
|
protected name: string;
|
|
60
46
|
protected supportsUndoManager: boolean;
|
|
@@ -67,4 +53,8 @@ declare class WeaveStoreWebsockets extends WeaveStore {
|
|
|
67
53
|
}
|
|
68
54
|
|
|
69
55
|
//#endregion
|
|
70
|
-
|
|
56
|
+
//#region src/constants.d.ts
|
|
57
|
+
declare const WEAVE_STORE_WEBSOCKETS = "store-websockets";
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { ExtractRoomId, FetchInitialState, FetchRoom, PerformUpgrade, PersistRoom, WEAVE_STORE_WEBSOCKETS, WeaveStoreWebsockets, WeaveStoreWebsocketsOptions };
|
package/dist/client.js
CHANGED
|
@@ -16,16 +16,17 @@ const WEAVE_TRANSFORMER_ANCHORS = {
|
|
|
16
16
|
["BOTTOM_RIGHT"]: "bottom-right"
|
|
17
17
|
};
|
|
18
18
|
const WEAVE_DEFAULT_ENABLED_ANCHORS = Object.values(WEAVE_TRANSFORMER_ANCHORS);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//#region src/constants.ts
|
|
22
|
-
const WEAVE_STORE_WEBSOCKETS = "store-websockets";
|
|
23
|
-
const WEAVE_STORE_WEBSOCKETS_CONNECTION_STATUS = {
|
|
19
|
+
const WEAVE_STORE_CONNECTION_STATUS = {
|
|
20
|
+
["ERROR"]: "error",
|
|
24
21
|
["CONNECTING"]: "connecting",
|
|
25
22
|
["CONNECTED"]: "connected",
|
|
26
23
|
["DISCONNECTED"]: "disconnected"
|
|
27
24
|
};
|
|
28
25
|
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/constants.ts
|
|
28
|
+
const WEAVE_STORE_WEBSOCKETS = "store-websockets";
|
|
29
|
+
|
|
29
30
|
//#endregion
|
|
30
31
|
//#region src/store-websockets.ts
|
|
31
32
|
var WeaveStoreWebsockets = class extends WeaveStore {
|
|
@@ -40,28 +41,34 @@ var WeaveStoreWebsockets = class extends WeaveStore {
|
|
|
40
41
|
}
|
|
41
42
|
init() {
|
|
42
43
|
const { wsOptions: { serverUrl } } = this.websocketOptions;
|
|
44
|
+
this.initialized = false;
|
|
43
45
|
this.provider = new WebsocketProvider(serverUrl, this.roomId, this.getDocument(), {
|
|
44
46
|
connect: false,
|
|
45
47
|
disableBc: true
|
|
46
48
|
});
|
|
47
49
|
this.provider.on("status", ({ status }) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
this.handleConnectionStatusChange(status);
|
|
51
|
+
if (!this.initialized && status === "connected") this.initialized = true;
|
|
52
|
+
});
|
|
53
|
+
this.provider.on("connection-close", () => {
|
|
54
|
+
if (this.initialized) {
|
|
55
|
+
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.CONNECTING);
|
|
56
|
+
return;
|
|
53
57
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED);
|
|
59
|
+
});
|
|
60
|
+
this.provider.on("connection-error", () => {
|
|
61
|
+
if (this.initialized) {
|
|
62
|
+
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.DISCONNECTED);
|
|
63
|
+
return;
|
|
59
64
|
}
|
|
60
|
-
this.
|
|
61
|
-
this.instance.emitEvent("onConnectionStatusChange", status);
|
|
65
|
+
this.handleConnectionStatusChange(WEAVE_STORE_CONNECTION_STATUS.ERROR);
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
connect() {
|
|
69
|
+
const awareness = this.provider.awareness;
|
|
70
|
+
awareness.on("update", this.handleAwarenessChange.bind(this));
|
|
71
|
+
awareness.on("change", this.handleAwarenessChange.bind(this));
|
|
65
72
|
this.provider.connect();
|
|
66
73
|
}
|
|
67
74
|
disconnect() {
|
|
@@ -84,4 +91,4 @@ var WeaveStoreWebsockets = class extends WeaveStore {
|
|
|
84
91
|
};
|
|
85
92
|
|
|
86
93
|
//#endregion
|
|
87
|
-
export { WEAVE_STORE_WEBSOCKETS,
|
|
94
|
+
export { WEAVE_STORE_WEBSOCKETS, WeaveStoreWebsockets };
|