@liveblocks/react 2.14.0 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_private.d.mts +10 -4
- package/dist/_private.d.ts +10 -4
- package/dist/_private.js +27 -14
- package/dist/_private.js.map +1 -1
- package/dist/_private.mjs +30 -17
- package/dist/_private.mjs.map +1 -1
- package/dist/chunk-36VCTTYL.js +23 -0
- package/dist/chunk-36VCTTYL.js.map +1 -0
- package/dist/chunk-4HZJQXE5.mjs +23 -0
- package/dist/chunk-4HZJQXE5.mjs.map +1 -0
- package/dist/{chunk-BRCWZCNY.mjs → chunk-NZZCQLBR.mjs} +934 -701
- package/dist/chunk-NZZCQLBR.mjs.map +1 -0
- package/dist/{chunk-X4DDEZYL.js → chunk-UKPVXB7D.js} +924 -691
- package/dist/chunk-UKPVXB7D.js.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-Rl_QnQMY.d.mts → room-XbmI0Hoh.d.mts} +134 -116
- package/dist/{room-Rl_QnQMY.d.ts → room-XbmI0Hoh.d.ts} +134 -116
- 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-BRCWZCNY.mjs.map +0 -1
- package/dist/chunk-IQJWVOHM.mjs +0 -22
- package/dist/chunk-IQJWVOHM.mjs.map +0 -1
- package/dist/chunk-L2RWXPYA.js +0 -22
- package/dist/chunk-L2RWXPYA.js.map +0 -1
- package/dist/chunk-X4DDEZYL.js.map +0 -1
package/dist/_private.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as
|
|
2
|
-
import { SyncSource } from '@liveblocks/core';
|
|
3
|
-
import '
|
|
1
|
+
export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as useCreateTextMention, f as useDeleteRoomComment, h as useDeleteRoomThread, i as useDeleteTextMention, j as useEditRoomComment, k as useEditRoomThreadMetadata, l as useMarkRoomThreadAsRead, m as useMarkRoomThreadAsResolved, n as useMarkRoomThreadAsUnresolved, o as useMentionSuggestionsCache, p as useRemoveRoomCommentReaction, q as useReportTextEditor, r as useResolveMentionSuggestions, s as useRoomAttachmentUrl, u as useRoomOrNull, t as useRoomPermissions, v as useYjsProvider } from './room-XbmI0Hoh.mjs';
|
|
2
|
+
import { ISignal, SyncSource } from '@liveblocks/core';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
|
5
|
+
import '@liveblocks/client';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @private For internal use only. Do not rely on this hook.
|
|
@@ -11,9 +12,14 @@ import 'react';
|
|
|
11
12
|
*/
|
|
12
13
|
declare function useMentionSuggestions(roomId: string, search?: string): string[] | undefined;
|
|
13
14
|
|
|
15
|
+
declare function useSignal<T>(signal: ISignal<T>): T;
|
|
16
|
+
declare function useSignal<T, V>(signal: ISignal<T>, selector: (value: T) => V, isEqual?: (a: V, b: V) => boolean): V;
|
|
17
|
+
|
|
18
|
+
declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe: (callback: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot: void | null | (() => Snapshot), selector: (snapshot: Snapshot) => Selection, isEqual?: (a: Selection, b: Selection) => boolean): Selection;
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* @private For internal use only. Do not rely on this hook.
|
|
16
22
|
*/
|
|
17
23
|
declare function useSyncSource(): SyncSource | undefined;
|
|
18
24
|
|
|
19
|
-
export { useMentionSuggestions, useSyncSource };
|
|
25
|
+
export { useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
|
package/dist/_private.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as
|
|
2
|
-
import { SyncSource } from '@liveblocks/core';
|
|
3
|
-
import '
|
|
1
|
+
export { C as CreateThreadError, g as getUmbrellaStoreForClient, b as useAddRoomCommentReaction, a as useClientOrNull, c as useCreateRoomComment, d as useCreateRoomThread, e as useCreateTextMention, f as useDeleteRoomComment, h as useDeleteRoomThread, i as useDeleteTextMention, j as useEditRoomComment, k as useEditRoomThreadMetadata, l as useMarkRoomThreadAsRead, m as useMarkRoomThreadAsResolved, n as useMarkRoomThreadAsUnresolved, o as useMentionSuggestionsCache, p as useRemoveRoomCommentReaction, q as useReportTextEditor, r as useResolveMentionSuggestions, s as useRoomAttachmentUrl, u as useRoomOrNull, t as useRoomPermissions, v as useYjsProvider } from './room-XbmI0Hoh.js';
|
|
2
|
+
import { ISignal, SyncSource } from '@liveblocks/core';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
4
|
import 'react';
|
|
5
|
+
import '@liveblocks/client';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @private For internal use only. Do not rely on this hook.
|
|
@@ -11,9 +12,14 @@ import 'react';
|
|
|
11
12
|
*/
|
|
12
13
|
declare function useMentionSuggestions(roomId: string, search?: string): string[] | undefined;
|
|
13
14
|
|
|
15
|
+
declare function useSignal<T>(signal: ISignal<T>): T;
|
|
16
|
+
declare function useSignal<T, V>(signal: ISignal<T>, selector: (value: T) => V, isEqual?: (a: V, b: V) => boolean): V;
|
|
17
|
+
|
|
18
|
+
declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe: (callback: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot: void | null | (() => Snapshot), selector: (snapshot: Snapshot) => Selection, isEqual?: (a: Selection, b: Selection) => boolean): Selection;
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* @private For internal use only. Do not rely on this hook.
|
|
16
22
|
*/
|
|
17
23
|
declare function useSyncSource(): SyncSource | undefined;
|
|
18
24
|
|
|
19
|
-
export { useMentionSuggestions, useSyncSource };
|
|
25
|
+
export { useMentionSuggestions, useSignal, useSyncExternalStoreWithSelector, useSyncSource };
|
package/dist/_private.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -18,19 +18,25 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
var _chunkUKPVXB7Djs = require('./chunk-UKPVXB7D.js');
|
|
22
29
|
|
|
23
30
|
// src/use-mention-suggestions.ts
|
|
24
31
|
var _core = require('@liveblocks/core');
|
|
25
|
-
var _react = require('react');
|
|
32
|
+
var _react = require('react');
|
|
26
33
|
var MENTION_SUGGESTIONS_DEBOUNCE = 500;
|
|
27
34
|
function useMentionSuggestions(roomId, search) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const resolveMentionSuggestions = client[_core.kInternal].resolveMentionSuggestions;
|
|
35
|
+
const [mentionSuggestions, setMentionSuggestions] = _react.useState.call(void 0, );
|
|
36
|
+
const lastInvokedAt = _react.useRef.call(void 0, );
|
|
37
|
+
const resolveMentionSuggestions = _chunkUKPVXB7Djs.useResolveMentionSuggestions.call(void 0, );
|
|
38
|
+
const mentionSuggestionsCache = _chunkUKPVXB7Djs.useMentionSuggestionsCache.call(void 0, );
|
|
39
|
+
_react.useEffect.call(void 0, () => {
|
|
34
40
|
if (search === void 0 || !resolveMentionSuggestions) {
|
|
35
41
|
return;
|
|
36
42
|
}
|
|
@@ -70,7 +76,7 @@ function useMentionSuggestions(roomId, search) {
|
|
|
70
76
|
isCanceled = true;
|
|
71
77
|
window.clearTimeout(debounceTimeout);
|
|
72
78
|
};
|
|
73
|
-
}, [
|
|
79
|
+
}, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);
|
|
74
80
|
return mentionSuggestions;
|
|
75
81
|
}
|
|
76
82
|
|
|
@@ -78,10 +84,10 @@ function useMentionSuggestions(roomId, search) {
|
|
|
78
84
|
|
|
79
85
|
|
|
80
86
|
function useSyncSource() {
|
|
81
|
-
const client =
|
|
87
|
+
const client = _chunkUKPVXB7Djs.useClient.call(void 0, );
|
|
82
88
|
const createSyncSource = client[_core.kInternal].createSyncSource;
|
|
83
|
-
const [syncSource, setSyncSource] =
|
|
84
|
-
|
|
89
|
+
const [syncSource, setSyncSource] = _react.useState.call(void 0, );
|
|
90
|
+
_react.useEffect.call(void 0, () => {
|
|
85
91
|
const newSyncSource = createSyncSource();
|
|
86
92
|
setSyncSource(newSyncSource);
|
|
87
93
|
return () => newSyncSource.destroy();
|
|
@@ -109,5 +115,12 @@ function useSyncSource() {
|
|
|
109
115
|
|
|
110
116
|
|
|
111
117
|
|
|
112
|
-
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
exports.CreateThreadError = _chunkUKPVXB7Djs.CreateThreadError; exports.getUmbrellaStoreForClient = _chunkUKPVXB7Djs.getUmbrellaStoreForClient; exports.useAddRoomCommentReaction = _chunkUKPVXB7Djs.useAddRoomCommentReaction; exports.useClientOrNull = _chunkUKPVXB7Djs.useClientOrNull; exports.useCreateRoomComment = _chunkUKPVXB7Djs.useCreateRoomComment; exports.useCreateRoomThread = _chunkUKPVXB7Djs.useCreateRoomThread; exports.useCreateTextMention = _chunkUKPVXB7Djs.useCreateTextMention; exports.useDeleteRoomComment = _chunkUKPVXB7Djs.useDeleteRoomComment; exports.useDeleteRoomThread = _chunkUKPVXB7Djs.useDeleteRoomThread; exports.useDeleteTextMention = _chunkUKPVXB7Djs.useDeleteTextMention; exports.useEditRoomComment = _chunkUKPVXB7Djs.useEditRoomComment; exports.useEditRoomThreadMetadata = _chunkUKPVXB7Djs.useEditRoomThreadMetadata; exports.useMarkRoomThreadAsRead = _chunkUKPVXB7Djs.useMarkRoomThreadAsRead; exports.useMarkRoomThreadAsResolved = _chunkUKPVXB7Djs.useMarkRoomThreadAsResolved; exports.useMarkRoomThreadAsUnresolved = _chunkUKPVXB7Djs.useMarkRoomThreadAsUnresolved; exports.useMentionSuggestions = useMentionSuggestions; exports.useMentionSuggestionsCache = _chunkUKPVXB7Djs.useMentionSuggestionsCache; exports.useRemoveRoomCommentReaction = _chunkUKPVXB7Djs.useRemoveRoomCommentReaction; exports.useReportTextEditor = _chunkUKPVXB7Djs.useReportTextEditor; exports.useResolveMentionSuggestions = _chunkUKPVXB7Djs.useResolveMentionSuggestions; exports.useRoomAttachmentUrl = _chunkUKPVXB7Djs.useRoomAttachmentUrl; exports.useRoomOrNull = _chunkUKPVXB7Djs.useRoomOrNull; exports.useRoomPermissions = _chunkUKPVXB7Djs.useRoomPermissions; exports.useSignal = _chunkUKPVXB7Djs.useSignal; exports.useSyncExternalStoreWithSelector = _chunkUKPVXB7Djs.useSyncExternalStoreWithSelector; exports.useSyncSource = useSyncSource; exports.useYjsProvider = _chunkUKPVXB7Djs.useYjsProvider;
|
|
113
126
|
//# sourceMappingURL=_private.js.map
|
package/dist/_private.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["mentionSuggestions","
|
|
1
|
+
{"version":3,"sources":["../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"names":["mentionSuggestions","useEffect","useState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,WAAW,QAAQ,gBAAgB;AAO5C,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAmB;AACvE,QAAM,gBAAgB,OAAe;AAErC,QAAM,4BAA4B,6BAA6B;AAC/D,QAAM,0BAA0B,2BAA2B;AAE3D,YAAU,MAAM;AACd,QAAI,WAAW,UAAa,CAAC,2BAA2B;AACtD;AAAA,IACF;AAEA,UAAM,gCAAgC,EAAE,MAAM,QAAQ,OAAO;AAC7D,UAAM,6BAA6B,UAAU,6BAA6B;AAC1E,QAAI;AACJ,QAAI,aAAa;AAEjB,UAAM,wBAAwB,YAAY;AACxC,UAAI;AACF,sBAAc,UAAU,YAAY,IAAI;AACxC,cAAMA,sBAAqB,MAAM;AAAA,UAC/B;AAAA,QACF;AAEA,YAAI,CAAC,YAAY;AACf,gCAAsBA,mBAAkB;AACxC,kCAAwB;AAAA,YACtB;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAO,OAAiB,OAAO;AAAA,MACzC;AAAA,IACF;AAEA,QAAI,wBAAwB,IAAI,0BAA0B,GAAG;AAE3D;AAAA,QACE,wBAAwB,IAAI,0BAA0B;AAAA,MACxD;AAAA,IACF,WACE,CAAC,cAAc,WACf,KAAK,IAAI,YAAY,IAAI,IAAI,cAAc,OAAO,IAChD,8BACF;AAGA,WAAK,sBAAsB;AAAA,IAC7B,OAAO;AAEL,wBAAkB,OAAO,WAAW,MAAM;AACxC,aAAK,sBAAsB;AAAA,MAC7B,GAAG,4BAA4B;AAAA,IACjC;AAEA,WAAO,MAAM;AACX,mBAAa;AACb,aAAO,aAAa,eAAe;AAAA,IACrC;AAAA,EACF,GAAG,CAAC,QAAQ,QAAQ,2BAA2B,uBAAuB,CAAC;AAEvE,SAAO;AACT;;;AC9EA,SAAS,iBAAiB;AAC1B,SAAS,aAAAC,YAAW,YAAAC,iBAAgB;AAO7B,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAO,SAAS,EAAE;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAIA,UAAiC;AAErE,EAAAD,WAAU,MAAM;AAEd,UAAM,gBAAgB,iBAAiB;AACvC,kBAAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT","sourcesContent":["import { stringify } from \"@liveblocks/core\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport {\n useMentionSuggestionsCache,\n useResolveMentionSuggestions,\n} from \"./room\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(roomId: string, search?: string) {\n const [mentionSuggestions, setMentionSuggestions] = useState<string[]>();\n const lastInvokedAt = useRef<number>();\n\n const resolveMentionSuggestions = useResolveMentionSuggestions();\n const mentionSuggestionsCache = useMentionSuggestionsCache();\n\n useEffect(() => {\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);\n let debounceTimeout: number | undefined;\n let isCanceled = false;\n\n const getMentionSuggestions = async () => {\n try {\n lastInvokedAt.current = performance.now();\n const mentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n setMentionSuggestions(mentionSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n mentionSuggestions\n );\n }\n } catch (error) {\n console.error((error as Error)?.message);\n }\n };\n\n if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {\n // If there are already cached mention suggestions, use them immediately.\n setMentionSuggestions(\n mentionSuggestionsCache.get(mentionSuggestionsCacheKey)\n );\n } else if (\n !lastInvokedAt.current ||\n Math.abs(performance.now() - lastInvokedAt.current) >\n MENTION_SUGGESTIONS_DEBOUNCE\n ) {\n // If on the debounce's leading edge (either because it's the first invokation or enough\n // time has passed since the last debounce), get mention suggestions immediately.\n void getMentionSuggestions();\n } else {\n // Otherwise, wait for the debounce delay.\n debounceTimeout = window.setTimeout(() => {\n void getMentionSuggestions();\n }, MENTION_SUGGESTIONS_DEBOUNCE);\n }\n\n return () => {\n isCanceled = true;\n window.clearTimeout(debounceTimeout);\n };\n }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useEffect, useState } from \"react\";\n\nimport { useClient } from \"./liveblocks\";\n\n/**\n * @private For internal use only. Do not rely on this hook.\n */\nexport function useSyncSource(): SyncSource | undefined {\n const client = useClient();\n const createSyncSource = client[kInternal].createSyncSource;\n const [syncSource, setSyncSource] = useState<SyncSource | undefined>();\n\n useEffect(() => {\n // Create new sync source on mount\n const newSyncSource = createSyncSource();\n setSyncSource(newSyncSource);\n return () => newSyncSource.destroy();\n }, [createSyncSource]);\n\n return syncSource;\n}\n"]}
|
package/dist/_private.mjs
CHANGED
|
@@ -6,31 +6,37 @@ import {
|
|
|
6
6
|
useClientOrNull,
|
|
7
7
|
useCreateRoomComment,
|
|
8
8
|
useCreateRoomThread,
|
|
9
|
+
useCreateTextMention,
|
|
9
10
|
useDeleteRoomComment,
|
|
10
11
|
useDeleteRoomThread,
|
|
12
|
+
useDeleteTextMention,
|
|
11
13
|
useEditRoomComment,
|
|
12
14
|
useEditRoomThreadMetadata,
|
|
13
15
|
useMarkRoomThreadAsRead,
|
|
14
16
|
useMarkRoomThreadAsResolved,
|
|
15
17
|
useMarkRoomThreadAsUnresolved,
|
|
18
|
+
useMentionSuggestionsCache,
|
|
16
19
|
useRemoveRoomCommentReaction,
|
|
17
20
|
useReportTextEditor,
|
|
21
|
+
useResolveMentionSuggestions,
|
|
18
22
|
useRoomAttachmentUrl,
|
|
19
23
|
useRoomOrNull,
|
|
20
|
-
useRoomPermissions
|
|
21
|
-
|
|
24
|
+
useRoomPermissions,
|
|
25
|
+
useSignal,
|
|
26
|
+
useSyncExternalStoreWithSelector,
|
|
27
|
+
useYjsProvider
|
|
28
|
+
} from "./chunk-NZZCQLBR.mjs";
|
|
22
29
|
|
|
23
30
|
// src/use-mention-suggestions.ts
|
|
24
|
-
import {
|
|
25
|
-
import
|
|
31
|
+
import { stringify } from "@liveblocks/core";
|
|
32
|
+
import { useEffect, useRef, useState } from "react";
|
|
26
33
|
var MENTION_SUGGESTIONS_DEBOUNCE = 500;
|
|
27
34
|
function useMentionSuggestions(roomId, search) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const resolveMentionSuggestions = client[kInternal].resolveMentionSuggestions;
|
|
35
|
+
const [mentionSuggestions, setMentionSuggestions] = useState();
|
|
36
|
+
const lastInvokedAt = useRef();
|
|
37
|
+
const resolveMentionSuggestions = useResolveMentionSuggestions();
|
|
38
|
+
const mentionSuggestionsCache = useMentionSuggestionsCache();
|
|
39
|
+
useEffect(() => {
|
|
34
40
|
if (search === void 0 || !resolveMentionSuggestions) {
|
|
35
41
|
return;
|
|
36
42
|
}
|
|
@@ -70,18 +76,18 @@ function useMentionSuggestions(roomId, search) {
|
|
|
70
76
|
isCanceled = true;
|
|
71
77
|
window.clearTimeout(debounceTimeout);
|
|
72
78
|
};
|
|
73
|
-
}, [
|
|
79
|
+
}, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);
|
|
74
80
|
return mentionSuggestions;
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
// src/use-sync-source.ts
|
|
78
|
-
import { kInternal
|
|
79
|
-
import
|
|
84
|
+
import { kInternal } from "@liveblocks/core";
|
|
85
|
+
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
80
86
|
function useSyncSource() {
|
|
81
87
|
const client = useClient();
|
|
82
|
-
const createSyncSource = client[
|
|
83
|
-
const [syncSource, setSyncSource] =
|
|
84
|
-
|
|
88
|
+
const createSyncSource = client[kInternal].createSyncSource;
|
|
89
|
+
const [syncSource, setSyncSource] = useState2();
|
|
90
|
+
useEffect2(() => {
|
|
85
91
|
const newSyncSource = createSyncSource();
|
|
86
92
|
setSyncSource(newSyncSource);
|
|
87
93
|
return () => newSyncSource.destroy();
|
|
@@ -95,19 +101,26 @@ export {
|
|
|
95
101
|
useClientOrNull,
|
|
96
102
|
useCreateRoomComment,
|
|
97
103
|
useCreateRoomThread,
|
|
104
|
+
useCreateTextMention,
|
|
98
105
|
useDeleteRoomComment,
|
|
99
106
|
useDeleteRoomThread,
|
|
107
|
+
useDeleteTextMention,
|
|
100
108
|
useEditRoomComment,
|
|
101
109
|
useEditRoomThreadMetadata,
|
|
102
110
|
useMarkRoomThreadAsRead,
|
|
103
111
|
useMarkRoomThreadAsResolved,
|
|
104
112
|
useMarkRoomThreadAsUnresolved,
|
|
105
113
|
useMentionSuggestions,
|
|
114
|
+
useMentionSuggestionsCache,
|
|
106
115
|
useRemoveRoomCommentReaction,
|
|
107
116
|
useReportTextEditor,
|
|
117
|
+
useResolveMentionSuggestions,
|
|
108
118
|
useRoomAttachmentUrl,
|
|
109
119
|
useRoomOrNull,
|
|
110
120
|
useRoomPermissions,
|
|
111
|
-
|
|
121
|
+
useSignal,
|
|
122
|
+
useSyncExternalStoreWithSelector,
|
|
123
|
+
useSyncSource,
|
|
124
|
+
useYjsProvider
|
|
112
125
|
};
|
|
113
126
|
//# sourceMappingURL=_private.mjs.map
|
package/dist/_private.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/use-mention-suggestions.ts","../src/use-sync-source.ts"],"sourcesContent":["import { stringify } from \"@liveblocks/core\";\nimport { useEffect, useRef, useState } from \"react\";\n\nimport {\n useMentionSuggestionsCache,\n useResolveMentionSuggestions,\n} from \"./room\";\n\nconst MENTION_SUGGESTIONS_DEBOUNCE = 500;\n\n/**\n * @private For internal use only. Do not rely on this hook.\n *\n * Simplistic debounced search, we don't need to worry too much about deduping\n * and race conditions as there can only be one search at a time.\n */\nexport function useMentionSuggestions(roomId: string, search?: string) {\n const [mentionSuggestions, setMentionSuggestions] = useState<string[]>();\n const lastInvokedAt = useRef<number>();\n\n const resolveMentionSuggestions = useResolveMentionSuggestions();\n const mentionSuggestionsCache = useMentionSuggestionsCache();\n\n useEffect(() => {\n if (search === undefined || !resolveMentionSuggestions) {\n return;\n }\n\n const resolveMentionSuggestionsArgs = { text: search, roomId };\n const mentionSuggestionsCacheKey = stringify(resolveMentionSuggestionsArgs);\n let debounceTimeout: number | undefined;\n let isCanceled = false;\n\n const getMentionSuggestions = async () => {\n try {\n lastInvokedAt.current = performance.now();\n const mentionSuggestions = await resolveMentionSuggestions(\n resolveMentionSuggestionsArgs\n );\n\n if (!isCanceled) {\n setMentionSuggestions(mentionSuggestions);\n mentionSuggestionsCache.set(\n mentionSuggestionsCacheKey,\n mentionSuggestions\n );\n }\n } catch (error) {\n console.error((error as Error)?.message);\n }\n };\n\n if (mentionSuggestionsCache.has(mentionSuggestionsCacheKey)) {\n // If there are already cached mention suggestions, use them immediately.\n setMentionSuggestions(\n mentionSuggestionsCache.get(mentionSuggestionsCacheKey)\n );\n } else if (\n !lastInvokedAt.current ||\n Math.abs(performance.now() - lastInvokedAt.current) >\n MENTION_SUGGESTIONS_DEBOUNCE\n ) {\n // If on the debounce's leading edge (either because it's the first invokation or enough\n // time has passed since the last debounce), get mention suggestions immediately.\n void getMentionSuggestions();\n } else {\n // Otherwise, wait for the debounce delay.\n debounceTimeout = window.setTimeout(() => {\n void getMentionSuggestions();\n }, MENTION_SUGGESTIONS_DEBOUNCE);\n }\n\n return () => {\n isCanceled = true;\n window.clearTimeout(debounceTimeout);\n };\n }, [search, roomId, resolveMentionSuggestions, mentionSuggestionsCache]);\n\n return mentionSuggestions;\n}\n","import type { SyncSource } from \"@liveblocks/core\";\nimport { kInternal } from \"@liveblocks/core\";\nimport { useEffect, useState } from \"react\";\n\nimport { useClient } from \"./liveblocks\";\n\n/**\n * @private For internal use only. Do not rely on this hook.\n */\nexport function useSyncSource(): SyncSource | undefined {\n const client = useClient();\n const createSyncSource = client[kInternal].createSyncSource;\n const [syncSource, setSyncSource] = useState<SyncSource | undefined>();\n\n useEffect(() => {\n // Create new sync source on mount\n const newSyncSource = createSyncSource();\n setSyncSource(newSyncSource);\n return () => newSyncSource.destroy();\n }, [createSyncSource]);\n\n return syncSource;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,WAAW,QAAQ,gBAAgB;AAO5C,IAAM,+BAA+B;AAQ9B,SAAS,sBAAsB,QAAgB,QAAiB;AACrE,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAmB;AACvE,QAAM,gBAAgB,OAAe;AAErC,QAAM,4BAA4B,6BAA6B;AAC/D,QAAM,0BAA0B,2BAA2B;AAE3D,YAAU,MAAM;AACd,QAAI,WAAW,UAAa,CAAC,2BAA2B;AACtD;AAAA,IACF;AAEA,UAAM,gCAAgC,EAAE,MAAM,QAAQ,OAAO;AAC7D,UAAM,6BAA6B,UAAU,6BAA6B;AAC1E,QAAI;AACJ,QAAI,aAAa;AAEjB,UAAM,wBAAwB,YAAY;AACxC,UAAI;AACF,sBAAc,UAAU,YAAY,IAAI;AACxC,cAAMA,sBAAqB,MAAM;AAAA,UAC/B;AAAA,QACF;AAEA,YAAI,CAAC,YAAY;AACf,gCAAsBA,mBAAkB;AACxC,kCAAwB;AAAA,YACtB;AAAA,YACAA;AAAA,UACF;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAO,OAAiB,OAAO;AAAA,MACzC;AAAA,IACF;AAEA,QAAI,wBAAwB,IAAI,0BAA0B,GAAG;AAE3D;AAAA,QACE,wBAAwB,IAAI,0BAA0B;AAAA,MACxD;AAAA,IACF,WACE,CAAC,cAAc,WACf,KAAK,IAAI,YAAY,IAAI,IAAI,cAAc,OAAO,IAChD,8BACF;AAGA,WAAK,sBAAsB;AAAA,IAC7B,OAAO;AAEL,wBAAkB,OAAO,WAAW,MAAM;AACxC,aAAK,sBAAsB;AAAA,MAC7B,GAAG,4BAA4B;AAAA,IACjC;AAEA,WAAO,MAAM;AACX,mBAAa;AACb,aAAO,aAAa,eAAe;AAAA,IACrC;AAAA,EACF,GAAG,CAAC,QAAQ,QAAQ,2BAA2B,uBAAuB,CAAC;AAEvE,SAAO;AACT;;;AC9EA,SAAS,iBAAiB;AAC1B,SAAS,aAAAC,YAAW,YAAAC,iBAAgB;AAO7B,SAAS,gBAAwC;AACtD,QAAM,SAAS,UAAU;AACzB,QAAM,mBAAmB,OAAO,SAAS,EAAE;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAIC,UAAiC;AAErE,EAAAC,WAAU,MAAM;AAEd,UAAM,gBAAgB,iBAAiB;AACvC,kBAAc,aAAa;AAC3B,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,gBAAgB,CAAC;AAErB,SAAO;AACT;","names":["mentionSuggestions","useEffect","useState","useState","useEffect"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/version.ts
|
|
2
|
+
var PKG_NAME = "@liveblocks/react";
|
|
3
|
+
var PKG_VERSION = "2.15.0";
|
|
4
|
+
var PKG_FORMAT = "cjs";
|
|
5
|
+
|
|
6
|
+
// src/ClientSideSuspense.tsx
|
|
7
|
+
var _react = require('react');
|
|
8
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
9
|
+
function ClientSideSuspense(props) {
|
|
10
|
+
const [mounted, setMounted] = _react.useState.call(void 0, false);
|
|
11
|
+
_react.useEffect.call(void 0, () => {
|
|
12
|
+
setMounted(true);
|
|
13
|
+
}, []);
|
|
14
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: props.fallback, children: mounted ? typeof props.children === "function" ? props.children() : props.children : props.fallback });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense;
|
|
23
|
+
//# sourceMappingURL=chunk-36VCTTYL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/version.ts","../src/ClientSideSuspense.tsx"],"names":[],"mappings":";AAGO,IAAM,WAAW;AACjB,IAAM,cAAiD;AACvD,IAAM,aAAgD;;;ACJ7D,SAAS,UAAU,WAAW,gBAAgB;AAkC1C;AAVG,SAAS,mBAAmB,OAAc;AAC/C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,YAAU,MAAM;AAGd,eAAW,IAAI;AAAA,EACjB,GAAG,CAAC,CAAC;AAEL,SACE,oBAAC,YAAS,UAAU,MAAM,UACvB,oBACG,OAAO,MAAM,aAAa,aACxB,MAAM,SAAS,IACf,MAAM,WACR,MAAM,UACZ;AAEJ","sourcesContent":["declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/version.ts
|
|
2
|
+
var PKG_NAME = "@liveblocks/react";
|
|
3
|
+
var PKG_VERSION = "2.15.0";
|
|
4
|
+
var PKG_FORMAT = "esm";
|
|
5
|
+
|
|
6
|
+
// src/ClientSideSuspense.tsx
|
|
7
|
+
import { Suspense, useEffect, useState } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function ClientSideSuspense(props) {
|
|
10
|
+
const [mounted, setMounted] = useState(false);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
setMounted(true);
|
|
13
|
+
}, []);
|
|
14
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: props.fallback, children: mounted ? typeof props.children === "function" ? props.children() : props.children : props.fallback });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
PKG_NAME,
|
|
19
|
+
PKG_VERSION,
|
|
20
|
+
PKG_FORMAT,
|
|
21
|
+
ClientSideSuspense
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-4HZJQXE5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/version.ts","../src/ClientSideSuspense.tsx"],"sourcesContent":["declare const __VERSION__: string;\ndeclare const TSUP_FORMAT: string;\n\nexport const PKG_NAME = \"@liveblocks/react\";\nexport const PKG_VERSION = typeof __VERSION__ === \"string\" && __VERSION__;\nexport const PKG_FORMAT = typeof TSUP_FORMAT === \"string\" && TSUP_FORMAT;\n","import type { ReactNode } from \"react\";\nimport { Suspense, useEffect, useState } from \"react\";\n\ntype Props = {\n fallback: ReactNode;\n children: (() => ReactNode | undefined) | ReactNode | undefined;\n};\n\n/**\n * Almost like a normal <Suspense> component, except that for server-side\n * renders, the fallback will be used.\n *\n * The child props will have to be provided in a function, i.e. change:\n *\n * <Suspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </Suspense>\n *\n * To:\n *\n * <ClientSideSuspense fallback={<Loading />}>\n * <MyRealComponent a={1} />\n * </ClientSideSuspense>\n *\n */\nexport function ClientSideSuspense(props: Props) {\n const [mounted, setMounted] = useState(false);\n\n useEffect(() => {\n // Effects are never executed on the server side. The point of this is to\n // delay the flipping of this boolean until after hydration has happened.\n setMounted(true);\n }, []);\n\n return (\n <Suspense fallback={props.fallback}>\n {mounted\n ? typeof props.children === \"function\"\n ? props.children()\n : props.children\n : props.fallback}\n </Suspense>\n );\n}\n"],"mappings":";AAGO,IAAM,WAAW;AACjB,IAAM,cAAiD;AACvD,IAAM,aAAgD;;;ACJ7D,SAAS,UAAU,WAAW,gBAAgB;AAkC1C;AAVG,SAAS,mBAAmB,OAAc;AAC/C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,YAAU,MAAM;AAGd,eAAW,IAAI;AAAA,EACjB,GAAG,CAAC,CAAC;AAEL,SACE,oBAAC,YAAS,UAAU,MAAM,UACvB,oBACG,OAAO,MAAM,aAAa,aACxB,MAAM,SAAS,IACf,MAAM,WACR,MAAM,UACZ;AAEJ;","names":[]}
|