@liveblocks/react 2.14.0-v2encoding → 2.15.0-debug1
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.
- package/dist/_private.d.mts +10 -4
- package/dist/_private.d.ts +10 -4
- package/dist/_private.js +16 -12
- package/dist/_private.js.map +1 -1
- package/dist/_private.mjs +12 -8
- package/dist/_private.mjs.map +1 -1
- package/dist/chunk-A4ABDZ5E.mjs +23 -0
- package/dist/chunk-A4ABDZ5E.mjs.map +1 -0
- package/dist/{chunk-7ZCTUIE6.js → chunk-KY7WMVMG.js} +464 -321
- package/dist/chunk-KY7WMVMG.js.map +1 -0
- package/dist/chunk-MI7M3UBZ.js +23 -0
- package/dist/chunk-MI7M3UBZ.js.map +1 -0
- package/dist/{chunk-BYPL4Y26.mjs → chunk-UJLD6FYC.mjs} +477 -334
- package/dist/chunk-UJLD6FYC.mjs.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.mjs +2 -2
- package/dist/{room-gbqt3lTY.d.mts → room-C_NzlTZP.d.mts} +56 -51
- package/dist/{room-gbqt3lTY.d.ts → room-C_NzlTZP.d.ts} +56 -51
- package/dist/suspense.d.mts +2 -1
- package/dist/suspense.d.ts +2 -1
- package/dist/suspense.js +4 -4
- package/dist/suspense.mjs +2 -2
- package/package.json +4 -6
- package/dist/chunk-7ZCTUIE6.js.map +0 -1
- package/dist/chunk-BYPL4Y26.mjs.map +0 -1
- package/dist/chunk-CAMSPWNT.mjs +0 -22
- package/dist/chunk-CAMSPWNT.mjs.map +0 -1
- package/dist/chunk-FPO6VPFA.js +0 -22
- package/dist/chunk-FPO6VPFA.js.map +0 -1
|
@@ -1,14 +1,90 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
2
|
-
var _react = require('react');
|
|
3
|
-
var RoomContext =
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/contexts.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
var RoomContext = _react.createContext.call(void 0, null);
|
|
4
4
|
function useRoomOrNull() {
|
|
5
|
-
return
|
|
5
|
+
return _react.useContext.call(void 0, RoomContext);
|
|
6
6
|
}
|
|
7
7
|
function useIsInsideRoom() {
|
|
8
8
|
const room = useRoomOrNull();
|
|
9
9
|
return room !== null;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// src/use-sync-external-store-with-selector.ts
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function is(x, y) {
|
|
21
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
22
|
+
}
|
|
23
|
+
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
24
|
+
const instRef = _react.useRef.call(void 0, null);
|
|
25
|
+
let inst;
|
|
26
|
+
if (instRef.current === null) {
|
|
27
|
+
inst = {
|
|
28
|
+
hasValue: false,
|
|
29
|
+
value: null
|
|
30
|
+
};
|
|
31
|
+
instRef.current = inst;
|
|
32
|
+
} else {
|
|
33
|
+
inst = instRef.current;
|
|
34
|
+
}
|
|
35
|
+
const [getSelection, getServerSelection] = _react.useMemo.call(void 0, () => {
|
|
36
|
+
let hasMemo = false;
|
|
37
|
+
let memoizedSnapshot;
|
|
38
|
+
let memoizedSelection;
|
|
39
|
+
const memoizedSelector = (nextSnapshot) => {
|
|
40
|
+
if (!hasMemo) {
|
|
41
|
+
hasMemo = true;
|
|
42
|
+
memoizedSnapshot = nextSnapshot;
|
|
43
|
+
const nextSelection2 = selector(nextSnapshot);
|
|
44
|
+
if (isEqual !== void 0) {
|
|
45
|
+
if (inst.hasValue) {
|
|
46
|
+
const currentSelection = inst.value;
|
|
47
|
+
if (isEqual(currentSelection, nextSelection2)) {
|
|
48
|
+
memoizedSelection = currentSelection;
|
|
49
|
+
return currentSelection;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
memoizedSelection = nextSelection2;
|
|
54
|
+
return nextSelection2;
|
|
55
|
+
}
|
|
56
|
+
const prevSnapshot = memoizedSnapshot;
|
|
57
|
+
const prevSelection = memoizedSelection;
|
|
58
|
+
if (is(prevSnapshot, nextSnapshot)) {
|
|
59
|
+
return prevSelection;
|
|
60
|
+
}
|
|
61
|
+
const nextSelection = selector(nextSnapshot);
|
|
62
|
+
if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
|
|
63
|
+
memoizedSnapshot = nextSnapshot;
|
|
64
|
+
return prevSelection;
|
|
65
|
+
}
|
|
66
|
+
memoizedSnapshot = nextSnapshot;
|
|
67
|
+
memoizedSelection = nextSelection;
|
|
68
|
+
return nextSelection;
|
|
69
|
+
};
|
|
70
|
+
const maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
|
|
71
|
+
const getSnapshotWithSelector = () => memoizedSelector(getSnapshot());
|
|
72
|
+
const getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : () => memoizedSelector(maybeGetServerSnapshot());
|
|
73
|
+
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
74
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]);
|
|
75
|
+
const value = _react.useSyncExternalStore.call(void 0,
|
|
76
|
+
subscribe,
|
|
77
|
+
getSelection,
|
|
78
|
+
getServerSelection
|
|
79
|
+
);
|
|
80
|
+
_react.useEffect.call(void 0, () => {
|
|
81
|
+
inst.hasValue = true;
|
|
82
|
+
inst.value = value;
|
|
83
|
+
}, [value]);
|
|
84
|
+
_react.useDebugValue.call(void 0, value);
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
|
|
12
88
|
// src/liveblocks.tsx
|
|
13
89
|
|
|
14
90
|
|
|
@@ -25,8 +101,8 @@ var _core = require('@liveblocks/core');
|
|
|
25
101
|
|
|
26
102
|
|
|
27
103
|
|
|
28
|
-
|
|
29
|
-
|
|
104
|
+
|
|
105
|
+
|
|
30
106
|
|
|
31
107
|
// src/config.ts
|
|
32
108
|
var SECONDS = 1e3;
|
|
@@ -132,6 +208,8 @@ var use = (
|
|
|
132
208
|
|
|
133
209
|
|
|
134
210
|
|
|
211
|
+
|
|
212
|
+
|
|
135
213
|
// src/lib/autobind.ts
|
|
136
214
|
function autobind(self) {
|
|
137
215
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -205,8 +283,8 @@ var ThreadDB = class _ThreadDB {
|
|
|
205
283
|
#byId;
|
|
206
284
|
#asc;
|
|
207
285
|
#desc;
|
|
208
|
-
|
|
209
|
-
|
|
286
|
+
// This signal will be notified on every mutation
|
|
287
|
+
|
|
210
288
|
constructor() {
|
|
211
289
|
this.#asc = _core.SortedList.from([], (t1, t2) => {
|
|
212
290
|
const d1 = t1.createdAt;
|
|
@@ -219,7 +297,7 @@ var ThreadDB = class _ThreadDB {
|
|
|
219
297
|
return d2 < d1 ? true : d2 === d1 ? t2.id < t1.id : false;
|
|
220
298
|
});
|
|
221
299
|
this.#byId = /* @__PURE__ */ new Map();
|
|
222
|
-
this
|
|
300
|
+
this.signal = new (0, _core.MutableSignal)(this);
|
|
223
301
|
}
|
|
224
302
|
//
|
|
225
303
|
// Public APIs
|
|
@@ -229,13 +307,8 @@ var ThreadDB = class _ThreadDB {
|
|
|
229
307
|
newPool.#byId = new Map(this.#byId);
|
|
230
308
|
newPool.#asc = this.#asc.clone();
|
|
231
309
|
newPool.#desc = this.#desc.clone();
|
|
232
|
-
newPool.#version = this.#version;
|
|
233
310
|
return newPool;
|
|
234
311
|
}
|
|
235
|
-
/** Gets the transaction count for this DB. Increments any time the DB is modified. */
|
|
236
|
-
get version() {
|
|
237
|
-
return this.#version;
|
|
238
|
-
}
|
|
239
312
|
/** Returns an existing thread by ID. Will never return a deleted thread. */
|
|
240
313
|
get(threadId) {
|
|
241
314
|
const thread = this.getEvenIfDeleted(threadId);
|
|
@@ -247,20 +320,22 @@ var ThreadDB = class _ThreadDB {
|
|
|
247
320
|
}
|
|
248
321
|
/** Adds or updates a thread in the DB. If the newly given thread is a deleted one, it will get deleted. */
|
|
249
322
|
upsert(thread) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (toRemove
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
323
|
+
this.signal.mutate(() => {
|
|
324
|
+
thread = sanitizeThread(thread);
|
|
325
|
+
const id = thread.id;
|
|
326
|
+
const toRemove = this.#byId.get(id);
|
|
327
|
+
if (toRemove) {
|
|
328
|
+
if (toRemove.deletedAt) return false;
|
|
329
|
+
this.#asc.remove(toRemove);
|
|
330
|
+
this.#desc.remove(toRemove);
|
|
331
|
+
}
|
|
332
|
+
if (!thread.deletedAt) {
|
|
333
|
+
this.#asc.add(thread);
|
|
334
|
+
this.#desc.add(thread);
|
|
335
|
+
}
|
|
336
|
+
this.#byId.set(id, thread);
|
|
337
|
+
return true;
|
|
338
|
+
});
|
|
264
339
|
}
|
|
265
340
|
/** Like .upsert(), except it won't update if a thread by this ID already exists. */
|
|
266
341
|
// TODO Consider renaming this to just .upsert(). I'm not sure if we really
|
|
@@ -301,12 +376,6 @@ var ThreadDB = class _ThreadDB {
|
|
|
301
376
|
crit.push(makeThreadsFilter(query));
|
|
302
377
|
return Array.from(index.filter((t) => crit.every((pred) => pred(t))));
|
|
303
378
|
}
|
|
304
|
-
//
|
|
305
|
-
// Private APIs
|
|
306
|
-
//
|
|
307
|
-
#touch() {
|
|
308
|
-
++this.#version;
|
|
309
|
-
}
|
|
310
379
|
};
|
|
311
380
|
|
|
312
381
|
// src/umbrella-store.ts
|
|
@@ -501,13 +570,50 @@ var SinglePageResource = class {
|
|
|
501
570
|
var UmbrellaStore = class {
|
|
502
571
|
#client;
|
|
503
572
|
#syncSource;
|
|
504
|
-
//
|
|
505
|
-
|
|
573
|
+
//
|
|
574
|
+
// Internally, the UmbrellaStore keeps track of a few source signals that can
|
|
575
|
+
// be set and mutated individually. When any of those are mutated then the
|
|
576
|
+
// clean "external state" is recomputed.
|
|
577
|
+
//
|
|
578
|
+
// Mutate inputs... ...observe clean/consistent output!
|
|
579
|
+
//
|
|
580
|
+
// .-> Base ThreadDB ---------+ +----> Clean threads by ID (Part 1)
|
|
581
|
+
// / | |
|
|
582
|
+
// mutate ----> Base Notifications --+ | | +--> Clean notifications (Part 1)
|
|
583
|
+
// \ | | | | & notifications by ID
|
|
584
|
+
// | \ | | Apply | |
|
|
585
|
+
// | `-> OptimisticUpdates --+--+--> Optimistic --+-+--> Notification Settings (Part 2)
|
|
586
|
+
// \ | Updates |
|
|
587
|
+
// `------- etc etc ---------+ +--> History Versions (Part 3)
|
|
588
|
+
// ^
|
|
589
|
+
// |
|
|
590
|
+
// | ^ ^
|
|
591
|
+
// Signal | |
|
|
592
|
+
// or DerivedSignal DerivedSignals
|
|
593
|
+
// MutableSignal
|
|
594
|
+
//
|
|
595
|
+
//
|
|
596
|
+
// Input signals.
|
|
597
|
+
// (Can be mutated directly.)
|
|
598
|
+
//
|
|
599
|
+
|
|
600
|
+
// Exposes its signal under `.signal` prop
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
//
|
|
607
|
+
// Output signals.
|
|
608
|
+
// (Readonly, clean, consistent. With optimistic updates applied.)
|
|
609
|
+
//
|
|
610
|
+
// Note that the output of threadifications signal is the same as the ones for
|
|
611
|
+
// threads and notifications separately, but the threadifications signal will
|
|
612
|
+
// be updated whenever either of them change.
|
|
613
|
+
//
|
|
614
|
+
// TODO(vincent+nimesh) APIs like getRoomThreadsLoadingState should really also be modeled as output signals.
|
|
615
|
+
//
|
|
506
616
|
|
|
507
|
-
#prevVersion = -1;
|
|
508
|
-
#store;
|
|
509
|
-
#prevState = null;
|
|
510
|
-
#stateCached = null;
|
|
511
617
|
// Notifications
|
|
512
618
|
#notificationsLastRequestedAt = null;
|
|
513
619
|
// Keeps track of when we successfully requested an inbox notifications update for the last time. Will be `null` as long as the first successful fetch hasn't happened yet.
|
|
@@ -543,34 +649,80 @@ var UmbrellaStore = class {
|
|
|
543
649
|
() => (
|
|
544
650
|
// Note that the store itself does not change, but it's only vehicle at
|
|
545
651
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
546
|
-
this
|
|
652
|
+
this.invalidateEntireStore()
|
|
653
|
+
)
|
|
654
|
+
);
|
|
655
|
+
this.baseThreadsDB = new ThreadDB();
|
|
656
|
+
this.optimisticUpdates = new (0, _core.Signal)([]);
|
|
657
|
+
this.baseVersionsByRoomId = new (0, _core.Signal)({});
|
|
658
|
+
this.baseNotificationsById = new (0, _core.Signal)({});
|
|
659
|
+
this.baseSettingsByRoomId = new (0, _core.Signal)({});
|
|
660
|
+
this.permissionHintsByRoomId = new (0, _core.Signal)({});
|
|
661
|
+
const threadifications = _core.DerivedSignal.from(
|
|
662
|
+
this.baseThreadsDB.signal,
|
|
663
|
+
this.baseNotificationsById,
|
|
664
|
+
this.optimisticUpdates,
|
|
665
|
+
(ts, ns, updates) => applyOptimisticUpdates_forThreadifications(ts, ns, updates)
|
|
666
|
+
);
|
|
667
|
+
const threads = _core.DerivedSignal.from(threadifications, (s) => ({
|
|
668
|
+
threadsDB: s.threadsDB
|
|
669
|
+
}));
|
|
670
|
+
const notifications = _core.DerivedSignal.from(threadifications, (s) => ({
|
|
671
|
+
sortedNotifications: s.sortedNotifications,
|
|
672
|
+
notificationsById: s.notificationsById
|
|
673
|
+
}));
|
|
674
|
+
const settingsByRoomId = _core.DerivedSignal.from(
|
|
675
|
+
this.baseSettingsByRoomId,
|
|
676
|
+
this.optimisticUpdates,
|
|
677
|
+
(settings, updates) => applyOptimisticUpdates_forSettings(settings, updates)
|
|
678
|
+
);
|
|
679
|
+
const versionsByRoomId = _core.DerivedSignal.from(
|
|
680
|
+
this.baseVersionsByRoomId,
|
|
681
|
+
(hv) => hv
|
|
682
|
+
);
|
|
683
|
+
this.outputs = {
|
|
684
|
+
threadifications,
|
|
685
|
+
threads,
|
|
686
|
+
notifications,
|
|
687
|
+
settingsByRoomId,
|
|
688
|
+
versionsByRoomId
|
|
689
|
+
};
|
|
690
|
+
this.optimisticUpdates.subscribe(
|
|
691
|
+
() => this.#syncSource.setSyncStatus(
|
|
692
|
+
this.optimisticUpdates.get().length > 0 ? "synchronizing" : "synchronized"
|
|
547
693
|
)
|
|
548
694
|
);
|
|
549
|
-
this._rawThreadsDB = new ThreadDB();
|
|
550
|
-
this.#store = _core.createStore.call(void 0, {
|
|
551
|
-
optimisticUpdates: [],
|
|
552
|
-
permissionsByRoom: {},
|
|
553
|
-
notificationsById: {},
|
|
554
|
-
settingsByRoomId: {},
|
|
555
|
-
versionsByRoomId: {}
|
|
556
|
-
});
|
|
557
695
|
autobind(this);
|
|
558
696
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
697
|
+
get1_both() {
|
|
698
|
+
return this.outputs.threadifications.get();
|
|
699
|
+
}
|
|
700
|
+
subscribe1_both(callback) {
|
|
701
|
+
return this.outputs.threadifications.subscribe(callback);
|
|
702
|
+
}
|
|
703
|
+
get1_threads() {
|
|
704
|
+
return this.outputs.threads.get();
|
|
705
|
+
}
|
|
706
|
+
subscribe1_threads(callback) {
|
|
707
|
+
return this.outputs.threads.subscribe(callback);
|
|
708
|
+
}
|
|
709
|
+
get1_notifications() {
|
|
710
|
+
return this.outputs.notifications.get();
|
|
711
|
+
}
|
|
712
|
+
subscribe1_notifications(callback) {
|
|
713
|
+
return this.outputs.notifications.subscribe(callback);
|
|
568
714
|
}
|
|
569
|
-
|
|
570
|
-
return this
|
|
715
|
+
get2() {
|
|
716
|
+
return this.outputs.settingsByRoomId.get();
|
|
571
717
|
}
|
|
572
|
-
|
|
573
|
-
return this.
|
|
718
|
+
subscribe2(callback) {
|
|
719
|
+
return this.outputs.settingsByRoomId.subscribe(callback);
|
|
720
|
+
}
|
|
721
|
+
get3() {
|
|
722
|
+
return this.outputs.versionsByRoomId.get();
|
|
723
|
+
}
|
|
724
|
+
subscribe3(callback) {
|
|
725
|
+
return this.outputs.versionsByRoomId.subscribe(callback);
|
|
574
726
|
}
|
|
575
727
|
/**
|
|
576
728
|
* Returns the async result of the given query and room id. If the query is success,
|
|
@@ -587,7 +739,7 @@ var UmbrellaStore = class {
|
|
|
587
739
|
if (asyncResult.isLoading || asyncResult.error) {
|
|
588
740
|
return asyncResult;
|
|
589
741
|
}
|
|
590
|
-
const threads = this.
|
|
742
|
+
const threads = this.get1_threads().threadsDB.findMany(
|
|
591
743
|
roomId,
|
|
592
744
|
_nullishCoalesce(query, () => ( {})),
|
|
593
745
|
"asc"
|
|
@@ -612,7 +764,7 @@ var UmbrellaStore = class {
|
|
|
612
764
|
if (asyncResult.isLoading || asyncResult.error) {
|
|
613
765
|
return asyncResult;
|
|
614
766
|
}
|
|
615
|
-
const threads = this.
|
|
767
|
+
const threads = this.get1_threads().threadsDB.findMany(
|
|
616
768
|
void 0,
|
|
617
769
|
// Do _not_ filter by roomId
|
|
618
770
|
_nullishCoalesce(query, () => ( {})),
|
|
@@ -637,7 +789,7 @@ var UmbrellaStore = class {
|
|
|
637
789
|
const page = asyncResult.data;
|
|
638
790
|
return {
|
|
639
791
|
isLoading: false,
|
|
640
|
-
inboxNotifications: this.
|
|
792
|
+
inboxNotifications: this.get1_notifications().sortedNotifications,
|
|
641
793
|
hasFetchedAll: page.hasFetchedAll,
|
|
642
794
|
isFetchingMore: page.isFetchingMore,
|
|
643
795
|
fetchMoreError: page.fetchMoreError,
|
|
@@ -645,6 +797,7 @@ var UmbrellaStore = class {
|
|
|
645
797
|
};
|
|
646
798
|
}
|
|
647
799
|
// NOTE: This will read the async result, but WILL NOT start loading at the moment!
|
|
800
|
+
// TODO(vincent+nimesh) This should really be a derived Signal!
|
|
648
801
|
getNotificationSettingsLoadingState(roomId) {
|
|
649
802
|
const queryKey = makeNotificationSettingsQueryKey(roomId);
|
|
650
803
|
const resource = this.#roomNotificationSettings.get(queryKey);
|
|
@@ -657,7 +810,7 @@ var UmbrellaStore = class {
|
|
|
657
810
|
}
|
|
658
811
|
return {
|
|
659
812
|
isLoading: false,
|
|
660
|
-
settings: _core.nn.call(void 0, this.
|
|
813
|
+
settings: _core.nn.call(void 0, this.get2()[roomId])
|
|
661
814
|
};
|
|
662
815
|
}
|
|
663
816
|
getRoomVersionsLoadingState(roomId) {
|
|
@@ -672,70 +825,53 @@ var UmbrellaStore = class {
|
|
|
672
825
|
}
|
|
673
826
|
return {
|
|
674
827
|
isLoading: false,
|
|
675
|
-
versions: Object.values(_nullishCoalesce(this.
|
|
828
|
+
versions: Object.values(_nullishCoalesce(this.get3()[roomId], () => ( {})))
|
|
676
829
|
};
|
|
677
830
|
}
|
|
678
|
-
subscribe(callback) {
|
|
679
|
-
return this.#store.subscribe(callback);
|
|
680
|
-
}
|
|
681
|
-
_getPermissions(roomId) {
|
|
682
|
-
return this.#store.get().permissionsByRoom[roomId];
|
|
683
|
-
}
|
|
684
831
|
// Direct low-level cache mutations ------------------------------------------------- {{{
|
|
685
832
|
#mutateThreadsDB(mutate) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
if (old !== db.version) {
|
|
690
|
-
this.#store.set((state) => ({ ...state }));
|
|
691
|
-
}
|
|
833
|
+
_core.batch.call(void 0, () => {
|
|
834
|
+
mutate(this.baseThreadsDB);
|
|
835
|
+
});
|
|
692
836
|
}
|
|
693
837
|
#updateInboxNotificationsCache(mapFn) {
|
|
694
|
-
this
|
|
695
|
-
const inboxNotifications = mapFn(state.notificationsById);
|
|
696
|
-
return inboxNotifications !== state.notificationsById ? { ...state, notificationsById: inboxNotifications } : state;
|
|
697
|
-
});
|
|
838
|
+
this.baseNotificationsById.set((prev) => mapFn(prev));
|
|
698
839
|
}
|
|
699
840
|
#setNotificationSettings(roomId, settings) {
|
|
700
|
-
this
|
|
841
|
+
this.baseSettingsByRoomId.set((state) => ({
|
|
701
842
|
...state,
|
|
702
|
-
|
|
703
|
-
...state.settingsByRoomId,
|
|
704
|
-
[roomId]: settings
|
|
705
|
-
}
|
|
843
|
+
[roomId]: settings
|
|
706
844
|
}));
|
|
707
845
|
}
|
|
708
846
|
#updateRoomVersions(roomId, versions) {
|
|
709
|
-
this
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
847
|
+
this.baseVersionsByRoomId.set((prev) => {
|
|
848
|
+
const newVersions = { ...prev[roomId] };
|
|
849
|
+
for (const version of versions) {
|
|
850
|
+
newVersions[version.id] = version;
|
|
851
|
+
}
|
|
713
852
|
return {
|
|
714
|
-
...
|
|
715
|
-
|
|
716
|
-
...state.versionsByRoomId,
|
|
717
|
-
[roomId]: {
|
|
718
|
-
// Merge with existing versions for the room, or start with an empty object
|
|
719
|
-
..._nullishCoalesce(state.versionsByRoomId[roomId], () => ( {})),
|
|
720
|
-
...versionsById
|
|
721
|
-
}
|
|
722
|
-
}
|
|
853
|
+
...prev,
|
|
854
|
+
[roomId]: newVersions
|
|
723
855
|
};
|
|
724
856
|
});
|
|
725
857
|
}
|
|
726
858
|
#updateOptimisticUpdatesCache(mapFn) {
|
|
727
|
-
this
|
|
728
|
-
const optimisticUpdates = mapFn(state.optimisticUpdates);
|
|
729
|
-
this.#syncSource.setSyncStatus(
|
|
730
|
-
optimisticUpdates.length > 0 ? "synchronizing" : "synchronized"
|
|
731
|
-
);
|
|
732
|
-
return { ...state, optimisticUpdates };
|
|
733
|
-
});
|
|
859
|
+
this.optimisticUpdates.set(mapFn);
|
|
734
860
|
}
|
|
735
861
|
// ---------------------------------------------------------------------------------- }}}
|
|
736
862
|
/** @internal - Only call this method from unit tests. */
|
|
737
|
-
|
|
738
|
-
|
|
863
|
+
force_set_versions(callback) {
|
|
864
|
+
_core.batch.call(void 0, () => {
|
|
865
|
+
this.baseVersionsByRoomId.set(callback);
|
|
866
|
+
this.invalidateEntireStore();
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
/** @internal - Only call this method from unit tests. */
|
|
870
|
+
force_set_notifications(callback) {
|
|
871
|
+
_core.batch.call(void 0, () => {
|
|
872
|
+
this.baseNotificationsById.set(callback);
|
|
873
|
+
this.invalidateEntireStore();
|
|
874
|
+
});
|
|
739
875
|
}
|
|
740
876
|
/**
|
|
741
877
|
* Updates an existing inbox notification with a new value, replacing the
|
|
@@ -745,18 +881,17 @@ var UmbrellaStore = class {
|
|
|
745
881
|
* the cache.
|
|
746
882
|
*/
|
|
747
883
|
updateInboxNotification(inboxNotificationId, optimisticUpdateId, callback) {
|
|
748
|
-
|
|
884
|
+
_core.batch.call(void 0, () => {
|
|
749
885
|
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
750
886
|
this.#updateInboxNotificationsCache((cache) => {
|
|
751
887
|
const existing = cache[inboxNotificationId];
|
|
752
888
|
if (!existing) {
|
|
753
889
|
return cache;
|
|
754
890
|
}
|
|
755
|
-
|
|
891
|
+
return {
|
|
756
892
|
...cache,
|
|
757
893
|
[inboxNotificationId]: callback(existing)
|
|
758
894
|
};
|
|
759
|
-
return inboxNotifications;
|
|
760
895
|
});
|
|
761
896
|
});
|
|
762
897
|
}
|
|
@@ -765,7 +900,7 @@ var UmbrellaStore = class {
|
|
|
765
900
|
* them, replacing the corresponding optimistic update.
|
|
766
901
|
*/
|
|
767
902
|
updateAllInboxNotifications(optimisticUpdateId, mapFn) {
|
|
768
|
-
|
|
903
|
+
_core.batch.call(void 0, () => {
|
|
769
904
|
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
770
905
|
this.#updateInboxNotificationsCache((cache) => _core.mapValues.call(void 0, cache, mapFn));
|
|
771
906
|
});
|
|
@@ -775,7 +910,7 @@ var UmbrellaStore = class {
|
|
|
775
910
|
* optimistic update.
|
|
776
911
|
*/
|
|
777
912
|
deleteInboxNotification(inboxNotificationId, optimisticUpdateId) {
|
|
778
|
-
|
|
913
|
+
_core.batch.call(void 0, () => {
|
|
779
914
|
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
780
915
|
this.#updateInboxNotificationsCache((cache) => {
|
|
781
916
|
const { [inboxNotificationId]: removed, ...newCache } = cache;
|
|
@@ -788,7 +923,7 @@ var UmbrellaStore = class {
|
|
|
788
923
|
* update.
|
|
789
924
|
*/
|
|
790
925
|
deleteAllInboxNotifications(optimisticUpdateId) {
|
|
791
|
-
|
|
926
|
+
_core.batch.call(void 0, () => {
|
|
792
927
|
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
793
928
|
this.#updateInboxNotificationsCache(() => ({}));
|
|
794
929
|
});
|
|
@@ -797,7 +932,7 @@ var UmbrellaStore = class {
|
|
|
797
932
|
* Creates an new thread, replacing the corresponding optimistic update.
|
|
798
933
|
*/
|
|
799
934
|
createThread(optimisticUpdateId, thread) {
|
|
800
|
-
|
|
935
|
+
_core.batch.call(void 0, () => {
|
|
801
936
|
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
802
937
|
this.#mutateThreadsDB((db) => db.upsert(thread));
|
|
803
938
|
});
|
|
@@ -813,7 +948,7 @@ var UmbrellaStore = class {
|
|
|
813
948
|
* update's timestamp (if given)
|
|
814
949
|
*/
|
|
815
950
|
#updateThread(threadId, optimisticUpdateId, callback, updatedAt) {
|
|
816
|
-
|
|
951
|
+
_core.batch.call(void 0, () => {
|
|
817
952
|
if (optimisticUpdateId !== null) {
|
|
818
953
|
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
819
954
|
}
|
|
@@ -870,9 +1005,9 @@ var UmbrellaStore = class {
|
|
|
870
1005
|
* updated correctly, replacing the corresponding optimistic update.
|
|
871
1006
|
*/
|
|
872
1007
|
createComment(newComment, optimisticUpdateId) {
|
|
873
|
-
|
|
1008
|
+
_core.batch.call(void 0, () => {
|
|
874
1009
|
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
875
|
-
const existingThread = this.
|
|
1010
|
+
const existingThread = this.baseThreadsDB.get(newComment.threadId);
|
|
876
1011
|
if (!existingThread) {
|
|
877
1012
|
return;
|
|
878
1013
|
}
|
|
@@ -913,7 +1048,7 @@ var UmbrellaStore = class {
|
|
|
913
1048
|
);
|
|
914
1049
|
}
|
|
915
1050
|
updateThreadAndNotification(thread, inboxNotification) {
|
|
916
|
-
|
|
1051
|
+
_core.batch.call(void 0, () => {
|
|
917
1052
|
this.#mutateThreadsDB((db) => db.upsertIfNewer(thread));
|
|
918
1053
|
if (inboxNotification !== void 0) {
|
|
919
1054
|
this.#updateInboxNotificationsCache((cache) => ({
|
|
@@ -924,7 +1059,7 @@ var UmbrellaStore = class {
|
|
|
924
1059
|
});
|
|
925
1060
|
}
|
|
926
1061
|
updateThreadsAndNotifications(threads, inboxNotifications, deletedThreads = [], deletedInboxNotifications = []) {
|
|
927
|
-
|
|
1062
|
+
_core.batch.call(void 0, () => {
|
|
928
1063
|
this.#mutateThreadsDB(
|
|
929
1064
|
(db) => applyThreadDeltaUpdates(db, { newThreads: threads, deletedThreads })
|
|
930
1065
|
);
|
|
@@ -941,7 +1076,7 @@ var UmbrellaStore = class {
|
|
|
941
1076
|
* replacing the corresponding optimistic update.
|
|
942
1077
|
*/
|
|
943
1078
|
updateRoomNotificationSettings_confirmOptimisticUpdate(roomId, optimisticUpdateId, settings) {
|
|
944
|
-
|
|
1079
|
+
_core.batch.call(void 0, () => {
|
|
945
1080
|
this.removeOptimisticUpdate(optimisticUpdateId);
|
|
946
1081
|
this.#setNotificationSettings(roomId, settings);
|
|
947
1082
|
});
|
|
@@ -979,19 +1114,18 @@ var UmbrellaStore = class {
|
|
|
979
1114
|
waitUntilNotificationsLoaded() {
|
|
980
1115
|
return this.#notifications.waitUntilLoaded();
|
|
981
1116
|
}
|
|
982
|
-
#
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
(permission
|
|
988
|
-
|
|
989
|
-
|
|
1117
|
+
#updatePermissionHints(newHints) {
|
|
1118
|
+
this.permissionHintsByRoomId.set((prev) => {
|
|
1119
|
+
const permissionsByRoom = { ...prev };
|
|
1120
|
+
for (const [roomId, newPermissions] of Object.entries(newHints)) {
|
|
1121
|
+
const existing = _nullishCoalesce(permissionsByRoom[roomId], () => ( /* @__PURE__ */ new Set()));
|
|
1122
|
+
for (const permission of newPermissions) {
|
|
1123
|
+
existing.add(permission);
|
|
1124
|
+
}
|
|
1125
|
+
permissionsByRoom[roomId] = existing;
|
|
1126
|
+
}
|
|
1127
|
+
return permissionsByRoom;
|
|
990
1128
|
});
|
|
991
|
-
this.#store.set((state) => ({
|
|
992
|
-
...state,
|
|
993
|
-
permissionsByRoom
|
|
994
|
-
}));
|
|
995
1129
|
}
|
|
996
1130
|
waitUntilRoomThreadsLoaded(roomId, query) {
|
|
997
1131
|
const threadsFetcher = async (cursor) => {
|
|
@@ -1004,7 +1138,7 @@ var UmbrellaStore = class {
|
|
|
1004
1138
|
result.threads,
|
|
1005
1139
|
result.inboxNotifications
|
|
1006
1140
|
);
|
|
1007
|
-
this.#
|
|
1141
|
+
this.#updatePermissionHints(result.permissionHints);
|
|
1008
1142
|
const lastRequestedAt = this.#roomThreadsLastRequestedAtByRoom.get(roomId);
|
|
1009
1143
|
if (lastRequestedAt === void 0 || lastRequestedAt > result.requestedAt) {
|
|
1010
1144
|
this.#roomThreadsLastRequestedAtByRoom.set(roomId, result.requestedAt);
|
|
@@ -1020,7 +1154,7 @@ var UmbrellaStore = class {
|
|
|
1020
1154
|
() => (
|
|
1021
1155
|
// Note that the store itself does not change, but it's only vehicle at
|
|
1022
1156
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1023
|
-
this
|
|
1157
|
+
this.invalidateEntireStore()
|
|
1024
1158
|
)
|
|
1025
1159
|
);
|
|
1026
1160
|
this.#roomThreads.set(queryKey, paginatedResource);
|
|
@@ -1042,7 +1176,7 @@ var UmbrellaStore = class {
|
|
|
1042
1176
|
updates.threads.deleted,
|
|
1043
1177
|
updates.inboxNotifications.deleted
|
|
1044
1178
|
);
|
|
1045
|
-
this.#
|
|
1179
|
+
this.#updatePermissionHints(updates.permissionHints);
|
|
1046
1180
|
if (lastRequestedAt < updates.requestedAt) {
|
|
1047
1181
|
this.#roomThreadsLastRequestedAtByRoom.set(roomId, updates.requestedAt);
|
|
1048
1182
|
}
|
|
@@ -1058,7 +1192,7 @@ var UmbrellaStore = class {
|
|
|
1058
1192
|
result.threads,
|
|
1059
1193
|
result.inboxNotifications
|
|
1060
1194
|
);
|
|
1061
|
-
this.#
|
|
1195
|
+
this.#updatePermissionHints(result.permissionHints);
|
|
1062
1196
|
if (this.#userThreadsLastRequestedAt === null) {
|
|
1063
1197
|
this.#userThreadsLastRequestedAt = result.requestedAt;
|
|
1064
1198
|
}
|
|
@@ -1072,12 +1206,23 @@ var UmbrellaStore = class {
|
|
|
1072
1206
|
() => (
|
|
1073
1207
|
// Note that the store itself does not change, but it's only vehicle at
|
|
1074
1208
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1075
|
-
this
|
|
1209
|
+
this.invalidateEntireStore()
|
|
1076
1210
|
)
|
|
1077
1211
|
);
|
|
1078
1212
|
this.#userThreads.set(queryKey, paginatedResource);
|
|
1079
1213
|
return paginatedResource.waitUntilLoaded();
|
|
1080
1214
|
}
|
|
1215
|
+
// TODO(vincent+nimesh) We should really be going over all call sites, and replace this call
|
|
1216
|
+
// with a more specific invalidation!
|
|
1217
|
+
invalidateEntireStore() {
|
|
1218
|
+
_core.batch.call(void 0, () => {
|
|
1219
|
+
this.baseVersionsByRoomId.set((store) => ({ ...store }));
|
|
1220
|
+
this.baseNotificationsById.set((store) => ({ ...store }));
|
|
1221
|
+
this.optimisticUpdates.set((store) => [...store]);
|
|
1222
|
+
this.permissionHintsByRoomId.set((store) => ({ ...store }));
|
|
1223
|
+
this.baseSettingsByRoomId.set((store) => ({ ...store }));
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1081
1226
|
async fetchUserThreadsDeltaUpdate(signal) {
|
|
1082
1227
|
const lastRequestedAt = this.#userThreadsLastRequestedAt;
|
|
1083
1228
|
if (lastRequestedAt === null) {
|
|
@@ -1096,7 +1241,7 @@ var UmbrellaStore = class {
|
|
|
1096
1241
|
result.threads.deleted,
|
|
1097
1242
|
result.inboxNotifications.deleted
|
|
1098
1243
|
);
|
|
1099
|
-
this.#
|
|
1244
|
+
this.#updatePermissionHints(result.permissionHints);
|
|
1100
1245
|
}
|
|
1101
1246
|
waitUntilRoomVersionsLoaded(roomId) {
|
|
1102
1247
|
const queryKey = makeVersionsQueryKey(roomId);
|
|
@@ -1126,7 +1271,7 @@ var UmbrellaStore = class {
|
|
|
1126
1271
|
() => (
|
|
1127
1272
|
// Note that the store itself does not change, but it's only vehicle at
|
|
1128
1273
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1129
|
-
this
|
|
1274
|
+
this.invalidateEntireStore()
|
|
1130
1275
|
)
|
|
1131
1276
|
);
|
|
1132
1277
|
this.#roomVersions.set(queryKey, resource);
|
|
@@ -1171,7 +1316,7 @@ var UmbrellaStore = class {
|
|
|
1171
1316
|
() => (
|
|
1172
1317
|
// Note that the store itself does not change, but it's only vehicle at
|
|
1173
1318
|
// the moment to trigger a re-render, so we'll do a no-op update here.
|
|
1174
|
-
this
|
|
1319
|
+
this.invalidateEntireStore()
|
|
1175
1320
|
)
|
|
1176
1321
|
);
|
|
1177
1322
|
this.#roomNotificationSettings.set(queryKey, resource);
|
|
@@ -1186,13 +1331,10 @@ var UmbrellaStore = class {
|
|
|
1186
1331
|
this.#setNotificationSettings(roomId, result);
|
|
1187
1332
|
}
|
|
1188
1333
|
};
|
|
1189
|
-
function
|
|
1190
|
-
const threadsDB =
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
settingsByRoomId: { ...state.settingsByRoomId }
|
|
1194
|
-
};
|
|
1195
|
-
for (const optimisticUpdate of state.optimisticUpdates) {
|
|
1334
|
+
function applyOptimisticUpdates_forThreadifications(baseThreadsDB, rawNotificationsById, optimisticUpdates) {
|
|
1335
|
+
const threadsDB = baseThreadsDB.clone();
|
|
1336
|
+
let notificationsById = { ...rawNotificationsById };
|
|
1337
|
+
for (const optimisticUpdate of optimisticUpdates) {
|
|
1196
1338
|
switch (optimisticUpdate.type) {
|
|
1197
1339
|
case "create-thread": {
|
|
1198
1340
|
threadsDB.upsert(optimisticUpdate.thread);
|
|
@@ -1230,15 +1372,13 @@ function internalToExternalState(state, rawThreadsDB) {
|
|
|
1230
1372
|
const thread = threadsDB.get(optimisticUpdate.comment.threadId);
|
|
1231
1373
|
if (thread === void 0) break;
|
|
1232
1374
|
threadsDB.upsert(applyUpsertComment(thread, optimisticUpdate.comment));
|
|
1233
|
-
const inboxNotification = Object.values(
|
|
1234
|
-
computed.notificationsById
|
|
1235
|
-
).find(
|
|
1375
|
+
const inboxNotification = Object.values(notificationsById).find(
|
|
1236
1376
|
(notification) => notification.kind === "thread" && notification.threadId === thread.id
|
|
1237
1377
|
);
|
|
1238
1378
|
if (inboxNotification === void 0) {
|
|
1239
1379
|
break;
|
|
1240
1380
|
}
|
|
1241
|
-
|
|
1381
|
+
notificationsById[inboxNotification.id] = {
|
|
1242
1382
|
...inboxNotification,
|
|
1243
1383
|
notifiedAt: optimisticUpdate.comment.createdAt,
|
|
1244
1384
|
readAt: optimisticUpdate.comment.createdAt
|
|
@@ -1301,23 +1441,23 @@ function internalToExternalState(state, rawThreadsDB) {
|
|
|
1301
1441
|
break;
|
|
1302
1442
|
}
|
|
1303
1443
|
case "mark-inbox-notification-as-read": {
|
|
1304
|
-
const ibn =
|
|
1444
|
+
const ibn = notificationsById[optimisticUpdate.inboxNotificationId];
|
|
1305
1445
|
if (ibn === void 0) {
|
|
1306
1446
|
break;
|
|
1307
1447
|
}
|
|
1308
|
-
|
|
1448
|
+
notificationsById[optimisticUpdate.inboxNotificationId] = {
|
|
1309
1449
|
...ibn,
|
|
1310
1450
|
readAt: optimisticUpdate.readAt
|
|
1311
1451
|
};
|
|
1312
1452
|
break;
|
|
1313
1453
|
}
|
|
1314
1454
|
case "mark-all-inbox-notifications-as-read": {
|
|
1315
|
-
for (const id in
|
|
1316
|
-
const ibn =
|
|
1455
|
+
for (const id in notificationsById) {
|
|
1456
|
+
const ibn = notificationsById[id];
|
|
1317
1457
|
if (ibn === void 0) {
|
|
1318
1458
|
break;
|
|
1319
1459
|
}
|
|
1320
|
-
|
|
1460
|
+
notificationsById[id] = {
|
|
1321
1461
|
...ibn,
|
|
1322
1462
|
readAt: optimisticUpdate.readAt
|
|
1323
1463
|
};
|
|
@@ -1325,38 +1465,44 @@ function internalToExternalState(state, rawThreadsDB) {
|
|
|
1325
1465
|
break;
|
|
1326
1466
|
}
|
|
1327
1467
|
case "delete-inbox-notification": {
|
|
1328
|
-
delete
|
|
1468
|
+
delete notificationsById[optimisticUpdate.inboxNotificationId];
|
|
1329
1469
|
break;
|
|
1330
1470
|
}
|
|
1331
1471
|
case "delete-all-inbox-notifications": {
|
|
1332
|
-
|
|
1472
|
+
notificationsById = {};
|
|
1333
1473
|
break;
|
|
1334
1474
|
}
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
const sortedNotifications = (
|
|
1478
|
+
// Sort so that the most recent notifications are first
|
|
1479
|
+
Object.values(notificationsById).filter(
|
|
1480
|
+
(ibn) => ibn.kind === "thread" ? threadsDB.get(ibn.threadId) !== void 0 : true
|
|
1481
|
+
).sort((a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime())
|
|
1482
|
+
);
|
|
1483
|
+
return {
|
|
1484
|
+
sortedNotifications,
|
|
1485
|
+
notificationsById,
|
|
1486
|
+
threadsDB
|
|
1487
|
+
};
|
|
1488
|
+
}
|
|
1489
|
+
function applyOptimisticUpdates_forSettings(baseSettingsByRoomId, optimisticUpdates) {
|
|
1490
|
+
const settingsByRoomId = { ...baseSettingsByRoomId };
|
|
1491
|
+
for (const optimisticUpdate of optimisticUpdates) {
|
|
1492
|
+
switch (optimisticUpdate.type) {
|
|
1335
1493
|
case "update-notification-settings": {
|
|
1336
|
-
const settings =
|
|
1494
|
+
const settings = settingsByRoomId[optimisticUpdate.roomId];
|
|
1337
1495
|
if (settings === void 0) {
|
|
1338
1496
|
break;
|
|
1339
1497
|
}
|
|
1340
|
-
|
|
1498
|
+
settingsByRoomId[optimisticUpdate.roomId] = {
|
|
1341
1499
|
...settings,
|
|
1342
1500
|
...optimisticUpdate.settings
|
|
1343
1501
|
};
|
|
1344
1502
|
}
|
|
1345
1503
|
}
|
|
1346
1504
|
}
|
|
1347
|
-
|
|
1348
|
-
// Sort so that the most recent notifications are first
|
|
1349
|
-
Object.values(computed.notificationsById).filter(
|
|
1350
|
-
(ibn) => ibn.kind === "thread" ? threadsDB.get(ibn.threadId) !== void 0 : true
|
|
1351
|
-
).sort((a, b) => b.notifiedAt.getTime() - a.notifiedAt.getTime())
|
|
1352
|
-
);
|
|
1353
|
-
return {
|
|
1354
|
-
cleanedNotifications,
|
|
1355
|
-
notificationsById: computed.notificationsById,
|
|
1356
|
-
settingsByRoomId: computed.settingsByRoomId,
|
|
1357
|
-
threadsDB,
|
|
1358
|
-
versionsByRoomId: state.versionsByRoomId
|
|
1359
|
-
};
|
|
1505
|
+
return settingsByRoomId;
|
|
1360
1506
|
}
|
|
1361
1507
|
function applyThreadDeltaUpdates(db, updates) {
|
|
1362
1508
|
updates.newThreads.forEach((thread) => db.upsertIfNewer(thread));
|
|
@@ -1563,6 +1709,7 @@ function upsertReaction(reactions, reaction) {
|
|
|
1563
1709
|
}
|
|
1564
1710
|
|
|
1565
1711
|
// src/liveblocks.tsx
|
|
1712
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
1566
1713
|
var ClientContext = _react.createContext.call(void 0, null);
|
|
1567
1714
|
function missingUserError(userId) {
|
|
1568
1715
|
return new Error(`resolveUsers didn't return anything for user '${userId}'`);
|
|
@@ -1696,7 +1843,7 @@ function makeLiveblocksContextBundle(client) {
|
|
|
1696
1843
|
const useDeleteAllInboxNotifications2 = () => useDeleteAllInboxNotifications_withClient(client);
|
|
1697
1844
|
function LiveblocksProvider2(props) {
|
|
1698
1845
|
useEnsureNoLiveblocksProvider();
|
|
1699
|
-
return /* @__PURE__ */
|
|
1846
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ClientContext.Provider, { value: client, children: props.children });
|
|
1700
1847
|
}
|
|
1701
1848
|
const shared = createSharedContext(client);
|
|
1702
1849
|
const bundle = {
|
|
@@ -1737,8 +1884,8 @@ function useInboxNotifications_withClient(client, selector, isEqual) {
|
|
|
1737
1884
|
poller.dec();
|
|
1738
1885
|
};
|
|
1739
1886
|
}, [poller]);
|
|
1740
|
-
return
|
|
1741
|
-
store.
|
|
1887
|
+
return useSyncExternalStoreWithSelector(
|
|
1888
|
+
store.subscribe1_threads,
|
|
1742
1889
|
store.getInboxNotificationsLoadingState,
|
|
1743
1890
|
store.getInboxNotificationsLoadingState,
|
|
1744
1891
|
selector,
|
|
@@ -1860,7 +2007,7 @@ function useDeleteAllInboxNotifications_withClient(client) {
|
|
|
1860
2007
|
}
|
|
1861
2008
|
function useInboxNotificationThread_withClient(client, inboxNotificationId) {
|
|
1862
2009
|
const { store } = getLiveblocksExtrasForClient(client);
|
|
1863
|
-
const getter = store.
|
|
2010
|
+
const getter = store.get1_both;
|
|
1864
2011
|
const selector = _react.useCallback.call(void 0,
|
|
1865
2012
|
(state) => {
|
|
1866
2013
|
const inboxNotification = _nullishCoalesce(state.notificationsById[inboxNotificationId], () => ( _core.raise.call(void 0, `Inbox notification with ID "${inboxNotificationId}" not found`)));
|
|
@@ -1876,8 +2023,8 @@ function useInboxNotificationThread_withClient(client, inboxNotificationId) {
|
|
|
1876
2023
|
},
|
|
1877
2024
|
[inboxNotificationId]
|
|
1878
2025
|
);
|
|
1879
|
-
return
|
|
1880
|
-
store.
|
|
2026
|
+
return useSyncExternalStoreWithSelector(
|
|
2027
|
+
store.subscribe1_both,
|
|
1881
2028
|
// Re-evaluate if we need to update any time the notification changes over time
|
|
1882
2029
|
getter,
|
|
1883
2030
|
getter,
|
|
@@ -1894,7 +2041,7 @@ function useUser_withClient(client, userId) {
|
|
|
1894
2041
|
(state) => selectorFor_useUser(state, userId),
|
|
1895
2042
|
[userId]
|
|
1896
2043
|
);
|
|
1897
|
-
const result =
|
|
2044
|
+
const result = useSyncExternalStoreWithSelector(
|
|
1898
2045
|
usersStore.subscribe,
|
|
1899
2046
|
getUserState,
|
|
1900
2047
|
getUserState,
|
|
@@ -1922,7 +2069,7 @@ function useUserSuspense_withClient(client, userId) {
|
|
|
1922
2069
|
if (!userState.data) {
|
|
1923
2070
|
throw missingUserError(userId);
|
|
1924
2071
|
}
|
|
1925
|
-
const state =
|
|
2072
|
+
const state = _react.useSyncExternalStore.call(void 0,
|
|
1926
2073
|
usersStore.subscribe,
|
|
1927
2074
|
getUserState,
|
|
1928
2075
|
getUserState
|
|
@@ -1946,7 +2093,7 @@ function useRoomInfo_withClient(client, roomId) {
|
|
|
1946
2093
|
(state) => selectorFor_useRoomInfo(state, roomId),
|
|
1947
2094
|
[roomId]
|
|
1948
2095
|
);
|
|
1949
|
-
const result =
|
|
2096
|
+
const result = useSyncExternalStoreWithSelector(
|
|
1950
2097
|
roomsInfoStore.subscribe,
|
|
1951
2098
|
getRoomInfoState,
|
|
1952
2099
|
getRoomInfoState,
|
|
@@ -1974,7 +2121,7 @@ function useRoomInfoSuspense_withClient(client, roomId) {
|
|
|
1974
2121
|
if (!roomInfoState.data) {
|
|
1975
2122
|
throw missingRoomInfoError(roomId);
|
|
1976
2123
|
}
|
|
1977
|
-
const state =
|
|
2124
|
+
const state = _react.useSyncExternalStore.call(void 0,
|
|
1978
2125
|
roomsInfoStore.subscribe,
|
|
1979
2126
|
getRoomInfoState,
|
|
1980
2127
|
getRoomInfoState
|
|
@@ -2027,7 +2174,7 @@ function useClient() {
|
|
|
2027
2174
|
}
|
|
2028
2175
|
function LiveblocksProviderWithClient(props) {
|
|
2029
2176
|
useEnsureNoLiveblocksProvider(props);
|
|
2030
|
-
return /* @__PURE__ */
|
|
2177
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ClientContext.Provider, { value: props.client, children: props.children });
|
|
2031
2178
|
}
|
|
2032
2179
|
function LiveblocksProvider(props) {
|
|
2033
2180
|
const { children, ...o } = props;
|
|
@@ -2056,7 +2203,7 @@ function LiveblocksProvider(props) {
|
|
|
2056
2203
|
)
|
|
2057
2204
|
};
|
|
2058
2205
|
const client = _react.useMemo.call(void 0, () => _core.createClient.call(void 0, options), []);
|
|
2059
|
-
return /* @__PURE__ */
|
|
2206
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LiveblocksProviderWithClient, { client, children });
|
|
2060
2207
|
}
|
|
2061
2208
|
function createLiveblocksContext(client) {
|
|
2062
2209
|
return getOrCreateContextBundle(client);
|
|
@@ -2092,8 +2239,8 @@ function useUserThreads_experimental(options = {
|
|
|
2092
2239
|
() => store.getUserThreadsLoadingState(options.query),
|
|
2093
2240
|
[store, options.query]
|
|
2094
2241
|
);
|
|
2095
|
-
return
|
|
2096
|
-
store.
|
|
2242
|
+
return useSyncExternalStoreWithSelector(
|
|
2243
|
+
store.subscribe1_threads,
|
|
2097
2244
|
getter,
|
|
2098
2245
|
getter,
|
|
2099
2246
|
identity,
|
|
@@ -2172,7 +2319,7 @@ function useSyncStatus_withClient(client, options) {
|
|
|
2172
2319
|
}
|
|
2173
2320
|
}
|
|
2174
2321
|
function useSyncStatusImmediate_withClient(client) {
|
|
2175
|
-
return
|
|
2322
|
+
return _react.useSyncExternalStore.call(void 0,
|
|
2176
2323
|
client.events.syncStatus.subscribe,
|
|
2177
2324
|
client.getSyncStatus,
|
|
2178
2325
|
client.getSyncStatus
|
|
@@ -2180,9 +2327,9 @@ function useSyncStatusImmediate_withClient(client) {
|
|
|
2180
2327
|
}
|
|
2181
2328
|
function useSyncStatusSmooth_withClient(client) {
|
|
2182
2329
|
const getter = client.getSyncStatus;
|
|
2183
|
-
const [status, setStatus] =
|
|
2330
|
+
const [status, setStatus] = _react.useState.call(void 0, getter);
|
|
2184
2331
|
const oldStatus = useLatest(getter());
|
|
2185
|
-
|
|
2332
|
+
_react.useEffect.call(void 0, () => {
|
|
2186
2333
|
let timeoutId;
|
|
2187
2334
|
const unsub = client.events.syncStatus.subscribe(() => {
|
|
2188
2335
|
const newStatus = getter();
|
|
@@ -2302,6 +2449,18 @@ var UpdateNotificationSettingsError = class extends Error {
|
|
|
2302
2449
|
}
|
|
2303
2450
|
};
|
|
2304
2451
|
|
|
2452
|
+
// src/use-signal.ts
|
|
2453
|
+
var identity2 = (value) => value;
|
|
2454
|
+
function useSignal(signal, selector, isEqual) {
|
|
2455
|
+
return useSyncExternalStoreWithSelector(
|
|
2456
|
+
signal.subscribe,
|
|
2457
|
+
signal.get,
|
|
2458
|
+
signal.get,
|
|
2459
|
+
_nullishCoalesce(selector, () => ( identity2)),
|
|
2460
|
+
isEqual
|
|
2461
|
+
);
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2305
2464
|
// src/room.tsx
|
|
2306
2465
|
var _client = require('@liveblocks/client');
|
|
2307
2466
|
|
|
@@ -2318,6 +2477,12 @@ var _client = require('@liveblocks/client');
|
|
|
2318
2477
|
|
|
2319
2478
|
|
|
2320
2479
|
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
|
|
2321
2486
|
|
|
2322
2487
|
|
|
2323
2488
|
// src/use-scroll-to-comment-on-load-effect.ts
|
|
@@ -2340,7 +2505,7 @@ function handleScrollToCommentOnLoad(shouldScrollOnLoad, state) {
|
|
|
2340
2505
|
comment.scrollIntoView();
|
|
2341
2506
|
}
|
|
2342
2507
|
function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
|
|
2343
|
-
|
|
2508
|
+
_react.useEffect.call(void 0,
|
|
2344
2509
|
() => {
|
|
2345
2510
|
handleScrollToCommentOnLoad(shouldScrollOnLoad, state);
|
|
2346
2511
|
},
|
|
@@ -2350,24 +2515,10 @@ function useScrollToCommentOnLoadEffect(shouldScrollOnLoad, state) {
|
|
|
2350
2515
|
}
|
|
2351
2516
|
|
|
2352
2517
|
// src/room.tsx
|
|
2518
|
+
|
|
2353
2519
|
var noop3 = () => {
|
|
2354
2520
|
};
|
|
2355
|
-
var
|
|
2356
|
-
var missing_unstable_batchedUpdates = (reactVersion, roomId) => `We noticed you\u2019re using React ${reactVersion}. Please pass unstable_batchedUpdates at the RoomProvider level until you\u2019re ready to upgrade to React 18:
|
|
2357
|
-
|
|
2358
|
-
import { unstable_batchedUpdates } from "react-dom"; // or "react-native"
|
|
2359
|
-
|
|
2360
|
-
<RoomProvider id=${JSON.stringify(
|
|
2361
|
-
roomId
|
|
2362
|
-
)} ... unstable_batchedUpdates={unstable_batchedUpdates}>
|
|
2363
|
-
...
|
|
2364
|
-
</RoomProvider>
|
|
2365
|
-
|
|
2366
|
-
Why? Please see https://liveblocks.io/docs/platform/troubleshooting#stale-props-zombie-child for more information`;
|
|
2367
|
-
var superfluous_unstable_batchedUpdates = "You don\u2019t need to pass unstable_batchedUpdates to RoomProvider anymore, since you\u2019re on React 18+ already.";
|
|
2368
|
-
function useSyncExternalStore2(s, gs, gss) {
|
|
2369
|
-
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0, s, gs, gss, identity2);
|
|
2370
|
-
}
|
|
2521
|
+
var identity3 = (x) => x;
|
|
2371
2522
|
var STABLE_EMPTY_LIST = Object.freeze([]);
|
|
2372
2523
|
function alwaysEmptyList() {
|
|
2373
2524
|
return STABLE_EMPTY_LIST;
|
|
@@ -2408,7 +2559,7 @@ function makeMutationContext(room) {
|
|
|
2408
2559
|
};
|
|
2409
2560
|
}
|
|
2410
2561
|
function getCurrentUserId(client) {
|
|
2411
|
-
const userId = client[_core.kInternal].
|
|
2562
|
+
const userId = client[_core.kInternal].currentUserId.get();
|
|
2412
2563
|
if (userId === void 0) {
|
|
2413
2564
|
return "anonymous";
|
|
2414
2565
|
}
|
|
@@ -2527,7 +2678,7 @@ function makeRoomExtrasForClient(client) {
|
|
|
2527
2678
|
}
|
|
2528
2679
|
function makeRoomContextBundle(client) {
|
|
2529
2680
|
function RoomProvider_withImplicitLiveblocksProvider(props) {
|
|
2530
|
-
return /* @__PURE__ */
|
|
2681
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LiveblocksProviderWithClient, { client, allowNesting: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RoomProvider, { ...props }) });
|
|
2531
2682
|
}
|
|
2532
2683
|
const shared = createSharedContext(client);
|
|
2533
2684
|
const bundle = {
|
|
@@ -2631,10 +2782,10 @@ function makeRoomContextBundle(client) {
|
|
|
2631
2782
|
}
|
|
2632
2783
|
function RoomProvider(props) {
|
|
2633
2784
|
const client = useClient();
|
|
2634
|
-
const [cache] =
|
|
2785
|
+
const [cache] = _react.useState.call(void 0,
|
|
2635
2786
|
() => /* @__PURE__ */ new Map()
|
|
2636
2787
|
);
|
|
2637
|
-
const stableEnterRoom =
|
|
2788
|
+
const stableEnterRoom = _react.useCallback.call(void 0,
|
|
2638
2789
|
(roomId, options) => {
|
|
2639
2790
|
const cached = cache.get(roomId);
|
|
2640
2791
|
if (cached) return cached;
|
|
@@ -2649,7 +2800,7 @@ function RoomProvider(props) {
|
|
|
2649
2800
|
},
|
|
2650
2801
|
[client, cache]
|
|
2651
2802
|
);
|
|
2652
|
-
return /* @__PURE__ */
|
|
2803
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2653
2804
|
RoomProviderInner,
|
|
2654
2805
|
{
|
|
2655
2806
|
...props,
|
|
@@ -2669,31 +2820,26 @@ function RoomProviderInner(props) {
|
|
|
2669
2820
|
if (!isString(roomId)) {
|
|
2670
2821
|
throw new Error("RoomProvider id property should be a string.");
|
|
2671
2822
|
}
|
|
2672
|
-
const majorReactVersion = parseInt(
|
|
2673
|
-
const
|
|
2823
|
+
const majorReactVersion = parseInt(_react.version) || 1;
|
|
2824
|
+
const requiredVersion = 18;
|
|
2674
2825
|
_core.errorIf.call(void 0,
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
);
|
|
2678
|
-
_core.deprecateIf.call(void 0,
|
|
2679
|
-
!oldReactVersion && props.unstable_batchedUpdates !== void 0,
|
|
2680
|
-
superfluous_unstable_batchedUpdates
|
|
2826
|
+
majorReactVersion < requiredVersion,
|
|
2827
|
+
`React ${requiredVersion} or higher is required (you\u2019re on ${_react.version})`
|
|
2681
2828
|
);
|
|
2682
2829
|
}
|
|
2683
2830
|
const frozenProps = useInitial({
|
|
2684
2831
|
initialPresence: props.initialPresence,
|
|
2685
2832
|
initialStorage: props.initialStorage,
|
|
2686
|
-
unstable_batchedUpdates: props.unstable_batchedUpdates,
|
|
2687
2833
|
autoConnect: _nullishCoalesce(props.autoConnect, () => ( typeof window !== "undefined"))
|
|
2688
2834
|
});
|
|
2689
|
-
const [{ room }, setRoomLeavePair] =
|
|
2835
|
+
const [{ room }, setRoomLeavePair] = _react.useState.call(void 0,
|
|
2690
2836
|
() => stableEnterRoom(roomId, {
|
|
2691
2837
|
...frozenProps,
|
|
2692
2838
|
autoConnect: false
|
|
2693
2839
|
// Deliberately using false here on the first render, see below
|
|
2694
2840
|
})
|
|
2695
2841
|
);
|
|
2696
|
-
|
|
2842
|
+
_react.useEffect.call(void 0, () => {
|
|
2697
2843
|
const { store } = getRoomExtrasForClient(client);
|
|
2698
2844
|
async function handleCommentEvent(message) {
|
|
2699
2845
|
if (message.type === _core.ServerMsgCode.THREAD_DELETED) {
|
|
@@ -2706,7 +2852,7 @@ function RoomProviderInner(props) {
|
|
|
2706
2852
|
return;
|
|
2707
2853
|
}
|
|
2708
2854
|
const { thread, inboxNotification } = info;
|
|
2709
|
-
const existingThread = store.
|
|
2855
|
+
const existingThread = store.get1_threads().threadsDB.getEvenIfDeleted(message.threadId);
|
|
2710
2856
|
switch (message.type) {
|
|
2711
2857
|
case _core.ServerMsgCode.COMMENT_EDITED:
|
|
2712
2858
|
case _core.ServerMsgCode.THREAD_METADATA_UPDATED:
|
|
@@ -2728,7 +2874,7 @@ function RoomProviderInner(props) {
|
|
|
2728
2874
|
(message) => void handleCommentEvent(message)
|
|
2729
2875
|
);
|
|
2730
2876
|
}, [client, room]);
|
|
2731
|
-
|
|
2877
|
+
_react.useEffect.call(void 0, () => {
|
|
2732
2878
|
const pair = stableEnterRoom(roomId, frozenProps);
|
|
2733
2879
|
setRoomLeavePair(pair);
|
|
2734
2880
|
const { room: room2, leave } = pair;
|
|
@@ -2739,7 +2885,7 @@ function RoomProviderInner(props) {
|
|
|
2739
2885
|
leave();
|
|
2740
2886
|
};
|
|
2741
2887
|
}, [roomId, frozenProps, stableEnterRoom]);
|
|
2742
|
-
return /* @__PURE__ */
|
|
2888
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RoomContext.Provider, { value: room, children: props.children });
|
|
2743
2889
|
}
|
|
2744
2890
|
function useRoom() {
|
|
2745
2891
|
const room = useRoomOrNull();
|
|
@@ -2753,12 +2899,12 @@ function useStatus() {
|
|
|
2753
2899
|
const subscribe = room.events.status.subscribe;
|
|
2754
2900
|
const getSnapshot = room.getStatus;
|
|
2755
2901
|
const getServerSnapshot = room.getStatus;
|
|
2756
|
-
return
|
|
2902
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getServerSnapshot);
|
|
2757
2903
|
}
|
|
2758
2904
|
function useReportTextEditor(editor, rootKey) {
|
|
2759
|
-
const isReported =
|
|
2905
|
+
const isReported = _react.useRef.call(void 0, false);
|
|
2760
2906
|
const room = useRoom();
|
|
2761
|
-
|
|
2907
|
+
_react.useEffect.call(void 0, () => {
|
|
2762
2908
|
if (isReported.current) {
|
|
2763
2909
|
return;
|
|
2764
2910
|
}
|
|
@@ -2773,20 +2919,20 @@ function useReportTextEditor(editor, rootKey) {
|
|
|
2773
2919
|
}
|
|
2774
2920
|
function useYjsProvider() {
|
|
2775
2921
|
const room = useRoom();
|
|
2776
|
-
const subscribe =
|
|
2922
|
+
const subscribe = _react.useCallback.call(void 0,
|
|
2777
2923
|
(onStoreChange) => {
|
|
2778
2924
|
return room[_core.kInternal].yjsProviderDidChange.subscribe(onStoreChange);
|
|
2779
2925
|
},
|
|
2780
2926
|
[room]
|
|
2781
2927
|
);
|
|
2782
|
-
const getSnapshot =
|
|
2928
|
+
const getSnapshot = _react.useCallback.call(void 0, () => {
|
|
2783
2929
|
return room[_core.kInternal].getYjsProvider();
|
|
2784
2930
|
}, [room]);
|
|
2785
|
-
return
|
|
2931
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
|
|
2786
2932
|
}
|
|
2787
2933
|
function useCreateTextMention() {
|
|
2788
2934
|
const room = useRoom();
|
|
2789
|
-
return
|
|
2935
|
+
return _react.useCallback.call(void 0,
|
|
2790
2936
|
(userId, mentionId) => {
|
|
2791
2937
|
room[_core.kInternal].createTextMention(userId, mentionId).catch((err) => {
|
|
2792
2938
|
_core.console.error(
|
|
@@ -2800,7 +2946,7 @@ function useCreateTextMention() {
|
|
|
2800
2946
|
}
|
|
2801
2947
|
function useDeleteTextMention() {
|
|
2802
2948
|
const room = useRoom();
|
|
2803
|
-
return
|
|
2949
|
+
return _react.useCallback.call(void 0,
|
|
2804
2950
|
(mentionId) => {
|
|
2805
2951
|
room[_core.kInternal].deleteTextMention(mentionId).catch((err) => {
|
|
2806
2952
|
_core.console.error(`Cannot delete text mention '${mentionId}'`, err);
|
|
@@ -2830,13 +2976,13 @@ function useStorageStatusImmediate() {
|
|
|
2830
2976
|
const subscribe = room.events.storageStatus.subscribe;
|
|
2831
2977
|
const getSnapshot = room.getStorageStatus;
|
|
2832
2978
|
const getServerSnapshot = room.getStorageStatus;
|
|
2833
|
-
return
|
|
2979
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getServerSnapshot);
|
|
2834
2980
|
}
|
|
2835
2981
|
function useStorageStatusSmooth() {
|
|
2836
2982
|
const room = useRoom();
|
|
2837
|
-
const [status, setStatus] =
|
|
2983
|
+
const [status, setStatus] = _react.useState.call(void 0, room.getStorageStatus);
|
|
2838
2984
|
const oldStatus = useLatest(room.getStorageStatus());
|
|
2839
|
-
|
|
2985
|
+
_react.useEffect.call(void 0, () => {
|
|
2840
2986
|
let timeoutId;
|
|
2841
2987
|
const unsub = room.events.storageStatus.subscribe((newStatus) => {
|
|
2842
2988
|
if (oldStatus.current === "synchronizing" && newStatus === "synchronized") {
|
|
@@ -2858,7 +3004,7 @@ function useBatch() {
|
|
|
2858
3004
|
}
|
|
2859
3005
|
function useBroadcastEvent() {
|
|
2860
3006
|
const room = useRoom();
|
|
2861
|
-
return
|
|
3007
|
+
return _react.useCallback.call(void 0,
|
|
2862
3008
|
(event, options = { shouldQueueEventIfNotReady: false }) => {
|
|
2863
3009
|
room.broadcastEvent(event, options);
|
|
2864
3010
|
},
|
|
@@ -2868,7 +3014,7 @@ function useBroadcastEvent() {
|
|
|
2868
3014
|
function useOthersListener(callback) {
|
|
2869
3015
|
const room = useRoom();
|
|
2870
3016
|
const savedCallback = useLatest(callback);
|
|
2871
|
-
|
|
3017
|
+
_react.useEffect.call(void 0,
|
|
2872
3018
|
() => room.events.others.subscribe((event) => savedCallback.current(event)),
|
|
2873
3019
|
[room, savedCallback]
|
|
2874
3020
|
);
|
|
@@ -2876,7 +3022,7 @@ function useOthersListener(callback) {
|
|
|
2876
3022
|
function useLostConnectionListener(callback) {
|
|
2877
3023
|
const room = useRoom();
|
|
2878
3024
|
const savedCallback = useLatest(callback);
|
|
2879
|
-
|
|
3025
|
+
_react.useEffect.call(void 0,
|
|
2880
3026
|
() => room.events.lostConnection.subscribe(
|
|
2881
3027
|
(event) => savedCallback.current(event)
|
|
2882
3028
|
),
|
|
@@ -2886,7 +3032,7 @@ function useLostConnectionListener(callback) {
|
|
|
2886
3032
|
function useErrorListener(callback) {
|
|
2887
3033
|
const room = useRoom();
|
|
2888
3034
|
const savedCallback = useLatest(callback);
|
|
2889
|
-
|
|
3035
|
+
_react.useEffect.call(void 0,
|
|
2890
3036
|
() => room.events.error.subscribe((e) => savedCallback.current(e)),
|
|
2891
3037
|
[room, savedCallback]
|
|
2892
3038
|
);
|
|
@@ -2894,7 +3040,7 @@ function useErrorListener(callback) {
|
|
|
2894
3040
|
function useEventListener(callback) {
|
|
2895
3041
|
const room = useRoom();
|
|
2896
3042
|
const savedCallback = useLatest(callback);
|
|
2897
|
-
|
|
3043
|
+
_react.useEffect.call(void 0, () => {
|
|
2898
3044
|
const listener = (eventData) => {
|
|
2899
3045
|
savedCallback.current(eventData);
|
|
2900
3046
|
};
|
|
@@ -2914,25 +3060,25 @@ function useCanUndo() {
|
|
|
2914
3060
|
const room = useRoom();
|
|
2915
3061
|
const subscribe = room.events.history.subscribe;
|
|
2916
3062
|
const canUndo = room.history.canUndo;
|
|
2917
|
-
return
|
|
3063
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, canUndo, canUndo);
|
|
2918
3064
|
}
|
|
2919
3065
|
function useCanRedo() {
|
|
2920
3066
|
const room = useRoom();
|
|
2921
3067
|
const subscribe = room.events.history.subscribe;
|
|
2922
3068
|
const canRedo = room.history.canRedo;
|
|
2923
|
-
return
|
|
3069
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, canRedo, canRedo);
|
|
2924
3070
|
}
|
|
2925
3071
|
function useSelf(maybeSelector, isEqual) {
|
|
2926
3072
|
const room = useRoom();
|
|
2927
3073
|
const subscribe = room.events.self.subscribe;
|
|
2928
3074
|
const getSnapshot = room.getSelf;
|
|
2929
|
-
const selector = _nullishCoalesce(maybeSelector, () => (
|
|
2930
|
-
const wrappedSelector =
|
|
3075
|
+
const selector = _nullishCoalesce(maybeSelector, () => ( identity3));
|
|
3076
|
+
const wrappedSelector = _react.useCallback.call(void 0,
|
|
2931
3077
|
(me) => me !== null ? selector(me) : null,
|
|
2932
3078
|
[selector]
|
|
2933
3079
|
);
|
|
2934
3080
|
const getServerSnapshot = alwaysNull;
|
|
2935
|
-
return
|
|
3081
|
+
return useSyncExternalStoreWithSelector(
|
|
2936
3082
|
subscribe,
|
|
2937
3083
|
getSnapshot,
|
|
2938
3084
|
getServerSnapshot,
|
|
@@ -2944,7 +3090,7 @@ function useMyPresence() {
|
|
|
2944
3090
|
const room = useRoom();
|
|
2945
3091
|
const subscribe = room.events.myPresence.subscribe;
|
|
2946
3092
|
const getSnapshot = room.getPresence;
|
|
2947
|
-
const presence =
|
|
3093
|
+
const presence = _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
|
|
2948
3094
|
const setPresence = room.updatePresence;
|
|
2949
3095
|
return [presence, setPresence];
|
|
2950
3096
|
}
|
|
@@ -2956,20 +3102,20 @@ function useOthers(selector, isEqual) {
|
|
|
2956
3102
|
const subscribe = room.events.others.subscribe;
|
|
2957
3103
|
const getSnapshot = room.getOthers;
|
|
2958
3104
|
const getServerSnapshot = alwaysEmptyList;
|
|
2959
|
-
return
|
|
3105
|
+
return useSyncExternalStoreWithSelector(
|
|
2960
3106
|
subscribe,
|
|
2961
3107
|
getSnapshot,
|
|
2962
3108
|
getServerSnapshot,
|
|
2963
|
-
_nullishCoalesce(selector, () => (
|
|
3109
|
+
_nullishCoalesce(selector, () => ( identity3)),
|
|
2964
3110
|
isEqual
|
|
2965
3111
|
);
|
|
2966
3112
|
}
|
|
2967
3113
|
function useOthersMapped(itemSelector, itemIsEqual) {
|
|
2968
|
-
const wrappedSelector =
|
|
3114
|
+
const wrappedSelector = _react.useCallback.call(void 0,
|
|
2969
3115
|
(others) => others.map((other) => [other.connectionId, itemSelector(other)]),
|
|
2970
3116
|
[itemSelector]
|
|
2971
3117
|
);
|
|
2972
|
-
const wrappedIsEqual =
|
|
3118
|
+
const wrappedIsEqual = _react.useCallback.call(void 0,
|
|
2973
3119
|
(a, b) => {
|
|
2974
3120
|
const eq = _nullishCoalesce(itemIsEqual, () => ( Object.is));
|
|
2975
3121
|
return a.length === b.length && a.every((atuple, index) => {
|
|
@@ -2986,14 +3132,14 @@ function useOthersConnectionIds() {
|
|
|
2986
3132
|
}
|
|
2987
3133
|
var NOT_FOUND = Symbol();
|
|
2988
3134
|
function useOther(connectionId, selector, isEqual) {
|
|
2989
|
-
const wrappedSelector =
|
|
3135
|
+
const wrappedSelector = _react.useCallback.call(void 0,
|
|
2990
3136
|
(others) => {
|
|
2991
3137
|
const other2 = others.find((other3) => other3.connectionId === connectionId);
|
|
2992
3138
|
return other2 !== void 0 ? selector(other2) : NOT_FOUND;
|
|
2993
3139
|
},
|
|
2994
3140
|
[connectionId, selector]
|
|
2995
3141
|
);
|
|
2996
|
-
const wrappedIsEqual =
|
|
3142
|
+
const wrappedIsEqual = _react.useCallback.call(void 0,
|
|
2997
3143
|
(prev, curr) => {
|
|
2998
3144
|
if (prev === NOT_FOUND || curr === NOT_FOUND) {
|
|
2999
3145
|
return prev === curr;
|
|
@@ -3016,7 +3162,7 @@ function useMutableStorageRoot() {
|
|
|
3016
3162
|
const subscribe = room.events.storageDidLoad.subscribeOnce;
|
|
3017
3163
|
const getSnapshot = room.getStorageSnapshot;
|
|
3018
3164
|
const getServerSnapshot = alwaysNull;
|
|
3019
|
-
return
|
|
3165
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getServerSnapshot);
|
|
3020
3166
|
}
|
|
3021
3167
|
function useStorageRoot() {
|
|
3022
3168
|
return [useMutableStorageRoot()];
|
|
@@ -3024,15 +3170,15 @@ function useStorageRoot() {
|
|
|
3024
3170
|
function useStorage(selector, isEqual) {
|
|
3025
3171
|
const room = useRoom();
|
|
3026
3172
|
const rootOrNull = useMutableStorageRoot();
|
|
3027
|
-
const wrappedSelector =
|
|
3173
|
+
const wrappedSelector = _react.useCallback.call(void 0,
|
|
3028
3174
|
(rootOrNull2) => rootOrNull2 !== null ? selector(rootOrNull2) : null,
|
|
3029
3175
|
[selector]
|
|
3030
3176
|
);
|
|
3031
|
-
const subscribe =
|
|
3177
|
+
const subscribe = _react.useCallback.call(void 0,
|
|
3032
3178
|
(onStoreChange) => rootOrNull !== null ? room.subscribe(rootOrNull, onStoreChange, { isDeep: true }) : noop3,
|
|
3033
3179
|
[room, rootOrNull]
|
|
3034
3180
|
);
|
|
3035
|
-
const getSnapshot =
|
|
3181
|
+
const getSnapshot = _react.useCallback.call(void 0, () => {
|
|
3036
3182
|
if (rootOrNull === null) {
|
|
3037
3183
|
return null;
|
|
3038
3184
|
} else {
|
|
@@ -3042,7 +3188,7 @@ function useStorage(selector, isEqual) {
|
|
|
3042
3188
|
}
|
|
3043
3189
|
}, [rootOrNull]);
|
|
3044
3190
|
const getServerSnapshot = alwaysNull;
|
|
3045
|
-
return
|
|
3191
|
+
return useSyncExternalStoreWithSelector(
|
|
3046
3192
|
subscribe,
|
|
3047
3193
|
getSnapshot,
|
|
3048
3194
|
getServerSnapshot,
|
|
@@ -3052,7 +3198,7 @@ function useStorage(selector, isEqual) {
|
|
|
3052
3198
|
}
|
|
3053
3199
|
function useMutation(callback, deps) {
|
|
3054
3200
|
const room = useRoom();
|
|
3055
|
-
return
|
|
3201
|
+
return _react.useMemo.call(void 0,
|
|
3056
3202
|
() => {
|
|
3057
3203
|
return (...args) => (
|
|
3058
3204
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
@@ -3079,7 +3225,7 @@ function useThreads(options = {
|
|
|
3079
3225
|
const room = useRoom();
|
|
3080
3226
|
const { store, getOrCreateThreadsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3081
3227
|
const poller = getOrCreateThreadsPollerForRoomId(room.id);
|
|
3082
|
-
|
|
3228
|
+
_react.useEffect.call(void 0,
|
|
3083
3229
|
() => {
|
|
3084
3230
|
void store.waitUntilRoomThreadsLoaded(room.id, options.query);
|
|
3085
3231
|
}
|
|
@@ -3092,20 +3238,20 @@ function useThreads(options = {
|
|
|
3092
3238
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
3093
3239
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
3094
3240
|
);
|
|
3095
|
-
|
|
3241
|
+
_react.useEffect.call(void 0, () => {
|
|
3096
3242
|
poller.inc();
|
|
3097
3243
|
poller.pollNowIfStale();
|
|
3098
3244
|
return () => poller.dec();
|
|
3099
3245
|
}, [poller]);
|
|
3100
|
-
const getter =
|
|
3246
|
+
const getter = _react.useCallback.call(void 0,
|
|
3101
3247
|
() => store.getRoomThreadsLoadingState(room.id, options.query),
|
|
3102
3248
|
[store, room.id, options.query]
|
|
3103
3249
|
);
|
|
3104
|
-
const state =
|
|
3105
|
-
store.
|
|
3250
|
+
const state = useSyncExternalStoreWithSelector(
|
|
3251
|
+
store.subscribe1_threads,
|
|
3106
3252
|
getter,
|
|
3107
3253
|
getter,
|
|
3108
|
-
|
|
3254
|
+
identity3,
|
|
3109
3255
|
shallow2
|
|
3110
3256
|
// NOTE: Using 2-level-deep shallow check here, because the result of selectThreads() is not stable!
|
|
3111
3257
|
);
|
|
@@ -3116,7 +3262,7 @@ function useCommentsErrorListener(callback) {
|
|
|
3116
3262
|
const client = useClient();
|
|
3117
3263
|
const savedCallback = useLatest(callback);
|
|
3118
3264
|
const { commentsErrorEventSource } = getRoomExtrasForClient(client);
|
|
3119
|
-
|
|
3265
|
+
_react.useEffect.call(void 0, () => {
|
|
3120
3266
|
return commentsErrorEventSource.subscribe(savedCallback.current);
|
|
3121
3267
|
}, [savedCallback, commentsErrorEventSource]);
|
|
3122
3268
|
}
|
|
@@ -3125,7 +3271,7 @@ function useCreateThread() {
|
|
|
3125
3271
|
}
|
|
3126
3272
|
function useCreateRoomThread(roomId) {
|
|
3127
3273
|
const client = useClient();
|
|
3128
|
-
return
|
|
3274
|
+
return _react.useCallback.call(void 0,
|
|
3129
3275
|
(options) => {
|
|
3130
3276
|
const body = options.body;
|
|
3131
3277
|
const metadata = _nullishCoalesce(options.metadata, () => ( {}));
|
|
@@ -3194,11 +3340,11 @@ function useDeleteThread() {
|
|
|
3194
3340
|
}
|
|
3195
3341
|
function useDeleteRoomThread(roomId) {
|
|
3196
3342
|
const client = useClient();
|
|
3197
|
-
return
|
|
3343
|
+
return _react.useCallback.call(void 0,
|
|
3198
3344
|
(threadId) => {
|
|
3199
3345
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3200
3346
|
const userId = getCurrentUserId(client);
|
|
3201
|
-
const existing = store.
|
|
3347
|
+
const existing = store.get1_threads().threadsDB.get(threadId);
|
|
3202
3348
|
if (_optionalChain([existing, 'optionalAccess', _17 => _17.comments, 'optionalAccess', _18 => _18[0], 'optionalAccess', _19 => _19.userId]) !== userId) {
|
|
3203
3349
|
throw new Error("Only the thread creator can delete the thread");
|
|
3204
3350
|
}
|
|
@@ -3227,7 +3373,7 @@ function useEditThreadMetadata() {
|
|
|
3227
3373
|
}
|
|
3228
3374
|
function useEditRoomThreadMetadata(roomId) {
|
|
3229
3375
|
const client = useClient();
|
|
3230
|
-
return
|
|
3376
|
+
return _react.useCallback.call(void 0,
|
|
3231
3377
|
(options) => {
|
|
3232
3378
|
if (!options.metadata) {
|
|
3233
3379
|
return;
|
|
@@ -3271,7 +3417,7 @@ function useCreateComment() {
|
|
|
3271
3417
|
}
|
|
3272
3418
|
function useCreateRoomComment(roomId) {
|
|
3273
3419
|
const client = useClient();
|
|
3274
|
-
return
|
|
3420
|
+
return _react.useCallback.call(void 0,
|
|
3275
3421
|
({ threadId, body, attachments }) => {
|
|
3276
3422
|
const commentId = _core.createCommentId.call(void 0, );
|
|
3277
3423
|
const createdAt = /* @__PURE__ */ new Date();
|
|
@@ -3317,11 +3463,11 @@ function useEditComment() {
|
|
|
3317
3463
|
}
|
|
3318
3464
|
function useEditRoomComment(roomId) {
|
|
3319
3465
|
const client = useClient();
|
|
3320
|
-
return
|
|
3466
|
+
return _react.useCallback.call(void 0,
|
|
3321
3467
|
({ threadId, commentId, body, attachments }) => {
|
|
3322
3468
|
const editedAt = /* @__PURE__ */ new Date();
|
|
3323
3469
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3324
|
-
const existing = store.
|
|
3470
|
+
const existing = store.get1_threads().threadsDB.getEvenIfDeleted(threadId);
|
|
3325
3471
|
if (existing === void 0) {
|
|
3326
3472
|
_core.console.warn(
|
|
3327
3473
|
`Internal unexpected behavior. Cannot edit comment in thread "${threadId}" because the thread does not exist in the cache.`
|
|
@@ -3371,7 +3517,7 @@ function useDeleteComment() {
|
|
|
3371
3517
|
}
|
|
3372
3518
|
function useDeleteRoomComment(roomId) {
|
|
3373
3519
|
const client = useClient();
|
|
3374
|
-
return
|
|
3520
|
+
return _react.useCallback.call(void 0,
|
|
3375
3521
|
({ threadId, commentId }) => {
|
|
3376
3522
|
const deletedAt = /* @__PURE__ */ new Date();
|
|
3377
3523
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
@@ -3410,7 +3556,7 @@ function useAddReaction() {
|
|
|
3410
3556
|
}
|
|
3411
3557
|
function useAddRoomCommentReaction(roomId) {
|
|
3412
3558
|
const client = useClient();
|
|
3413
|
-
return
|
|
3559
|
+
return _react.useCallback.call(void 0,
|
|
3414
3560
|
({ threadId, commentId, emoji }) => {
|
|
3415
3561
|
const createdAt = /* @__PURE__ */ new Date();
|
|
3416
3562
|
const userId = getCurrentUserId(client);
|
|
@@ -3455,7 +3601,7 @@ function useRemoveReaction() {
|
|
|
3455
3601
|
}
|
|
3456
3602
|
function useRemoveRoomCommentReaction(roomId) {
|
|
3457
3603
|
const client = useClient();
|
|
3458
|
-
return
|
|
3604
|
+
return _react.useCallback.call(void 0,
|
|
3459
3605
|
({ threadId, commentId, emoji }) => {
|
|
3460
3606
|
const userId = getCurrentUserId(client);
|
|
3461
3607
|
const removedAt = /* @__PURE__ */ new Date();
|
|
@@ -3499,11 +3645,11 @@ function useMarkThreadAsRead() {
|
|
|
3499
3645
|
}
|
|
3500
3646
|
function useMarkRoomThreadAsRead(roomId) {
|
|
3501
3647
|
const client = useClient();
|
|
3502
|
-
return
|
|
3648
|
+
return _react.useCallback.call(void 0,
|
|
3503
3649
|
(threadId) => {
|
|
3504
3650
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3505
3651
|
const inboxNotification = Object.values(
|
|
3506
|
-
store.
|
|
3652
|
+
store.get1_notifications().notificationsById
|
|
3507
3653
|
).find(
|
|
3508
3654
|
(inboxNotification2) => inboxNotification2.kind === "thread" && inboxNotification2.threadId === threadId
|
|
3509
3655
|
);
|
|
@@ -3545,7 +3691,7 @@ function useMarkThreadAsResolved() {
|
|
|
3545
3691
|
}
|
|
3546
3692
|
function useMarkRoomThreadAsResolved(roomId) {
|
|
3547
3693
|
const client = useClient();
|
|
3548
|
-
return
|
|
3694
|
+
return _react.useCallback.call(void 0,
|
|
3549
3695
|
(threadId) => {
|
|
3550
3696
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
3551
3697
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
@@ -3581,7 +3727,7 @@ function useMarkThreadAsUnresolved() {
|
|
|
3581
3727
|
}
|
|
3582
3728
|
function useMarkRoomThreadAsUnresolved(roomId) {
|
|
3583
3729
|
const client = useClient();
|
|
3584
|
-
return
|
|
3730
|
+
return _react.useCallback.call(void 0,
|
|
3585
3731
|
(threadId) => {
|
|
3586
3732
|
const updatedAt = /* @__PURE__ */ new Date();
|
|
3587
3733
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
@@ -3615,9 +3761,10 @@ function useMarkRoomThreadAsUnresolved(roomId) {
|
|
|
3615
3761
|
function useThreadSubscription(threadId) {
|
|
3616
3762
|
const client = useClient();
|
|
3617
3763
|
const { store } = getRoomExtrasForClient(client);
|
|
3618
|
-
const
|
|
3764
|
+
const signal = store.outputs.threadifications;
|
|
3765
|
+
const selector = _react.useCallback.call(void 0,
|
|
3619
3766
|
(state) => {
|
|
3620
|
-
const notification = state.
|
|
3767
|
+
const notification = state.sortedNotifications.find(
|
|
3621
3768
|
(inboxNotification) => inboxNotification.kind === "thread" && inboxNotification.threadId === threadId
|
|
3622
3769
|
);
|
|
3623
3770
|
const thread = state.threadsDB.get(threadId);
|
|
@@ -3631,12 +3778,7 @@ function useThreadSubscription(threadId) {
|
|
|
3631
3778
|
},
|
|
3632
3779
|
[threadId]
|
|
3633
3780
|
);
|
|
3634
|
-
return
|
|
3635
|
-
store.subscribe,
|
|
3636
|
-
store.getFullState,
|
|
3637
|
-
store.getFullState,
|
|
3638
|
-
selector
|
|
3639
|
-
);
|
|
3781
|
+
return useSignal(signal, selector, _client.shallow);
|
|
3640
3782
|
}
|
|
3641
3783
|
function useRoomNotificationSettings() {
|
|
3642
3784
|
const updateRoomNotificationSettings = useUpdateRoomNotificationSettings();
|
|
@@ -3644,7 +3786,7 @@ function useRoomNotificationSettings() {
|
|
|
3644
3786
|
const room = useRoom();
|
|
3645
3787
|
const { store, getOrCreateNotificationsSettingsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3646
3788
|
const poller = getOrCreateNotificationsSettingsPollerForRoomId(room.id);
|
|
3647
|
-
|
|
3789
|
+
_react.useEffect.call(void 0,
|
|
3648
3790
|
() => {
|
|
3649
3791
|
void store.waitUntilRoomNotificationSettingsLoaded(room.id);
|
|
3650
3792
|
}
|
|
@@ -3657,25 +3799,25 @@ function useRoomNotificationSettings() {
|
|
|
3657
3799
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
3658
3800
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
3659
3801
|
);
|
|
3660
|
-
|
|
3802
|
+
_react.useEffect.call(void 0, () => {
|
|
3661
3803
|
poller.inc();
|
|
3662
3804
|
poller.pollNowIfStale();
|
|
3663
3805
|
return () => {
|
|
3664
3806
|
poller.dec();
|
|
3665
3807
|
};
|
|
3666
3808
|
}, [poller]);
|
|
3667
|
-
const getter =
|
|
3809
|
+
const getter = _react.useCallback.call(void 0,
|
|
3668
3810
|
() => store.getNotificationSettingsLoadingState(room.id),
|
|
3669
3811
|
[store, room.id]
|
|
3670
3812
|
);
|
|
3671
|
-
const settings =
|
|
3672
|
-
store.
|
|
3813
|
+
const settings = useSyncExternalStoreWithSelector(
|
|
3814
|
+
store.subscribe2,
|
|
3673
3815
|
getter,
|
|
3674
3816
|
getter,
|
|
3675
|
-
|
|
3817
|
+
identity3,
|
|
3676
3818
|
shallow2
|
|
3677
3819
|
);
|
|
3678
|
-
return
|
|
3820
|
+
return _react.useMemo.call(void 0, () => {
|
|
3679
3821
|
return [settings, updateRoomNotificationSettings];
|
|
3680
3822
|
}, [settings, updateRoomNotificationSettings]);
|
|
3681
3823
|
}
|
|
@@ -3687,16 +3829,16 @@ function useRoomNotificationSettingsSuspense() {
|
|
|
3687
3829
|
const [settings, updateRoomNotificationSettings] = useRoomNotificationSettings();
|
|
3688
3830
|
_core.assert.call(void 0, !settings.error, "Did not expect error");
|
|
3689
3831
|
_core.assert.call(void 0, !settings.isLoading, "Did not expect loading");
|
|
3690
|
-
return
|
|
3832
|
+
return _react.useMemo.call(void 0, () => {
|
|
3691
3833
|
return [settings, updateRoomNotificationSettings];
|
|
3692
3834
|
}, [settings, updateRoomNotificationSettings]);
|
|
3693
3835
|
}
|
|
3694
3836
|
function useHistoryVersionData(versionId) {
|
|
3695
|
-
const [state, setState] =
|
|
3837
|
+
const [state, setState] = _react.useState.call(void 0, {
|
|
3696
3838
|
isLoading: true
|
|
3697
3839
|
});
|
|
3698
3840
|
const room = useRoom();
|
|
3699
|
-
|
|
3841
|
+
_react.useEffect.call(void 0, () => {
|
|
3700
3842
|
setState({ isLoading: true });
|
|
3701
3843
|
const load = async () => {
|
|
3702
3844
|
try {
|
|
@@ -3725,16 +3867,16 @@ function useHistoryVersions() {
|
|
|
3725
3867
|
const room = useRoom();
|
|
3726
3868
|
const { store, getOrCreateVersionsPollerForRoomId } = getRoomExtrasForClient(client);
|
|
3727
3869
|
const poller = getOrCreateVersionsPollerForRoomId(room.id);
|
|
3728
|
-
|
|
3870
|
+
_react.useEffect.call(void 0, () => {
|
|
3729
3871
|
poller.inc();
|
|
3730
3872
|
poller.pollNowIfStale();
|
|
3731
3873
|
return () => poller.dec();
|
|
3732
3874
|
}, [poller]);
|
|
3733
|
-
const getter =
|
|
3875
|
+
const getter = _react.useCallback.call(void 0,
|
|
3734
3876
|
() => store.getRoomVersionsLoadingState(room.id),
|
|
3735
3877
|
[store, room.id]
|
|
3736
3878
|
);
|
|
3737
|
-
|
|
3879
|
+
_react.useEffect.call(void 0,
|
|
3738
3880
|
() => {
|
|
3739
3881
|
void store.waitUntilRoomVersionsLoaded(room.id);
|
|
3740
3882
|
}
|
|
@@ -3747,11 +3889,11 @@ function useHistoryVersions() {
|
|
|
3747
3889
|
// 3. If ever the promise would fail, then after 5 seconds it would reset, and on the very
|
|
3748
3890
|
// *next* render after that, a *new* fetch/promise will get created.
|
|
3749
3891
|
);
|
|
3750
|
-
const state =
|
|
3751
|
-
store.
|
|
3892
|
+
const state = useSyncExternalStoreWithSelector(
|
|
3893
|
+
store.subscribe3,
|
|
3752
3894
|
getter,
|
|
3753
3895
|
getter,
|
|
3754
|
-
|
|
3896
|
+
identity3,
|
|
3755
3897
|
shallow2
|
|
3756
3898
|
);
|
|
3757
3899
|
return state;
|
|
@@ -3769,7 +3911,7 @@ function useHistoryVersionsSuspense() {
|
|
|
3769
3911
|
function useUpdateRoomNotificationSettings() {
|
|
3770
3912
|
const client = useClient();
|
|
3771
3913
|
const room = useRoom();
|
|
3772
|
-
return
|
|
3914
|
+
return _react.useCallback.call(void 0,
|
|
3773
3915
|
(settings) => {
|
|
3774
3916
|
const { store, onMutationFailure } = getRoomExtrasForClient(client);
|
|
3775
3917
|
const optimisticUpdateId = store.addOptimisticUpdate({
|
|
@@ -3883,14 +4025,14 @@ function useAttachmentUrl(attachmentId) {
|
|
|
3883
4025
|
function useRoomAttachmentUrl(attachmentId, roomId) {
|
|
3884
4026
|
const client = useClient();
|
|
3885
4027
|
const store = client[_core.kInternal].httpClient.getOrCreateAttachmentUrlsStore(roomId);
|
|
3886
|
-
const getAttachmentUrlState =
|
|
4028
|
+
const getAttachmentUrlState = _react.useCallback.call(void 0,
|
|
3887
4029
|
() => store.getState(attachmentId),
|
|
3888
4030
|
[store, attachmentId]
|
|
3889
4031
|
);
|
|
3890
|
-
|
|
4032
|
+
_react.useEffect.call(void 0, () => {
|
|
3891
4033
|
void store.get(attachmentId);
|
|
3892
4034
|
}, [store, attachmentId]);
|
|
3893
|
-
return
|
|
4035
|
+
return useSyncExternalStoreWithSelector(
|
|
3894
4036
|
store.subscribe,
|
|
3895
4037
|
getAttachmentUrlState,
|
|
3896
4038
|
getAttachmentUrlState,
|
|
@@ -3901,7 +4043,7 @@ function useRoomAttachmentUrl(attachmentId, roomId) {
|
|
|
3901
4043
|
function useAttachmentUrlSuspense(attachmentId) {
|
|
3902
4044
|
const room = useRoom();
|
|
3903
4045
|
const { attachmentUrlsStore } = room[_core.kInternal];
|
|
3904
|
-
const getAttachmentUrlState =
|
|
4046
|
+
const getAttachmentUrlState = _react.useCallback.call(void 0,
|
|
3905
4047
|
() => attachmentUrlsStore.getState(attachmentId),
|
|
3906
4048
|
[attachmentUrlsStore, attachmentId]
|
|
3907
4049
|
);
|
|
@@ -3912,7 +4054,7 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
3912
4054
|
if (attachmentUrlState.error) {
|
|
3913
4055
|
throw attachmentUrlState.error;
|
|
3914
4056
|
}
|
|
3915
|
-
const state =
|
|
4057
|
+
const state = _react.useSyncExternalStore.call(void 0,
|
|
3916
4058
|
attachmentUrlsStore.subscribe,
|
|
3917
4059
|
getAttachmentUrlState,
|
|
3918
4060
|
getAttachmentUrlState
|
|
@@ -3929,11 +4071,10 @@ function useAttachmentUrlSuspense(attachmentId) {
|
|
|
3929
4071
|
function useRoomPermissions(roomId) {
|
|
3930
4072
|
const client = useClient();
|
|
3931
4073
|
const store = getRoomExtrasForClient(client).store;
|
|
3932
|
-
return
|
|
3933
|
-
store.
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
), () => ( /* @__PURE__ */ new Set()));
|
|
4074
|
+
return useSignal(
|
|
4075
|
+
store.permissionHintsByRoomId,
|
|
4076
|
+
(hints) => _nullishCoalesce(hints[roomId], () => ( /* @__PURE__ */ new Set()))
|
|
4077
|
+
);
|
|
3937
4078
|
}
|
|
3938
4079
|
function createRoomContext(client) {
|
|
3939
4080
|
return getOrCreateRoomContextBundle(client);
|
|
@@ -4079,5 +4220,7 @@ var _useUpdateMyPresence = useUpdateMyPresence;
|
|
|
4079
4220
|
|
|
4080
4221
|
|
|
4081
4222
|
|
|
4082
|
-
|
|
4083
|
-
|
|
4223
|
+
|
|
4224
|
+
|
|
4225
|
+
exports.RoomContext = RoomContext; exports.useRoomOrNull = useRoomOrNull; exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; exports.ClientContext = ClientContext; exports.getUmbrellaStoreForClient = getUmbrellaStoreForClient; exports.useClientOrNull = useClientOrNull; exports.useClient = useClient; exports.LiveblocksProvider = LiveblocksProvider; exports.createLiveblocksContext = createLiveblocksContext; exports.useInboxNotifications = useInboxNotifications; exports.useInboxNotificationsSuspense = useInboxNotificationsSuspense; exports.useMarkAllInboxNotificationsAsRead = useMarkAllInboxNotificationsAsRead; exports.useMarkInboxNotificationAsRead = useMarkInboxNotificationAsRead; exports.useDeleteAllInboxNotifications = useDeleteAllInboxNotifications; exports.useDeleteInboxNotification = useDeleteInboxNotification; exports.useUnreadInboxNotificationsCount = useUnreadInboxNotificationsCount; exports.useUnreadInboxNotificationsCountSuspense = useUnreadInboxNotificationsCountSuspense; exports.useRoomInfo = useRoomInfo; exports.useRoomInfoSuspense = useRoomInfoSuspense; exports._useInboxNotificationThread = _useInboxNotificationThread; exports._useUser = _useUser; exports._useUserSuspense = _useUserSuspense; exports._useUserThreads_experimental = _useUserThreads_experimental; exports._useUserThreadsSuspense_experimental = _useUserThreadsSuspense_experimental; exports.useSyncStatus = useSyncStatus; exports.CreateThreadError = CreateThreadError; exports.useSignal = useSignal; exports.useStatus = useStatus; exports.useReportTextEditor = useReportTextEditor; exports.useYjsProvider = useYjsProvider; exports.useCreateTextMention = useCreateTextMention; exports.useDeleteTextMention = useDeleteTextMention; exports.useResolveMentionSuggestions = useResolveMentionSuggestions; exports.useMentionSuggestionsCache = useMentionSuggestionsCache; exports.useStorageStatus = useStorageStatus; exports.useBatch = useBatch; exports.useLostConnectionListener = useLostConnectionListener; exports.useErrorListener = useErrorListener; exports.useHistory = useHistory; exports.useUndo = useUndo; exports.useRedo = useRedo; exports.useCanUndo = useCanUndo; exports.useCanRedo = useCanRedo; exports.useOthersConnectionIds = useOthersConnectionIds; exports.useCommentsErrorListener = useCommentsErrorListener; exports.useCreateRoomThread = useCreateRoomThread; exports.useDeleteRoomThread = useDeleteRoomThread; exports.useEditRoomThreadMetadata = useEditRoomThreadMetadata; exports.useCreateComment = useCreateComment; exports.useCreateRoomComment = useCreateRoomComment; exports.useEditComment = useEditComment; exports.useEditRoomComment = useEditRoomComment; exports.useDeleteComment = useDeleteComment; exports.useDeleteRoomComment = useDeleteRoomComment; exports.useAddRoomCommentReaction = useAddRoomCommentReaction; exports.useRemoveReaction = useRemoveReaction; exports.useRemoveRoomCommentReaction = useRemoveRoomCommentReaction; exports.useMarkThreadAsRead = useMarkThreadAsRead; exports.useMarkRoomThreadAsRead = useMarkRoomThreadAsRead; exports.useMarkThreadAsResolved = useMarkThreadAsResolved; exports.useMarkRoomThreadAsResolved = useMarkRoomThreadAsResolved; exports.useMarkThreadAsUnresolved = useMarkThreadAsUnresolved; exports.useMarkRoomThreadAsUnresolved = useMarkRoomThreadAsUnresolved; exports.useThreadSubscription = useThreadSubscription; exports.useHistoryVersionData = useHistoryVersionData; exports.useUpdateRoomNotificationSettings = useUpdateRoomNotificationSettings; exports.useOthersConnectionIdsSuspense = useOthersConnectionIdsSuspense; exports.useStorageStatusSuspense = useStorageStatusSuspense; exports.useAttachmentUrl = useAttachmentUrl; exports.useRoomAttachmentUrl = useRoomAttachmentUrl; exports.useAttachmentUrlSuspense = useAttachmentUrlSuspense; exports.useRoomPermissions = useRoomPermissions; exports.createRoomContext = createRoomContext; exports._RoomProvider = _RoomProvider; exports._useBroadcastEvent = _useBroadcastEvent; exports._useOthersListener = _useOthersListener; exports._useRoom = _useRoom; exports._useIsInsideRoom = _useIsInsideRoom; exports._useAddReaction = _useAddReaction; exports._useMutation = _useMutation; exports._useCreateThread = _useCreateThread; exports._useDeleteThread = _useDeleteThread; exports._useEditThreadMetadata = _useEditThreadMetadata; exports._useEventListener = _useEventListener; exports._useMyPresence = _useMyPresence; exports._useOthersMapped = _useOthersMapped; exports._useOthersMappedSuspense = _useOthersMappedSuspense; exports._useThreads = _useThreads; exports._useThreadsSuspense = _useThreadsSuspense; exports._useRoomNotificationSettings = _useRoomNotificationSettings; exports._useRoomNotificationSettingsSuspense = _useRoomNotificationSettingsSuspense; exports._useHistoryVersions = _useHistoryVersions; exports._useHistoryVersionsSuspense = _useHistoryVersionsSuspense; exports._useOther = _useOther; exports._useOthers = _useOthers; exports._useOtherSuspense = _useOtherSuspense; exports._useOthersSuspense = _useOthersSuspense; exports._useStorage = _useStorage; exports._useStorageSuspense = _useStorageSuspense; exports._useSelf = _useSelf; exports._useSelfSuspense = _useSelfSuspense; exports._useStorageRoot = _useStorageRoot; exports._useUpdateMyPresence = _useUpdateMyPresence;
|
|
4226
|
+
//# sourceMappingURL=chunk-KY7WMVMG.js.map
|