@pluv/types 2.2.1 → 2.2.3
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 +130 -126
- package/package.json +5 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/types@2.2.
|
|
2
|
+
> @pluv/types@2.2.3 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
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.
|
|
7
|
+
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[32m1.37 KB[39m
|
|
12
|
-
[32mCJS[39m ⚡️ Build success in 37ms
|
|
13
11
|
[32mESM[39m [1mdist/index.mjs [22m[32m330.00 B[39m
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 37ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m1.37 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 36ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1355ms
|
|
17
17
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m18.73 KB[39m
|
|
18
18
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m18.73 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# @pluv/types
|
|
2
2
|
|
|
3
|
+
## 2.2.3
|
|
4
|
+
|
|
5
|
+
## 2.2.2
|
|
6
|
+
|
|
3
7
|
## 2.2.1
|
|
4
8
|
|
|
5
9
|
## 2.2.0
|
|
@@ -26,9 +30,9 @@
|
|
|
26
30
|
|
|
27
31
|
- af94706: pluv.io is now stable and production ready!
|
|
28
32
|
|
|
29
|
-
|
|
33
|
+
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.
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
|
|
32
36
|
|
|
33
37
|
## 0.44.2
|
|
34
38
|
|
|
@@ -206,95 +210,95 @@
|
|
|
206
210
|
|
|
207
211
|
- 99b5ca9: ## Breaking Changes
|
|
208
212
|
|
|
209
|
-
|
|
213
|
+
- `@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.
|
|
210
214
|
|
|
211
|
-
|
|
215
|
+
### Before:
|
|
212
216
|
|
|
213
|
-
|
|
214
|
-
|
|
217
|
+
```ts
|
|
218
|
+
// backend/io.ts
|
|
215
219
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
import { createIO } from "@pluv/io";
|
|
221
|
+
import { createPluvHandler, platformNode } from "@pluv/platform-node";
|
|
222
|
+
import { z } from "zod";
|
|
219
223
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
})
|
|
223
|
-
.event("SEND_MESSAGE", {
|
|
224
|
-
input: z.object({ message: z.string() }),
|
|
225
|
-
resolver: ({ message }) => ({ RECEIVE_MESSAGE: { message } }),
|
|
224
|
+
export const io = createIO({
|
|
225
|
+
platform: platformNode(),
|
|
226
226
|
})
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
.event("SEND_MESSAGE", {
|
|
228
|
+
input: z.object({ message: z.string() }),
|
|
229
|
+
resolver: ({ message }) => ({ RECEIVE_MESSAGE: { message } }),
|
|
230
|
+
})
|
|
231
|
+
.event("DOUBLE_VALUE", {
|
|
232
|
+
input: z.object({ value: z.number() }),
|
|
233
|
+
resolver: ({ value }) => ({ VALUE_DOUBLED: { value: value * 2 } }),
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const Pluv = createPluvHandler({
|
|
237
|
+
io,
|
|
238
|
+
/* ... */
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
// frontend/pluv.ts
|
|
244
|
+
|
|
245
|
+
import { createClient } from "@pluv/react";
|
|
246
|
+
import type { io } from "../backend/io";
|
|
247
|
+
|
|
248
|
+
const client = createClient<typeof io>({
|
|
249
|
+
/* ... */
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Now:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
import { createIO } from "@pluv/io";
|
|
257
|
+
import { createPluvHandler, platformNode } from "@pluv/platform-node";
|
|
258
|
+
import { z } from "zod";
|
|
259
|
+
|
|
260
|
+
const io = createIO({
|
|
261
|
+
platform: platformNode(),
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const router = io.router({
|
|
265
|
+
SEND_MESSAGE: io.procedure
|
|
266
|
+
.input(z.object({ message: z.string() }))
|
|
267
|
+
.broadcast(({ message }) => ({
|
|
268
|
+
RECEIVE_MESSAGE: { message },
|
|
269
|
+
})),
|
|
270
|
+
DOUBLE_VALUE: io.procedure
|
|
271
|
+
.input(z.object({ value: z.number() }))
|
|
272
|
+
.broadcast(({ value }) => ({
|
|
273
|
+
VALUE_DOUBLED: { value: value * 2 },
|
|
274
|
+
})),
|
|
230
275
|
});
|
|
231
276
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
platform: platformNode(),
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
const router = io.router({
|
|
261
|
-
SEND_MESSAGE: io.procedure
|
|
262
|
-
.input(z.object({ message: z.string() }))
|
|
263
|
-
.broadcast(({ message }) => ({
|
|
264
|
-
RECEIVE_MESSAGE: { message },
|
|
265
|
-
})),
|
|
266
|
-
DOUBLE_VALUE: io.procedure
|
|
267
|
-
.input(z.object({ value: z.number() }))
|
|
268
|
-
.broadcast(({ value }) => ({
|
|
269
|
-
VALUE_DOUBLED: { value: value * 2 },
|
|
270
|
-
})),
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
export const ioServer = io.server({ router });
|
|
274
|
-
|
|
275
|
-
const Pluv = createPluvHandler({
|
|
276
|
-
io: ioServer, // <- This uses the PluvServer now
|
|
277
|
-
/* ... */
|
|
278
|
-
});
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
```ts
|
|
282
|
-
// frontend/pluv.ts
|
|
283
|
-
|
|
284
|
-
import { createClient } from "@pluv/react";
|
|
285
|
-
import type { ioServer } from "../backend/io";
|
|
286
|
-
|
|
287
|
-
// This users the PluvServer type now
|
|
288
|
-
const client = createClient<typeof ioServer>({
|
|
289
|
-
/* ... */
|
|
290
|
-
});
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
- `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:
|
|
294
|
-
|
|
295
|
-
```ts
|
|
296
|
-
const router = io.mergeRouters(router1, router2);
|
|
297
|
-
```
|
|
277
|
+
export const ioServer = io.server({ router });
|
|
278
|
+
|
|
279
|
+
const Pluv = createPluvHandler({
|
|
280
|
+
io: ioServer, // <- This uses the PluvServer now
|
|
281
|
+
/* ... */
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
// frontend/pluv.ts
|
|
287
|
+
|
|
288
|
+
import { createClient } from "@pluv/react";
|
|
289
|
+
import type { ioServer } from "../backend/io";
|
|
290
|
+
|
|
291
|
+
// This users the PluvServer type now
|
|
292
|
+
const client = createClient<typeof ioServer>({
|
|
293
|
+
/* ... */
|
|
294
|
+
});
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
- `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:
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
const router = io.mergeRouters(router1, router2);
|
|
301
|
+
```
|
|
298
302
|
|
|
299
303
|
## 0.17.3
|
|
300
304
|
|
|
@@ -309,48 +313,48 @@
|
|
|
309
313
|
- 507bc00: _BREAKING_: The `authorize` config when calling `createIO` can now also be a function that exposes the platform context.
|
|
310
314
|
This allows accessing the `env` in Cloudflare workers.
|
|
311
315
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
316
|
+
```ts
|
|
317
|
+
import { createIO } from "@pluv/io";
|
|
318
|
+
import { platformCloudflare } from "@pluv/platform-cloudflare";
|
|
319
|
+
import { z } from "zod";
|
|
320
|
+
|
|
321
|
+
const io = createIO({
|
|
322
|
+
authorize: ({ env }) => ({
|
|
323
|
+
required: true,
|
|
324
|
+
secret: env.PLUV_AUTHORIZE_SECRET,
|
|
325
|
+
user: z.object({
|
|
326
|
+
id: z.string(),
|
|
327
|
+
name: z.string(),
|
|
328
|
+
}),
|
|
329
|
+
}),
|
|
330
|
+
platform: platformCloudflare<{ PLUV_AUTHORIZE_SECRET: string }>(),
|
|
331
|
+
// ...
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
This also requires that the platform contexts are passed to `io.createToken`.
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
// If using `platformNode`
|
|
339
|
+
await io.createToken({
|
|
340
|
+
req, // This `IncomingMessage` is now required
|
|
341
|
+
room,
|
|
342
|
+
user: {
|
|
343
|
+
id: "user_123",
|
|
344
|
+
name: "john doe",
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
// If using `platformCloudflare`
|
|
349
|
+
await io.createToken({
|
|
350
|
+
env, // This env is now required from the handler's fetch function
|
|
351
|
+
room,
|
|
352
|
+
user: {
|
|
353
|
+
id: "user_123",
|
|
354
|
+
name: "john doe",
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
```
|
|
354
358
|
|
|
355
359
|
## 0.16.3
|
|
356
360
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/types",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "@pluv/io shared types",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"eslint": "^9.
|
|
20
|
-
"tsup": "^8.
|
|
19
|
+
"eslint": "^9.27.0",
|
|
20
|
+
"tsup": "^8.5.0",
|
|
21
21
|
"typescript": "^5.8.3",
|
|
22
|
-
"@pluv/tsconfig": "^2.2.
|
|
23
|
-
"eslint-config-pluv": "^2.2.
|
|
22
|
+
"@pluv/tsconfig": "^2.2.3",
|
|
23
|
+
"eslint-config-pluv": "^2.2.3"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"wonka": "^6.3.5"
|