@pluv/io 0.32.1 → 0.32.2
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +11 -4
- package/dist/index.mjs +11 -4
- package/package.json +5 -5
- package/src/IORoom.ts +1 -0
- package/src/PluvServer.ts +10 -4
- package/src/index.ts +1 -0
- package/src/types.ts +13 -2
- package/src/version.generated.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/io@0.32.
|
|
2
|
+
> @pluv/io@0.32.2 build /home/runner/work/pluv/pluv/packages/io
|
|
3
3
|
> pnpm run version && tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @pluv/io@0.32.
|
|
6
|
+
> @pluv/io@0.32.2 version /home/runner/work/pluv/pluv/packages/io
|
|
7
7
|
> genversion ./src/version.generated.ts --esm
|
|
8
8
|
|
|
9
9
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
[34mCLI[39m Target: es6
|
|
13
13
|
[34mESM[39m Build start
|
|
14
14
|
[34mCJS[39m Build start
|
|
15
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
17
|
-
[32mCJS[39m [1mdist/index.js [22m[32m42.
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m40.14 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 156ms
|
|
17
|
+
[32mCJS[39m [1mdist/index.js [22m[32m42.31 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 157ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 2478ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m26.33 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m26.33 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @pluv/io
|
|
2
2
|
|
|
3
|
+
## 0.32.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 890d45b: Update `onRoomMessage` and `onStorageUpdated` events to include the WebSocket as part of the `event` parameter of those listeners.
|
|
8
|
+
- @pluv/crdt@0.32.2
|
|
9
|
+
- @pluv/types@0.32.2
|
|
10
|
+
|
|
3
11
|
## 0.32.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -182,7 +182,7 @@ type GetInitialStorageFn<TPlatform extends AbstractPlatform> = (event: GetInitia
|
|
|
182
182
|
interface PluvIOListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
|
|
183
183
|
onRoomDeleted: (event: IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
184
184
|
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
185
|
-
onStorageUpdated: (event:
|
|
185
|
+
onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
186
186
|
}
|
|
187
187
|
type IORoomListenerEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = {
|
|
188
188
|
context: TContext;
|
|
@@ -192,6 +192,11 @@ type IORoomListenerEvent<TPlatform extends AbstractPlatform<any>, TAuthorize ext
|
|
|
192
192
|
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents> & {
|
|
193
193
|
message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
|
|
194
194
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
195
|
+
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
196
|
+
};
|
|
197
|
+
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents> & {
|
|
198
|
+
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
199
|
+
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
195
200
|
};
|
|
196
201
|
type WebSocketType<TPlatform extends AbstractPlatform> = InferPlatformWebSocketType<TPlatform> | InferPlatformWebSocketSource<TPlatform>;
|
|
197
202
|
|
|
@@ -354,7 +359,7 @@ type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize e
|
|
|
354
359
|
debug?: boolean;
|
|
355
360
|
};
|
|
356
361
|
type CreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = keyof InferRoomContextType<TPlatform> extends never ? [BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>] | [] : [Id<BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents> & InferRoomContextType<TPlatform>>];
|
|
357
|
-
declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements
|
|
362
|
+
declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
|
|
358
363
|
readonly version: string;
|
|
359
364
|
private readonly _authorize;
|
|
360
365
|
private readonly _baseRouter;
|
|
@@ -418,4 +423,4 @@ type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<a
|
|
|
418
423
|
};
|
|
419
424
|
declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}>, TContext extends Record<string, any> = {}, TAuthorizeUser extends BaseUser = BaseUser, TAuthorizeRequired extends boolean = false>(params: CreateIOParams<TPlatform, TContext, TAuthorizeUser, TAuthorizeRequired>) => PluvIO<TPlatform, IOAuthorize<TAuthorizeUser, TAuthorizeRequired, InferInitContextType<TPlatform>>, TContext>;
|
|
420
425
|
|
|
421
|
-
export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, PluvIO, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
|
|
426
|
+
export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type IOStorageUpdatedEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, PluvIO, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
|
package/dist/index.d.ts
CHANGED
|
@@ -182,7 +182,7 @@ type GetInitialStorageFn<TPlatform extends AbstractPlatform> = (event: GetInitia
|
|
|
182
182
|
interface PluvIOListeners<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> {
|
|
183
183
|
onRoomDeleted: (event: IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
184
184
|
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
185
|
-
onStorageUpdated: (event:
|
|
185
|
+
onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
186
186
|
}
|
|
187
187
|
type IORoomListenerEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = {
|
|
188
188
|
context: TContext;
|
|
@@ -192,6 +192,11 @@ type IORoomListenerEvent<TPlatform extends AbstractPlatform<any>, TAuthorize ext
|
|
|
192
192
|
type IORoomMessageEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents> & {
|
|
193
193
|
message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
|
|
194
194
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
195
|
+
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
196
|
+
};
|
|
197
|
+
type IOStorageUpdatedEvent<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents> & {
|
|
198
|
+
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
199
|
+
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
195
200
|
};
|
|
196
201
|
type WebSocketType<TPlatform extends AbstractPlatform> = InferPlatformWebSocketType<TPlatform> | InferPlatformWebSocketSource<TPlatform>;
|
|
197
202
|
|
|
@@ -354,7 +359,7 @@ type BaseCreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize e
|
|
|
354
359
|
debug?: boolean;
|
|
355
360
|
};
|
|
356
361
|
type CreateRoomOptions<TPlatform extends AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>, TContext extends Record<string, any>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>> = keyof InferRoomContextType<TPlatform> extends never ? [BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents>] | [] : [Id<BaseCreateRoomOptions<TPlatform, TAuthorize, TContext, TEvents> & InferRoomContextType<TPlatform>>];
|
|
357
|
-
declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements
|
|
362
|
+
declare class PluvServer<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> implements IOLike<TAuthorize, TEvents> {
|
|
358
363
|
readonly version: string;
|
|
359
364
|
private readonly _authorize;
|
|
360
365
|
private readonly _baseRouter;
|
|
@@ -418,4 +423,4 @@ type CreateIOParams<TPlatform extends AbstractPlatform<any> = AbstractPlatform<a
|
|
|
418
423
|
};
|
|
419
424
|
declare const createIO: <TPlatform extends AbstractPlatform<any> = AbstractPlatform<any, {}, {}>, TContext extends Record<string, any> = {}, TAuthorizeUser extends BaseUser = BaseUser, TAuthorizeRequired extends boolean = false>(params: CreateIOParams<TPlatform, TContext, TAuthorizeUser, TAuthorizeRequired>) => PluvIO<TPlatform, IOAuthorize<TAuthorizeUser, TAuthorizeRequired, InferInitContextType<TPlatform>>, TContext>;
|
|
420
425
|
|
|
421
|
-
export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, PluvIO, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
|
|
426
|
+
export { type AbstractCloseEvent, type AbstractErrorEvent, type AbstractEvent, type AbstractEventMap, type AbstractListener, type AbstractMessageEvent, AbstractPersistence, AbstractPlatform, type AbstractPlatformConfig, AbstractPubSub, AbstractWebSocket, type AbstractWebSocketConfig, type AbstractWebSocketHandleErrorParams, type AuthorizeModule, type AuthorizeParams, type ConvertWebSocketConfig, type CrdtLibraryType, type CreateIOParams, type CreateRoomOptions, type GetInitialStorageFn, type IOPubSubEventMessage, IORoom, type IORoomListenerEvent, type IORoomMessageEvent, type IOStorageUpdatedEvent, type InferIORoom, type InferInitContextType, type InferPlatformWebSocketType, type InferRoomContextType, type JWT, type JWTEncodeParams, type MergedRouter, PluvIO, type PluvIOConfig, type PluvIOListeners, PluvProcedure, type PluvProcedureConfig, PluvRouter, type PluvRouterEventConfig, PluvServer, type PluvServerConfig, type ServerConfig, type WebSocketRegistrationMode, type WebSocketSerializedState, type WebSocketSession, authorize, createIO };
|
package/dist/index.js
CHANGED
|
@@ -774,7 +774,8 @@ var IORoom = class {
|
|
|
774
774
|
encodedState: doc.getEncodedState(),
|
|
775
775
|
message,
|
|
776
776
|
room: this.id,
|
|
777
|
-
user: session.user
|
|
777
|
+
user: session.user,
|
|
778
|
+
webSocket: session.webSocket.webSocket
|
|
778
779
|
}));
|
|
779
780
|
const sessionId = session.id;
|
|
780
781
|
const user = session.user;
|
|
@@ -932,7 +933,7 @@ var IORoom = class {
|
|
|
932
933
|
};
|
|
933
934
|
|
|
934
935
|
// src/version.generated.ts
|
|
935
|
-
var version = "0.32.
|
|
936
|
+
var version = "0.32.2";
|
|
936
937
|
|
|
937
938
|
// src/PluvServer.ts
|
|
938
939
|
var PluvServer = class {
|
|
@@ -971,7 +972,7 @@ var PluvServer = class {
|
|
|
971
972
|
presence
|
|
972
973
|
}
|
|
973
974
|
};
|
|
974
|
-
}).self((_0, _1) => __async(this, [_0, _1], function* (data, { context, doc, room }) {
|
|
975
|
+
}).self((_0, _1) => __async(this, [_0, _1], function* (data, { context, doc, room, session }) {
|
|
975
976
|
var _a, _b;
|
|
976
977
|
const oldState = yield this._platform.persistence.getStorageState(room);
|
|
977
978
|
const update = data == null ? void 0 : data.update;
|
|
@@ -982,7 +983,13 @@ var PluvServer = class {
|
|
|
982
983
|
if (updates.some((_update) => !!_update)) {
|
|
983
984
|
const encodedState = doc.batchApplyEncodedState(updates).getEncodedState();
|
|
984
985
|
yield this._platform.persistence.setStorageState(room, encodedState);
|
|
985
|
-
this._getListeners().onStorageUpdated({
|
|
986
|
+
this._getListeners().onStorageUpdated({
|
|
987
|
+
context,
|
|
988
|
+
encodedState,
|
|
989
|
+
room,
|
|
990
|
+
user: session == null ? void 0 : session.user,
|
|
991
|
+
webSocket: session == null ? void 0 : session.webSocket.webSocket
|
|
992
|
+
});
|
|
986
993
|
}
|
|
987
994
|
const state = (_b = yield this._platform.persistence.getStorageState(room)) != null ? _b : doc.getEncodedState();
|
|
988
995
|
return { $STORAGE_RECEIVED: { state } };
|
package/dist/index.mjs
CHANGED
|
@@ -732,7 +732,8 @@ var IORoom = class {
|
|
|
732
732
|
encodedState: doc.getEncodedState(),
|
|
733
733
|
message,
|
|
734
734
|
room: this.id,
|
|
735
|
-
user: session.user
|
|
735
|
+
user: session.user,
|
|
736
|
+
webSocket: session.webSocket.webSocket
|
|
736
737
|
}));
|
|
737
738
|
const sessionId = session.id;
|
|
738
739
|
const user = session.user;
|
|
@@ -890,7 +891,7 @@ var IORoom = class {
|
|
|
890
891
|
};
|
|
891
892
|
|
|
892
893
|
// src/version.generated.ts
|
|
893
|
-
var version = "0.32.
|
|
894
|
+
var version = "0.32.2";
|
|
894
895
|
|
|
895
896
|
// src/PluvServer.ts
|
|
896
897
|
var PluvServer = class {
|
|
@@ -929,7 +930,7 @@ var PluvServer = class {
|
|
|
929
930
|
presence
|
|
930
931
|
}
|
|
931
932
|
};
|
|
932
|
-
}).self((_0, _1) => __async(this, [_0, _1], function* (data, { context, doc, room }) {
|
|
933
|
+
}).self((_0, _1) => __async(this, [_0, _1], function* (data, { context, doc, room, session }) {
|
|
933
934
|
var _a, _b;
|
|
934
935
|
const oldState = yield this._platform.persistence.getStorageState(room);
|
|
935
936
|
const update = data == null ? void 0 : data.update;
|
|
@@ -940,7 +941,13 @@ var PluvServer = class {
|
|
|
940
941
|
if (updates.some((_update) => !!_update)) {
|
|
941
942
|
const encodedState = doc.batchApplyEncodedState(updates).getEncodedState();
|
|
942
943
|
yield this._platform.persistence.setStorageState(room, encodedState);
|
|
943
|
-
this._getListeners().onStorageUpdated({
|
|
944
|
+
this._getListeners().onStorageUpdated({
|
|
945
|
+
context,
|
|
946
|
+
encodedState,
|
|
947
|
+
room,
|
|
948
|
+
user: session == null ? void 0 : session.user,
|
|
949
|
+
webSocket: session == null ? void 0 : session.webSocket.webSocket
|
|
950
|
+
});
|
|
944
951
|
}
|
|
945
952
|
const state = (_b = yield this._platform.persistence.getStorageState(room)) != null ? _b : doc.getEncodedState();
|
|
946
953
|
return { $STORAGE_RECEIVED: { state } };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/io",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.2",
|
|
4
4
|
"description": "@pluv/io server-side websocket manager",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,16 +21,16 @@
|
|
|
21
21
|
"jose": "^5.9.3",
|
|
22
22
|
"kleur": "^4.1.5",
|
|
23
23
|
"wonka": "^6.3.4",
|
|
24
|
-
"@pluv/crdt": "^0.32.
|
|
25
|
-
"@pluv/types": "^0.32.
|
|
24
|
+
"@pluv/crdt": "^0.32.2",
|
|
25
|
+
"@pluv/types": "^0.32.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"eslint": "^8.57.0",
|
|
29
29
|
"genversion": "^3.2.0",
|
|
30
30
|
"tsup": "^8.3.0",
|
|
31
31
|
"typescript": "^5.6.2",
|
|
32
|
-
"@pluv/tsconfig": "^0.32.
|
|
33
|
-
"eslint-config-pluv": "^0.32.
|
|
32
|
+
"@pluv/tsconfig": "^0.32.2",
|
|
33
|
+
"eslint-config-pluv": "^0.32.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
|
package/src/IORoom.ts
CHANGED
|
@@ -606,6 +606,7 @@ export class IORoom<
|
|
|
606
606
|
message: message as InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>,
|
|
607
607
|
room: this.id,
|
|
608
608
|
user: session.user,
|
|
609
|
+
webSocket: session.webSocket.webSocket,
|
|
609
610
|
});
|
|
610
611
|
|
|
611
612
|
const sessionId = session.id;
|
package/src/PluvServer.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { noop } from "@pluv/crdt";
|
|
|
3
3
|
import type {
|
|
4
4
|
BaseIOAuthorize,
|
|
5
5
|
IOAuthorize,
|
|
6
|
-
|
|
6
|
+
IOLike,
|
|
7
7
|
Id,
|
|
8
8
|
InferIOAuthorize,
|
|
9
9
|
InferIOAuthorizeUser,
|
|
@@ -66,7 +66,7 @@ export class PluvServer<
|
|
|
66
66
|
TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize,
|
|
67
67
|
TContext extends Record<string, any> = {},
|
|
68
68
|
TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {},
|
|
69
|
-
> implements
|
|
69
|
+
> implements IOLike<TAuthorize, TEvents>
|
|
70
70
|
{
|
|
71
71
|
public readonly version: string = __PLUV_VERSION as any;
|
|
72
72
|
|
|
@@ -120,7 +120,7 @@ export class PluvServer<
|
|
|
120
120
|
},
|
|
121
121
|
};
|
|
122
122
|
})
|
|
123
|
-
.self(async (data, { context, doc, room }) => {
|
|
123
|
+
.self(async (data, { context, doc, room, session }) => {
|
|
124
124
|
const oldState = await this._platform.persistence.getStorageState(room);
|
|
125
125
|
const update = (data as any)?.update as Maybe<string>;
|
|
126
126
|
|
|
@@ -134,7 +134,13 @@ export class PluvServer<
|
|
|
134
134
|
|
|
135
135
|
await this._platform.persistence.setStorageState(room, encodedState);
|
|
136
136
|
|
|
137
|
-
this._getListeners().onStorageUpdated({
|
|
137
|
+
this._getListeners().onStorageUpdated({
|
|
138
|
+
context,
|
|
139
|
+
encodedState,
|
|
140
|
+
room,
|
|
141
|
+
user: session?.user,
|
|
142
|
+
webSocket: session?.webSocket.webSocket,
|
|
143
|
+
});
|
|
138
144
|
}
|
|
139
145
|
|
|
140
146
|
const state = (await this._platform.persistence.getStorageState(room)) ?? doc.getEncodedState();
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
InferPlatformWebSocketType,
|
|
19
19
|
InferRoomContextType,
|
|
20
20
|
} from "./AbstractPlatform";
|
|
21
|
-
import type { AbstractWebSocket } from "./AbstractWebSocket";
|
|
21
|
+
import type { AbstractWebSocket, InferWebSocketSource } from "./AbstractWebSocket";
|
|
22
22
|
import type { PluvRouterEventConfig } from "./PluvRouter";
|
|
23
23
|
|
|
24
24
|
declare global {
|
|
@@ -122,7 +122,7 @@ export interface PluvIOListeners<
|
|
|
122
122
|
> {
|
|
123
123
|
onRoomDeleted: (event: IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
124
124
|
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
125
|
-
onStorageUpdated: (event:
|
|
125
|
+
onStorageUpdated: (event: IOStorageUpdatedEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export type IORoomListenerEvent<
|
|
@@ -144,6 +144,17 @@ export type IORoomMessageEvent<
|
|
|
144
144
|
> = IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents> & {
|
|
145
145
|
message: InferEventMessage<InferEventsOutput<TEvents>, keyof InferEventsOutput<TEvents>>;
|
|
146
146
|
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
147
|
+
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type IOStorageUpdatedEvent<
|
|
151
|
+
TPlatform extends AbstractPlatform<any>,
|
|
152
|
+
TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>>,
|
|
153
|
+
TContext extends Record<string, any>,
|
|
154
|
+
TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>,
|
|
155
|
+
> = IORoomListenerEvent<TPlatform, TAuthorize, TContext, TEvents> & {
|
|
156
|
+
user?: InferIOAuthorizeUser<TAuthorize>;
|
|
157
|
+
webSocket?: InferPlatformWebSocketSource<TPlatform>;
|
|
147
158
|
};
|
|
148
159
|
|
|
149
160
|
export type WebSocketType<TPlatform extends AbstractPlatform> =
|
package/src/version.generated.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.32.
|
|
2
|
+
export const version = '0.32.2'
|