@pluv/client 0.38.11 → 0.38.12

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/client@0.38.11 build /home/runner/work/pluv/pluv/packages/client
2
+ > @pluv/client@0.38.12 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
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 48.04 KB
12
- ESM ⚡️ Build success in 109ms
13
- CJS dist/index.js 49.35 KB
14
- CJS ⚡️ Build success in 115ms
11
+ ESM dist/index.mjs 48.06 KB
12
+ ESM ⚡️ Build success in 117ms
13
+ CJS dist/index.js 49.38 KB
14
+ CJS ⚡️ Build success in 117ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3258ms
17
- DTS dist/index.d.mts 23.16 KB
18
- DTS dist/index.d.ts 23.16 KB
16
+ DTS ⚡️ Build success in 3216ms
17
+ DTS dist/index.d.mts 23.23 KB
18
+ DTS dist/index.d.ts 23.23 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @pluv/client
2
2
 
3
+ ## 0.38.12
4
+
5
+ ### Patch Changes
6
+
7
+ - b617726: Fix broken type narrowing for `PluvRoom.event` and `PluvRoom.broadcast`.
8
+ - @pluv/crdt@0.38.12
9
+ - @pluv/types@0.38.12
10
+
3
11
  ## 0.38.11
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, EventRecord, Inf
4
4
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
5
5
  import { Subject } from 'wonka';
6
6
 
7
- type EventNotifierSubscriptionCallback<TIO extends IOLike, TEvent extends keyof InferIOOutput<TIO>> = (value: Id<IOEventMessage<TIO, TEvent>>) => void;
7
+ type EventNotifierSubscriptionCallback<TIO extends IOLike<any, any>, TEvent extends keyof InferIOOutput<TIO>> = (value: Id<IOEventMessage<TIO, TEvent>>) => void;
8
8
 
9
9
  declare enum ConnectionState {
10
10
  Closed = "Closed",
@@ -225,12 +225,12 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
225
225
  constructor(room: string, options: RoomConfig<TIO, TMetadata, TPresence, TStorage, TEvents>);
226
226
  get storageLoaded(): boolean;
227
227
  get webSocket(): WebSocket | null;
228
- broadcast: (<TEvent extends keyof InferIOInput<MergeEvents<TEvents, TIO>>>(event: TEvent, data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>) => Promise<void>) & { [event in keyof InferIOInput<TIO>]: (data: Id<InferIOInput<TIO>[event]>) => Promise<void>; };
228
+ broadcast: (<TEvent extends keyof InferIOInput<MergeEvents<TEvents, TIO>>>(event: TEvent, data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>) => Promise<void>) & { [PEvent in keyof InferIOInput<MergeEvents<TEvents, TIO>>]: (data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[PEvent]>) => Promise<void>; };
229
229
  canRedo: () => boolean;
230
230
  canUndo: () => boolean;
231
231
  connect(): Promise<void>;
232
232
  disconnect(): Promise<void>;
233
- event: (<TEvent extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(event: TEvent, callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, TEvent>) => () => void) & { [event in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, any>) => () => void; };
233
+ event: (<TEvent extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(event: TEvent, callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, TEvent>) => () => void) & { [PEvent in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, PEvent>) => () => void; };
234
234
  getConnection: () => WebSocketConnection;
235
235
  getDoc: () => AbstractCrdtDoc<TStorage>;
236
236
  getMyPresence: () => TPresence;
@@ -334,7 +334,7 @@ declare class PluvClient<TIO extends IOLike<any, any>, TPresence extends JsonObj
334
334
  };
335
335
  get procedure(): PluvProcedure<TIO, {}, {}, TPresence, TStorage>;
336
336
  constructor(options: PluvClientOptions<TIO, TPresence, TStorage, TMetadata>);
