@pluv/types 1.0.0 → 1.0.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @pluv/types@1.0.0 build /home/runner/work/pluv/pluv/packages/types
2
+ > @pluv/types@1.0.2 build /home/runner/work/pluv/pluv/packages/types
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 0 B
12
- ESM ⚡️ Build success in 36ms
13
11
  CJS dist/index.js 758.00 B
14
- CJS ⚡️ Build success in 37ms
12
+ CJS ⚡️ Build success in 31ms
13
+ ESM dist/index.mjs 0 B
14
+ ESM ⚡️ Build success in 32ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 749ms
17
- DTS dist/index.d.mts 7.39 KB
18
- DTS dist/index.d.ts 7.39 KB
16
+ DTS ⚡️ Build success in 718ms
17
+ DTS dist/index.d.mts 7.48 KB
18
+ DTS dist/index.d.ts 7.48 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @pluv/types
2
2
 
3
+ ## 1.0.2
4
+
5
+ ## 1.0.1
6
+
3
7
  ## 1.0.0
4
8
 
5
9
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -90,11 +90,13 @@ type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
90
90
  $registered: {
91
91
  presence: JsonObject | null;
92
92
  sessionId: string;
93
+ state: string | null;
93
94
  timers: {
94
95
  presence: number | null;
95
96
  };
96
97
  };
97
98
  $storageReceived: {
99
+ changeKind: "empty" | "initialized" | "unchanged";
98
100
  state: string;
99
101
  };
100
102
  $storageUpdated: {
package/dist/index.d.ts CHANGED
@@ -90,11 +90,13 @@ type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
90
90
  $registered: {
91
91
  presence: JsonObject | null;
92
92
  sessionId: string;
93
+ state: string | null;
93
94
  timers: {
94
95
  presence: number | null;
95
96
  };
96
97
  };
97
98
  $storageReceived: {
99
+ changeKind: "empty" | "initialized" | "unchanged";
98
100
  state: string;
99
101
  };
100
102
  $storageUpdated: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/types",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "@pluv/io shared types",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -19,8 +19,8 @@
19
19
  "eslint": "^9.25.1",
20
20
  "tsup": "^8.4.0",
21
21
  "typescript": "^5.8.3",
22
- "@pluv/tsconfig": "^1.0.0",
23
- "eslint-config-pluv": "^1.0.0"
22
+ "@pluv/tsconfig": "^1.0.2",
23
+ "eslint-config-pluv": "^1.0.2"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/general.ts CHANGED
@@ -30,7 +30,9 @@ type SpreadTwo<L, R> = Id<
30
30
  SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>
31
31
  >;
32
32
 
33
- export type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R] ? SpreadTwo<L, Spread<R>> : unknown;
33
+ export type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R]
34
+ ? SpreadTwo<L, Spread<R>>
35
+ : unknown;
34
36
 
35
37
  export type DeepPartial<T> = {
36
38
  [P in keyof T]?: T[P] extends Array<infer U>
@@ -63,6 +65,8 @@ export type JsonObject = Record<string, Json>;
63
65
 
64
66
  export type StringLiteral<T> = T extends string ? (string extends T ? never : T) : never;
65
67
 
66
- export type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) extends (arg: infer I) => void
68
+ export type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) extends (
69
+ arg: infer I,
70
+ ) => void
67
71
  ? I
68
72
  : never;
