@pluv/types 0.1.6 → 0.2.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 +6 -6
- package/CHANGELOG.md +11 -0
- package/dist/index.d.ts +16 -4
- package/package.json +3 -3
- package/src/index.ts +3 -0
- package/src/pluv.ts +57 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/types@0.
|
|
2
|
+
> @pluv/types@0.2.0 build /home/runner/work/pluv/pluv/packages/types
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,10 +8,10 @@
|
|
|
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[32m0 B[39m
|
|
12
|
-
[32mESM[39m ⚡️ Build success in 26ms
|
|
13
11
|
[32mCJS[39m [1mdist/index.js [22m[32m754.00 B[39m
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 35ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m0 B[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 38ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1181ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m7.18 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @pluv/types
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bb2886b: allow sending multiple output types (broadcast, self, sync) per event
|
|
8
|
+
- ae679a8: updated offline presence to be set when reconnecting to a room
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 0dd847e: updated storage to be synced when reconnected to the room
|
|
13
|
+
|
|
3
14
|
## 0.1.6
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,10 @@ type BaseUser = {
|
|
|
41
41
|
};
|
|
42
42
|
interface BaseClientEventRecord {
|
|
43
43
|
$GET_OTHERS: {};
|
|
44
|
+
$INITIALIZE_SESSION: {
|
|
45
|
+
presence: JsonObject;
|
|
46
|
+
update: string | null;
|
|
47
|
+
};
|
|
44
48
|
$PING: {};
|
|
45
49
|
$UPDATE_PRESENCE: {
|
|
46
50
|
presence: JsonObject;
|
|
@@ -70,6 +74,7 @@ interface BaseIOAuthorizeEventRecord<TAuthorize extends IOAuthorize<any, any>> {
|
|
|
70
74
|
$USER_JOINED: {
|
|
71
75
|
connectionId: string;
|
|
72
76
|
user: NonNullable<InferIOAuthorizeUser<TAuthorize>>;
|
|
77
|
+
presence: JsonObject;
|
|
73
78
|
};
|
|
74
79
|
}
|
|
75
80
|
type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = BaseIOAuthorizeEventRecord<TAuthorize> & {
|
|
@@ -109,7 +114,10 @@ type InferIOAuthorize<TIO extends IOLike> = TIO extends IOLike<infer IAuthorize>
|
|
|
109
114
|
type InferIOAuthorizeRequired<TAuthorize extends IOAuthorize<any, any>> = TAuthorize extends IOAuthorize<any, infer IRequired> ? IRequired : never;
|
|
110
115
|
type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any>> = TAuthorize extends IOAuthorize<infer IUser, infer IRequired> ? IRequired extends true ? IUser : IUser | null : never;
|
|
111
116
|
type InferIOInput<TIO extends IOLike> = TIO extends IOLike<any, infer IInput> ? IInput : never;
|
|
112
|
-
type InferIOOutput<TIO extends IOLike> = TIO extends IOLike<any, any, infer
|
|
117
|
+
type InferIOOutput<TIO extends IOLike> = TIO extends IOLike<any, any, infer IOutputBroadcast, infer IOutputSelf, infer IOutputSync> ? Spread<[IOutputBroadcast, IOutputSelf, IOutputSync]> : never;
|
|
118
|
+
type InferIOOutputBroadcast<TIO extends IOLike> = TIO extends IOLike<any, any, infer IOutput> ? IOutput : never;
|
|
119
|
+
type InferIOOutputSelf<TIO extends IOLike> = TIO extends IOLike<any, any, any, infer IOutput> ? IOutput : never;
|
|
120
|
+
type InferIOOutputSync<TIO extends IOLike> = TIO extends IOLike<any, any, any, any, infer IOutput> ? IOutput : never;
|
|
113
121
|
type InputZodLike<TData extends JsonObject> = {
|
|
114
122
|
_input: TData;
|
|
115
123
|
parse: (data: unknown) => TData;
|
|
@@ -128,13 +136,17 @@ type IOAuthorizeRequiredEventMessage<TIO extends IOLike> = NonNilProps<IOAuthori
|
|
|
128
136
|
type IOEventMessage<TIO extends IOLike, TEvent extends keyof InferIOOutput<TIO> = keyof InferIOOutput<TIO>> = Id<{
|
|
129
137
|
room: string;
|
|
130
138
|
} & InferEventMessage<InferIOOutput<TIO>, TEvent> & (InferEventMessage<InferIOOutput<TIO>, TEvent>["type"] extends "$ERROR" ? IOAuthorizeOptionalEventMessage<TIO> : IOAuthorizeEventMessage<TIO>)>;
|
|
131
|
-
interface IOLike<TAuthorize extends IOAuthorize<any, any> = IOAuthorize<any, any>, TInput extends EventRecord<string, any> = {},
|
|
139
|
+
interface IOLike<TAuthorize extends IOAuthorize<any, any> = IOAuthorize<any, any>, TInput extends EventRecord<string, any> = {}, TOutputBroadcast extends EventRecord<string, any> = {}, TOutputSelf extends EventRecord<string, any> = {}, TOutputSync extends EventRecord<string, any> = {}> {
|
|
132
140
|
_authorize: TAuthorize | null;
|
|
133
141
|
_events: {
|
|
134
142
|
[P in keyof TInput]: P extends string ? {
|
|
135
|
-
resolver: (data: TInput[P], ...args: any[]) => MaybePromise<
|
|
143
|
+
resolver: ((data: TInput[P], ...args: any[]) => MaybePromise<TOutputBroadcast | void>) | {
|
|
144
|
+
broadcast?: (data: TInput[P], ...args: any[]) => MaybePromise<TOutputBroadcast | void>;
|
|
145
|
+
self?: (data: TInput[P], ...args: any[]) => MaybePromise<TOutputSelf | void>;
|
|
146
|
+
sync?: (data: TInput[P], ...args: any[]) => MaybePromise<TOutputSync | void>;
|
|
147
|
+
};
|
|
136
148
|
} : never;
|
|
137
149
|
};
|
|
138
150
|
}
|
|
139
151
|
|
|
140
|
-
export { BaseClientEventRecord, BaseClientMessage, BaseIOAuthorize, BaseIOAuthorizeEventRecord, BaseIOEventRecord, BaseUser, Constructable, DeepPartial, DeepWriteable, EventMessage, EventRecord, GetEventMessage, IOAuthorize, IOAuthorizeEventMessage, IOAuthorizeOptionalEventMessage, IOAuthorizeRequiredEventMessage, IOEventMessage, IOLike, Id, InferEventMessage, InferIOAuthorize, InferIOAuthorizeRequired, InferIOAuthorizeUser, InferIOInput, InferIOOutput, InputZodLike, Json, JsonObject, JsonPrimitive, Maybe, MaybePromise, MaybeReadonlyArray, NonNilProps, OptionalProps, Spread, SpreadProperties };
|
|
152
|
+
export { BaseClientEventRecord, BaseClientMessage, BaseIOAuthorize, BaseIOAuthorizeEventRecord, BaseIOEventRecord, BaseUser, Constructable, DeepPartial, DeepWriteable, EventMessage, EventRecord, GetEventMessage, IOAuthorize, IOAuthorizeEventMessage, IOAuthorizeOptionalEventMessage, IOAuthorizeRequiredEventMessage, IOEventMessage, IOLike, Id, InferEventMessage, InferIOAuthorize, InferIOAuthorizeRequired, InferIOAuthorizeUser, InferIOInput, InferIOOutput, InferIOOutputBroadcast, InferIOOutputSelf, InferIOOutputSync, InputZodLike, Json, JsonObject, JsonPrimitive, Maybe, MaybePromise, MaybeReadonlyArray, NonNilProps, OptionalProps, Spread, SpreadProperties };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "@pluv/io shared types",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"tsup": "^6.7.0",
|
|
20
20
|
"typescript": "^5.0.4",
|
|
21
|
-
"@pluv/tsconfig": "^0.1.
|
|
22
|
-
"eslint-config-pluv": "^0.1.
|
|
21
|
+
"@pluv/tsconfig": "^0.1.6",
|
|
22
|
+
"eslint-config-pluv": "^0.1.11"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/index.ts
CHANGED
package/src/pluv.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Id, JsonObject, MaybePromise, NonNilProps } from "./general";
|
|
1
|
+
import { Id, JsonObject, MaybePromise, NonNilProps, Spread } from "./general";
|
|
2
2
|
|
|
3
3
|
export type BaseUser = {
|
|
4
4
|
id: string;
|
|
@@ -6,6 +6,10 @@ export type BaseUser = {
|
|
|
6
6
|
|
|
7
7
|
export interface BaseClientEventRecord {
|
|
8
8
|
$GET_OTHERS: {};
|
|
9
|
+
$INITIALIZE_SESSION: {
|
|
10
|
+
presence: JsonObject;
|
|
11
|
+
update: string | null;
|
|
12
|
+
};
|
|
9
13
|
$PING: {};
|
|
10
14
|
$UPDATE_PRESENCE: {
|
|
11
15
|
presence: JsonObject;
|
|
@@ -40,6 +44,7 @@ export interface BaseIOAuthorizeEventRecord<
|
|
|
40
44
|
$USER_JOINED: {
|
|
41
45
|
connectionId: string;
|
|
42
46
|
user: NonNullable<InferIOAuthorizeUser<TAuthorize>>;
|
|
47
|
+
presence: JsonObject;
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -115,6 +120,35 @@ export type InferIOInput<TIO extends IOLike> = TIO extends IOLike<
|
|
|
115
120
|
: never;
|
|
116
121
|
|
|
117
122
|
export type InferIOOutput<TIO extends IOLike> = TIO extends IOLike<
|
|
123
|
+
any,
|
|
124
|
+
any,
|
|
125
|
+
infer IOutputBroadcast,
|
|
126
|
+
infer IOutputSelf,
|
|
127
|
+
infer IOutputSync
|
|
128
|
+
>
|
|
129
|
+
? Spread<[IOutputBroadcast, IOutputSelf, IOutputSync]>
|
|
130
|
+
: never;
|
|
131
|
+
|
|
132
|
+
export type InferIOOutputBroadcast<TIO extends IOLike> = TIO extends IOLike<
|
|
133
|
+
any,
|
|
134
|
+
any,
|
|
135
|
+
infer IOutput
|
|
136
|
+
>
|
|
137
|
+
? IOutput
|
|
138
|
+
: never;
|
|
139
|
+
|
|
140
|
+
export type InferIOOutputSelf<TIO extends IOLike> = TIO extends IOLike<
|
|
141
|
+
any,
|
|
142
|
+
any,
|
|
143
|
+
any,
|
|
144
|
+
infer IOutput
|
|
145
|
+
>
|
|
146
|
+
? IOutput
|
|
147
|
+
: never;
|
|
148
|
+
|
|
149
|
+
export type InferIOOutputSync<TIO extends IOLike> = TIO extends IOLike<
|
|
150
|
+
any,
|
|
151
|
+
any,
|
|
118
152
|
any,
|
|
119
153
|
any,
|
|
120
154
|
infer IOutput
|
|
@@ -164,16 +198,33 @@ export type IOEventMessage<
|
|
|
164
198
|
export interface IOLike<
|
|
165
199
|
TAuthorize extends IOAuthorize<any, any> = IOAuthorize<any, any>,
|
|
166
200
|
TInput extends EventRecord<string, any> = {},
|
|
167
|
-
|
|
201
|
+
TOutputBroadcast extends EventRecord<string, any> = {},
|
|
202
|
+
TOutputSelf extends EventRecord<string, any> = {},
|
|
203
|
+
TOutputSync extends EventRecord<string, any> = {}
|
|
168
204
|
> {
|
|
169
205
|
_authorize: TAuthorize | null;
|
|
170
206
|
_events: {
|
|
171
207
|
[P in keyof TInput]: P extends string
|
|
172
208
|
? {
|
|
173
|
-
resolver:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
209
|
+
resolver:
|
|
210
|
+
| ((
|
|
211
|
+
data: TInput[P],
|
|
212
|
+
...args: any[]
|
|
213
|
+
) => MaybePromise<TOutputBroadcast | void>)
|
|
214
|
+
| {
|
|
215
|
+
broadcast?: (
|
|
216
|
+
data: TInput[P],
|
|
217
|
+
...args: any[]
|
|
218
|
+
) => MaybePromise<TOutputBroadcast | void>;
|
|
219
|
+
self?: (
|
|
220
|
+
data: TInput[P],
|
|
221
|
+
...args: any[]
|
|
222
|
+
) => MaybePromise<TOutputSelf | void>;
|
|
223
|
+
sync?: (
|
|
224
|
+
data: TInput[P],
|
|
225
|
+
...args: any[]
|
|
226
|
+
) => MaybePromise<TOutputSync | void>;
|
|
227
|
+
};
|
|
177
228
|
}
|
|
178
229
|
: never;
|
|
179
230
|
};
|