@liveblocks/react 1.12.0-test1 → 1.12.0-test2
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/index.d.mts +17 -17
- package/dist/index.d.ts +17 -17
- package/dist/index.js +36 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReactElement, ReactNode, PropsWithChildren } from 'react';
|
|
|
2
2
|
import { JsonObject, LsonObject, BaseUserMeta, LiveObject, User, Json, RoomNotificationSettings, Room, Status, BroadcastOptions, OthersEvent, LostConnectionEvent, History, BaseMetadata as BaseMetadata$1, Client } from '@liveblocks/client';
|
|
3
3
|
export { Json, JsonObject, shallow } from '@liveblocks/client';
|
|
4
4
|
import * as _liveblocks_core from '@liveblocks/core';
|
|
5
|
-
import { BaseMetadata, Resolve, ToImmutable, kInternal, ThreadData, InboxNotificationData, LiveblocksError, RoomEventMessage, CommentData, RoomInfo, CommentBody, PartialNullable, RoomInitializers, ResolveUsersArgs, OptionalPromise, ResolveMentionSuggestionsArgs, BaseUserMeta as BaseUserMeta$1 } from '@liveblocks/core';
|
|
5
|
+
import { BaseMetadata, QueryMetadata, Resolve, ToImmutable, kInternal, ThreadData, InboxNotificationData, LiveblocksError, RoomEventMessage, CommentData, RoomInfo, CommentBody, PartialNullable, RoomInitializers, ResolveUsersArgs, OptionalPromise, ResolveMentionSuggestionsArgs, BaseUserMeta as BaseUserMeta$1 } from '@liveblocks/core';
|
|
6
6
|
|
|
7
7
|
declare type Props = {
|
|
8
8
|
fallback: NonNullable<ReactNode> | null;
|
|
@@ -37,7 +37,7 @@ declare type UseThreadsOptions<TThreadMetadata extends BaseMetadata> = {
|
|
|
37
37
|
* The metadata to filter the threads by. If provided, only threads with metadata that matches
|
|
38
38
|
* the provided metadata will be returned. If not provided, all threads will be returned.
|
|
39
39
|
*/
|
|
40
|
-
metadata?: Partial<TThreadMetadata
|
|
40
|
+
metadata?: Partial<QueryMetadata<TThreadMetadata>>;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* Whether to scroll to a comment on load based on the URL hash. Defaults to `true`.
|
|
@@ -952,7 +952,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
952
952
|
/**
|
|
953
953
|
* Properties that are the same in LiveblocksContext and LiveblocksContext["suspense"].
|
|
954
954
|
*/
|
|
955
|
-
declare type LiveblocksContextBundleCommon = {
|
|
955
|
+
declare type LiveblocksContextBundleCommon<TThreadMetadata extends BaseMetadata> = {
|
|
956
956
|
/**
|
|
957
957
|
* @beta
|
|
958
958
|
*
|
|
@@ -980,6 +980,15 @@ declare type LiveblocksContextBundleCommon = {
|
|
|
980
980
|
* markAllInboxNotificationsAsRead();
|
|
981
981
|
*/
|
|
982
982
|
useMarkAllInboxNotificationsAsRead(): () => void;
|
|
983
|
+
/**
|
|
984
|
+
* @beta
|
|
985
|
+
*
|
|
986
|
+
* Returns the thread associated with a `"thread"` inbox notification.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* const thread = useInboxNotificationThread("in_xxx");
|
|
990
|
+
*/
|
|
991
|
+
useInboxNotificationThread(inboxNotificationId: string): ThreadData<TThreadMetadata>;
|
|
983
992
|
};
|
|
984
993
|
/**
|
|
985
994
|
* @private
|
|
@@ -989,15 +998,6 @@ declare type LiveblocksContextBundleCommon = {
|
|
|
989
998
|
* will probably happen if you do.
|
|
990
999
|
*/
|
|
991
1000
|
declare type PrivateLiveblocksContextApi = {
|
|
992
|
-
/**
|
|
993
|
-
* @private
|
|
994
|
-
*
|
|
995
|
-
* Returns a thread from the cache.
|
|
996
|
-
*
|
|
997
|
-
* @example
|
|
998
|
-
* const thread = useThreadFromCache("th_xxx");
|
|
999
|
-
*/
|
|
1000
|
-
useThreadFromCache(threadId: string): ThreadData<BaseMetadata>;
|
|
1001
1001
|
/**
|
|
1002
1002
|
* @private
|
|
1003
1003
|
*
|
|
@@ -1005,7 +1005,7 @@ declare type PrivateLiveblocksContextApi = {
|
|
|
1005
1005
|
*/
|
|
1006
1006
|
useCurrentUserId(): string | null;
|
|
1007
1007
|
};
|
|
1008
|
-
declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta> = Resolve<LiveblocksContextBundleCommon & Omit<SharedContextBundle<TUserMeta>, "suspense"> & {
|
|
1008
|
+
declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta, TThreadMetadata extends BaseMetadata> = Resolve<LiveblocksContextBundleCommon<TThreadMetadata> & Omit<SharedContextBundle<TUserMeta>, "suspense"> & {
|
|
1009
1009
|
/**
|
|
1010
1010
|
* @beta
|
|
1011
1011
|
*
|
|
@@ -1024,7 +1024,7 @@ declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta> = Resolve<L
|
|
|
1024
1024
|
* const { count, error, isLoading } = useUnreadInboxNotificationsCount();
|
|
1025
1025
|
*/
|
|
1026
1026
|
useUnreadInboxNotificationsCount(): UnreadInboxNotificationsCountState;
|
|
1027
|
-
suspense: Resolve<LiveblocksContextBundleCommon & SharedContextBundle<TUserMeta>["suspense"] & {
|
|
1027
|
+
suspense: Resolve<LiveblocksContextBundleCommon<TThreadMetadata> & SharedContextBundle<TUserMeta>["suspense"] & {
|
|
1028
1028
|
/**
|
|
1029
1029
|
* @beta
|
|
1030
1030
|
*
|
|
@@ -1060,8 +1060,8 @@ declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta> = Resolve<L
|
|
|
1060
1060
|
*
|
|
1061
1061
|
* This is an internal API, use "createLiveblocksContext" instead.
|
|
1062
1062
|
*/
|
|
1063
|
-
declare function useLiveblocksContextBundle(): LiveblocksContextBundle<BaseUserMeta>;
|
|
1064
|
-
declare function createLiveblocksContext<TUserMeta extends BaseUserMeta = BaseUserMeta, TThreadMetadata extends BaseMetadata$1 = never>(client: Client): LiveblocksContextBundle<TUserMeta>;
|
|
1063
|
+
declare function useLiveblocksContextBundle(): LiveblocksContextBundle<BaseUserMeta, BaseMetadata$1>;
|
|
1064
|
+
declare function createLiveblocksContext<TUserMeta extends BaseUserMeta = BaseUserMeta, TThreadMetadata extends BaseMetadata$1 = never>(client: Client): LiveblocksContextBundle<TUserMeta, TThreadMetadata>;
|
|
1065
1065
|
|
|
1066
1066
|
/**
|
|
1067
1067
|
* @private
|
|
@@ -1092,6 +1092,6 @@ declare function createRoomContext<TPresence extends JsonObject, TStorage extend
|
|
|
1092
1092
|
*
|
|
1093
1093
|
* This is an internal API, use `createLiveblocksContext` or `createRoomContext` instead.
|
|
1094
1094
|
*/
|
|
1095
|
-
declare function useSharedContextBundle(): RoomContextBundle<_liveblocks_core.JsonObject, _liveblocks_core.LsonObject, BaseUserMeta$1, never, _liveblocks_core.BaseMetadata> | LiveblocksContextBundle<BaseUserMeta$1>;
|
|
1095
|
+
declare function useSharedContextBundle(): RoomContextBundle<_liveblocks_core.JsonObject, _liveblocks_core.LsonObject, BaseUserMeta$1, never, _liveblocks_core.BaseMetadata> | LiveblocksContextBundle<BaseUserMeta$1, _liveblocks_core.BaseMetadata>;
|
|
1096
1096
|
|
|
1097
1097
|
export { ClientSideSuspense, type MutationContext, type UseThreadsOptions, createLiveblocksContext, createRoomContext, useLiveblocksContextBundle, useRoomContextBundle, useSharedContextBundle };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReactElement, ReactNode, PropsWithChildren } from 'react';
|
|
|
2
2
|
import { JsonObject, LsonObject, BaseUserMeta, LiveObject, User, Json, RoomNotificationSettings, Room, Status, BroadcastOptions, OthersEvent, LostConnectionEvent, History, BaseMetadata as BaseMetadata$1, Client } from '@liveblocks/client';
|
|
3
3
|
export { Json, JsonObject, shallow } from '@liveblocks/client';
|
|
4
4
|
import * as _liveblocks_core from '@liveblocks/core';
|
|
5
|
-
import { BaseMetadata, Resolve, ToImmutable, kInternal, ThreadData, InboxNotificationData, LiveblocksError, RoomEventMessage, CommentData, RoomInfo, CommentBody, PartialNullable, RoomInitializers, ResolveUsersArgs, OptionalPromise, ResolveMentionSuggestionsArgs, BaseUserMeta as BaseUserMeta$1 } from '@liveblocks/core';
|
|
5
|
+
import { BaseMetadata, QueryMetadata, Resolve, ToImmutable, kInternal, ThreadData, InboxNotificationData, LiveblocksError, RoomEventMessage, CommentData, RoomInfo, CommentBody, PartialNullable, RoomInitializers, ResolveUsersArgs, OptionalPromise, ResolveMentionSuggestionsArgs, BaseUserMeta as BaseUserMeta$1 } from '@liveblocks/core';
|
|
6
6
|
|
|
7
7
|
declare type Props = {
|
|
8
8
|
fallback: NonNullable<ReactNode> | null;
|
|
@@ -37,7 +37,7 @@ declare type UseThreadsOptions<TThreadMetadata extends BaseMetadata> = {
|
|
|
37
37
|
* The metadata to filter the threads by. If provided, only threads with metadata that matches
|
|
38
38
|
* the provided metadata will be returned. If not provided, all threads will be returned.
|
|
39
39
|
*/
|
|
40
|
-
metadata?: Partial<TThreadMetadata
|
|
40
|
+
metadata?: Partial<QueryMetadata<TThreadMetadata>>;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* Whether to scroll to a comment on load based on the URL hash. Defaults to `true`.
|
|
@@ -952,7 +952,7 @@ declare type RoomContextBundle<TPresence extends JsonObject, TStorage extends Ls
|
|
|
952
952
|
/**
|
|
953
953
|
* Properties that are the same in LiveblocksContext and LiveblocksContext["suspense"].
|
|
954
954
|
*/
|
|
955
|
-
declare type LiveblocksContextBundleCommon = {
|
|
955
|
+
declare type LiveblocksContextBundleCommon<TThreadMetadata extends BaseMetadata> = {
|
|
956
956
|
/**
|
|
957
957
|
* @beta
|
|
958
958
|
*
|
|
@@ -980,6 +980,15 @@ declare type LiveblocksContextBundleCommon = {
|
|
|
980
980
|
* markAllInboxNotificationsAsRead();
|
|
981
981
|
*/
|
|
982
982
|
useMarkAllInboxNotificationsAsRead(): () => void;
|
|
983
|
+
/**
|
|
984
|
+
* @beta
|
|
985
|
+
*
|
|
986
|
+
* Returns the thread associated with a `"thread"` inbox notification.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* const thread = useInboxNotificationThread("in_xxx");
|
|
990
|
+
*/
|
|
991
|
+
useInboxNotificationThread(inboxNotificationId: string): ThreadData<TThreadMetadata>;
|
|
983
992
|
};
|
|
984
993
|
/**
|
|
985
994
|
* @private
|
|
@@ -989,15 +998,6 @@ declare type LiveblocksContextBundleCommon = {
|
|
|
989
998
|
* will probably happen if you do.
|
|
990
999
|
*/
|
|
991
1000
|
declare type PrivateLiveblocksContextApi = {
|
|
992
|
-
/**
|
|
993
|
-
* @private
|
|
994
|
-
*
|
|
995
|
-
* Returns a thread from the cache.
|
|
996
|
-
*
|
|
997
|
-
* @example
|
|
998
|
-
* const thread = useThreadFromCache("th_xxx");
|
|
999
|
-
*/
|
|
1000
|
-
useThreadFromCache(threadId: string): ThreadData<BaseMetadata>;
|
|
1001
1001
|
/**
|
|
1002
1002
|
* @private
|
|
1003
1003
|
*
|
|
@@ -1005,7 +1005,7 @@ declare type PrivateLiveblocksContextApi = {
|
|
|
1005
1005
|
*/
|
|
1006
1006
|
useCurrentUserId(): string | null;
|
|
1007
1007
|
};
|
|
1008
|
-
declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta> = Resolve<LiveblocksContextBundleCommon & Omit<SharedContextBundle<TUserMeta>, "suspense"> & {
|
|
1008
|
+
declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta, TThreadMetadata extends BaseMetadata> = Resolve<LiveblocksContextBundleCommon<TThreadMetadata> & Omit<SharedContextBundle<TUserMeta>, "suspense"> & {
|
|
1009
1009
|
/**
|
|
1010
1010
|
* @beta
|
|
1011
1011
|
*
|
|
@@ -1024,7 +1024,7 @@ declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta> = Resolve<L
|
|
|
1024
1024
|
* const { count, error, isLoading } = useUnreadInboxNotificationsCount();
|
|
1025
1025
|
*/
|
|
1026
1026
|
useUnreadInboxNotificationsCount(): UnreadInboxNotificationsCountState;
|
|
1027
|
-
suspense: Resolve<LiveblocksContextBundleCommon & SharedContextBundle<TUserMeta>["suspense"] & {
|
|
1027
|
+
suspense: Resolve<LiveblocksContextBundleCommon<TThreadMetadata> & SharedContextBundle<TUserMeta>["suspense"] & {
|
|
1028
1028
|
/**
|
|
1029
1029
|
* @beta
|
|
1030
1030
|
*
|
|
@@ -1060,8 +1060,8 @@ declare type LiveblocksContextBundle<TUserMeta extends BaseUserMeta> = Resolve<L
|
|
|
1060
1060
|
*
|
|
1061
1061
|
* This is an internal API, use "createLiveblocksContext" instead.
|
|
1062
1062
|
*/
|
|
1063
|
-
declare function useLiveblocksContextBundle(): LiveblocksContextBundle<BaseUserMeta>;
|
|
1064
|
-
declare function createLiveblocksContext<TUserMeta extends BaseUserMeta = BaseUserMeta, TThreadMetadata extends BaseMetadata$1 = never>(client: Client): LiveblocksContextBundle<TUserMeta>;
|
|
1063
|
+
declare function useLiveblocksContextBundle(): LiveblocksContextBundle<BaseUserMeta, BaseMetadata$1>;
|
|
1064
|
+
declare function createLiveblocksContext<TUserMeta extends BaseUserMeta = BaseUserMeta, TThreadMetadata extends BaseMetadata$1 = never>(client: Client): LiveblocksContextBundle<TUserMeta, TThreadMetadata>;
|
|
1065
1065
|
|
|
1066
1066
|
/**
|
|
1067
1067
|
* @private
|
|
@@ -1092,6 +1092,6 @@ declare function createRoomContext<TPresence extends JsonObject, TStorage extend
|
|
|
1092
1092
|
*
|
|
1093
1093
|
* This is an internal API, use `createLiveblocksContext` or `createRoomContext` instead.
|
|
1094
1094
|
*/
|
|
1095
|
-
declare function useSharedContextBundle(): RoomContextBundle<_liveblocks_core.JsonObject, _liveblocks_core.LsonObject, BaseUserMeta$1, never, _liveblocks_core.BaseMetadata> | LiveblocksContextBundle<BaseUserMeta$1>;
|
|
1095
|
+
declare function useSharedContextBundle(): RoomContextBundle<_liveblocks_core.JsonObject, _liveblocks_core.LsonObject, BaseUserMeta$1, never, _liveblocks_core.BaseMetadata> | LiveblocksContextBundle<BaseUserMeta$1, _liveblocks_core.BaseMetadata>;
|
|
1096
1096
|
|
|
1097
1097
|
export { ClientSideSuspense, type MutationContext, type UseThreadsOptions, createLiveblocksContext, createRoomContext, useLiveblocksContextBundle, useRoomContextBundle, useSharedContextBundle };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var _core = require('@liveblocks/core');
|
|
|
5
5
|
|
|
6
6
|
// src/version.ts
|
|
7
7
|
var PKG_NAME = "@liveblocks/react";
|
|
8
|
-
var PKG_VERSION = "1.12.0-
|
|
8
|
+
var PKG_VERSION = "1.12.0-test2";
|
|
9
9
|
var PKG_FORMAT = "cjs";
|
|
10
10
|
|
|
11
11
|
// src/ClientSideSuspense.tsx
|
|
@@ -194,7 +194,14 @@ function selectedThreads(roomId, state, options) {
|
|
|
194
194
|
if (!query)
|
|
195
195
|
return true;
|
|
196
196
|
for (const key in query.metadata) {
|
|
197
|
-
|
|
197
|
+
const metadataValue = thread.metadata[key];
|
|
198
|
+
const filterValue = query.metadata[key];
|
|
199
|
+
if (assertFilterIsStartsWithOperator(filterValue) && assertMetadataValueIsString(metadataValue)) {
|
|
200
|
+
if (metadataValue.startsWith(filterValue.startsWith)) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (metadataValue !== filterValue) {
|
|
198
205
|
return false;
|
|
199
206
|
}
|
|
200
207
|
}
|
|
@@ -202,6 +209,16 @@ function selectedThreads(roomId, state, options) {
|
|
|
202
209
|
});
|
|
203
210
|
return threads.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
204
211
|
}
|
|
212
|
+
var assertFilterIsStartsWithOperator = (filter) => {
|
|
213
|
+
if (typeof filter === "object" && typeof filter.startsWith === "string") {
|
|
214
|
+
return true;
|
|
215
|
+
} else {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
var assertMetadataValueIsString = (value) => {
|
|
220
|
+
return typeof value === "string";
|
|
221
|
+
};
|
|
205
222
|
|
|
206
223
|
// src/lib/use-initial.ts
|
|
207
224
|
|
|
@@ -2270,18 +2287,29 @@ function createLiveblocksContext(client) {
|
|
|
2270
2287
|
);
|
|
2271
2288
|
}, []);
|
|
2272
2289
|
}
|
|
2273
|
-
function
|
|
2290
|
+
function useInboxNotificationThread(inboxNotificationId) {
|
|
2274
2291
|
const selector = _react.useCallback.call(void 0,
|
|
2275
2292
|
(state) => {
|
|
2276
|
-
const
|
|
2293
|
+
const inboxNotification = state.inboxNotifications[inboxNotificationId];
|
|
2294
|
+
if (inboxNotification === void 0) {
|
|
2295
|
+
throw new Error(
|
|
2296
|
+
`Inbox notification with ID "${inboxNotificationId}" not found`
|
|
2297
|
+
);
|
|
2298
|
+
}
|
|
2299
|
+
if (inboxNotification.kind !== "thread") {
|
|
2300
|
+
throw new Error(
|
|
2301
|
+
`Inbox notification with ID "${inboxNotificationId}" is not of kind "thread"`
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
const thread = state.threads[inboxNotification.threadId];
|
|
2277
2305
|
if (thread === void 0) {
|
|
2278
2306
|
throw new Error(
|
|
2279
|
-
`
|
|
2307
|
+
`Thread with ID "${inboxNotification.threadId}" not found, this inbox notification might not be of kind "thread"`
|
|
2280
2308
|
);
|
|
2281
2309
|
}
|
|
2282
2310
|
return thread;
|
|
2283
2311
|
},
|
|
2284
|
-
[
|
|
2312
|
+
[inboxNotificationId]
|
|
2285
2313
|
);
|
|
2286
2314
|
return _withselectorjs.useSyncExternalStoreWithSelector.call(void 0,
|
|
2287
2315
|
store.subscribe,
|
|
@@ -2304,6 +2332,7 @@ function createLiveblocksContext(client) {
|
|
|
2304
2332
|
useUnreadInboxNotificationsCount,
|
|
2305
2333
|
useMarkInboxNotificationAsRead,
|
|
2306
2334
|
useMarkAllInboxNotificationsAsRead,
|
|
2335
|
+
useInboxNotificationThread,
|
|
2307
2336
|
...shared,
|
|
2308
2337
|
suspense: {
|
|
2309
2338
|
LiveblocksProvider,
|
|
@@ -2311,10 +2340,10 @@ function createLiveblocksContext(client) {
|
|
|
2311
2340
|
useUnreadInboxNotificationsCount: useUnreadInboxNotificationsCountSuspense,
|
|
2312
2341
|
useMarkInboxNotificationAsRead,
|
|
2313
2342
|
useMarkAllInboxNotificationsAsRead,
|
|
2343
|
+
useInboxNotificationThread,
|
|
2314
2344
|
...shared.suspense
|
|
2315
2345
|
},
|
|
2316
2346
|
[_core.kInternal]: {
|
|
2317
|
-
useThreadFromCache,
|
|
2318
2347
|
useCurrentUserId
|
|
2319
2348
|
}
|
|
2320
2349
|
};
|