package/src/pluv.ts CHANGED
@@ -49,9 +49,11 @@ export type BaseIOEventRecord<TAuthorize extends IOAuthorize<any, any>> = {
49
49
  $registered: {
50
50
  presence: JsonObject | null;
51
51
  sessionId: string;
52
+ state: string | null;
52
53
  timers: { presence: number | null };
53
54
  };
54
55
  $storageReceived: {
56
+ changeKind: "empty" | "initialized" | "unchanged";
55
57
  state: string;
56
58
  };
57
59
  $storageUpdated: {
@@ -77,11 +79,13 @@ export type EventRecord<TEvent extends string, TData extends JsonObject> = {
77
79
  [key in `${TEvent}`]: TData;
78
80
  };
79
81
 
80
- export type GetEventMessage<T extends EventRecord<string, any>, TEvent extends keyof T> = TEvent extends string
81
- ? EventMessage<TEvent, T[TEvent]>
82
- : never;
82
+ export type GetEventMessage<
83
+ T extends EventRecord<string, any>,
84
+ TEvent extends keyof T,
85
+ > = TEvent extends string ? EventMessage<TEvent, T[TEvent]> : never;
83
86
 
84
- export type InferIOAuthorize<TIO extends IOLike<any, any>> = TIO extends IOLike<infer IAuthorize> ? IAuthorize : never;
87
+ export type InferIOAuthorize<TIO extends IOLike<any, any>> =
88
+ TIO extends IOLike<infer IAuthorize> ? IAuthorize : never;
85
89
 
86
90
  export type InferIOAuthorizeUser<TAuthorize extends IOAuthorize<any, any> | null> =
87
91
  TAuthorize extends IOAuthorize<infer IUser, any> ? IUser : null;
@@ -90,7 +94,10 @@ export type InputZodLike<TData extends JsonObject> = {
90
94
  parse: (data: unknown) => TData;
91
95
  } & ({ _input: TData } | { _zod: { input: TData } });
92
96
 
93
- export type IOAuthorize<TUser extends BaseUser | null = any, TContext extends Record<string, unknown> = {}> =
97
+ export type IOAuthorize<
98
+ TUser extends BaseUser | null = any,
99
+ TContext extends Record<string, unknown> = {},
100
+ > =
94
101
  | (TUser extends BaseUser
95
102
  ? {
96
103
  secret?: string;
@@ -109,9 +116,14 @@ export type IOAuthorizeEventMessage<TIO extends IOLike> = {
109
116
  user: InferIOAuthorizeUser<InferIOAuthorize<TIO>>;
110
117
  };
111
118
 
112
- export type ProcedureLike<TInput extends JsonObject = {}, TOutput extends EventRecord<string, any> = {}> = {
119
+ export type ProcedureLike<
120
+ TInput extends JsonObject = {},
121
+ TOutput extends EventRecord<string, any> = {},
122
+ > = {
113
123
  config: {
114
- broadcast?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
124
+ broadcast?:
125
+ | ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>)
126
+ | null;
115
127
  input?: InputZodLike<TInput> | null;
116
128
  resolver: (data: TInput, ...args: any[]) => MaybePromise<TOutput>;
117
129
  self?: ((data: TInput, ...args: any[]) => MaybePromise<Partial<TOutput> | void>) | null;
@@ -139,11 +151,14 @@ export type InferEventsInput<TEvents extends Record<string, ProcedureLike<any, a
139
151
  [P in keyof TEvents]: TEvents[P] extends ProcedureLike<infer IInput, any> ? IInput : never;
140
152
  };
141
153
 
142
- export type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> = UnionToIntersection<
143
- {
144
- [P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput> ? IOutput : never;
145
- }[keyof TEvents]
146
- >;
154
+ export type InferEventsOutput<TEvents extends Record<string, ProcedureLike<any, any>>> =
155
+ UnionToIntersection<
156
+ {
157
+ [P in keyof TEvents]: TEvents[P] extends ProcedureLike<any, infer IOutput>
158
+ ? IOutput
159
+ : never;
160
+ }[keyof TEvents]
161
+ >;
147
162
 
148
163
  export type InferIOInput<TRouter extends IORouterLike<any>> =
149
164
  TRouter extends IORouterLike<infer IEvents> ? InferEventsInput<IEvents> : never;
@@ -151,7 +166,10 @@ export type InferIOInput<TRouter extends IORouterLike<any>> =
151
166
  export type InferIOOutput<TRouter extends IORouterLike<any>> =
152
167
  TRouter extends IORouterLike<infer IEvents> ? InferEventsOutput<IEvents> : never;
153
168
 
154
- export type InferEventMessage<TEvents = EventRecord<string, any>, TEvent extends keyof TEvents = keyof TEvents> =
169
+ export type InferEventMessage<
170
+ TEvents = EventRecord<string, any>,
171
+ TEvent extends keyof TEvents = keyof TEvents,
172
+ > =
155
173
  TEvents extends EventRecord<string, any>
156
174
  ? { [P in TEvent]: P extends string ? Id<EventMessage<P, TEvents[P]>> : never }[TEvent]
157
175
  : never;