337
- createRoom: <TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(room: string, options: CreateRoomOptions<TIO, TPresence, TStorage, TMetadata, TEvents>) => PluvRoom<TIO, TMetadata, TPresence, TStorage>;
337
+ createRoom: <TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(room: string, options: CreateRoomOptions<TIO, TPresence, TStorage, TMetadata, TEvents>) => PluvRoom<TIO, TMetadata, TPresence, TStorage, TEvents>;
338
338
  enter: (room: string | PluvRoom<TIO, any, any, any>) => Promise<PluvRoom<TIO, TMetadata, TPresence, TStorage, any>>;
339
339
  getRoom: (room: string) => PluvRoom<TIO, TMetadata, TPresence, TStorage, any> | null;
340
340
  getRooms: () => readonly PluvRoom<TIO, TMetadata, TPresence, TStorage, any>[];
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, EventRecord, Inf
4
4
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
5
5
  import { Subject } from 'wonka';
6
6
 
7
- type EventNotifierSubscriptionCallback<TIO extends IOLike, TEvent extends keyof InferIOOutput<TIO>> = (value: Id<IOEventMessage<TIO, TEvent>>) => void;
7
+ type EventNotifierSubscriptionCallback<TIO extends IOLike<any, any>, TEvent extends keyof InferIOOutput<TIO>> = (value: Id<IOEventMessage<TIO, TEvent>>) => void;
8
8
 
9
9
  declare enum ConnectionState {
10
10
  Closed = "Closed",
@@ -225,12 +225,12 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
225
225
  constructor(room: string, options: RoomConfig<TIO, TMetadata, TPresence, TStorage, TEvents>);
226
226
  get storageLoaded(): boolean;
227
227
  get webSocket(): WebSocket | null;
228
- broadcast: (<TEvent extends keyof InferIOInput<MergeEvents<TEvents, TIO>>>(event: TEvent, data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>) => Promise<void>) & { [event in keyof InferIOInput<TIO>]: (data: Id<InferIOInput<TIO>[event]>) => Promise<void>; };
228
+ broadcast: (<TEvent extends keyof InferIOInput<MergeEvents<TEvents, TIO>>>(event: TEvent, data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>) => Promise<void>) & { [PEvent in keyof InferIOInput<MergeEvents<TEvents, TIO>>]: (data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[PEvent]>) => Promise<void>; };
229
229
  canRedo: () => boolean;
230
230
  canUndo: () => boolean;
231
231
  connect(): Promise<void>;
232
232
  disconnect(): Promise<void>;
233
- event: (<TEvent extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(event: TEvent, callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, TEvent>) => () => void) & { [event in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, any>) => () => void; };
233
+ event: (<TEvent extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(event: TEvent, callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, TEvent>) => () => void) & { [PEvent in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, PEvent>) => () => void; };
234
234
  getConnection: () => WebSocketConnection;
235
235
  getDoc: () => AbstractCrdtDoc<TStorage>;
236
236
  getMyPresence: () => TPresence;
@@ -334,7 +334,7 @@ declare class PluvClient<TIO extends IOLike<any, any>, TPresence extends JsonObj
334
334
  };
335
335
  get procedure(): PluvProcedure<TIO, {}, {}, TPresence, TStorage>;
336
336
  constructor(options: PluvClientOptions<TIO, TPresence, TStorage, TMetadata>);
337
- createRoom: <TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(room: string, options: CreateRoomOptions<TIO, TPresence, TStorage, TMetadata, TEvents>) => PluvRoom<TIO, TMetadata, TPresence, TStorage>;
337
+ createRoom: <TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(room: string, options: CreateRoomOptions<TIO, TPresence, TStorage, TMetadata, TEvents>) => PluvRoom<TIO, TMetadata, TPresence, TStorage, TEvents>;
338
338
  enter: (room: string | PluvRoom<TIO, any, any, any>) => Promise<PluvRoom<TIO, TMetadata, TPresence, TStorage, any>>;
339
339
  getRoom: (room: string) => PluvRoom<TIO, TMetadata, TPresence, TStorage, any> | null;
