@pluv/client 0.35.3 → 0.36.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.
@@ -1,18 +1,18 @@
1
1
 
2
- > @pluv/client@0.35.3 build /home/runner/work/pluv/pluv/packages/client
2
+ > @pluv/client@0.36.0 build /home/runner/work/pluv/pluv/packages/client
3
3
  > tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.3.6
7
+ CLI tsup v8.4.0
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- CJS dist/index.js 48.48 KB
12
- CJS ⚡️ Build success in 120ms
13
- ESM dist/index.mjs 47.18 KB
14
- ESM ⚡️ Build success in 121ms
11
+ ESM dist/index.mjs 47.24 KB
12
+ ESM ⚡️ Build success in 135ms
13
+ CJS dist/index.js 48.56 KB
14
+ CJS ⚡️ Build success in 138ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3832ms
17
- DTS dist/index.d.mts 22.65 KB
18
- DTS dist/index.d.ts 22.65 KB
16
+ DTS ⚡️ Build success in 3381ms
17
+ DTS dist/index.d.mts 22.82 KB
18
+ DTS dist/index.d.ts 22.82 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # @pluv/client
2
2
 
3
+ ## 0.36.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4518b6d: **BREAKING**
8
+ Updated how `createClient` infers the `PluvServer` type (again 🙁). The property to specify the type-inferred `PluvServer` type has been renamed to `types` from `infer`. `@pluv/client` now exports a function called `infer` that must now be used to construct the inferred `types` property. `infer` must be called before, and outside of `createClient` due to TypeScript inferrence limitations. See examples below:
9
+
10
+ ```ts
11
+ // Before
12
+
13
+ import { createClient } from "@pluv/client";
14
+ import type { ioServer } from "../server/pluv";
15
+
16
+ const client = createClient({
17
+ // ...
18
+ infer: (i) => ({ io: i<typeof ioServer> }),
19
+ // ...
20
+ });
21
+
22
+ // After
23
+
24
+ import { createClient, infer } from "@pluv/client";
25
+ import type { ioServer } from "../server/pluv";
26
+
27
+ // Observe that `types` is initialized outside of `createClient`, instead of
28
+ // inline within the `createClient` function.`
29
+ const types = infer((i) => ({ io: i<typeof ioServer> }));
30
+ const client = createClient({
31
+ // ...
32
+ // Avoid calling `infer` inline within this function like in the commented
33
+ // example below:
34
+ // types: infer((i) => ({ io: i<typeof ioServer> })),
35
+ types,
36
+ // ...
37
+ });
38
+ ```
39
+
40
+ ### Patch Changes
41
+
42
+ - @pluv/crdt@0.36.0
43
+ - @pluv/types@0.36.0
44
+
45
+ ## 0.35.4
46
+
47
+ ### Patch Changes
48
+
49
+ - @pluv/crdt@0.35.4
50
+ - @pluv/types@0.35.4
51
+
3
52
  ## 0.35.3
4
53
 
5
54
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CrdtType, AbstractCrdtDoc, InferCrdtJson, AbstractCrdtDocFactory } from '@pluv/crdt';
2
2
  export { CrdtType, InferCrdtJson } from '@pluv/crdt';
3
- import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, InferIOAuthorizeUser, InferIOAuthorize, EventRecord, MaybePromise, InputZodLike, ProcedureLike, IORouterLike, InferIOInput, BaseUser } from '@pluv/types';
3
+ import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, EventRecord, InferIOAuthorizeUser, InferIOAuthorize, MaybePromise, ProcedureLike, InputZodLike, IORouterLike, InferIOInput, BaseUser } from '@pluv/types';
4
4
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
5
5
  import { Subject } from 'wonka';
6
6
 
@@ -134,6 +134,13 @@ declare abstract class AbstractStorageStore {
134
134
  abstract initialize(): Promise<void>;
135
135
  }
136
136
 
137
+ declare const identity: <T extends unknown>(x: T) => T;
138
+
139
+ type InferCallback<TIO extends IOLike<any, any>> = (i: typeof identity) => {
140
+ io: (io: TIO) => TIO;
141
+ };
142
+ declare const infer: <TIO extends IOLike<any, any>>(callback: InferCallback<TIO>) => InferCallback<TIO>;
143
+
137
144
  type CrdtManagerOptions<TStorage extends Record<string, CrdtType<any, any>> = {}> = {
138
145
  encodedState?: string | Uint8Array | null;
139
146
  initialStorage?: AbstractCrdtDocFactory<TStorage>;
@@ -161,7 +168,7 @@ type FetchOptions = {
161
168
  url: string;
162
169
  options?: RequestInit;
163
170
  };
164
- type RoomEndpoints<TIO extends IOLike, TMetadata extends JsonObject> = {
171
+ type RoomEndpoints<TIO extends IOLike<any, any>, TMetadata extends JsonObject> = {
165
172
  wsEndpoint?: WsEndpoint<TMetadata>;
166
173
  } & (InferIOAuthorizeUser<InferIOAuthorize<TIO>> extends BaseUser ? {
167
174
  authEndpoint: AuthEndpoint<TMetadata>;
@@ -287,20 +294,15 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
287
294
  private _updateState;
288
295
  }
289
296
 
290
- declare const identity: <T extends unknown>(x: T) => T;
291
-
292
- type InferCallback<TIO extends IOLike<any, any>> = (i: typeof identity) => {
293
- io: (io: TIO) => TIO;
294
- };
295
297
  type PluvClientOptions<TIO extends IOLike<any, any>, TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>, TMetadata extends JsonObject> = RoomEndpoints<TIO, TMetadata> & {
296
298
  debug?: boolean;
297
- infer: InferCallback<TIO>;
298
299
  initialStorage?: AbstractCrdtDocFactory<TStorage>;
299
300
  metadata?: InputZodLike<TMetadata>;
300
301
  presence?: InputZodLike<TPresence>;
301
302
  publicKey?: string;
303
+ types: InferCallback<TIO>;
302
304
  };
303
- type CreateRoomOptions<TIO extends IOLike, TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>, TMetadata extends JsonObject, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> = {
305
+ type CreateRoomOptions<TIO extends IOLike<any, any>, TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>, TMetadata extends JsonObject, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> = {
304
306
  addons?: readonly PluvRoomAddon<TIO, TMetadata, TPresence, TStorage>[];
305
307
  debug?: boolean | PluvRoomDebug<TIO>;
306
308
  initialPresence?: TPresence;
@@ -312,7 +314,7 @@ type CreateRoomOptions<TIO extends IOLike, TPresence extends JsonObject, TStorag
312
314
  } : {
313
315
  metadata: TMetadata;
314
316
  });
315
- declare class PluvClient<TIO extends IOLike = IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TMetadata extends JsonObject = {}> {
317
+ declare class PluvClient<TIO extends IOLike<any, any>, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TMetadata extends JsonObject = {}> {
316
318
  private readonly _authEndpoint;
317
319
  private readonly _debug;
318
320
  private readonly _initialStorage?;
@@ -391,4 +393,4 @@ declare const register: <TMetadata extends JsonObject>(params: RegisterParams<TM
391
393
  wsEndpoint: (params: EndpointParams<TMetadata>) => string;
392
394
  };
393
395
 
394
- export { AbstractRoom, AbstractStorageStore, ConnectionState, type CreateRoomOptions, type MergeEvents, MockedRoom, type MockedRoomConfig, type MockedRoomEvents, PluvClient, type PluvClientOptions, type PluvProcedureConfig, PluvRoom, type PluvRoomAddon, type PluvRoomAddonInput, type PluvRoomAddonResult, type PluvRoomDebug, PluvRouter, type PluvRouterEventConfig, type RegisterParams, type UserInfo, type WebSocketConnection, type WebSocketState, createClient, register };
396
+ export { AbstractRoom, AbstractStorageStore, ConnectionState, type CreateRoomOptions, type InferCallback, type MergeEvents, MockedRoom, type MockedRoomConfig, type MockedRoomEvents, PluvClient, type PluvClientOptions, type PluvProcedureConfig, PluvRoom, type PluvRoomAddon, type PluvRoomAddonInput, type PluvRoomAddonResult, type PluvRoomDebug, PluvRouter, type PluvRouterEventConfig, type RegisterParams, type RoomEndpoints, type UserInfo, type WebSocketConnection, type WebSocketState, createClient, infer, register };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { CrdtType, AbstractCrdtDoc, InferCrdtJson, AbstractCrdtDocFactory } from '@pluv/crdt';
2
2
  export { CrdtType, InferCrdtJson } from '@pluv/crdt';
3
- import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, InferIOAuthorizeUser, InferIOAuthorize, EventRecord, MaybePromise, InputZodLike, ProcedureLike, IORouterLike, InferIOInput, BaseUser } from '@pluv/types';
3
+ import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, EventRecord, InferIOAuthorizeUser, InferIOAuthorize, MaybePromise, ProcedureLike, InputZodLike, IORouterLike, InferIOInput, BaseUser } from '@pluv/types';
4
4
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
5
5
  import { Subject } from 'wonka';
6
6
 
@@ -134,6 +134,13 @@ declare abstract class AbstractStorageStore {
134
134
  abstract initialize(): Promise<void>;
135
135
  }
136
136
 
137
+ declare const identity: <T extends unknown>(x: T) => T;
138
+
139
+ type InferCallback<TIO extends IOLike<any, any>> = (i: typeof identity) => {
140
+ io: (io: TIO) => TIO;
141
+ };
142
+ declare const infer: <TIO extends IOLike<any, any>>(callback: InferCallback<TIO>) => InferCallback<TIO>;
143
+
137
144
  type CrdtManagerOptions<TStorage extends Record<string, CrdtType<any, any>> = {}> = {
138
145
  encodedState?: string | Uint8Array | null;
139
146
  initialStorage?: AbstractCrdtDocFactory<TStorage>;
@@ -161,7 +168,7 @@ type FetchOptions = {
161
168
  url: string;
162
169
  options?: RequestInit;
163
170
  };
164
- type RoomEndpoints<TIO extends IOLike, TMetadata extends JsonObject> = {
171
+ type RoomEndpoints<TIO extends IOLike<any, any>, TMetadata extends JsonObject> = {
165
172
  wsEndpoint?: WsEndpoint<TMetadata>;
166
173
  } & (InferIOAuthorizeUser<InferIOAuthorize<TIO>> extends BaseUser ? {
167
174
  authEndpoint: AuthEndpoint<TMetadata>;
@@ -287,20 +294,15 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
287
294
  private _updateState;
288
295
  }
289
296
 
290
- declare const identity: <T extends unknown>(x: T) => T;
291
-
292
- type InferCallback<TIO extends IOLike<any, any>> = (i: typeof identity) => {
293
- io: (io: TIO) => TIO;
294
- };
295
297
  type PluvClientOptions<TIO extends IOLike<any, any>, TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>, TMetadata extends JsonObject> = RoomEndpoints<TIO, TMetadata> & {
296
298
  debug?: boolean;
297
- infer: InferCallback<TIO>;
298
299
  initialStorage?: AbstractCrdtDocFactory<TStorage>;
299
300
  metadata?: InputZodLike<TMetadata>;
300
301
  presence?: InputZodLike<TPresence>;
301
302
  publicKey?: string;
303
+ types: InferCallback<TIO>;
302
304
  };
303
- type CreateRoomOptions<TIO extends IOLike, TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>, TMetadata extends JsonObject, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> = {
305
+ type CreateRoomOptions<TIO extends IOLike<any, any>, TPresence extends JsonObject, TStorage extends Record<string, CrdtType<any, any>>, TMetadata extends JsonObject, TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}> = {
304
306
  addons?: readonly PluvRoomAddon<TIO, TMetadata, TPresence, TStorage>[];
305
307
  debug?: boolean | PluvRoomDebug<TIO>;
306
308
  initialPresence?: TPresence;
@@ -312,7 +314,7 @@ type CreateRoomOptions<TIO extends IOLike, TPresence extends JsonObject, TStorag
312
314
  } : {
313
315
  metadata: TMetadata;
314
316
  });
315
- declare class PluvClient<TIO extends IOLike = IOLike, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TMetadata extends JsonObject = {}> {
317
+ declare class PluvClient<TIO extends IOLike<any, any>, TPresence extends JsonObject = {}, TStorage extends Record<string, CrdtType<any, any>> = {}, TMetadata extends JsonObject = {}> {
316
318
  private readonly _authEndpoint;
317
319
  private readonly _debug;
318
320
  private readonly _initialStorage?;
@@ -391,4 +393,4 @@ declare const register: <TMetadata extends JsonObject>(params: RegisterParams<TM
391
393
  wsEndpoint: (params: EndpointParams<TMetadata>) => string;
392
394
  };
393
395
 
394
- export { AbstractRoom, AbstractStorageStore, ConnectionState, type CreateRoomOptions, type MergeEvents, MockedRoom, type MockedRoomConfig, type MockedRoomEvents, PluvClient, type PluvClientOptions, type PluvProcedureConfig, PluvRoom, type PluvRoomAddon, type PluvRoomAddonInput, type PluvRoomAddonResult, type PluvRoomDebug, PluvRouter, type PluvRouterEventConfig, type RegisterParams, type UserInfo, type WebSocketConnection, type WebSocketState, createClient, register };
396
+ export { AbstractRoom, AbstractStorageStore, ConnectionState, type CreateRoomOptions, type InferCallback, type MergeEvents, MockedRoom, type MockedRoomConfig, type MockedRoomEvents, PluvClient, type PluvClientOptions, type PluvProcedureConfig, PluvRoom, type PluvRoomAddon, type PluvRoomAddonInput, type PluvRoomAddonResult, type PluvRoomDebug, PluvRouter, type PluvRouterEventConfig, type RegisterParams, type RoomEndpoints, type UserInfo, type WebSocketConnection, type WebSocketState, createClient, infer, register };
package/dist/index.js CHANGED
@@ -64,6 +64,7 @@ __export(index_exports, {
64
64
  PluvClient: () => PluvClient,
65
65
  PluvRoom: () => PluvRoom,
66
66
  createClient: () => createClient,
67
+ infer: () => infer,
67
68
  register: () => register
68
69
  });
69
70
  module.exports = __toCommonJS(index_exports);
@@ -1261,6 +1262,9 @@ var createClient = (options) => {
1261
1262
  return new PluvClient(options);
1262
1263
  };
1263
1264
 
1265
+ // src/infer.ts
1266
+ var infer = (callback) => callback;
1267
+
1264
1268
  // src/MockedRoom.ts
1265
1269
  var MockedRoom = class extends AbstractRoom {
1266
1270
  constructor(room, options) {
@@ -1470,5 +1474,6 @@ var register = (params) => {
1470
1474
  PluvClient,
1471
1475
  PluvRoom,
1472
1476
  createClient,
1477
+ infer,
1473
1478
  register
1474
1479
  });
package/dist/index.mjs CHANGED
@@ -1231,6 +1231,9 @@ var createClient = (options) => {
1231
1231
  return new PluvClient(options);
1232
1232
  };
1233
1233
 
1234
+ // src/infer.ts
1235
+ var infer = (callback) => callback;
1236
+
1234
1237
  // src/MockedRoom.ts
1235
1238
  var MockedRoom = class extends AbstractRoom {
1236
1239
  constructor(room, options) {
@@ -1439,5 +1442,6 @@ export {
1439
1442
  PluvClient,
1440
1443
  PluvRoom,
1441
1444
  createClient,
1445
+ infer,
1442
1446
  register
1443
1447
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/client",
3
- "version": "0.35.3",
3
+ "version": "0.36.0",
4
4
  "description": "@pluv/io frontend client",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "wonka": "^6.3.4",
21
- "@pluv/crdt": "^0.35.3",
22
- "@pluv/types": "^0.35.3"
21
+ "@pluv/crdt": "^0.36.0",
22
+ "@pluv/types": "^0.36.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "^8.57.1",
26
- "tsup": "^8.3.6",
26
+ "tsup": "^8.4.0",
27
27
  "typescript": "^5.7.3",
28
- "@pluv/tsconfig": "^0.35.3",
29
- "eslint-config-pluv": "^0.35.3"
28
+ "@pluv/tsconfig": "^0.36.0",
29
+ "eslint-config-pluv": "^0.36.0"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/PluvClient.ts CHANGED
@@ -1,15 +1,11 @@
1
1
  import type { AbstractCrdtDocFactory, CrdtType } from "@pluv/crdt";
2
2
  import type { InputZodLike, IOLike, JsonObject } from "@pluv/types";
3
+ import type { InferCallback } from "./infer";
3
4
  import { PluvProcedure } from "./PluvProcedure";
4
5
  import type { AuthEndpoint, PluvRoomAddon, PluvRoomDebug, RoomConfig, RoomEndpoints, WsEndpoint } from "./PluvRoom";
5
6
  import { PluvRoom } from "./PluvRoom";
6
7
  import type { PluvRouterEventConfig } from "./PluvRouter";
7
8
  import { PluvRouter } from "./PluvRouter";
8
- import type { identity } from "./utils";
9
-
10
- export type InferCallback<TIO extends IOLike<any, any>> = (i: typeof identity) => {
11
- io: (io: TIO) => TIO;
12
- };
13
9
 
14
10
  export type PluvClientOptions<
15
11
  TIO extends IOLike<any, any>,
@@ -18,15 +14,15 @@ export type PluvClientOptions<
18
14
  TMetadata extends JsonObject,
19
15
  > = RoomEndpoints<TIO, TMetadata> & {
20
16
  debug?: boolean;
21
- infer: InferCallback<TIO>;
22
17
  initialStorage?: AbstractCrdtDocFactory<TStorage>;
23
18
  metadata?: InputZodLike<TMetadata>;
24
19
  presence?: InputZodLike<TPresence>;
25
20
  publicKey?: string;
21
+ types: InferCallback<TIO>;
26
22
  };
27
23
 
28
24
  export type CreateRoomOptions<
29
- TIO extends IOLike,
25
+ TIO extends IOLike<any, any>,
30
26
  TPresence extends JsonObject,
31
27
  TStorage extends Record<string, CrdtType<any, any>>,
32
28
  TMetadata extends JsonObject,
@@ -41,7 +37,7 @@ export type CreateRoomOptions<
41
37
  } & (keyof TMetadata extends never ? { metadata?: undefined } : { metadata: TMetadata });
42
38
 
43
39
  export class PluvClient<
44
- TIO extends IOLike = IOLike,
40
+ TIO extends IOLike<any, any>,
45
41
  TPresence extends JsonObject = {},
46
42
  TStorage extends Record<string, CrdtType<any, any>> = {},
47
43
  TMetadata extends JsonObject = {},
package/src/PluvRoom.ts CHANGED
@@ -101,7 +101,7 @@ export type WsEndpoint<TMetadata extends JsonObject> = string | ((params: Endpoi
101
101
 
102
102
  type FetchOptions = { url: string; options?: RequestInit };
103
103
 
104
- export type RoomEndpoints<TIO extends IOLike, TMetadata extends JsonObject> = {
104
+ export type RoomEndpoints<TIO extends IOLike<any, any>, TMetadata extends JsonObject> = {
105
105
  wsEndpoint?: WsEndpoint<TMetadata>;
106
106
  } & (InferIOAuthorizeUser<InferIOAuthorize<TIO>> extends BaseUser
107
107
  ? { authEndpoint: AuthEndpoint<TMetadata> }
package/src/index.ts CHANGED
@@ -4,13 +4,15 @@ export { AbstractRoom } from "./AbstractRoom";
4
4
  export { AbstractStorageStore } from "./AbstractStorageStore";
5
5
  export { createClient } from "./createClient";
6
6
  export { ConnectionState } from "./enums";
7
+ export { infer } from "./infer";
8
+ export type { InferCallback } from "./infer";
7
9
  export { MockedRoom } from "./MockedRoom";
8
10
  export type { MockedRoomConfig, MockedRoomEvents } from "./MockedRoom";
9
11
  export { PluvClient } from "./PluvClient";
10
12
  export type { CreateRoomOptions, PluvClientOptions } from "./PluvClient";
11
13
  export type { PluvProcedureConfig } from "./PluvProcedure";
12
14
  export { PluvRoom } from "./PluvRoom";
13
- export type { PluvRoomAddon, PluvRoomAddonInput, PluvRoomAddonResult, PluvRoomDebug } from "./PluvRoom";
15
+ export type { PluvRoomAddon, PluvRoomAddonInput, PluvRoomAddonResult, PluvRoomDebug, RoomEndpoints } from "./PluvRoom";
14
16
  export type { MergeEvents, PluvRouter, PluvRouterEventConfig } from "./PluvRouter";
15
17
  export { register } from "./register";
16
18
  export type { RegisterParams } from "./register";
package/src/infer.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { IOLike } from "@pluv/types";
2
+ import type { identity } from "./utils";
3
+
4
+ export type InferCallback<TIO extends IOLike<any, any>> = (i: typeof identity) => {
5
+ io: (io: TIO) => TIO;
6
+ };
7
+
8
+ export const infer = <TIO extends IOLike<any, any>>(callback: InferCallback<TIO>): InferCallback<TIO> => callback;