@pluv/io 0.26.0 → 0.27.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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +48 -0
- package/dist/index.d.mts +2 -8
- package/dist/index.d.ts +2 -8
- package/dist/index.js +12 -6
- package/dist/index.mjs +12 -6
- package/package.json +8 -8
- package/src/IORoom.ts +11 -4
- package/src/PluvProcedure.ts +4 -4
- package/src/PluvServer.ts +1 -1
- package/src/version.generated.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/io@0.
|
|
2
|
+
> @pluv/io@0.27.0 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.
|
|
6
|
+
> @pluv/io@0.27.0 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
|
|
10
10
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
11
|
-
[34mCLI[39m tsup v8.
|
|
11
|
+
[34mCLI[39m tsup v8.3.0
|
|
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[32m39.
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
17
|
-
[32mCJS[39m [1mdist/index.js [22m[32m41.
|
|
18
|
-
[32mCJS[39m ⚡️ Build success in
|
|
15
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m39.84 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 179ms
|
|
17
|
+
[32mCJS[39m [1mdist/index.js [22m[32m41.98 KB[39m
|
|
18
|
+
[32mCJS[39m ⚡️ Build success in 187ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m25.
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m25.
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 2694ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m25.32 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m25.32 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @pluv/io
|
|
2
2
|
|
|
3
|
+
## 0.27.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 19ed36c: Fixed custom events not properly registering on IORoom.
|
|
8
|
+
- e309b0b: Events without a procedure will now automatically be passed-through to connected peers as-if they were broadcast.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
// backend
|
|
12
|
+
|
|
13
|
+
const io = createIO({
|
|
14
|
+
/* ... */
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ioServer = io.server({
|
|
18
|
+
router: io.router({
|
|
19
|
+
sendGreeting: io.procedure
|
|
20
|
+
.input(z.object({ name: z.string() }))
|
|
21
|
+
.broadcast(({ name }) => ({
|
|
22
|
+
receiveGreeting: { greeting: `Hi, I'm ${name}!` },
|
|
23
|
+
})),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// frontend
|
|
28
|
+
|
|
29
|
+
const broadcast = useBroadcast();
|
|
30
|
+
|
|
31
|
+
// This will be captured in the server procedure and emit receiveGreeting
|
|
32
|
+
broadcast.sendGreeting({ name: "leedavidcs" });
|
|
33
|
+
|
|
34
|
+
event.receiveGreeting.useEvent(({ data }) => {
|
|
35
|
+
console.log(data.greeting);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// This is not captured by any server procedure and will be broadcast to peers as-is
|
|
39
|
+
|
|
40
|
+
broadcast.myCustomUncaughtEvent({ randomData: "Hello world!" });
|
|
41
|
+
|
|
42
|
+
// This will be be received by all connections, passed as-is from the server
|
|
43
|
+
event.myCustomUncaughtEvent.useEvent(({ data }) => {
|
|
44
|
+
console.log(data.randomData);
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- @pluv/crdt@0.27.0
|
|
49
|
+
- @pluv/types@0.27.0
|
|
50
|
+
|
|
3
51
|
## 0.26.0
|
|
4
52
|
|
|
5
53
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, BaseIOAuthorize, IORouterLike, InferIOAuthorizeUser, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, BaseUser, InferIOInput, InferIOAuthorize } from '@pluv/types';
|
|
1
|
+
import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, ProcedureLike, BaseIOAuthorize, IORouterLike, InferIOAuthorizeUser, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, BaseUser, InferIOInput, InferIOAuthorize } from '@pluv/types';
|
|
2
2
|
export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
|
|
3
3
|
import { AbstractCrdtDoc, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
4
4
|
|
|
@@ -93,13 +93,7 @@ declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize
|
|
|
93
93
|
private _input;
|
|
94
94
|
private _self;
|
|
95
95
|
private _sync;
|
|
96
|
-
get config():
|
|
97
|
-
broadcast: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
98
|
-
input: InputZodLike<TInput> | null;
|
|
99
|
-
resolver: () => EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TOutput>;
|
|
100
|
-
self: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
101
|
-
sync: EventResolver<TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
102
|
-
};
|
|
96
|
+
get config(): ProcedureLike<TInput, TOutput>["config"];
|
|
103
97
|
constructor(config?: PluvProcedureConfig<TPlatform, TAuthorize, TContext, TInput, TOutput>);
|
|
104
98
|
broadcast<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "broadcast">, TFilled | "input" | "broadcast">;
|
|
105
99
|
input<TData extends JsonObject>(input: InputZodLike<TData>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TData, {}, TFilled | "input">, TFilled | "input">;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, BaseIOAuthorize, IORouterLike, InferIOAuthorizeUser, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, BaseUser, InferIOInput, InferIOAuthorize } from '@pluv/types';
|
|
1
|
+
import { JsonObject, MaybePromise, IOAuthorize, IOEventMessage, EventRecord, InputZodLike, ProcedureLike, BaseIOAuthorize, IORouterLike, InferIOAuthorizeUser, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, BaseUser, InferIOInput, InferIOAuthorize } from '@pluv/types';
|
|
2
2
|
export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
|
|
3
3
|
import { AbstractCrdtDoc, AbstractCrdtDocFactory } from '@pluv/crdt';
|
|
4
4
|
|
|
@@ -93,13 +93,7 @@ declare class PluvProcedure<TPlatform extends AbstractPlatform<any>, TAuthorize
|
|
|
93
93
|
private _input;
|
|
94
94
|
private _self;
|
|
95
95
|
private _sync;
|
|
96
|
-
get config():
|
|
97
|
-
broadcast: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
98
|
-
input: InputZodLike<TInput> | null;
|
|
99
|
-
resolver: () => EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TOutput>;
|
|
100
|
-
self: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, Partial<TOutput>> | null;
|
|
101
|
-
sync: EventResolver<TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null;
|
|
102
|
-
};
|
|
96
|
+
get config(): ProcedureLike<TInput, TOutput>["config"];
|
|
103
97
|
constructor(config?: PluvProcedureConfig<TPlatform, TAuthorize, TContext, TInput, TOutput>);
|
|
104
98
|
broadcast<TResult extends EventRecord<string, any> = {}>(resolver: EventResolver<TPlatform, TAuthorize, TContext & InferRoomContextType<TPlatform>, TInput, TResult>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TInput, MergeEventRecords<[TOutput, TResult]>, TFilled | "input" | "broadcast">, TFilled | "input" | "broadcast">;
|
|
105
99
|
input<TData extends JsonObject>(input: InputZodLike<TData>): Omit<PluvProcedure<TPlatform, TAuthorize, TContext, TData, {}, TFilled | "input">, TFilled | "input">;
|
package/dist/index.js
CHANGED
|
@@ -302,7 +302,7 @@ var PluvProcedure = class _PluvProcedure {
|
|
|
302
302
|
return {
|
|
303
303
|
broadcast: (_b = (_a = this._broadcast) == null ? void 0 : _a.bind(this)) != null ? _b : null,
|
|
304
304
|
input: (_c = this._input) != null ? _c : null,
|
|
305
|
-
resolver: this._resolver,
|
|
305
|
+
resolver: this._resolver(),
|
|
306
306
|
self: (_e = (_d = this._self) == null ? void 0 : _d.bind(this)) != null ? _e : null,
|
|
307
307
|
sync: (_g = (_f = this._sync) == null ? void 0 : _f.bind(this)) != null ? _g : null
|
|
308
308
|
};
|
|
@@ -773,7 +773,15 @@ var IORoom = class {
|
|
|
773
773
|
room: this.id,
|
|
774
774
|
user: session.user
|
|
775
775
|
}));
|
|
776
|
-
|
|
776
|
+
const sessionId = session.id;
|
|
777
|
+
const user = session.user;
|
|
778
|
+
if (!procedure) {
|
|
779
|
+
yield this._broadcast({
|
|
780
|
+
message,
|
|
781
|
+
senderId: sessionId
|
|
782
|
+
});
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
777
785
|
let inputs;
|
|
778
786
|
try {
|
|
779
787
|
inputs = this._getProcedureInputs(message);
|
|
@@ -792,8 +800,6 @@ var IORoom = class {
|
|
|
792
800
|
(_d = (_c = procedure.config).self) == null ? void 0 : _d.call(_c, inputs, extendedContext),
|
|
793
801
|
(_f = (_e = procedure.config).sync) == null ? void 0 : _f.call(_e, inputs, baseContext)
|
|
794
802
|
]).then((_0) => __async(this, [_0], function* ([broadcast, self, sync]) {
|
|
795
|
-
const sessionId = session.id;
|
|
796
|
-
const user = session.user;
|
|
797
803
|
const handleBroadcast = () => __async(this, null, function* () {
|
|
798
804
|
if (!broadcast) return;
|
|
799
805
|
yield Promise.all(
|
|
@@ -924,7 +930,7 @@ var IORoom = class {
|
|
|
924
930
|
};
|
|
925
931
|
|
|
926
932
|
// src/version.generated.ts
|
|
927
|
-
var version = "0.
|
|
933
|
+
var version = "0.27.0";
|
|
928
934
|
|
|
929
935
|
// src/PluvServer.ts
|
|
930
936
|
var PluvServer = class {
|
|
@@ -1031,7 +1037,7 @@ var PluvServer = class {
|
|
|
1031
1037
|
this._crdt = crdt;
|
|
1032
1038
|
this._debug = debug;
|
|
1033
1039
|
this._platform = platform;
|
|
1034
|
-
this._router = router ?
|
|
1040
|
+
this._router = router ? PluvRouter.merge(this._baseRouter, router) : this._baseRouter;
|
|
1035
1041
|
if (authorize2) this._authorize = authorize2;
|
|
1036
1042
|
if (context) this._context = context;
|
|
1037
1043
|
if (getInitialStorage) this._getInitialStorage = getInitialStorage;
|
package/dist/index.mjs
CHANGED
|
@@ -261,7 +261,7 @@ var PluvProcedure = class _PluvProcedure {
|
|
|
261
261
|
return {
|
|
262
262
|
broadcast: (_b = (_a = this._broadcast) == null ? void 0 : _a.bind(this)) != null ? _b : null,
|
|
263
263
|
input: (_c = this._input) != null ? _c : null,
|
|
264
|
-
resolver: this._resolver,
|
|
264
|
+
resolver: this._resolver(),
|
|
265
265
|
self: (_e = (_d = this._self) == null ? void 0 : _d.bind(this)) != null ? _e : null,
|
|
266
266
|
sync: (_g = (_f = this._sync) == null ? void 0 : _f.bind(this)) != null ? _g : null
|
|
267
267
|
};
|
|
@@ -732,7 +732,15 @@ var IORoom = class {
|
|
|
732
732
|
room: this.id,
|
|
733
733
|
user: session.user
|
|
734
734
|
}));
|
|
735
|
-
|
|
735
|
+
const sessionId = session.id;
|
|
736
|
+
const user = session.user;
|
|
737
|
+
if (!procedure) {
|
|
738
|
+
yield this._broadcast({
|
|
739
|
+
message,
|
|
740
|
+
senderId: sessionId
|
|
741
|
+
});
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
736
744
|
let inputs;
|
|
737
745
|
try {
|
|
738
746
|
inputs = this._getProcedureInputs(message);
|
|
@@ -751,8 +759,6 @@ var IORoom = class {
|
|
|
751
759
|
(_d = (_c = procedure.config).self) == null ? void 0 : _d.call(_c, inputs, extendedContext),
|
|
752
760
|
(_f = (_e = procedure.config).sync) == null ? void 0 : _f.call(_e, inputs, baseContext)
|
|
753
761
|
]).then((_0) => __async(this, [_0], function* ([broadcast, self, sync]) {
|
|
754
|
-
const sessionId = session.id;
|
|
755
|
-
const user = session.user;
|
|
756
762
|
const handleBroadcast = () => __async(this, null, function* () {
|
|
757
763
|
if (!broadcast) return;
|
|
758
764
|
yield Promise.all(
|
|
@@ -883,7 +889,7 @@ var IORoom = class {
|
|
|
883
889
|
};
|
|
884
890
|
|
|
885
891
|
// src/version.generated.ts
|
|
886
|
-
var version = "0.
|
|
892
|
+
var version = "0.27.0";
|
|
887
893
|
|
|
888
894
|
// src/PluvServer.ts
|
|
889
895
|
var PluvServer = class {
|
|
@@ -990,7 +996,7 @@ var PluvServer = class {
|
|
|
990
996
|
this._crdt = crdt;
|
|
991
997
|
this._debug = debug;
|
|
992
998
|
this._platform = platform;
|
|
993
|
-
this._router = router ?
|
|
999
|
+
this._router = router ? PluvRouter.merge(this._baseRouter, router) : this._baseRouter;
|
|
994
1000
|
if (authorize2) this._authorize = authorize2;
|
|
995
1001
|
if (context) this._context = context;
|
|
996
1002
|
if (getInitialStorage) this._getInitialStorage = getInitialStorage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/io",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "@pluv/io server-side websocket manager",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@panva/hkdf": "^1.2.1",
|
|
21
|
-
"jose": "^5.
|
|
21
|
+
"jose": "^5.9.2",
|
|
22
22
|
"kleur": "^4.1.5",
|
|
23
23
|
"wonka": "^6.3.4",
|
|
24
|
-
"@pluv/crdt": "^0.
|
|
25
|
-
"@pluv/types": "^0.
|
|
24
|
+
"@pluv/crdt": "^0.27.0",
|
|
25
|
+
"@pluv/types": "^0.27.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"eslint": "^8.57.0",
|
|
29
29
|
"genversion": "^3.2.0",
|
|
30
|
-
"tsup": "^8.
|
|
31
|
-
"typescript": "^5.
|
|
32
|
-
"@pluv/tsconfig": "^0.
|
|
33
|
-
"eslint-config-pluv": "^0.
|
|
30
|
+
"tsup": "^8.3.0",
|
|
31
|
+
"typescript": "^5.6.2",
|
|
32
|
+
"@pluv/tsconfig": "^0.27.0",
|
|
33
|
+
"eslint-config-pluv": "^0.27.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
|
package/src/IORoom.ts
CHANGED
|
@@ -595,7 +595,17 @@ export class IORoom<
|
|
|
595
595
|
user: session.user,
|
|
596
596
|
});
|
|
597
597
|
|
|
598
|
-
|
|
598
|
+
const sessionId = session.id;
|
|
599
|
+
const user = session.user;
|
|
600
|
+
|
|
601
|
+
if (!procedure) {
|
|
602
|
+
await this._broadcast({
|
|
603
|
+
message: message as any,
|
|
604
|
+
senderId: sessionId,
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
599
609
|
|
|
600
610
|
let inputs: InferIOInput<this>[keyof TEvents];
|
|
601
611
|
|
|
@@ -623,9 +633,6 @@ export class IORoom<
|
|
|
623
633
|
procedure.config.self?.(inputs, extendedContext),
|
|
624
634
|
procedure.config.sync?.(inputs, baseContext),
|
|
625
635
|
]).then(async ([broadcast, self, sync]) => {
|
|
626
|
-
const sessionId = session.id;
|
|
627
|
-
const user = session.user;
|
|
628
|
-
|
|
629
636
|
const handleBroadcast = async () => {
|
|
630
637
|
if (!broadcast) return;
|
|
631
638
|
|
package/src/PluvProcedure.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventRecord, IOAuthorize, InputZodLike, JsonObject } from "@pluv/types";
|
|
1
|
+
import type { EventRecord, IOAuthorize, InputZodLike, JsonObject, ProcedureLike } from "@pluv/types";
|
|
2
2
|
import type { AbstractPlatform, InferRoomContextType } from "./AbstractPlatform";
|
|
3
3
|
import type { EventResolver, MergeEventRecords } from "./types";
|
|
4
4
|
|
|
@@ -52,14 +52,14 @@ export class PluvProcedure<
|
|
|
52
52
|
> | null = null;
|
|
53
53
|
private _sync: EventResolver<TPlatform, TAuthorize, TContext, TInput, Partial<TOutput>> | null = null;
|
|
54
54
|
|
|
55
|
-
public get config() {
|
|
55
|
+
public get config(): ProcedureLike<TInput, TOutput>["config"] {
|
|
56
56
|
return {
|
|
57
57
|
broadcast: this._broadcast?.bind(this) ?? null,
|
|
58
58
|
input: this._input ?? null,
|
|
59
|
-
resolver: this._resolver,
|
|
59
|
+
resolver: this._resolver(),
|
|
60
60
|
self: this._self?.bind(this) ?? null,
|
|
61
61
|
sync: this._sync?.bind(this) ?? null,
|
|
62
|
-
};
|
|
62
|
+
} as ProcedureLike<TInput, TOutput>["config"];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
constructor(config: PluvProcedureConfig<TPlatform, TAuthorize, TContext, TInput, TOutput> = {}) {
|
package/src/PluvServer.ts
CHANGED
|
@@ -235,7 +235,7 @@ export class PluvServer<
|
|
|
235
235
|
this._crdt = crdt;
|
|
236
236
|
this._debug = debug;
|
|
237
237
|
this._platform = platform;
|
|
238
|
-
this._router = (router ?
|
|
238
|
+
this._router = (router ? PluvRouter.merge(this._baseRouter, router) : this._baseRouter) as PluvRouter<
|
|
239
239
|
TPlatform,
|
|
240
240
|
TAuthorize,
|
|
241
241
|
TContext,
|
package/src/version.generated.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.
|
|
2
|
+
export const version = '0.27.0'
|