@pluv/io 0.2.2 → 0.2.4

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,17 +1,17 @@
1
1
 
2
- > @pluv/io@0.2.2 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@0.2.4 build /home/runner/work/pluv/pluv/packages/io
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 v6.5.0
7
+ CLI tsup v6.6.3
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
- ESM dist/index.mjs 26.79 KB
12
- ESM ⚡️ Build success in 104ms
13
- CJS dist/index.js 28.59 KB
14
- CJS ⚡️ Build success in 106ms
11
+ CJS dist/index.js 29.22 KB
12
+ CJS ⚡️ Build success in 97ms
13
+ ESM dist/index.mjs 27.14 KB
14
+ ESM ⚡️ Build success in 99ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 2852ms
16
+ DTS ⚡️ Build success in 2738ms
17
17
  DTS dist/index.d.ts 12.86 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 0.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 8bf62cb: bumped dependencies
8
+ - 7e52685: Bumped dependencies
9
+ - 3b7b17a: docs: corrected readme typos
10
+ - b1cb325: Updated dependencies
11
+ - 8e97fb2: Updated dependencies
12
+ - Updated dependencies [8bf62cb]
13
+ - Updated dependencies [7e52685]
14
+ - Updated dependencies [b1cb325]
15
+ - Updated dependencies [327a6ef]
16
+ - Updated dependencies [8e97fb2]
17
+ - @pluv/crdt-yjs@0.3.0
18
+ - @pluv/types@0.1.3
19
+
20
+ ## 0.2.3
21
+
22
+ ### Patch Changes
23
+
24
+ - 95b5ef8: breaking: update PluvRoom.broadcast api
25
+ - e23fbbe: update demo gif in README
26
+ - Updated dependencies [6858682]
27
+ - @pluv/crdt-yjs@0.2.0
28
+ - @pluv/types@0.1.2
29
+
3
30
  ## 0.2.2
4
31
 
5
32
  ### Patch Changes
package/README.md CHANGED
@@ -19,13 +19,19 @@
19
19
  <a href="https://github.com/pluv-io/pluv/blob/master/LICENSE">
20
20
  <img alt="GitHub" src="https://img.shields.io/github/license/pluv-io/pluv" alt="License MIT" />
21
21
  </a>
22
- <img src="https://badgen.net/badge/-/TypeScript?icon=typescript&label&labelColor=blue&color=555555" alt="TypeScript">
23
22
  <a href="https://commitizen.github.io/cz-cli/">
24
23
  <img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="Commitizen friendly" />
25
24
  </a>
26
25
  <img src="https://img.shields.io/badge/website-coming%20soon!-blue" alt="Website coming soon!" />
27
26
  </p>
28
27
 
28
+ <p align="center">
29
+ <img src="https://badgen.net/badge/-/TypeScript?icon=typescript&label&labelColor=blue&color=555555" alt="TypeScript">
30
+ <a href="https://openbase.com/js/@pluv/io?utm_source=embedded&amp;utm_medium=badge&amp;utm_campaign=rate-badge">
31
+ <img src="https://badges.openbase.com/js/featured/@pluv/io.svg?token=FdWfpo90mCUb7InAjDG0KeXM/uH+KdHK3us2pNRgWf0=" alt="Featured on Openbase" />
32
+ </a>
33
+ </p>
34
+
29
35
  <p align="center">
30
36
  <a href="#intro">Intro</a> •
31
37
  <a href="#usage">Usage</a> •
@@ -34,31 +40,32 @@
34
40
  <a href="#license">License</a>
35
41
  </p>
36
42
 
37
- <img src="https://github.com/pluv-io/pluv/blob/master/assets/demo-events.gif?raw=true" alt="Demo" />
43
+ <p align="center">
44
+ <img src="https://github.com/pluv-io/pluv/blob/master/assets/demo-events.gif?raw=true" alt="Demo" />
45
+ </p>
38
46
 
39
47
  ## Intro
40
48
 
41
- Pluv.IO allows you to build real-time collaborate features with a fully end-to-end type-safe api.
49
+ Pluv.IO allows you to build real-time collaborative features with a fully end-to-end type-safe api.
42
50
 
43
51
  ### Why?
44
52
 
45
53
  So you can do this:
46
54
 
