@pluv/react 3.1.5 → 3.1.7

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/react@3.1.5 build /home/runner/work/pluv/pluv/packages/react
2
+ > @pluv/react@3.1.7 build /home/runner/work/pluv/pluv/packages/react
3
3
  > tsup src/index.ts --format esm,cjs --dts --external react
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
- CJS dist/index.js 19.63 KB
12
- CJS ⚡️ Build success in 107ms
13
- ESM dist/index.mjs 17.24 KB
14
- ESM ⚡️ Build success in 107ms
11
+ ESM dist/index.mjs 17.22 KB
12
+ ESM ⚡️ Build success in 122ms
13
+ CJS dist/index.js 19.62 KB
14
+ CJS ⚡️ Build success in 125ms
15
15
  DTS Build start
16
- DTS ⚡️ Build success in 6174ms
16
+ DTS ⚡️ Build success in 6092ms
17
17
  DTS dist/index.d.mts 6.00 KB
18
18
  DTS dist/index.d.ts 6.00 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @pluv/react
2
2
 
3
+ ## 3.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - @pluv/client@3.1.7
8
+ - @pluv/crdt@3.1.7
9
+ - @pluv/types@3.1.7
10
+
11
+ ## 3.1.6
12
+
13
+ ### Patch Changes
14
+
15
+ - fd8d314: Fix creating excessive storage subscriptions.
16
+ - @pluv/client@3.1.6
17
+ - @pluv/crdt@3.1.6
18
+ - @pluv/types@3.1.6
19
+
3
20
  ## 3.1.5
4
21
 
5
22
  ### Patch Changes
package/dist/index.js CHANGED
@@ -234,7 +234,7 @@ var createBundle = (client, options = {}) => {
234
234
  return new import_client.MockedRoom(_room, {
235
235
  events,
236
236
  initialPresence,
237
- initialStorage: typeof initialStorage === "function" ? (_a = client._defs.initialStorage) == null ? void 0 : _a.getFactory(initialStorage) : client._defs.initialStorage
237
+ initialStorage: typeof initialStorage === "function" ? (_a = client._defs.initialStorage) == null ? void 0 : _a.getFactory(initialStorage) : void 0
238
238
  });
239
239
  });
