@pluv/io 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 +9 -9
- package/CHANGELOG.md +35 -0
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +5 -5
- package/src/PluvIO.ts +1 -1
- package/src/PluvServer.ts +3 -3
- package/src/types.ts +5 -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.8 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.8 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
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m44.81 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 108ms
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m42.64 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 126ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m27.
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m27.
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 2223ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m27.33 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m27.33 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @pluv/io
|
|
2
2
|
|
|
3
|
+
## 0.32.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e659f8a: Update `getInitialStorage` so that the context is made available on the `context` event property.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createIO } from "@pluv/io";
|
|
11
|
+
|
|
12
|
+
// Before
|
|
13
|
+
const io = createIO({
|
|
14
|
+
getInitialStorage: ({ room, ...context }) => {
|
|
15
|
+
// ...
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// After
|
|
20
|
+
const io = createIO({
|
|
21
|
+
// Context is now an explicit property on the event
|
|
22
|
+
getInitialStorage: ({ room, context }) => {
|
|
23
|
+
// ...
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- @pluv/crdt@0.32.8
|
|
29
|
+
- @pluv/types@0.32.8
|
|
30
|
+
|
|
31
|
+
## 0.32.7
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- @pluv/crdt@0.32.7
|
|
36
|
+
- @pluv/types@0.32.7
|
|
37
|
+
|
|
3
38
|
## 0.32.6
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -175,10 +175,11 @@ type MergeEventRecords<TEventRecords extends EventRecord<string, any>[], TRoot e
|
|
|
175
175
|
] ? MergeEventRecords<ITail, Omit<TRoot, keyof IHead> & {
|
|
176
176
|
[P in keyof IHead]: TRoot extends Record<P, any> ? TRoot[P] | IHead[P] : IHead[P];
|
|
177
177
|
}> : Id<TRoot>;
|
|
178
|
-
type GetInitialStorageEvent = {
|
|
178
|
+
type GetInitialStorageEvent<TContext extends Record<string, any>> = {
|
|
179
|
+
context: TContext;
|
|
179
180
|
room: string;
|
|
180
181
|
};
|
|
181
|
-
type GetInitialStorageFn = (event: GetInitialStorageEvent) => MaybePromise<Maybe<string>>;
|
|
182
|
+
type GetInitialStorageFn<TContext extends Record<string, any>> = (event: GetInitialStorageEvent<TContext>) => MaybePromise<Maybe<string>>;
|
|
182
183
|
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
184
|
onRoomDeleted: (event: IORoomListenerEvent<TContext>) => void;
|
|
184
185
|
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
@@ -373,7 +374,7 @@ type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform
|
|
|
373
374
|
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
374
375
|
};
|
|
375
376
|
debug?: boolean;
|
|
376
|
-
getInitialStorage?: GetInitialStorageFn
|
|
377
|
+
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
377
378
|
platform: TPlatform;
|
|
378
379
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
379
380
|
};
|
|
@@ -418,7 +419,7 @@ type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IO
|
|
|
418
419
|
platform: TPlatform;
|
|
419
420
|
};
|
|
420
421
|
type ServerConfig<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> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
421
|
-
getInitialStorage?: GetInitialStorageFn
|
|
422
|
+
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
422
423
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
423
424
|
};
|
|
424
425
|
declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}> {
|
package/dist/index.d.ts
CHANGED
|
@@ -175,10 +175,11 @@ type MergeEventRecords<TEventRecords extends EventRecord<string, any>[], TRoot e
|
|
|
175
175
|
] ? MergeEventRecords<ITail, Omit<TRoot, keyof IHead> & {
|
|
176
176
|
[P in keyof IHead]: TRoot extends Record<P, any> ? TRoot[P] | IHead[P] : IHead[P];
|
|
177
177
|
}> : Id<TRoot>;
|
|
178
|
-
type GetInitialStorageEvent = {
|
|
178
|
+
type GetInitialStorageEvent<TContext extends Record<string, any>> = {
|
|
179
|
+
context: TContext;
|
|
179
180
|
room: string;
|
|
180
181
|
};
|
|
181
|
-
type GetInitialStorageFn = (event: GetInitialStorageEvent) => MaybePromise<Maybe<string>>;
|
|
182
|
+
type GetInitialStorageFn<TContext extends Record<string, any>> = (event: GetInitialStorageEvent<TContext>) => MaybePromise<Maybe<string>>;
|
|
182
183
|
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
184
|
onRoomDeleted: (event: IORoomListenerEvent<TContext>) => void;
|
|
184
185
|
onRoomMessage: (event: IORoomMessageEvent<TPlatform, TAuthorize, TContext, TEvents>) => void;
|
|
@@ -373,7 +374,7 @@ type PluvServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform
|
|
|
373
374
|
doc: (value: any) => AbstractCrdtDocFactory<any>;
|
|
374
375
|
};
|
|
375
376
|
debug?: boolean;
|
|
376
|
-
getInitialStorage?: GetInitialStorageFn
|
|
377
|
+
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
377
378
|
platform: TPlatform;
|
|
378
379
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
379
380
|
};
|
|
@@ -418,7 +419,7 @@ type PluvIOConfig<TPlatform extends AbstractPlatform<any>, TAuthorize extends IO
|
|
|
418
419
|
platform: TPlatform;
|
|
419
420
|
};
|
|
420
421
|
type ServerConfig<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> = {}> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
421
|
-
getInitialStorage?: GetInitialStorageFn
|
|
422
|
+
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
422
423
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
423
424
|
};
|
|
424
425
|
declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends IOAuthorize<any, any, InferInitContextType<TPlatform>> = BaseIOAuthorize, TContext extends Record<string, any> = {}> {
|
package/dist/index.js
CHANGED
|
@@ -1002,7 +1002,7 @@ var IORoom = class {
|
|
|
1002
1002
|
};
|
|
1003
1003
|
|
|
1004
1004
|
// src/version.generated.ts
|
|
1005
|
-
var version = "0.32.
|
|
1005
|
+
var version = "0.32.8";
|
|
1006
1006
|
|
|
1007
1007
|
// src/PluvServer.ts
|
|
1008
1008
|
var PluvServer = class {
|
|
@@ -1046,7 +1046,7 @@ var PluvServer = class {
|
|
|
1046
1046
|
const oldState = yield this._platform.persistence.getStorageState(room);
|
|
1047
1047
|
const update = data == null ? void 0 : data.update;
|
|
1048
1048
|
const updates = [
|
|
1049
|
-
oldState ? null : yield (_a = this._getInitialStorage) == null ? void 0 : _a.call(this,
|
|
1049
|
+
oldState ? null : yield (_a = this._getInitialStorage) == null ? void 0 : _a.call(this, { context, room }),
|
|
1050
1050
|
update
|
|
1051
1051
|
];
|
|
1052
1052
|
if (updates.some((_update) => !!_update)) {
|
package/dist/index.mjs
CHANGED
|
@@ -960,7 +960,7 @@ var IORoom = class {
|
|
|
960
960
|
};
|
|
961
961
|
|
|
962
962
|
// src/version.generated.ts
|
|
963
|
-
var version = "0.32.
|
|
963
|
+
var version = "0.32.8";
|
|
964
964
|
|
|
965
965
|
// src/PluvServer.ts
|
|
966
966
|
var PluvServer = class {
|
|
@@ -1004,7 +1004,7 @@ var PluvServer = class {
|
|
|
1004
1004
|
const oldState = yield this._platform.persistence.getStorageState(room);
|
|
1005
1005
|
const update = data == null ? void 0 : data.update;
|
|
1006
1006
|
const updates = [
|
|
1007
|
-
oldState ? null : yield (_a = this._getInitialStorage) == null ? void 0 : _a.call(this,
|
|
1007
|
+
oldState ? null : yield (_a = this._getInitialStorage) == null ? void 0 : _a.call(this, { context, room }),
|
|
1008
1008
|
update
|
|
1009
1009
|
];
|
|
1010
1010
|
if (updates.some((_update) => !!_update)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/io",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.8",
|
|
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.6",
|
|
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.8",
|
|
25
|
+
"@pluv/types": "^0.32.8"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"eslint": "^8.57.0",
|
|
29
29
|
"genversion": "^3.2.0",
|
|
30
30
|
"tsup": "^8.3.5",
|
|
31
31
|
"typescript": "^5.6.3",
|
|
32
|
-
"@pluv/tsconfig": "^0.32.
|
|
33
|
-
"eslint-config-pluv": "^0.32.
|
|
32
|
+
"@pluv/tsconfig": "^0.32.8",
|
|
33
|
+
"eslint-config-pluv": "^0.32.8"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
|
package/src/PluvIO.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type ServerConfig<
|
|
|
29
29
|
TContext extends Record<string, any> = {},
|
|
30
30
|
TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {},
|
|
31
31
|
> = Partial<PluvIOListeners<TPlatform, TAuthorize, TContext, TEvents>> & {
|
|
32
|
-
getInitialStorage?: GetInitialStorageFn
|
|
32
|
+
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
33
33
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
34
34
|
};
|
|
35
35
|
|
package/src/PluvServer.ts
CHANGED
|
@@ -38,7 +38,7 @@ export type PluvServerConfig<
|
|
|
38
38
|
context?: PluvContext<TPlatform, TContext>;
|
|
39
39
|
crdt?: { doc: (value: any) => AbstractCrdtDocFactory<any> };
|
|
40
40
|
debug?: boolean;
|
|
41
|
-
getInitialStorage?: GetInitialStorageFn
|
|
41
|
+
getInitialStorage?: GetInitialStorageFn<TContext>;
|
|
42
42
|
platform: TPlatform;
|
|
43
43
|
router?: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
44
44
|
};
|
|
@@ -125,7 +125,7 @@ export class PluvServer<
|
|
|
125
125
|
const update = (data as any)?.update as Maybe<string>;
|
|
126
126
|
|
|
127
127
|
const updates: readonly Maybe<string>[] = [
|
|
128
|
-
oldState ? null : await this._getInitialStorage?.({
|
|
128
|
+
oldState ? null : await this._getInitialStorage?.({ context, room }),
|
|
129
129
|
update,
|
|
130
130
|
];
|
|
131
131
|
|
|
@@ -197,7 +197,7 @@ export class PluvServer<
|
|
|
197
197
|
private readonly _context: PluvContext<TPlatform, TContext> = {} as PluvContext<TPlatform, TContext>;
|
|
198
198
|
private readonly _crdt: { doc: (value: any) => AbstractCrdtDocFactory<any> };
|
|
199
199
|
private readonly _debug: boolean;
|
|
200
|
-
private readonly _getInitialStorage: GetInitialStorageFn | null = null;
|
|
200
|
+
private readonly _getInitialStorage: GetInitialStorageFn<TContext> | null = null;
|
|
201
201
|
private readonly _platform: TPlatform;
|
|
202
202
|
private readonly _router: PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
|
|
203
203
|
|
package/src/types.ts
CHANGED
|
@@ -106,11 +106,14 @@ export type MergeEventRecords<
|
|
|
106
106
|
>
|
|
107
107
|
: Id<TRoot>;
|
|
108
108
|
|
|
109
|
-
export type GetInitialStorageEvent = {
|
|
109
|
+
export type GetInitialStorageEvent<TContext extends Record<string, any>> = {
|
|
110
|
+
context: TContext;
|
|
110
111
|
room: string;
|
|
111
112
|
};
|
|
112
113
|
|
|
113
|
-
export type GetInitialStorageFn
|
|
114
|
+
export type GetInitialStorageFn<TContext extends Record<string, any>> = (
|
|
115
|
+
event: GetInitialStorageEvent<TContext>,
|
|
116
|
+
) => MaybePromise<Maybe<string>>;
|
|
114
117
|
|
|
115
118
|
export interface PluvIOListeners<
|
|
116
119
|
TPlatform extends AbstractPlatform<any>,
|
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.8'
|