@pluv/platform-pluv 0.32.6 → 0.32.8
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 +8 -8
- package/CHANGELOG.md +18 -0
- package/dist/index.d.mts +150 -2
- package/dist/index.d.ts +150 -2
- package/dist/index.js +3 -1
- package/dist/index.mjs +2 -1
- package/package.json +6 -6
- package/src/PluvIO.ts +6 -3
- package/src/index.ts +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/platform-pluv@0.32.
|
|
2
|
+
> @pluv/platform-pluv@0.32.8 build /home/runner/work/pluv/pluv/packages/platform-pluv
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m8.
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[32m9.
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m8.85 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 105ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m9.75 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 106ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 6280ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m6.99 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m6.99 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @pluv/platform-pluv
|
|
2
2
|
|
|
3
|
+
## 0.32.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [e659f8a]
|
|
8
|
+
- @pluv/io@0.32.8
|
|
9
|
+
- @pluv/crdt@0.32.8
|
|
10
|
+
- @pluv/types@0.32.8
|
|
11
|
+
|
|
12
|
+
## 0.32.7
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- a9a1f7b: Export event schemas.
|
|
17
|
+
- @pluv/crdt@0.32.7
|
|
18
|
+
- @pluv/io@0.32.7
|
|
19
|
+
- @pluv/types@0.32.7
|
|
20
|
+
|
|
3
21
|
## 0.32.6
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AbstractPlatform, WebSocketRegistrationMode, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, JWTEncodeParams, GetInitialStorageFn, BaseUser as BaseUser$1 } from '@pluv/io';
|
|
2
2
|
import * as hono from 'hono';
|
|
3
3
|
import { BaseUser, InputZodLike, IOLike } from '@pluv/types';
|
|
4
|
+
import { z } from 'zod';
|
|
4
5
|
|
|
5
6
|
declare class PluvPlatform extends AbstractPlatform {
|
|
6
7
|
_registrationMode: WebSocketRegistrationMode;
|
|
@@ -39,7 +40,7 @@ type UserDisconnectedEventData<TUser extends BaseUser> = {
|
|
|
39
40
|
user: TUser;
|
|
40
41
|
};
|
|
41
42
|
type PluvIOListeners<TUser extends BaseUser> = {
|
|
42
|
-
getInitialStorage?: GetInitialStorageFn
|
|
43
|
+
getInitialStorage?: GetInitialStorageFn<{}>;
|
|
43
44
|
onRoomDeleted: (event: RoomDeletedMessageEventData) => void;
|
|
44
45
|
onUserConnected: (event: UserConnectedEventData<TUser>) => void;
|
|
45
46
|
onUserDisconnected: (event: UserDisconnectedEventData<TUser>) => void;
|
|
@@ -96,4 +97,151 @@ declare class PluvIO<TUser extends BaseUser> implements IOLike<PluvAuthorize<TUs
|
|
|
96
97
|
|
|
97
98
|
declare const createIO: <TUser extends BaseUser$1>(config: PluvIOConfig<TUser>) => PluvIO<TUser>;
|
|
98
99
|
|
|
99
|
-
|
|
100
|
+
declare const ZodEvent: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
|
|
101
|
+
event: z.ZodLiteral<"initial-storage">;
|
|
102
|
+
data: z.ZodObject<{
|
|
103
|
+
room: z.ZodNullable<z.ZodString>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
room: string | null;
|
|
106
|
+
}, {
|
|
107
|
+
room: string | null;
|
|
108
|
+
}>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
event: "initial-storage";
|
|
111
|
+
data: {
|
|
112
|
+
room: string | null;
|
|
113
|
+
};
|
|
114
|
+
}, {
|
|
115
|
+
event: "initial-storage";
|
|
116
|
+
data: {
|
|
117
|
+
room: string | null;
|
|
118
|
+
};
|
|
119
|
+
}>, z.ZodObject<{
|
|
120
|
+
event: z.ZodLiteral<"room-deleted">;
|
|
121
|
+
data: z.ZodObject<{
|
|
122
|
+
room: z.ZodString;
|
|
123
|
+
storage: z.ZodNullable<z.ZodString>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
room: string;
|
|
126
|
+
storage: string | null;
|
|
127
|
+
}, {
|
|
128
|
+
room: string;
|
|
129
|
+
storage: string | null;
|
|
130
|
+
}>;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
event: "room-deleted";
|
|
133
|
+
data: {
|
|
134
|
+
room: string;
|
|
135
|
+
storage: string | null;
|
|
136
|
+
};
|
|
137
|
+
}, {
|
|
138
|
+
event: "room-deleted";
|
|
139
|
+
data: {
|
|
140
|
+
room: string;
|
|
141
|
+
storage: string | null;
|
|
142
|
+
};
|
|
143
|
+
}>, z.ZodObject<{
|
|
144
|
+
event: z.ZodLiteral<"user-connected">;
|
|
145
|
+
data: z.ZodObject<{
|
|
146
|
+
room: z.ZodString;
|
|
147
|
+
storage: z.ZodNullable<z.ZodString>;
|
|
148
|
+
user: z.ZodObject<{
|
|
149
|
+
id: z.ZodString;
|
|
150
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
151
|
+
id: z.ZodString;
|
|
152
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
153
|
+
id: z.ZodString;
|
|
154
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
room: string;
|
|
157
|
+
storage: string | null;
|
|
158
|
+
user: {
|
|
159
|
+
id: string;
|
|
160
|
+
} & {
|
|
161
|
+
[k: string]: unknown;
|
|
162
|
+
};
|
|
163
|
+
}, {
|
|
164
|
+
room: string;
|
|
165
|
+
storage: string | null;
|
|
166
|
+
user: {
|
|
167
|
+
id: string;
|
|
168
|
+
} & {
|
|
169
|
+
[k: string]: unknown;
|
|
170
|
+
};
|
|
171
|
+
}>;
|
|
172
|
+
}, "strip", z.ZodTypeAny, {
|
|
173
|
+
event: "user-connected";
|
|
174
|
+
data: {
|
|
175
|
+
room: string;
|
|
176
|
+
storage: string | null;
|
|
177
|
+
user: {
|
|
178
|
+
id: string;
|
|
179
|
+
} & {
|
|
180
|
+
[k: string]: unknown;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
}, {
|
|
184
|
+
event: "user-connected";
|
|
185
|
+
data: {
|
|
186
|
+
room: string;
|
|
187
|
+
storage: string | null;
|
|
188
|
+
user: {
|
|
189
|
+
id: string;
|
|
190
|
+
} & {
|
|
191
|
+
[k: string]: unknown;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
}>, z.ZodObject<{
|
|
195
|
+
event: z.ZodLiteral<"user-disconnected">;
|
|
196
|
+
data: z.ZodObject<{
|
|
197
|
+
room: z.ZodString;
|
|
198
|
+
storage: z.ZodNullable<z.ZodString>;
|
|
199
|
+
user: z.ZodObject<{
|
|
200
|
+
id: z.ZodString;
|
|
201
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
202
|
+
id: z.ZodString;
|
|
203
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
204
|
+
id: z.ZodString;
|
|
205
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
206
|
+
}, "strip", z.ZodTypeAny, {
|
|
207
|
+
room: string;
|
|
208
|
+
storage: string | null;
|
|
209
|
+
user: {
|
|
210
|
+
id: string;
|
|
211
|
+
} & {
|
|
212
|
+
[k: string]: unknown;
|
|
213
|
+
};
|
|
214
|
+
}, {
|
|
215
|
+
room: string;
|
|
216
|
+
storage: string | null;
|
|
217
|
+
user: {
|
|
218
|
+
id: string;
|
|
219
|
+
} & {
|
|
220
|
+
[k: string]: unknown;
|
|
221
|
+
};
|
|
222
|
+
}>;
|
|
223
|
+
}, "strip", z.ZodTypeAny, {
|
|
224
|
+
event: "user-disconnected";
|
|
225
|
+
data: {
|
|
226
|
+
room: string;
|
|
227
|
+
storage: string | null;
|
|
228
|
+
user: {
|
|
229
|
+
id: string;
|
|
230
|
+
} & {
|
|
231
|
+
[k: string]: unknown;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
}, {
|
|
235
|
+
event: "user-disconnected";
|
|
236
|
+
data: {
|
|
237
|
+
room: string;
|
|
238
|
+
storage: string | null;
|
|
239
|
+
user: {
|
|
240
|
+
id: string;
|
|
241
|
+
} & {
|
|
242
|
+
[k: string]: unknown;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
}>]>;
|
|
246
|
+
|
|
247
|
+
export { PluvIO, type PluvIOConfig, PluvPlatform, ZodEvent, createIO };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AbstractPlatform, WebSocketRegistrationMode, AbstractWebSocket, ConvertWebSocketConfig, WebSocketSerializedState, AbstractPlatformConfig, JWTEncodeParams, GetInitialStorageFn, BaseUser as BaseUser$1 } from '@pluv/io';
|
|
2
2
|
import * as hono from 'hono';
|
|
3
3
|
import { BaseUser, InputZodLike, IOLike } from '@pluv/types';
|
|
4
|
+
import { z } from 'zod';
|
|
4
5
|
|
|
5
6
|
declare class PluvPlatform extends AbstractPlatform {
|
|
6
7
|
_registrationMode: WebSocketRegistrationMode;
|
|
@@ -39,7 +40,7 @@ type UserDisconnectedEventData<TUser extends BaseUser> = {
|
|
|
39
40
|
user: TUser;
|
|
40
41
|
};
|
|
41
42
|
type PluvIOListeners<TUser extends BaseUser> = {
|
|
42
|
-
getInitialStorage?: GetInitialStorageFn
|
|
43
|
+
getInitialStorage?: GetInitialStorageFn<{}>;
|
|
43
44
|
onRoomDeleted: (event: RoomDeletedMessageEventData) => void;
|
|
44
45
|
onUserConnected: (event: UserConnectedEventData<TUser>) => void;
|
|
45
46
|
onUserDisconnected: (event: UserDisconnectedEventData<TUser>) => void;
|
|
@@ -96,4 +97,151 @@ declare class PluvIO<TUser extends BaseUser> implements IOLike<PluvAuthorize<TUs
|
|
|
96
97
|
|
|
97
98
|
declare const createIO: <TUser extends BaseUser$1>(config: PluvIOConfig<TUser>) => PluvIO<TUser>;
|
|
98
99
|
|
|
99
|
-
|
|
100
|
+
declare const ZodEvent: z.ZodDiscriminatedUnion<"event", [z.ZodObject<{
|
|
101
|
+
event: z.ZodLiteral<"initial-storage">;
|
|
102
|
+
data: z.ZodObject<{
|
|
103
|
+
room: z.ZodNullable<z.ZodString>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
room: string | null;
|
|
106
|
+
}, {
|
|
107
|
+
room: string | null;
|
|
108
|
+
}>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
event: "initial-storage";
|
|
111
|
+
data: {
|
|
112
|
+
room: string | null;
|
|
113
|
+
};
|
|
114
|
+
}, {
|
|
115
|
+
event: "initial-storage";
|
|
116
|
+
data: {
|
|
117
|
+
room: string | null;
|
|
118
|
+
};
|
|
119
|
+
}>, z.ZodObject<{
|
|
120
|
+
event: z.ZodLiteral<"room-deleted">;
|
|
121
|
+
data: z.ZodObject<{
|
|
122
|
+
room: z.ZodString;
|
|
123
|
+
storage: z.ZodNullable<z.ZodString>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
room: string;
|
|
126
|
+
storage: string | null;
|
|
127
|
+
}, {
|
|
128
|
+
room: string;
|
|
129
|
+
storage: string | null;
|
|
130
|
+
}>;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
event: "room-deleted";
|
|
133
|
+
data: {
|
|
134
|
+
room: string;
|
|
135
|
+
storage: string | null;
|
|
136
|
+
};
|
|
137
|
+
}, {
|
|
138
|
+
event: "room-deleted";
|
|
139
|
+
data: {
|
|
140
|
+
room: string;
|
|
141
|
+
storage: string | null;
|
|
142
|
+
};
|
|
143
|
+
}>, z.ZodObject<{
|
|
144
|
+
event: z.ZodLiteral<"user-connected">;
|
|
145
|
+
data: z.ZodObject<{
|
|
146
|
+
room: z.ZodString;
|
|
147
|
+
storage: z.ZodNullable<z.ZodString>;
|
|
148
|
+
user: z.ZodObject<{
|
|
149
|
+
id: z.ZodString;
|
|
150
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
151
|
+
id: z.ZodString;
|
|
152
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
153
|
+
id: z.ZodString;
|
|
154
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
room: string;
|
|
157
|
+
storage: string | null;
|
|
158
|
+
user: {
|
|
159
|
+
id: string;
|
|
160
|
+
} & {
|
|
161
|
+
[k: string]: unknown;
|
|
162
|
+
};
|
|
163
|
+
}, {
|
|
164
|
+
room: string;
|
|
165
|
+
storage: string | null;
|
|
166
|
+
user: {
|
|
167
|
+
id: string;
|
|
168
|
+
} & {
|
|
169
|
+
[k: string]: unknown;
|
|
170
|
+
};
|
|
171
|
+
}>;
|
|
172
|
+
}, "strip", z.ZodTypeAny, {
|
|
173
|
+
event: "user-connected";
|
|
174
|
+
data: {
|
|
175
|
+
room: string;
|
|
176
|
+
storage: string | null;
|
|
177
|
+
user: {
|
|
178
|
+
id: string;
|
|
179
|
+
} & {
|
|
180
|
+
[k: string]: unknown;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
}, {
|
|
184
|
+
event: "user-connected";
|
|
185
|
+
data: {
|
|
186
|
+
room: string;
|
|
187
|
+
storage: string | null;
|
|
188
|
+
user: {
|
|
189
|
+
id: string;
|
|
190
|
+
} & {
|
|
191
|
+
[k: string]: unknown;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
}>, z.ZodObject<{
|
|
195
|
+
event: z.ZodLiteral<"user-disconnected">;
|
|
196
|
+
data: z.ZodObject<{
|
|
197
|
+
room: z.ZodString;
|
|
198
|
+
storage: z.ZodNullable<z.ZodString>;
|
|
199
|
+
user: z.ZodObject<{
|
|
200
|
+
id: z.ZodString;
|
|
201
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
202
|
+
id: z.ZodString;
|
|
203
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
204
|
+
id: z.ZodString;
|
|
205
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
206
|
+
}, "strip", z.ZodTypeAny, {
|
|
207
|
+
room: string;
|
|
208
|
+
storage: string | null;
|
|
209
|
+
user: {
|
|
210
|
+
id: string;
|
|
211
|
+
} & {
|
|
212
|
+
[k: string]: unknown;
|
|
213
|
+
};
|
|
214
|
+
}, {
|
|
215
|
+
room: string;
|
|
216
|
+
storage: string | null;
|
|
217
|
+
user: {
|
|
218
|
+
id: string;
|
|
219
|
+
} & {
|
|
220
|
+
[k: string]: unknown;
|
|
221
|
+
};
|
|
222
|
+
}>;
|
|
223
|
+
}, "strip", z.ZodTypeAny, {
|
|
224
|
+
event: "user-disconnected";
|
|
225
|
+
data: {
|
|
226
|
+
room: string;
|
|
227
|
+
storage: string | null;
|
|
228
|
+
user: {
|
|
229
|
+
id: string;
|
|
230
|
+
} & {
|
|
231
|
+
[k: string]: unknown;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
}, {
|
|
235
|
+
event: "user-disconnected";
|
|
236
|
+
data: {
|
|
237
|
+
room: string;
|
|
238
|
+
storage: string | null;
|
|
239
|
+
user: {
|
|
240
|
+
id: string;
|
|
241
|
+
} & {
|
|
242
|
+
[k: string]: unknown;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
}>]>;
|
|
246
|
+
|
|
247
|
+
export { PluvIO, type PluvIOConfig, PluvPlatform, ZodEvent, createIO };
|
package/dist/index.js
CHANGED
|
@@ -54,6 +54,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
54
54
|
// src/index.ts
|
|
55
55
|
var src_exports = {};
|
|
56
56
|
__export(src_exports, {
|
|
57
|
+
ZodEvent: () => ZodEvent,
|
|
57
58
|
createIO: () => createIO
|
|
58
59
|
});
|
|
59
60
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -179,7 +180,7 @@ var PluvIO = class {
|
|
|
179
180
|
switch (event) {
|
|
180
181
|
case "initial-storage": {
|
|
181
182
|
const room = data.room;
|
|
182
|
-
const storage = typeof room === "string" ? (_b = yield (_a = this._getInitialStorage) == null ? void 0 : _a.call(this, { room })) != null ? _b : null : null;
|
|
183
|
+
const storage = typeof room === "string" ? (_b = yield (_a = this._getInitialStorage) == null ? void 0 : _a.call(this, { context: {}, room })) != null ? _b : null : null;
|
|
183
184
|
return c.json({ data: { storage } }, 200);
|
|
184
185
|
}
|
|
185
186
|
case "room-deleted": {
|
|
@@ -289,5 +290,6 @@ var createIO = (config) => {
|
|
|
289
290
|
};
|
|
290
291
|
// Annotate the CommonJS export names for ESM import in node:
|
|
291
292
|
0 && (module.exports = {
|
|
293
|
+
ZodEvent,
|
|
292
294
|
createIO
|
|
293
295
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -162,7 +162,7 @@ var PluvIO = class {
|
|
|
162
162
|
switch (event) {
|
|
163
163
|
case "initial-storage": {
|
|
164
164
|
const room = data.room;
|
|
165
|
-
const storage = typeof room === "string" ? (_b = yield (_a = this._getInitialStorage) == null ? void 0 : _a.call(this, { room })) != null ? _b : null : null;
|
|
165
|
+
const storage = typeof room === "string" ? (_b = yield (_a = this._getInitialStorage) == null ? void 0 : _a.call(this, { context: {}, room })) != null ? _b : null : null;
|
|
166
166
|
return c.json({ data: { storage } }, 200);
|
|
167
167
|
}
|
|
168
168
|
case "room-deleted": {
|
|
@@ -271,5 +271,6 @@ var createIO = (config) => {
|
|
|
271
271
|
return new PluvIO(config);
|
|
272
272
|
};
|
|
273
273
|
export {
|
|
274
|
+
ZodEvent,
|
|
274
275
|
createIO
|
|
275
276
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/platform-pluv",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.8",
|
|
4
4
|
"description": "@pluv/io adapter for pluv.io",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"@types/node": "^22.8.1",
|
|
21
21
|
"hono": "^4.6.7",
|
|
22
22
|
"zod": "^3.23.8",
|
|
23
|
-
"@pluv/crdt": "^0.32.
|
|
24
|
-
"@pluv/
|
|
25
|
-
"@pluv/
|
|
23
|
+
"@pluv/crdt": "^0.32.8",
|
|
24
|
+
"@pluv/types": "^0.32.8",
|
|
25
|
+
"@pluv/io": "^0.32.8"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"eslint": "^8.57.0",
|
|
29
29
|
"tsup": "^8.3.5",
|
|
30
30
|
"typescript": "^5.6.3",
|
|
31
|
-
"@pluv/tsconfig": "^0.32.
|
|
32
|
-
"eslint-config-pluv": "^0.32.
|
|
31
|
+
"@pluv/tsconfig": "^0.32.8",
|
|
32
|
+
"eslint-config-pluv": "^0.32.8"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/PluvIO.ts
CHANGED
|
@@ -35,7 +35,7 @@ type UserDisconnectedEventData<TUser extends BaseUser> = {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
type PluvIOListeners<TUser extends BaseUser> = {
|
|
38
|
-
getInitialStorage?: GetInitialStorageFn
|
|
38
|
+
getInitialStorage?: GetInitialStorageFn<{}>;
|
|
39
39
|
onRoomDeleted: (event: RoomDeletedMessageEventData) => void;
|
|
40
40
|
onUserConnected: (event: UserConnectedEventData<TUser>) => void;
|
|
41
41
|
onUserDisconnected: (event: UserDisconnectedEventData<TUser>) => void;
|
|
@@ -66,7 +66,7 @@ export class PluvIO<TUser extends BaseUser> implements IOLike<PluvAuthorize<TUse
|
|
|
66
66
|
private readonly _authorize: PluvAuthorize<TUser>;
|
|
67
67
|
private readonly _basePath: string;
|
|
68
68
|
private readonly _endpoints: PluvIOEndpoints;
|
|
69
|
-
private readonly _getInitialStorage?: GetInitialStorageFn
|
|
69
|
+
private readonly _getInitialStorage?: GetInitialStorageFn<{}>;
|
|
70
70
|
private readonly _listeners: PluvIOListeners<TUser>;
|
|
71
71
|
private readonly _publicKey: string;
|
|
72
72
|
private readonly _secretKey: string;
|
|
@@ -124,7 +124,10 @@ export class PluvIO<TUser extends BaseUser> implements IOLike<PluvAuthorize<TUse
|
|
|
124
124
|
switch (event) {
|
|
125
125
|
case "initial-storage": {
|
|
126
126
|
const room = data.room;
|
|
127
|
-
const storage =
|
|
127
|
+
const storage =
|
|
128
|
+
typeof room === "string"
|
|
129
|
+
? ((await this._getInitialStorage?.({ context: {}, room })) ?? null)
|
|
130
|
+
: null;
|
|
128
131
|
|
|
129
132
|
return c.json({ data: { storage } }, 200);
|
|
130
133
|
}
|
package/src/index.ts
CHANGED