240
240
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MockedRoomContext.Provider, { value: room, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PluvRoomContext.Provider, { value: room, children }) });
@@ -383,9 +383,7 @@ var createBundle = (client, options = {}) => {
383
383
  var _a;
384
384
  const room = useRoom();
385
385
  const subscribe = (0, import_react6.useCallback)(
386
- (onStoreChange) => {
387
- return room.subscribe.connection(onStoreChange);
388
- },
386
+ (onStoreChange) => room.subscribe.connection(onStoreChange),
389
387
  [room]
390
388
  );
391
389
  const getSnapshot = room.getConnection;
@@ -404,9 +402,7 @@ var createBundle = (client, options = {}) => {
404
402
  const useDoc = () => {
405
403
  const room = useRoom();
406
404
  const subscribe = (0, import_react6.useCallback)(
407
- (onStoreChange) => {
408
- return room.subscribe.storageLoaded(onStoreChange);
409
- },
405
+ (onStoreChange) => room.subscribe.storageLoaded(onStoreChange),
410
406
  [room]
411
407
  );
412
408
  const getSnapshot = room.getDoc;
@@ -439,9 +435,7 @@ var createBundle = (client, options = {}) => {
439
435
  var _a;
440
436
  const room = useRoom();
441
437
  const subscribe = (0, import_react6.useCallback)(
442
- (onStoreChange) => {
443
- return room.subscribe.myPresence(onStoreChange);
444
- },
438
+ (onStoreChange) => room.subscribe.myPresence(onStoreChange),
445
439
  [room]
446
440
  );
447
441
  const getSnapshot = room.getMyPresence;
@@ -462,9 +456,7 @@ var createBundle = (client, options = {}) => {
462
456
  var _a;
463
457
  const room = useRoom();
464
458
  const subscribe = (0, import_react6.useCallback)(
465
- (onStoreChange) => {
466
- return room.subscribe.myself(onStoreChange);
467
- },
459
+ (onStoreChange) => room.subscribe.myself(onStoreChange),
468
460
  [room]
469
461
  );
470
462
  const getSnapshot = room.getMyself;
@@ -508,9 +500,7 @@ var createBundle = (client, options = {}) => {
508
500
  var _a;
509
501
  const room = useRoom();
510
502
  const subscribe = (0, import_react6.useCallback)(
511
- (onStoreChange) => {
512
- return room.subscribe.others(onStoreChange);
513
- },
503
+ (onStoreChange) => room.subscribe.others(onStoreChange),
514
504
  [room]
515
505
  );
516
506
  const getSnapshot = room.getOthers;
@@ -535,9 +525,14 @@ var createBundle = (client, options = {}) => {
535
525
  var _a, _b;
536
526
  const room = useRoom();
537
527
  const rerender = useRerender();
538
- room.subscribe.storageLoaded(() => {
539
- rerender();
540
- });
528
+ (0, import_react6.useEffect)(() => {
529
+ const unsubscribe = room.subscribe.storageLoaded(() => {
530
+ rerender();
531
+ });
532
+ return () => {
533
+ unsubscribe();
534
+ };
535
+ }, [rerender, room]);
541
536
  const subscribe = (0, import_react6.useCallback)(
542
537
  (onStoreChange) => room.subscribe.storage(key, onStoreChange),
543
538
  [key, room]
package/dist/index.mjs CHANGED
@@ -210,7 +210,7 @@ var createBundle = (client, options = {}) => {
210
210
  return new MockedRoom(_room, {
211
211
  events,
212
212
  initialPresence,
213
- initialStorage: typeof initialStorage === "function" ? (_a = client._defs.initialStorage) == null ? void 0 : _a.getFactory(initialStorage) : client._defs.initialStorage
213
+ initialStorage: typeof initialStorage === "function" ? (_a = client._defs.initialStorage) == null ? void 0 : _a.getFactory(initialStorage) : void 0
214
214
  });
215
215
  });
216
216
  return /* @__PURE__ */ jsx(MockedRoomContext.Provider, { value: room, children: /* @__PURE__ */ jsx(PluvRoomContext.Provider, { value: room, children }) });
@@ -359,9 +359,7 @@ var createBundle = (client, options = {}) => {
359
359
  var _a;
360
360
  const room = useRoom();
361
361
  const subscribe = useCallback4(
362
- (onStoreChange) => {
363
- return room.subscribe.connection(onStoreChange);
364
- },
362
+ (onStoreChange) => room.subscribe.connection(onStoreChange),
365
363
  [room]
366
364
  );
367
365
  const getSnapshot = room.getConnection;
@@ -380,9 +378,7 @@ var createBundle = (client, options = {}) => {
380
378
  const useDoc = () => {
381
379
  const room = useRoom();
382
380
  const subscribe = useCallback4(
383
- (onStoreChange) => {
384
- return room.subscribe.storageLoaded(onStoreChange);
385
- },
381
+ (onStoreChange) => room.subscribe.storageLoaded(onStoreChange),
386
382
  [room]
387
383
  );
388
384
  const getSnapshot = room.getDoc;
@@ -415,9 +411,7 @@ var createBundle = (client, options = {}) => {
415
411
  var _a;
416
412
  const room = useRoom();
417
413
  const subscribe = useCallback4(
418
- (onStoreChange) => {
419
- return room.subscribe.myPresence(onStoreChange);
420
- },
414
+ (onStoreChange) => room.subscribe.myPresence(onStoreChange),
421
415
  [room]
422
416
  );
423
417
  const getSnapshot = room.getMyPresence;
@@ -438,9 +432,7 @@ var createBundle = (client, options = {}) => {
438
432
  var _a;
439
433
  const room = useRoom();
440
434
  const subscribe = useCallback4(
441
- (onStoreChange) => {
442
- return room.subscribe.myself(onStoreChange);
443
- },
435
+ (onStoreChange) => room.subscribe.myself(onStoreChange),
444
436
  [room]
445
437
  );
446
438
  const getSnapshot = room.getMyself;
@@ -484,9 +476,7 @@ var createBundle = (client, options = {}) => {
484
476
  var _a;
485
477
  const room = useRoom();
486
478
  const subscribe = useCallback4(
487
- (onStoreChange) => {
488
- return room.subscribe.others(onStoreChange);
489
- },
479
+ (onStoreChange) => room.subscribe.others(onStoreChange),
490
480
  [room]
491
481
  );
492
482
  const getSnapshot = room.getOthers;
@@ -511,9 +501,14 @@ var createBundle = (client, options = {}) => {
511
501
  var _a, _b;
512
502
  const room = useRoom();
513
503
  const rerender = useRerender();
514
- room.subscribe.storageLoaded(() => {
515
- rerender();
516
- });
504
+ useEffect3(() => {
505
+ const unsubscribe = room.subscribe.storageLoaded(() => {
506
+ rerender();
507
+ });
508
+ return () => {
509
+ unsubscribe();
510
+ };
511
+ }, [rerender, room]);
517
512
  const subscribe = useCallback4(
518
513
  (onStoreChange) => room.subscribe.storage(key, onStoreChange),
519
514
  [key, room]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/react",
3
- "version": "3.1.5",
3
+ "version": "3.1.7",
4
4
  "description": "@pluv/client React.js bindings",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,9 +18,9 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "fast-deep-equal": "^3.1.3",
21
- "@pluv/client": "^3.1.5",
22
- "@pluv/crdt": "^3.1.5",
23
- "@pluv/types": "^3.1.5"
21
+ "@pluv/client": "^3.1.7",
22
+ "@pluv/crdt": "^3.1.7",
23
+ "@pluv/types": "^3.1.7"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@types/react": "^18.0.0 || ^19.0.0",
@@ -32,8 +32,8 @@
32
32
  "react": "^19.1.0",
33
33
  "tsup": "^8.5.0",
34
34
  "typescript": "^5.8.3",
35
- "@pluv/tsconfig": "^3.1.5",
36
- "eslint-config-pluv": "^3.1.5"
35
+ "@pluv/tsconfig": "^3.1.7",
36
+ "eslint-config-pluv": "^3.1.7"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsup src/index.ts --format esm,cjs --dts --external react",
@@ -110,7 +110,7 @@ export const createBundle = <
110
110
  initialStorage:
111
111
  typeof initialStorage === "function"
112
112
  ? (client._defs.initialStorage?.getFactory(initialStorage) as TCrdt)
113
- : client._defs.initialStorage,
113
+ : undefined,
114
114
  });
115
115
  });
116
116
 
@@ -329,9 +329,7 @@ export const createBundle = <
329
329
  const room = useRoom();
330
330
 
331
331
  const subscribe = useCallback(
332
- (onStoreChange: () => void) => {
333
- return room.subscribe.connection(onStoreChange);
334
- },
332
+ (onStoreChange: () => void) => room.subscribe.connection(onStoreChange),
335
333
  [room],
336
334
  );
337
335
 
@@ -355,9 +353,7 @@ export const createBundle = <
355
353
  const room = useRoom();
356
354
 
357
355
  const subscribe = useCallback(
358
- (onStoreChange: () => void) => {
359
- return room.subscribe.storageLoaded(onStoreChange);
360
- },
356
+ (onStoreChange: () => void) => room.subscribe.storageLoaded(onStoreChange),
361
357
  [room],
362
358
  );
363
359
 
@@ -413,9 +409,7 @@ export const createBundle = <
413
409
  const room = useRoom();
414
410
 
415
411
  const subscribe = useCallback(
416
- (onStoreChange: () => void) => {
417
- return room.subscribe.myPresence(onStoreChange);
418
- },
412
+ (onStoreChange: () => void) => room.subscribe.myPresence(onStoreChange),
419
413
  [room],
420
414
  );
421
415
 
@@ -444,9 +438,7 @@ export const createBundle = <
444
438
  const room = useRoom();
445
439
 
446
440
  const subscribe = useCallback(
447
- (onStoreChange: () => void) => {
448
- return room.subscribe.myself(onStoreChange);
449
- },
441
+ (onStoreChange: () => void) => room.subscribe.myself(onStoreChange),
450
442
  [room],
451
443
  );
452
444
 
@@ -505,9 +497,7 @@ export const createBundle = <
505
497
  const room = useRoom();
506
498
 
507
499
  const subscribe = useCallback(
508
- (onStoreChange: () => void) => {
509
- return room.subscribe.others(onStoreChange);
510
- },
500
+ (onStoreChange: () => void) => room.subscribe.others(onStoreChange),
511
501
  [room],
512
502
  );
513
503
 
@@ -554,9 +544,15 @@ export const createBundle = <
554
544
  const room = useRoom();
555
545
  const rerender = useRerender();
556
546
 
557
- room.subscribe.storageLoaded(() => {
558
- rerender();
559
- });
547
+ useEffect(() => {
548
+ const unsubscribe = room.subscribe.storageLoaded(() => {
549
+ rerender();
550
+ });
551
+
552
+ return () => {
553
+ unsubscribe();
554
+ };
555
+ }, [rerender, room]);
560
556
 
561
557
  const subscribe = useCallback(
562
558
  (onStoreChange: () => void) => room.subscribe.storage(key, onStoreChange),