@pluv/types 5.0.1 → 5.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.
package/CHANGELOG.md DELETED
@@ -1,540 +0,0 @@
1
- # @pluv/types
2
-
3
- ## 5.0.1
4
-
5
- ## 5.0.0
6
-
7
- ## 4.1.0
8
-
9
- ## 4.0.2
10
-
11
- ### Patch Changes
12
-
13
- - e1913b3: Upgraded internal dependencies
14
-
15
- ## 4.0.1
16
-
17
- ## 4.0.0
18
-
19
- ### Major Changes
20
-
21
- - df5c39c: Update all packages to be ESM only.
22
-
23
- ### Minor Changes
24
-
25
- - 037074e: Migrated build process from tsup to tsdown.
26
-
27
- ### Patch Changes
28
-
29
- - 2eb5def: Bumped dependencies.
30
-
31
- ## 3.2.2
32
-
33
- ### Patch Changes
34
-
35
- - 8665dbe: Updated types of `createClient` so that the types inferred from `createClient` are flattened and no-longer depend on `@pluv/server`.
36
-
37
- ## 3.2.1
38
-
39
- ## 3.2.0
40
-
41
- ## 3.1.7
42
-
43
- ## 3.1.6
44
-
45
- ## 3.1.5
46
-
47
- ## 3.1.4
48
-
49
- ## 3.1.3
50
-
51
- ## 3.1.2
52
-
53
- ## 3.1.1
54
-
55
- ## 3.1.0
56
-
57
- ## 3.0.0
58
-
59
- ## 2.3.1
60
-
61
- ## 2.3.0
62
-
63
- ## 2.2.8
64
-
65
- ## 2.2.7
66
-
67
- ## 2.2.6
68
-
69
- ## 2.2.5
70
-
71
- ## 2.2.4
72
-
73
- ## 2.2.3
74
-
75
- ## 2.2.2
76
-
77
- ## 2.2.1
78
-
79
- ## 2.2.0
80
-
81
- ## 2.1.0
82
-
83
- ## 2.0.2
84
-
85
- ## 2.0.1
86
-
87
- ## 2.0.0
88
-
89
- ### Patch Changes
90
-
91
- - 047a1d8: Moved several internal types to `@pluv/types`.
92
-
93
- ## 1.0.2
94
-
95
- ## 1.0.1
96
-
97
- ## 1.0.0
98
-
99
- ### Major Changes
100
-
101
- - af94706: pluv.io is now stable and production ready!
102
-
103
- With this v1 release, pluv.io will now follow [semantic versioning](https://semver.org/) with more comprehensive release notes for future changes to the library.
104
-
105
- Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
106
-
107
- ## 0.44.2
108
-
109
- ## 0.44.1
110
-
111
- ## 0.44.0
112
-
113
- ## 0.43.0
114
-
115
- ## 0.42.0
116
-
117
- ## 0.41.7
118
-
119
- ## 0.41.6
120
-
121
- ## 0.41.5
122
-
123
- ## 0.41.4
124
-
125
- ## 0.41.3
126
-
127
- ## 0.41.2
128
-
129
- ## 0.41.1
130
-
131
- ## 0.41.0
132
-
133
- ## 0.40.2
134
-
135
- ## 0.40.1
136
-
137
- ## 0.40.0
138
-
139
- ## 0.39.1
140
-
141
- ## 0.39.0
142
-
143
- ## 0.38.14
144
-
145
- ## 0.38.13
146
-
147
- ## 0.38.12
148
-
149
- ## 0.38.11
150
-
151
- ## 0.38.10
152
-
153
- ## 0.38.9
154
-
155
- ## 0.38.8
156
-
157
- ## 0.38.7
158
-
159
- ## 0.38.6
160
-
161
- ## 0.38.5
162
-
163
- ## 0.38.4
164
-
165
- ## 0.38.3
166
-
167
- ## 0.38.2
168
-
169
- ## 0.38.1
170
-
171
- ## 0.38.0
172
-
173
- ### Minor Changes
174
-
175
- - f4ceca3: Updated internal event names to follow a new naming convention.
176
-
177
- ## 0.37.7
178
-
179
- ## 0.37.6
180
-
181
- ## 0.37.5
182
-
183
- ## 0.37.4
184
-
185
- ## 0.37.3
186
-
187
- ## 0.37.2
188
-
189
- ## 0.37.1
190
-
191
- ## 0.37.0
192
-
193
- ## 0.36.0
194
-
195
- ## 0.35.4
196
-
197
- ## 0.35.3
198
-
199
- ## 0.35.2
200
-
201
- ### Patch Changes
202
-
203
- - 81cb692: Fixed type inference of the `authorize` option in `createIO` when used as a function.
204
-
205
- ## 0.35.1
206
-
207
- ## 0.35.0
208
-
209
- ## 0.34.1
210
-
211
- ## 0.34.0
212
-
213
- ## 0.33.0
214
-
215
- ## 0.32.9
216
-
217
- ## 0.32.8
218
-
219
- ## 0.32.7
220
-
221
- ## 0.32.6
222
-
223
- ## 0.32.5
224
-
225
- ## 0.32.4
226
-
227
- ## 0.32.3
228
-
229
- ## 0.32.2
230
-
231
- ## 0.32.1
232
-
233
- ## 0.32.0
234
-
235
- ## 0.31.0
236
-
237
- ## 0.30.2
238
-
239
- ## 0.30.1
240
-
241
- ## 0.30.0
242
-
243
- ## 0.29.0
244
-
245
- ## 0.28.0
246
-
247
- ## 0.27.0
248
-
249
- ## 0.26.0
250
-
251
- ## 0.25.4
252
-
253
- ## 0.25.3
254
-
255
- ## 0.25.2
256
-
257
- ## 0.25.1
258
-
259
- ## 0.25.0
260
-
261
- ## 0.24.1
262
-
263
- ## 0.24.0
264
-
265
- ## 0.23.0
266
-
267
- ## 0.22.0
268
-
269
- ## 0.21.1
270
-
271
- ## 0.21.0
272
-
273
- ## 0.20.0
274
-
275
- ## 0.19.0
276
-
277
- ## 0.18.0
278
-
279
- ### Minor Changes
280
-
281
- - 99b5ca9: ## Breaking Changes
282
- - `@pluv/io` has been updated to introduce `PluvProcedure`, `PluvRouter` and `PluvServer`. This change is intended to improve the ergonomics of declaring events and simplifying inferences of event types.
283
-
284
- ### Before:
285
-
286
- ```ts
287
- // backend/io.ts
288
-
289
- import { createIO } from "@pluv/io";
290
- import { createPluvHandler, platformNode } from "@pluv/platform-node";
291
- import { z } from "zod";
292
-
293
- export const io = createIO({
294
- platform: platformNode(),
295
- })
296
- .event("SEND_MESSAGE", {
297
- input: z.object({ message: z.string() }),
298
- resolver: ({ message }) => ({ RECEIVE_MESSAGE: { message } }),
299
- })
300
- .event("DOUBLE_VALUE", {
301
- input: z.object({ value: z.number() }),
302
- resolver: ({ value }) => ({ VALUE_DOUBLED: { value: value * 2 } }),
303
- });
304
-
305
- const Pluv = createPluvHandler({
306
- io,
307
- /* ... */
308
- });
309
- ```
310
-
311
- ```ts
312
- // frontend/pluv.ts
313
-
314
- import { createClient } from "@pluv/react";
315
- import type { io } from "../backend/io";
316
-
317
- const client = createClient<typeof io>({/* ... */});
318
- ```
319
-
320
- ### Now:
321
-
322
- ```ts
323
- import { createIO } from "@pluv/io";
324
- import { createPluvHandler, platformNode } from "@pluv/platform-node";
325
- import { z } from "zod";
326
-
327
- const io = createIO({
328
- platform: platformNode(),
329
- });
330
-
331
- const router = io.router({
332
- SEND_MESSAGE: io.procedure
333
- .input(z.object({ message: z.string() }))
334
- .broadcast(({ message }) => ({
335
- RECEIVE_MESSAGE: { message },
336
- })),
337
- DOUBLE_VALUE: io.procedure
338
- .input(z.object({ value: z.number() }))
339
- .broadcast(({ value }) => ({
340
- VALUE_DOUBLED: { value: value * 2 },
341
- })),
342
- });
343
-
344
- export const ioServer = io.server({ router });
345
-
346
- const Pluv = createPluvHandler({
347
- io: ioServer, // <- This uses the PluvServer now
348
- /* ... */
349
- });
350
- ```
351
-
352
- ```ts
353
- // frontend/pluv.ts
354
-
355
- import { createClient } from "@pluv/react";
356
- import type { ioServer } from "../backend/io";
357
-
358
- // This users the PluvServer type now
359
- const client = createClient<typeof ioServer>({/* ... */});
360
- ```
361
-
362
- - `PluvRouter` instances can also be merged via the `mergeRouters` method, which effectively performs an `Object.assign` of the events object and returns a new `PluvRouter` with the correct types:
363
-
364
- ```ts
365
- const router = io.mergeRouters(router1, router2);
366
- ```
367
-
368
- ## 0.17.3
369
-
370
- ## 0.17.2
371
-
372
- ## 0.17.1
373
-
374
- ## 0.17.0
375
-
376
- ### Minor Changes
377
-
378
- - 507bc00: _BREAKING_: The `authorize` config when calling `createIO` can now also be a function that exposes the platform context.
379
- This allows accessing the `env` in Cloudflare workers.
380
-
381
- ```ts
382
- import { createIO } from "@pluv/io";
383
- import { platformCloudflare } from "@pluv/platform-cloudflare";
384
- import { z } from "zod";
385
-
386
- const io = createIO({
387
- authorize: ({ env }) => ({
388
- required: true,
389
- secret: env.PLUV_AUTHORIZE_SECRET,
390
- user: z.object({
391
- id: z.string(),
392
- name: z.string(),
393
- }),
394
- }),
395
- platform: platformCloudflare<{ PLUV_AUTHORIZE_SECRET: string }>(),
396
- // ...
397
- });
398
- ```
399
-
400
- This also requires that the platform contexts are passed to `io.createToken`.
401
-
402
- ```ts
403
- // If using `platformNode`
404
- await io.createToken({
405
- req, // This `IncomingMessage` is now required
406
- room,
407
- user: {
408
- id: "user_123",
409
- name: "john doe",
410
- },
411
- });
412
-
413
- // If using `platformCloudflare`
414
- await io.createToken({
415
- env, // This env is now required from the handler's fetch function
416
- room,
417
- user: {
418
- id: "user_123",
419
- name: "john doe",
420
- },
421
- });
422
- ```
423
-
424
- ## 0.16.3
425
-
426
- ## 0.16.2
427
-
428
- ## 0.16.1
429
-
430
- ## 0.16.0
431
-
432
- ## 0.15.0
433
-
434
- ## 0.14.1
435
-
436
- ## 0.14.0
437
-
438
- ## 0.13.0
439
-
440
- ## 0.12.3
441
-
442
- ## 0.12.2
443
-
444
- ### Patch Changes
445
-
446
- - 259a7da: Bumped dependencies
447
-
448
- ## 0.12.1
449
-
450
- ## 0.12.0
451
-
452
- ## 0.11.1
453
-
454
- ## 0.11.0
455
-
456
- ## 0.10.3
457
-
458
- ## 0.10.2
459
-
460
- ## 0.10.1
461
-
462
- ### Patch Changes
463
-
464
- - 885835d: remove unnecessary dependency
465
-
466
- ## 0.10.0
467
-
468
- ### Minor Changes
469
-
470
- - f43f1cc: Change packages to all be versioned together for consistency.
471
-
472
- ## 0.2.2
473
-
474
- ### Patch Changes
475
-
476
- - 8fba48b: fix including incorrect dependency
477
- - 8997c65: bumped dependencies
478
-
479
- ## 0.2.1
480
-
481
- ### Patch Changes
482
-
483
- - 8d11672: bumped dependencies to latest
484
-
485
- ## 0.2.0
486
-
487
- ### Minor Changes
488
-
489
- - bb2886b: allow sending multiple output types (broadcast, self, sync) per event
490
- - ae679a8: updated offline presence to be set when reconnecting to a room
491
-
492
- ### Patch Changes
493
-
494
- - 0dd847e: updated storage to be synced when reconnected to the room
495
-
496
- ## 0.1.6
497
-
498
- ### Patch Changes
499
-
500
- - 850626e: bumped dependencies
501
-
502
- ## 0.1.5
503
-
504
- ### Patch Changes
505
-
506
- - 74870ee: bumped dependencies
507
-
508
- ## 0.1.4
509
-
510
- ### Patch Changes
511
-
512
- - 9516a4e: updated typescript to 5.0
513
- - 7b6da1c: bumped dependencies
514
- - e9c1514: bumped dependencies
515
-
516
- ## 0.1.3
517
-
518
- ### Patch Changes
519
-
520
- - 8bf62cb: bumped dependencies
521
- - 7e52685: Bumped dependencies
522
- - 8e97fb2: Updated dependencies
523
-
524
- ## 0.1.2
525
-
526
- ### Patch Changes
527
-
528
- - fe80d7b: added preview disclaimer about breaking changes in the readme
529
-
530
- ## 0.1.1
531
-
532
- ### Patch Changes
533
-
534
- - 24016e6: Updated dependencies
535
-
536
- ## 0.1.0
537
-
538
- ### Minor Changes
539
-
540
- - a22f525: Added documentation
package/eslint.config.mjs DELETED
@@ -1,4 +0,0 @@
1
- import { config } from "eslint-config-pluv/base";
2
-
3
- /** @type {import("eslint").Linter.Config} */
4
- export default config;
package/src/general.ts DELETED
@@ -1,90 +0,0 @@
1
- export type Constructable = { new (...args: any[]): any };
2
-
3
- export type HasRequiredProperty<T> = {
4
- [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
5
- }[keyof T] extends never
6
- ? false
7
- : true;
8
-
9
- export type Maybe<T> = T | Nil;
10
- export type MaybePromise<T> = Promise<T> | T;
11
- export type MaybeReadonlyArray<T> = T[] | readonly T[];
12
- export type Nil = null | undefined;
13
-
14
- type OptionalPropertyNames<T> = {
15
- [K in keyof T]-?: {} extends { [P in K]: T[K] } ? K : never;
16
- }[keyof T];
17
-
18
- export type SpreadProperties<L, R, K extends keyof L & keyof R> = {
19
- [P in K]: L[P] | Exclude<R[P], undefined>;
20
- };
21
-
22
- export type Id<T> = T extends Nil
23
- ? T
24
- : T extends infer U
25
- ? U extends Constructable
26
- ? U
27
- : { [K in keyof U]: U[K] }
28
- : never;
29
-
30
- export type Primitive = string | number | boolean | null | undefined;
31
-
32
- type SpreadTwo<L, R> = Id<
33
- Pick<L, Exclude<keyof L, keyof R>> &
34
- Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> &
35
- Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> &
36
- SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>
37
- >;
38
-
39
- export type Spread<A extends readonly [...any]> = A extends [infer L, ...infer R]
40
- ? SpreadTwo<L, Spread<R>>
41
- : unknown;
42
-
43
- export type DeepPartial<T> = {
44
- [P in keyof T]?: T[P] extends Array<infer U>
45
- ? Array<DeepPartial<U>>
46
- : T[P] extends ReadonlyArray<infer U>
47
- ? ReadonlyArray<DeepPartial<U>>
48
- : DeepPartial<T[P]>;
49
- };
50
-
51
- export type DeepWriteable<T> = {
52
- -readonly [P in keyof T]: DeepWriteable<T[P]>;
53
- };
54
-
55
- export type UndefinedProps<T extends Record<string, any>, K extends keyof T = keyof T> = Id<
56
- { [P in K]?: undefined } & { [P in Exclude<keyof T, K>]: T[P] }
57
- >;
58
-
59
- export type OptionalProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> &
60
- Partial<Pick<T, K>>;
61
-
62
- export type NonNilProps<T extends Record<string, any>, K extends keyof T = keyof T> = Omit<T, K> & {
63
- [P in K]-?: NonNullable<T[P]>;
64
- };
65
-
66
- export type JsonPrimitive = string | number | boolean | null;
67
-
68
- export type Json = JsonPrimitive | Json[] | readonly Json[] | { [key: string]: Json };
69
-
70
- export type JsonObject = Record<string, Json>;
71
-
72
- export type StringLiteral<T> = T extends string ? (string extends T ? never : T) : never;
73
-
74
- export type UnionToIntersection<U> = (U extends any ? (arg: U) => any : never) extends (
75
- arg: infer I,
76
- ) => void
77
- ? I
78
- : never;
79
-
80
- // Check if all properties in T are optional
81
- // - If T is {} (no keys), all properties are optional (none exist)
82
- // - Use HasRequiredProperty which properly handles intersection types
83
- // - If HasRequiredProperty<T> is false, then all properties are optional
84
- export type AreAllOptional<T> = [T] extends [{}]
85
- ? keyof T extends never
86
- ? true // T is {} - no properties, so all are "optional" (none exist)
87
- : HasRequiredProperty<T> extends true
88
- ? false // T has at least one required property
89
- : true // T has no required properties, so all are optional
90
- : false;
package/src/index.ts DELETED
@@ -1,82 +0,0 @@
1
- export type {
2
- AreAllOptional,
3
- Constructable,
4
- DeepPartial,
5
- DeepWriteable,
6
- HasRequiredProperty,
7
- Id,
8
- Json,
9
- JsonObject,
10
- JsonPrimitive,
11
- Maybe,
12
- MaybePromise,
13
- MaybeReadonlyArray,
14
- NonNilProps,
15
- OptionalProps,
16
- Spread,
17
- SpreadProperties,
18
- UndefinedProps,
19
- } from "./general";
20
- export { ConnectionState, StorageState } from "./pluv";
21
- export type {
22
- BaseClientEventRecord,
23
- BaseClientMessage,
24
- BaseIOEventRecord,
25
- BaseUser,
26
- BroadcastProxy,
27
- CrdtDocFactory,
28
- CrdtDocLike,
29
- CrdtLibraryType,
30
- CrdtType,
31
- DocApplyEncodedStateParams,
32
- DocBatchApplyEncodedStateParams,
33
- DocSubscribeCallbackParams,
34
- EventMessage,
35
- EventNotifierSubscriptionCallback,
36
- EventProxy,
37
- EventRecord,
38
- GetEventMessage,
39
- InferCrdtJson,
40
- InferEventMessage,
41
- InferEventsInput,
42
- InferEventsOutput,
43
- InferIOAuthorize,
44
- InferIOAuthorizeUser,
45
- InferIOCrdt,
46
- InferIOCrdtKind,
47
- InferIOEvents,
48
- InferIOInput,
49
- InferIOOutput,
50
- InferIOProcedureInput,
51
- InferIOProcedureOutput,
52
- InputZodLike,
53
- IOAuthorize,
54
- IOAuthorizeEventMessage,
55
- IOEventMessage,
56
- IOLike,
57
- IORouterLike,
58
- MergeEvents,
59
- OthersSubscriptionCallback,
60
- OthersSubscriptionEvent,
61
- OthersSubscriptionFn,
62
- OtherSubscriptionCallback,
63
- OtherSubscriptionFn,
64
- PluvRouterEventConfig,
65
- ProcedureLike,
66
- RoomEventListenerMap,
67
- RoomLike,
68
- StateNotifierSubjects,
69
- StorageInfo,
70
- StorageProxy,
71
- StorageRootSubscriptionCallback,
72
- StorageRootSubscriptionFn,
73
- StorageSubscriptionCallback,
74
- StorageSubscriptionFn,
75
- SubscribeFn,
76
- SubscribeProxy,
77
- SubscriptionCallback,
78
- UpdateMyPresenceAction,
79
- UserInfo,
80
- WebSocketConnection,
81
- WebSocketState,
82
- } from "./pluv";