47
55
  ```tsx
56
+ const broadcast = usePluvBroadcast();
57
+
48
58
  usePluvEvent("RECEIVE_MESSAGE", ({ data }) => {
49
59
  setMessages([...messages, data.message]);
50
60
  });
51
61
 
52
- usePluvBroadcast({
53
- type: "SEND_MESSAGE",
54
- data: { message: "Hello world!" },
55
- });
62
+ broadcast("SEND_MESSAGE", { message: "Hello world!" });
56
63
  ```
57
64
 
58
65
  And this:
59
66
 
60
67
  ```tsx
61
- const [myCursor, updatePresence] = usePluvMyPresence((me) => me.presence.cursor);
68
+ const [myCursor, updatePresence] = usePluvMyPresence((me) => me.cursor);
62
69
  const cursors = usePluvOthers((others) => {
63
70
  return others.map((other) => other.presence.cursor);
64
71
  });
@@ -116,9 +123,9 @@ And more. With **E2E type-safety**, **great intellisense** and the **[yjs](https
116
123
  - ✅ [Map](https://docs.yjs.dev/api/shared-types/y.map)
117
124
  - ✅ [Array](https://docs.yjs.dev/api/shared-types/y.array)
118
125
  - ✅ [Text](https://docs.yjs.dev/api/shared-types/y.text)
119
- - ⬜ [XmlFragment](https://docs.yjs.dev/api/shared-types/y.xmlfragment)
120
- - ⬜ [XmlElement](https://docs.yjs.dev/api/shared-types/y.xmlelement)
121
- - ⬜ [XmlText](https://docs.yjs.dev/api/shared-types/y.xmltext)
126
+ - ✅ [XmlFragment](https://docs.yjs.dev/api/shared-types/y.xmlfragment)
127
+ - ✅ [XmlElement](https://docs.yjs.dev/api/shared-types/y.xmlelement)
128
+ - ✅ [XmlText](https://docs.yjs.dev/api/shared-types/y.xmltext)
122
129
  - ⬜ Studio (admin & developer panel)
123
130
 
124
131
  ### Runtimes
package/dist/index.js CHANGED
@@ -47,6 +47,10 @@ var __copyProps = (to, from, except, desc) => {
47
47
  return to;
48
48
  };
49
49
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
50
54
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
51
55
  mod
52
56
  ));
@@ -160,8 +164,11 @@ var PubSub = class extends AbstractPubSub {
160
164
  constructor() {
161
165
  super(...arguments);
162
166
  this._currentSubscriptionId = 0;
167
+ // Map of roomName to subjects
163
168
  this._subjects = /* @__PURE__ */ new Map();
169
+ // Map of roomName to subscription ids
164
170
  this._subscriptionsRefs = /* @__PURE__ */ new Map();
171
+ // Map of
165
172
  this._unsubscriptions = /* @__PURE__ */ new Map();
166
173
  }
167
174
  publish(roomName, payload) {
@@ -219,9 +226,13 @@ var AbstractPlatform = class {
219
226
  // src/AbstractWebSocket.ts
220
227
  var AbstractWebSocket = class {
221
228
  constructor(config) {
229
+ /** The connection is not yet open. */
222
230
  this.CONNECTING = 0;
231
+ /** The connection is open and ready to communicate. */
223
232
  this.OPEN = 1;
233
+ /** The connection is in the process of closing. */
224
234
  this.CLOSING = 2;
235
+ /** The connection is closed. */
225
236
  this.CLOSED = 3;
226
237
  const { room } = config;
227
238
  this.room = room;
@@ -356,7 +367,7 @@ var IORoom = class {
356
367
  pluvWs.close(3e3, "WebSocket unauthorized.");
357
368
  return;
358
369
  }
359
- const currentTime = new Date().getTime();
370
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
360
371
  const session = {
361
372
  id: sessionId,
362
373
  presence: null,
@@ -481,7 +492,7 @@ var IORoom = class {
481
492
  _broadcast(params) {
482
493
  var _a;
483
494
  const { message, senderId } = params;
484
- const currentTime = new Date().getTime();
495
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
485
496
  const sender = senderId ? this._sessions.get(senderId) : null;
486
497
  const quitters = Array.from(this._sessions.values()).filter(
487
498
  (session) => session.quit || currentTime - session.timers.ping > PING_TIMEOUT_MS
@@ -577,7 +588,7 @@ var IORoom = class {
577
588
  });
578
589
  }
579
590
  _getSessionsSize() {
580
- const currentTime = new Date().getTime();
591
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
581
592
  return Array.from(this._sessions.values()).reduce((count, session) => {
582
593
  if (session.quit)
583
594
  return count;
@@ -741,7 +752,7 @@ var PluvIO = class {
741
752
  resolver: (data, { session }) => {
742
753
  if (!session)
743
754
  return {};
744
- const currentTime = new Date().getTime();
755
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
745
756
  session.timers.ping = currentTime;
746
757
  return { $PONG: {} };
747
758
  },
package/dist/index.mjs CHANGED
@@ -127,8 +127,11 @@ var PubSub = class extends AbstractPubSub {
127
127
  constructor() {
128
128
  super(...arguments);
129
129
  this._currentSubscriptionId = 0;
130
+ // Map of roomName to subjects
130
131
  this._subjects = /* @__PURE__ */ new Map();
132
+ // Map of roomName to subscription ids
131
133
  this._subscriptionsRefs = /* @__PURE__ */ new Map();
134
+ // Map of
132
135
  this._unsubscriptions = /* @__PURE__ */ new Map();
133
136
  }
134
137
  publish(roomName, payload) {
@@ -186,9 +189,13 @@ var AbstractPlatform = class {
186
189
  // src/AbstractWebSocket.ts
187
190
  var AbstractWebSocket = class {
188
191
  constructor(config) {
192
+ /** The connection is not yet open. */
189
193
  this.CONNECTING = 0;
194
+ /** The connection is open and ready to communicate. */
190
195
  this.OPEN = 1;
196
+ /** The connection is in the process of closing. */
191
197
  this.CLOSING = 2;
198
+ /** The connection is closed. */
192
199
  this.CLOSED = 3;
193
200
  const { room } = config;
194
201
  this.room = room;
@@ -323,7 +330,7 @@ var IORoom = class {
323
330
  pluvWs.close(3e3, "WebSocket unauthorized.");
324
331
  return;
325
332
  }
326
- const currentTime = new Date().getTime();
333
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
327
334
  const session = {
328
335
  id: sessionId,
329
336
  presence: null,
@@ -448,7 +455,7 @@ var IORoom = class {
448
455
  _broadcast(params) {
449
456
  var _a;
450
457
  const { message, senderId } = params;
451
- const currentTime = new Date().getTime();
458
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
452
459
  const sender = senderId ? this._sessions.get(senderId) : null;
453
460
  const quitters = Array.from(this._sessions.values()).filter(
454
461
  (session) => session.quit || currentTime - session.timers.ping > PING_TIMEOUT_MS
@@ -544,7 +551,7 @@ var IORoom = class {
544
551
  });
545
552
  }
546
553
  _getSessionsSize() {
547
- const currentTime = new Date().getTime();
554
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
548
555
  return Array.from(this._sessions.values()).reduce((count, session) => {
549
556
  if (session.quit)
550
557
  return count;
@@ -708,7 +715,7 @@ var PluvIO = class {
708
715
  resolver: (data, { session }) => {
709
716
  if (!session)
710
717
  return {};
711
- const currentTime = new Date().getTime();
718
+ const currentTime = (/* @__PURE__ */ new Date()).getTime();
712
719
  session.timers.ping = currentTime;
713
720
  return { $PONG: {} };
714
721
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "@pluv/io server-side websocket manager",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -17,22 +17,22 @@
17
17
  "access": "public"
18
18
  },
19
19
  "dependencies": {
20
- "@panva/hkdf": "^1.0.2",
20
+ "@panva/hkdf": "^1.0.4",
21
21
  "chalk": "^4.1.2",
22
- "jose": "^4.11.2",
23
- "wonka": "^6.1.2",
24
- "@pluv/crdt-yjs": "^0.1.3",
25
- "@pluv/types": "^0.1.2"
22
+ "jose": "^4.13.1",
23
+ "wonka": "^6.2.3",
24
+ "@pluv/crdt-yjs": "^0.3.0",
25
+ "@pluv/types": "^0.1.3"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "yjs": "^13.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "tsup": "^6.5.0",
32
- "typescript": "^4.9.4",
33
- "yjs": "^13.5.44",
34
- "@pluv/tsconfig": "^0.1.2",
35
- "eslint-config-pluv": "^0.1.2"
31
+ "tsup": "^6.6.3",
32
+ "typescript": "^4.9.5",
33
+ "yjs": "^13.5.49",
34
+ "@pluv/tsconfig": "^0.1.3",
35
+ "eslint-config-pluv": "^0.1.4"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsup src/index.ts --format esm,cjs --dts",