340
340
  getRooms: () => readonly PluvRoom<TIO, TMetadata, TPresence, TStorage, any>[];
package/dist/index.js CHANGED
@@ -630,7 +630,10 @@ var PluvRoom = class extends AbstractRoom {
630
630
  this._listeners = {
631
631
  onAuthorizationFail: (error) => {
632
632
  this._clearTimeout(this._timeouts.reconnect);
633
- this._timeouts.reconnect = setTimeout(this._reconnect.bind(this), RECONNECT_TIMEOUT_MS);
633
+ this._timeouts.reconnect = setTimeout(
634
+ this._reconnect.bind(this),
635
+ RECONNECT_TIMEOUT_MS
636
+ );
634
637
  onAuthorizationFail == null ? void 0 : onAuthorizationFail(error);
635
638
  }
636
639
  };
package/dist/index.mjs CHANGED
@@ -599,7 +599,10 @@ var PluvRoom = class extends AbstractRoom {
599
599
  this._listeners = {
600
600
  onAuthorizationFail: (error) => {
601
601
  this._clearTimeout(this._timeouts.reconnect);
602
- this._timeouts.reconnect = setTimeout(this._reconnect.bind(this), RECONNECT_TIMEOUT_MS);
602
+ this._timeouts.reconnect = setTimeout(
603
+ this._reconnect.bind(this),
604
+ RECONNECT_TIMEOUT_MS
605
+ );
603
606
  onAuthorizationFail == null ? void 0 : onAuthorizationFail(error);
604
607
  }
605
608
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/client",
3
- "version": "0.38.11",
3
+ "version": "0.38.12",
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.5",
21
- "@pluv/crdt": "^0.38.11",
22
- "@pluv/types": "^0.38.11"
21
+ "@pluv/crdt": "^0.38.12",
22
+ "@pluv/types": "^0.38.12"
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "^8.57.1",
26
26
  "tsup": "^8.4.0",
27
27
  "typescript": "^5.8.3",
28
- "@pluv/tsconfig": "^0.38.11",
29
- "eslint-config-pluv": "^0.38.11"
28
+ "@pluv/tsconfig": "^0.38.12",
29
+ "eslint-config-pluv": "^0.38.12"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts --format esm,cjs --dts",
@@ -2,7 +2,7 @@ import type { Id, InferIOOutput, IOEventMessage, IOLike } from "@pluv/types";
2
2
  import type { Subject } from "wonka";
3
3
  import { makeSubject, subscribe } from "wonka";
4
4
 
5
- export type EventNotifierSubscriptionCallback<TIO extends IOLike, TEvent extends keyof InferIOOutput<TIO>> = (
5
+ export type EventNotifierSubscriptionCallback<TIO extends IOLike<any, any>, TEvent extends keyof InferIOOutput<TIO>> = (
6
6
  value: Id<IOEventMessage<TIO, TEvent>>,
7
7
  ) => void;
8
8
 
package/src/PluvClient.ts CHANGED
@@ -78,7 +78,7 @@ export class PluvClient<
78
78
  public createRoom = <TEvents extends PluvRouterEventConfig<TIO, TPresence, TStorage> = {}>(
79
79
  room: string,
80
80
  options: CreateRoomOptions<TIO, TPresence, TStorage, TMetadata, TEvents>,
81
- ): PluvRoom<TIO, TMetadata, TPresence, TStorage> => {
81
+ ): PluvRoom<TIO, TMetadata, TPresence, TStorage, TEvents> => {
82
82
  const oldRoom = this.getRoom(room);
83
83
 
84
84
  if (oldRoom) return oldRoom;
package/src/PluvRoom.ts CHANGED
@@ -50,6 +50,14 @@ const RECONNECT_TIMEOUT_MS = 30_000;
50
50
  const ORIGIN_INITIALIZED = "$initialized";
51
51
  const ORIGIN_STORAGE_UPDATED = "$storageUpdated";
52
52
 
53
+ declare global {
54
+ var process: {
55
+ env: {
56
+ [key: string]: string | undefined;
57
+ };
58
+ };
59
+ }
60
+
53
61
  export const DEFAULT_PLUV_CLIENT_ADDON = <
54
62
  TIO extends IOLike = IOLike,
55
63
  TMetadata extends JsonObject = {},
@@ -61,14 +69,6 @@ export const DEFAULT_PLUV_CLIENT_ADDON = <
61
69
  storage: new StorageStore(input.room.id),
62
70
  });
63
71
 
64
- declare global {
65
- var process: {
66
- env: {
67
- [key: string]: string | undefined;
68
- };
69
- };
70
- }
71
-
72
72
  interface WindowListeners {
73
73
  onNavigatorOnline: () => void;
74
74
  onVisibilityChange: () => void;
@@ -237,7 +237,10 @@ export class PluvRoom<
237
237
  this._listeners = {
238
238
  onAuthorizationFail: (error) => {
239
239
  this._clearTimeout(this._timeouts.reconnect);
240
- this._timeouts.reconnect = setTimeout(this._reconnect.bind(this), RECONNECT_TIMEOUT_MS);
240
+ this._timeouts.reconnect = setTimeout(
241
+ this._reconnect.bind(this),
242
+ RECONNECT_TIMEOUT_MS,
243
+ ) as unknown as number;
241
244
 
242
245
  onAuthorizationFail?.(error);
243
246
  },
@@ -312,7 +315,9 @@ export class PluvRoom<
312
315
  event: TEvent,
313
316
  data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>,
314
317
  ) => Promise<void>) & {
315
- [event in keyof InferIOInput<TIO>]: (data: Id<InferIOInput<TIO>[event]>) => Promise<void>;
318
+ [PEvent in keyof InferIOInput<MergeEvents<TEvents, TIO>>]: (
319
+ data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[PEvent]>,
320
+ ) => Promise<void>;
316
321
  };
317
322
 
318
323
  public canRedo = (): boolean => {
@@ -417,8 +422,8 @@ export class PluvRoom<
417
422
  event: TEvent,
418
423
  callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, TEvent>,
419
424
  ) => () => void) & {
420
- [event in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (
421
- callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, any>,
425
+ [PEvent in keyof InferIOOutput<MergeEvents<TEvents, TIO>>]: (
426
+ callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, PEvent>,
422
427
  ) => () => void;
423
428
  };
424
429
 
@@ -954,7 +959,7 @@ export class PluvRoom<
954
959
 
955
960
  private _heartbeat(): void {
956
961
  this._clearTimeout(this._timeouts.pong);
957
- this._timeouts.pong = setTimeout(this._reconnect.bind(this), PONG_TIMEOUT_MS);
962
+ this._timeouts.pong = setTimeout(this._reconnect.bind(this), PONG_TIMEOUT_MS) as unknown as number;
958
963
 
959
964
  /**
960
965
  * !HACK
@@ -967,7 +972,7 @@ export class PluvRoom<
967
972
 
968
973
  private _logDebug(...data: any[]): void {
969
974
  // eslint-disable-next-line turbo/no-undeclared-env-vars
970
- if (process?.env?.NODE_ENV === "production") return;
975
+ if ((process as unknown as any)?.env?.NODE_ENV === "production") return;
971
976
 
972
977
  this._debug && console.log(...data);
973
978
  }
@@ -1108,7 +1113,7 @@ export class PluvRoom<
1108
1113
  });
1109
1114
 
1110
1115
  this._clearInterval(this._intervals.heartbeat);
1111
- this._intervals.heartbeat = setInterval(this._heartbeat.bind(this), HEARTBEAT_INTERVAL_MS);
1116
+ this._intervals.heartbeat = setInterval(this._heartbeat.bind(this), HEARTBEAT_INTERVAL_MS) as unknown as number;
1112
1117
  }
1113
1118
 
1114
1119
  private async _onNavigatorOnline(): Promise<void> {