@pluv/client 0.1.3 → 0.2.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,5 +1,5 @@
1
1
 
2
- > @pluv/client@0.1.3 build /home/runner/work/pluv/pluv/packages/client
2
+ > @pluv/client@0.2.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
@@ -8,10 +8,10 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 29.33 KB
12
- ESM ⚡️ Build success in 95ms
13
- CJS dist/index.js 30.41 KB
14
- CJS ⚡️ Build success in 96ms
11
+ ESM dist/index.mjs 29.38 KB
12
+ ESM ⚡️ Build success in 86ms
13
+ CJS dist/index.js 30.46 KB
14
+ CJS ⚡️ Build success in 98ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 3487ms
17
- DTS dist/index.d.ts 8.23 KB
16
+ DTS ⚡️ Build success in 2621ms
17
+ DTS dist/index.d.ts 8.26 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pluv/client
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 95b5ef8: breaking: update PluvRoom.broadcast api
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [6858682]
12
+ - @pluv/crdt-yjs@0.2.0
13
+ - @pluv/types@0.1.2
14
+
3
15
  ## 0.1.3
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -26,7 +26,9 @@
26
26
  <img src="https://img.shields.io/badge/docs-coming%20soon!-blue" alt="Docs coming soon!" />
27
27
  </p>
28
28
 
29
- <img src="https://github.com/pluv-io/pluv/blob/master/assets/demo-events.gif?raw=true" alt="Demo" />
29
+ <p align="center">
30
+ <img src="https://github.com/pluv-io/pluv/blob/master/assets/demo-events.gif?raw=true" alt="Demo" />
31
+ </p>
30
32
 
31
33
  ## `@pluv/client`
32
34
 
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { InferYjsSharedTypeJson, array, map, text, unstable__object } from '@pluv/crdt-yjs';
2
2
  export { InferYjsSharedTypeJson } from '@pluv/crdt-yjs';
3
3
  import * as _pluv_types from '@pluv/types';
4
- import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, InferIOAuthorizeUser, InferIOAuthorize, InputZodLike, InferIOInput, InferEventMessage, InferIOAuthorizeRequired } from '@pluv/types';
4
+ import { IOLike, InferIOOutput, Id, IOEventMessage, JsonObject, InferIOAuthorizeUser, InferIOAuthorize, InputZodLike, InferIOInput, InferIOAuthorizeRequired } from '@pluv/types';
5
5
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
6
6
  import { AbstractType } from 'yjs';
7
7
  export { AbstractType } from 'yjs';
@@ -105,10 +105,10 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
105
105
  private _usersManager;
106
106
  constructor(room: string, options: RoomConfig<TIO, TPresence, TStorage>);
107
107
  get webSocket(): WebSocket | null;
108
- broadcast(message: Id<InferEventMessage<InferIOInput<TIO>>>): void;
108
+ broadcast<TEvent extends keyof InferIOInput<TIO>>(event: TEvent, data: Id<InferIOInput<TIO>[TEvent]>): void;
109
109
  connect(): Promise<void>;
110
110
  disconnect(): void;
111
- event: <TEvent extends keyof InferIOOutput<TIO>>(name: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => (() => void);
111
+ event: <TEvent extends keyof InferIOOutput<TIO>>(event: TEvent, callback: EventNotifierSubscriptionCallback<TIO, TEvent>) => (() => void);
112
112
  getConnection(): WebSocketConnection;
113
113
  getMyPresence: () => TPresence | null;
114
114
  getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
package/dist/index.js CHANGED
@@ -298,8 +298,8 @@ var PluvRoom = class {
298
298
  };
299
299
  this._windowListeners = null;
300
300
  this._wsListeners = null;
301
- this.event = (name, callback) => {
302
- return this._eventNotifier.subscribe(name, callback);
301
+ this.event = (event, callback) => {
302
+ return this._eventNotifier.subscribe(event, callback);
303
303
  };
304
304
  this.getMyPresence = () => {
305
305
  var _a, _b;
@@ -362,12 +362,13 @@ var PluvRoom = class {
362
362
  get webSocket() {
363
363
  return this._state.webSocket;
364
364
  }
365
- broadcast(message) {
365
+ broadcast(event, data) {
366
366
  if (!this._state.webSocket)
367
367
  return;
368
368
  if (this._state.connection.state !== "Open" /* Open */)
369
369
  return;
370
- this._sendMessage(message);
370
+ const type = event.toString();
371
+ this._sendMessage({ data, type });
371
372
  }
372
373
  connect() {
373
374
  return __async(this, null, function* () {
package/dist/index.mjs CHANGED
@@ -275,8 +275,8 @@ var PluvRoom = class {
275
275
  };
276
276
  this._windowListeners = null;
277
277
  this._wsListeners = null;
278
- this.event = (name, callback) => {
279
- return this._eventNotifier.subscribe(name, callback);
278
+ this.event = (event, callback) => {
279
+ return this._eventNotifier.subscribe(event, callback);
280
280
  };
281
281
  this.getMyPresence = () => {
282
282
  var _a, _b;
@@ -339,12 +339,13 @@ var PluvRoom = class {
339
339
  get webSocket() {
340
340
  return this._state.webSocket;
341
341
  }
342
- broadcast(message) {
342
+ broadcast(event, data) {
343
343
  if (!this._state.webSocket)
344
344
  return;
345
345
  if (this._state.connection.state !== "Open" /* Open */)
346
346
  return;
347
- this._sendMessage(message);
347
+ const type = event.toString();
348
+ this._sendMessage({ data, type });
348
349
  }
349
350
  connect() {
350
351
  return __async(this, null, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/client",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "@pluv/io frontend client",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "wonka": "^6.1.2",
21
- "@pluv/crdt-yjs": "^0.1.3",
21
+ "@pluv/crdt-yjs": "^0.2.0",
22
22
  "@pluv/types": "^0.1.2"
23
23
  },
24
24
  "peerDependencies": {
@@ -29,7 +29,7 @@
29
29
  "typescript": "^4.9.4",
30
30
  "yjs": "^13.5.44",
31
31
  "@pluv/tsconfig": "^0.1.2",
32
- "eslint-config-pluv": "^0.1.2"
32
+ "eslint-config-pluv": "^0.1.3"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/PluvRoom.ts CHANGED
@@ -201,11 +201,16 @@ export class PluvRoom<
201
201
  return this._state.webSocket;
202
202
  }
203
203
 
204
- public broadcast(message: Id<InferEventMessage<InferIOInput<TIO>>>): void {
204
+ public broadcast<TEvent extends keyof InferIOInput<TIO>>(
205
+ event: TEvent,
206
+ data: Id<InferIOInput<TIO>[TEvent]>
207
+ ): void {
205
208
  if (!this._state.webSocket) return;
206
209
  if (this._state.connection.state !== ConnectionState.Open) return;
207
210
 
208
- this._sendMessage(message);
211
+ const type = event.toString();
212
+
213
+ this._sendMessage({ data, type });
209
214
  }
210
215
 
211
216
  public async connect(): Promise<void> {
@@ -291,10 +296,10 @@ export class PluvRoom<
291
296
  }
292
297
 
293
298
  public event = <TEvent extends keyof InferIOOutput<TIO>>(
294
- name: TEvent,
299
+ event: TEvent,
295
300
  callback: EventNotifierSubscriptionCallback<TIO, TEvent>
296
301
  ): (() => void) => {
297
- return this._eventNotifier.subscribe(name, callback);
302
+ return this._eventNotifier.subscribe(event, callback);
298
303
  };
299
304
 
300
305
  public getConnection(): WebSocketConnection {