@pluv/types 0.0.0-experimental-20250527040415
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 +19 -0
- package/.turbo/turbo-lint.log +5 -0
- package/CHANGELOG.md +485 -0
- package/LICENSE +21 -0
- package/dist/index.d.mts +373 -0
- package/dist/index.d.ts +373 -0
- package/dist/index.js +46 -0
- package/dist/index.mjs +18 -0
- package/eslint.config.mjs +4 -0
- package/package.json +34 -0
- package/src/general.ts +72 -0
- package/src/index.ts +73 -0
- package/src/pluv/crdt.ts +66 -0
- package/src/pluv/enums.ts +18 -0
- package/src/pluv/index.ts +4 -0
- package/src/pluv/room.ts +254 -0
- package/src/pluv/shared.ts +209 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
> @pluv/types@2.2.4 build /home/leedavidcs/projects/pluv/packages/types
|
|
4
|
+
> tsup src/index.ts --format esm,cjs --dts
|
|
5
|
+
|
|
6
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
7
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
+
[34mCLI[39m tsup v8.5.0
|
|
9
|
+
[34mCLI[39m Target: es6
|
|
10
|
+
[34mESM[39m Build start
|
|
11
|
+
[34mCJS[39m Build start
|
|
12
|
+
DTS Build start
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m330.00 B[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 1491ms
|
|
15
|
+
[32mCJS[39m [1mdist/index.js [22m[32m1.37 KB[39m
|
|
16
|
+
[32mCJS[39m ⚡️ Build success in 1492ms
|
|
17
|
+
DTS ⚡️ Build success in 1194ms
|
|
18
|
+
DTS dist/index.d.mts 18.73 KB
|
|
19
|
+
DTS dist/index.d.ts 18.73 KB
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
# @pluv/types
|
|
2
|
+
|
|
3
|
+
## 0.0.0-experimental-20250527040415
|
|
4
|
+
|
|
5
|
+
## 2.2.7
|
|
6
|
+
|
|
7
|
+
## 2.2.6
|
|
8
|
+
|
|
9
|
+
## 2.2.5
|
|
10
|
+
|
|
11
|
+
## 2.2.4
|
|
12
|
+
|
|
13
|
+
## 2.2.3
|
|
14
|
+
|
|
15
|
+
## 2.2.2
|
|
16
|
+
|
|
17
|
+
## 2.2.1
|
|
18
|
+
|
|
19
|
+
## 2.2.0
|
|
20
|
+
|
|
21
|
+
## 2.1.0
|
|
22
|
+
|
|
23
|
+
## 2.0.2
|
|
24
|
+
|
|
25
|
+
## 2.0.1
|
|
26
|
+
|
|
27
|
+
## 2.0.0
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 047a1d8: Moved several internal types to `@pluv/types`.
|
|
32
|
+
|
|
33
|
+
## 1.0.2
|
|
34
|
+
|
|
35
|
+
## 1.0.1
|
|
36
|
+
|
|
37
|
+
## 1.0.0
|
|
38
|
+
|
|
39
|
+
### Major Changes
|
|
40
|
+
|
|
41
|
+
- af94706: pluv.io is now stable and production ready!
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
|
|
46
|
+
|
|
47
|
+
## 0.44.2
|
|
48
|
+
|
|
49
|
+
## 0.44.1
|
|
50
|
+
|
|
51
|
+
## 0.44.0
|
|
52
|
+
|
|
53
|
+
## 0.43.0
|
|
54
|
+
|
|
55
|
+
## 0.42.0
|
|
56
|
+
|
|
57
|
+
## 0.41.7
|
|
58
|
+
|
|
59
|
+
## 0.41.6
|
|
60
|
+
|
|
61
|
+
## 0.41.5
|
|
62
|
+
|
|
63
|
+
## 0.41.4
|
|
64
|
+
|
|
65
|
+
## 0.41.3
|
|
66
|
+
|
|
67
|
+
## 0.41.2
|
|
68
|
+
|
|
69
|
+
## 0.41.1
|
|
70
|
+
|
|
71
|
+
## 0.41.0
|
|
72
|
+
|
|
73
|
+
## 0.40.2
|
|
74
|
+
|
|
75
|
+
## 0.40.1
|
|
76
|
+
|
|
77
|
+
## 0.40.0
|
|
78
|
+
|
|
79
|
+
## 0.39.1
|
|
80
|
+
|
|
81
|
+
## 0.39.0
|
|
82
|
+
|
|
83
|
+
## 0.38.14
|
|
84
|
+
|
|
85
|
+
## 0.38.13
|
|
86
|
+
|
|
87
|
+
## 0.38.12
|
|
88
|
+
|
|
89
|
+
## 0.38.11
|
|
90
|
+
|
|
91
|
+
## 0.38.10
|
|
92
|
+
|
|
93
|
+
## 0.38.9
|
|
94
|
+
|
|
95
|
+
## 0.38.8
|
|
96
|
+
|
|
97
|
+
## 0.38.7
|
|
98
|
+
|
|
99
|
+
## 0.38.6
|
|
100
|
+
|
|
101
|
+
## 0.38.5
|
|
102
|
+
|
|
103
|
+
## 0.38.4
|
|
104
|
+
|
|
105
|
+
## 0.38.3
|
|
106
|
+
|
|
107
|
+
## 0.38.2
|
|
108
|
+
|
|
109
|
+
## 0.38.1
|
|
110
|
+
|
|
111
|
+
## 0.38.0
|
|
112
|
+
|
|
113
|
+
### Minor Changes
|
|
114
|
+
|
|
115
|
+
- f4ceca3: Updated internal event names to follow a new naming convention.
|
|
116
|
+
|
|
117
|
+
## 0.37.7
|
|
118
|
+
|
|
119
|
+
## 0.37.6
|
|
120
|
+
|
|
121
|
+
## 0.37.5
|
|
122
|
+
|
|
123
|
+
## 0.37.4
|
|
124
|
+
|
|
125
|
+
## 0.37.3
|
|
126
|
+
|
|
127
|
+
## 0.37.2
|
|
128
|
+
|
|
129
|
+
## 0.37.1
|
|
130
|
+
|
|
131
|
+
## 0.37.0
|
|
132
|
+
|
|
133
|
+
## 0.36.0
|
|
134
|
+
|
|
135
|
+
## 0.35.4
|
|
136
|
+
|
|
137
|
+
## 0.35.3
|
|
138
|
+
|
|
139
|
+
## 0.35.2
|
|
140
|
+
|
|
141
|
+
### Patch Changes
|
|
142
|
+
|
|
143
|
+
- 81cb692: Fixed type inference of the `authorize` option in `createIO` when used as a function.
|
|
144
|
+
|
|
145
|
+
## 0.35.1
|
|
146
|
+
|
|
147
|
+
## 0.35.0
|
|
148
|
+
|
|
149
|
+
## 0.34.1
|
|
150
|
+
|
|
151
|
+
## 0.34.0
|
|
152
|
+
|
|
153
|
+
## 0.33.0
|
|
154
|
+
|
|
155
|
+
## 0.32.9
|
|
156
|
+
|
|
157
|
+
## 0.32.8
|
|
158
|
+
|
|
159
|
+
## 0.32.7
|
|
160
|
+
|
|
161
|
+
## 0.32.6
|
|
162
|
+
|
|
163
|
+
## 0.32.5
|
|
164
|
+
|
|
165
|
+
## 0.32.4
|
|
166
|
+
|
|
167
|
+
## 0.32.3
|
|
168
|
+
|
|
169
|
+
## 0.32.2
|
|
170
|
+
|
|
171
|
+
## 0.32.1
|
|
172
|
+
|
|
173
|
+
## 0.32.0
|
|
174
|
+
|
|
175
|
+
## 0.31.0
|
|
176
|
+
|
|
177
|
+
## 0.30.2
|
|
178
|
+
|
|
179
|
+
## 0.30.1
|
|
180
|
+
|
|
181
|
+
## 0.30.0
|
|
182
|
+
|
|
183
|
+
## 0.29.0
|
|
184
|
+
|
|
185
|
+
## 0.28.0
|
|
186
|
+
|
|
187
|
+
## 0.27.0
|
|
188
|
+
|
|
189
|
+
## 0.26.0
|
|
190
|
+
|
|
191
|
+
## 0.25.4
|
|
192
|
+
|
|
193
|
+
## 0.25.3
|
|
194
|
+
|
|
195
|
+
## 0.25.2
|
|
196
|
+
|
|
197
|
+
## 0.25.1
|
|
198
|
+
|
|
199
|
+
## 0.25.0
|
|
200
|
+
|
|
201
|
+
## 0.24.1
|
|
202
|
+
|
|
203
|
+
## 0.24.0
|
|
204
|
+
|
|
205
|
+
## 0.23.0
|
|
206
|
+
|
|
207
|
+
## 0.22.0
|
|
208
|
+
|
|
209
|
+
## 0.21.1
|
|
210
|
+
|
|
211
|
+
## 0.21.0
|
|
212
|
+
|
|
213
|
+
## 0.20.0
|
|
214
|
+
|
|
215
|
+
## 0.19.0
|
|
216
|
+
|
|
217
|
+
## 0.18.0
|
|
218
|
+
|
|
219
|
+
### Minor Changes
|
|
220
|
+
|
|
221
|
+
- 99b5ca9: ## Breaking Changes
|
|
222
|
+
|
|
223
|
+
- `@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.
|
|
224
|
+
|
|
225
|
+
### Before:
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
// backend/io.ts
|
|
229
|
+
|
|
230
|
+
import { createIO } from "@pluv/io";
|
|
231
|
+
import { createPluvHandler, platformNode } from "@pluv/platform-node";
|
|
232
|
+
import { z } from "zod";
|
|
233
|
+
|
|
234
|
+
export const io = createIO({
|
|
235
|
+
platform: platformNode(),
|
|
236
|
+
})
|
|
237
|
+
.event("SEND_MESSAGE", {
|
|
238
|
+
input: z.object({ message: z.string() }),
|
|
239
|
+
resolver: ({ message }) => ({ RECEIVE_MESSAGE: { message } }),
|
|
240
|
+
})
|
|
241
|
+
.event("DOUBLE_VALUE", {
|
|
242
|
+
input: z.object({ value: z.number() }),
|
|
243
|
+
resolver: ({ value }) => ({ VALUE_DOUBLED: { value: value * 2 } }),
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const Pluv = createPluvHandler({
|
|
247
|
+
io,
|
|
248
|
+
/* ... */
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
// frontend/pluv.ts
|
|
254
|
+
|
|
255
|
+
import { createClient } from "@pluv/react";
|
|
256
|
+
import type { io } from "../backend/io";
|
|
257
|
+
|
|
258
|
+
const client = createClient<typeof io>({
|
|
259
|
+
/* ... */
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Now:
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
import { createIO } from "@pluv/io";
|
|
267
|
+
import { createPluvHandler, platformNode } from "@pluv/platform-node";
|
|
268
|
+
import { z } from "zod";
|
|
269
|
+
|
|
270
|
+
const io = createIO({
|
|
271
|
+
platform: platformNode(),
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
const router = io.router({
|
|
275
|
+
SEND_MESSAGE: io.procedure
|
|
276
|
+
.input(z.object({ message: z.string() }))
|
|
277
|
+
.broadcast(({ message }) => ({
|
|
278
|
+
RECEIVE_MESSAGE: { message },
|
|
279
|
+
})),
|
|
280
|
+
DOUBLE_VALUE: io.procedure
|
|
281
|
+
.input(z.object({ value: z.number() }))
|
|
282
|
+
.broadcast(({ value }) => ({
|
|
283
|
+
VALUE_DOUBLED: { value: value * 2 },
|
|
284
|
+
})),
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
export const ioServer = io.server({ router });
|
|
288
|
+
|
|
289
|
+
const Pluv = createPluvHandler({
|
|
290
|
+
io: ioServer, // <- This uses the PluvServer now
|
|
291
|
+
/* ... */
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
// frontend/pluv.ts
|
|
297
|
+
|
|
298
|
+
import { createClient } from "@pluv/react";
|
|
299
|
+
import type { ioServer } from "../backend/io";
|
|
300
|
+
|
|
301
|
+
// This users the PluvServer type now
|
|
302
|
+
const client = createClient<typeof ioServer>({
|
|
303
|
+
/* ... */
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
- `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:
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
const router = io.mergeRouters(router1, router2);
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## 0.17.3
|
|
314
|
+
|
|
315
|
+
## 0.17.2
|
|
316
|
+
|
|
317
|
+
## 0.17.1
|
|
318
|
+
|
|
319
|
+
## 0.17.0
|
|
320
|
+
|
|
321
|
+
### Minor Changes
|
|
322
|
+
|
|
323
|
+
- 507bc00: _BREAKING_: The `authorize` config when calling `createIO` can now also be a function that exposes the platform context.
|
|
324
|
+
This allows accessing the `env` in Cloudflare workers.
|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
import { createIO } from "@pluv/io";
|
|
328
|
+
import { platformCloudflare } from "@pluv/platform-cloudflare";
|
|
329
|
+
import { z } from "zod";
|
|
330
|
+
|
|
331
|
+
const io = createIO({
|
|
332
|
+
authorize: ({ env }) => ({
|
|
333
|
+
required: true,
|
|
334
|
+
secret: env.PLUV_AUTHORIZE_SECRET,
|
|
335
|
+
user: z.object({
|
|
336
|
+
id: z.string(),
|
|
337
|
+
name: z.string(),
|
|
338
|
+
}),
|
|
339
|
+
}),
|
|
340
|
+
platform: platformCloudflare<{ PLUV_AUTHORIZE_SECRET: string }>(),
|
|
341
|
+
// ...
|
|
342
|
+
});
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
This also requires that the platform contexts are passed to `io.createToken`.
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
// If using `platformNode`
|
|
349
|
+
await io.createToken({
|
|
350
|
+
req, // This `IncomingMessage` is now required
|
|
351
|
+
room,
|
|
352
|
+
user: {
|
|
353
|
+
id: "user_123",
|
|
354
|
+
name: "john doe",
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// If using `platformCloudflare`
|
|
359
|
+
await io.createToken({
|
|
360
|
+
env, // This env is now required from the handler's fetch function
|
|
361
|
+
room,
|
|
362
|
+
user: {
|
|
363
|
+
id: "user_123",
|
|
364
|
+
name: "john doe",
|
|
365
|
+
},
|
|
366
|
+
});
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## 0.16.3
|
|
370
|
+
|
|
371
|
+
## 0.16.2
|
|
372
|
+
|
|
373
|
+
## 0.16.1
|
|
374
|
+
|
|
375
|
+
## 0.16.0
|
|
376
|
+
|
|
377
|
+
## 0.15.0
|
|
378
|
+
|
|
379
|
+
## 0.14.1
|
|
380
|
+
|
|
381
|
+
## 0.14.0
|
|
382
|
+
|
|
383
|
+
## 0.13.0
|
|
384
|
+
|
|
385
|
+
## 0.12.3
|
|
386
|
+
|
|
387
|
+
## 0.12.2
|
|
388
|
+
|
|
389
|
+
### Patch Changes
|
|
390
|
+
|
|
391
|
+
- 259a7da: Bumped dependencies
|
|
392
|
+
|
|
393
|
+
## 0.12.1
|
|
394
|
+
|
|
395
|
+
## 0.12.0
|
|
396
|
+
|
|
397
|
+
## 0.11.1
|
|
398
|
+
|
|
399
|
+
## 0.11.0
|
|
400
|
+
|
|
401
|
+
## 0.10.3
|
|
402
|
+
|
|
403
|
+
## 0.10.2
|
|
404
|
+
|
|
405
|
+
## 0.10.1
|
|
406
|
+
|
|
407
|
+
### Patch Changes
|
|
408
|
+
|
|
409
|
+
- 885835d: remove unnecessary dependency
|
|
410
|
+
|
|
411
|
+
## 0.10.0
|
|
412
|
+
|
|
413
|
+
### Minor Changes
|
|
414
|
+
|
|
415
|
+
- f43f1cc: Change packages to all be versioned together for consistency.
|
|
416
|
+
|
|
417
|
+
## 0.2.2
|
|
418
|
+
|
|
419
|
+
### Patch Changes
|
|
420
|
+
|
|
421
|
+
- 8fba48b: fix including incorrect dependency
|
|
422
|
+
- 8997c65: bumped dependencies
|
|
423
|
+
|
|
424
|
+
## 0.2.1
|
|
425
|
+
|
|
426
|
+
### Patch Changes
|
|
427
|
+
|
|
428
|
+
- 8d11672: bumped dependencies to latest
|
|
429
|
+
|
|
430
|
+
## 0.2.0
|
|
431
|
+
|
|
432
|
+
### Minor Changes
|
|
433
|
+
|
|
434
|
+
- bb2886b: allow sending multiple output types (broadcast, self, sync) per event
|
|
435
|
+
- ae679a8: updated offline presence to be set when reconnecting to a room
|
|
436
|
+
|
|
437
|
+
### Patch Changes
|
|
438
|
+
|
|
439
|
+
- 0dd847e: updated storage to be synced when reconnected to the room
|
|
440
|
+
|
|
441
|
+
## 0.1.6
|
|
442
|
+
|
|
443
|
+
### Patch Changes
|
|
444
|
+
|
|
445
|
+
- 850626e: bumped dependencies
|
|
446
|
+
|
|
447
|
+
## 0.1.5
|
|
448
|
+
|
|
449
|
+
### Patch Changes
|
|
450
|
+
|
|
451
|
+
- 74870ee: bumped dependencies
|
|
452
|
+
|
|
453
|
+
## 0.1.4
|
|
454
|
+
|
|
455
|
+
### Patch Changes
|
|
456
|
+
|
|
457
|
+
- 9516a4e: updated typescript to 5.0
|
|
458
|
+
- 7b6da1c: bumped dependencies
|
|
459
|
+
- e9c1514: bumped dependencies
|
|
460
|
+
|
|
461
|
+
## 0.1.3
|
|
462
|
+
|
|
463
|
+
### Patch Changes
|
|
464
|
+
|
|
465
|
+
- 8bf62cb: bumped dependencies
|
|
466
|
+
- 7e52685: Bumped dependencies
|
|
467
|
+
- 8e97fb2: Updated dependencies
|
|
468
|
+
|
|
469
|
+
## 0.1.2
|
|
470
|
+
|
|
471
|
+
### Patch Changes
|
|
472
|
+
|
|
473
|
+
- fe80d7b: added preview disclaimer about breaking changes in the readme
|
|
474
|
+
|
|
475
|
+
## 0.1.1
|
|
476
|
+
|
|
477
|
+
### Patch Changes
|
|
478
|
+
|
|
479
|
+
- 24016e6: Updated dependencies
|
|
480
|
+
|
|
481
|
+
## 0.1.0
|
|
482
|
+
|
|
483
|
+
### Minor Changes
|
|
484
|
+
|
|
485
|
+
- a22f525: Added documentation
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Shoubhit Dash
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|