Fixed Liveblocks Config

This commit is contained in:
Ahmad 2024-03-24 17:18:00 -04:00
parent fd40614b93
commit 807b9ac75c
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
3 changed files with 93 additions and 32 deletions

View file

@ -1,23 +1,92 @@
/* import { createClient } from '@liveblocks/client'; import { createClient } from '@liveblocks/client';
import { createRoomContext, createLiveblocksContext } from '@liveblocks/react'; import { createRoomContext, createLiveblocksContext } from '@liveblocks/react';
const client = createClient({ const client = createClient({
publicApiKey: process.env.NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY!, publicApiKey: process.env.NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY!,
// authEndpoint: "/api/liveblocks-auth",
throttle: 16, throttle: 16,
async resolveUsers({ userIds }) {
// Used only for Comments and Notifications. Return a list of user information
// retrieved from `userIds`. This info is used in comments, mentions etc.
// const usersData = await __fetchUsersFromDB__(userIds);
//
// return usersData.map((userData) => ({
// name: userData.name,
// avatar: userData.avatar.src,
// }));
return [];
},
async resolveMentionSuggestions({ text }) {
// Used only for Comments. Return a list of userIds that match `text`.
// These userIds are used to create a mention list when typing in the
// composer.
//
// For example when you type "@jo", `text` will be `"jo"`, and
// you should to return an array with John and Joanna's userIds:
// ["john@example.com", "joanna@example.com"]
// const users = await getUsers({ search: text });
// return users.map((user) => user.id);
return [];
},
async resolveRoomsInfo({ roomIds }) {
// Used only for Comments and Notifications. Return a list of room information
// retrieved from `roomIds`.
// const roomsData = await __fetchRoomsFromDB__(roomIds);
//
// return roomsData.map((roomData) => ({
// name: roomData.name,
// url: roomData.url,
// }));
return [];
},
}); });
// Presence represents the properties that exist on every user in the Room
// and that will automatically be kept in sync. Accessible through the
// `user.presence` property. Must be JSON-serializable.
type Presence = { type Presence = {
cursor: { x: number; y: number } | null; cursor: { x: number; y: number } | null;
}; };
type Storage = {}; // Optionally, Storage represents the shared document that persists in the
// Room, even after all users leave. Fields under Storage typically are
// LiveList, LiveMap, LiveObject instances, for which updates are
// automatically persisted and synced to all connected clients.
type Storage = {
// author: LiveObject<{ firstName: string, lastName: string }>,
// ...
};
type UserMeta = {}; // Optionally, UserMeta represents static/readonly metadata on each user, as
// provided by your own custom auth back end (if used). Useful for data that
// will not change during a session, like a user's name or avatar.
type UserMeta = {
// id?: string, // Accessible through `user.id`
// info?: Json, // Accessible through `user.info`
};
type RoomEvent = {}; // Optionally, the type of custom events broadcast and listened to in this
// room. Use a union for multiple events. Must be JSON-serializable.
type RoomEvent = {
// type: "NOTIFICATION",
// ...
};
export type ThreadMetadata = {}; // Optionally, when using Comments, ThreadMetadata represents metadata on
// each thread. Can only contain booleans, strings, and numbers.
export type ThreadMetadata = {
// resolved: boolean;
// quote: string;
// time: number;
};
// Room-level hooks, use inside `RoomProvider`
export const { export const {
suspense: { suspense: {
RoomProvider, RoomProvider,
@ -34,6 +103,9 @@ export const {
useEventListener, useEventListener,
useErrorListener, useErrorListener,
useStorage, useStorage,
useObject,
useMap,
useList,
useBatch, useBatch,
useHistory, useHistory,
useUndo, useUndo,
@ -55,11 +127,16 @@ export const {
useMarkThreadAsRead, useMarkThreadAsRead,
useRoomNotificationSettings, useRoomNotificationSettings,
useUpdateRoomNotificationSettings, useUpdateRoomNotificationSettings,
// These hooks can be exported from either context
// useUser,
// useRoomInfo
}, },
} = createRoomContext<Presence, Storage, UserMeta, RoomEvent, ThreadMetadata>( } = createRoomContext<Presence, Storage, UserMeta, RoomEvent, ThreadMetadata>(
client client
); );
// Project-level hooks, use inside `LiveblocksProvider`
export const { export const {
suspense: { suspense: {
LiveblocksProvider, LiveblocksProvider,
@ -67,7 +144,9 @@ export const {
useMarkAllInboxNotificationsAsRead, useMarkAllInboxNotificationsAsRead,
useInboxNotifications, useInboxNotifications,
useUnreadInboxNotificationsCount, useUnreadInboxNotificationsCount,
// These hooks can be exported from either context
useUser, useUser,
useRoomInfo, useRoomInfo,
}, },
} = createLiveblocksContext<UserMeta, ThreadMetadata>(client); */ } = createLiveblocksContext<UserMeta, ThreadMetadata>(client);

32
package-lock.json generated
View file

@ -13,7 +13,7 @@
"@hello-pangea/dnd": "^16.5.0", "@hello-pangea/dnd": "^16.5.0",
"@liveblocks/client": "^1.11.0", "@liveblocks/client": "^1.11.0",
"@liveblocks/node": "^1.11.0", "@liveblocks/node": "^1.11.0",
"@liveblocks/react": "^1.10.4", "@liveblocks/react": "^1.11.0",
"@microsoft/eslint-formatter-sarif": "^3.0.0", "@microsoft/eslint-formatter-sarif": "^3.0.0",
"@prisma/client": "^5.11.0", "@prisma/client": "^5.11.0",
"@prisma/extension-accelerate": "^1.0.0", "@prisma/extension-accelerate": "^1.0.0",
@ -450,16 +450,11 @@
"@liveblocks/core": "1.11.0" "@liveblocks/core": "1.11.0"
} }
}, },
"node_modules/@liveblocks/client/node_modules/@liveblocks/core": { "node_modules/@liveblocks/core": {
"version": "1.11.0", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/@liveblocks/core/-/core-1.11.0.tgz", "resolved": "https://registry.npmjs.org/@liveblocks/core/-/core-1.11.0.tgz",
"integrity": "sha512-fB5ZlT/HiXHynDiVwtGz7/9ZJy9RF7nziJ7LicVvMc9OCuibLj8xl4Mp/ZHvFSAcbpWA2kKQe0m0wPawSkamIw==" "integrity": "sha512-fB5ZlT/HiXHynDiVwtGz7/9ZJy9RF7nziJ7LicVvMc9OCuibLj8xl4Mp/ZHvFSAcbpWA2kKQe0m0wPawSkamIw=="
}, },
"node_modules/@liveblocks/core": {
"version": "1.10.4",
"resolved": "https://registry.npmjs.org/@liveblocks/core/-/core-1.10.4.tgz",
"integrity": "sha512-Gh9V3Ayoxhg/GAzVX0LcRo+0BLlaJNkDT8g/Kt7UnXDiXWdi5CXzniqnaPf+9mwrohsVGFdZVdF1ixIzk6JAtA=="
},
"node_modules/@liveblocks/node": { "node_modules/@liveblocks/node": {
"version": "1.11.0", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/@liveblocks/node/-/node-1.11.0.tgz", "resolved": "https://registry.npmjs.org/@liveblocks/node/-/node-1.11.0.tgz",
@ -471,18 +466,13 @@
"node-fetch": "^2.6.1" "node-fetch": "^2.6.1"
} }
}, },
"node_modules/@liveblocks/node/node_modules/@liveblocks/core": {
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/@liveblocks/core/-/core-1.11.0.tgz",
"integrity": "sha512-fB5ZlT/HiXHynDiVwtGz7/9ZJy9RF7nziJ7LicVvMc9OCuibLj8xl4Mp/ZHvFSAcbpWA2kKQe0m0wPawSkamIw=="
},
"node_modules/@liveblocks/react": { "node_modules/@liveblocks/react": {
"version": "1.10.4", "version": "1.11.0",
"resolved": "https://registry.npmjs.org/@liveblocks/react/-/react-1.10.4.tgz", "resolved": "https://registry.npmjs.org/@liveblocks/react/-/react-1.11.0.tgz",
"integrity": "sha512-HQWbGvMY6Hto3eAOVl/LczNZ17I2YHNzHtSVKqu0a1PuM5joAFI5DgZxvMfBsOUenhdzc0xrF8PaVjF9KB7vUg==", "integrity": "sha512-ADBTXLDR34I2Pj8kvRTpuVkQLAf12Oqk/6zQJ3Qi5L4s9/JBzwUmmH5SqwwtXoxSJtLnIBhQaz62CB5tGrFomQ==",
"dependencies": { "dependencies": {
"@liveblocks/client": "1.10.4", "@liveblocks/client": "1.11.0",
"@liveblocks/core": "1.10.4", "@liveblocks/core": "1.11.0",
"nanoid": "^3", "nanoid": "^3",
"use-sync-external-store": "^1.2.0" "use-sync-external-store": "^1.2.0"
}, },
@ -490,14 +480,6 @@
"react": "^16.14.0 || ^17 || ^18" "react": "^16.14.0 || ^17 || ^18"
} }
}, },
"node_modules/@liveblocks/react/node_modules/@liveblocks/client": {
"version": "1.10.4",
"resolved": "https://registry.npmjs.org/@liveblocks/client/-/client-1.10.4.tgz",
"integrity": "sha512-klmFd1kVkUbUzYue/tMxRmqJwE/4hw9Yqv5KnbzNAK8HxQ/X6e2m/eEXvNdMsP2Uco0qJDfJsJBjEjKFxCOf1A==",
"dependencies": {
"@liveblocks/core": "1.10.4"
}
},
"node_modules/@microsoft/eslint-formatter-sarif": { "node_modules/@microsoft/eslint-formatter-sarif": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/@microsoft/eslint-formatter-sarif/-/eslint-formatter-sarif-3.0.0.tgz", "resolved": "https://registry.npmjs.org/@microsoft/eslint-formatter-sarif/-/eslint-formatter-sarif-3.0.0.tgz",

View file

@ -16,7 +16,7 @@
"@hello-pangea/dnd": "^16.5.0", "@hello-pangea/dnd": "^16.5.0",
"@liveblocks/client": "^1.11.0", "@liveblocks/client": "^1.11.0",
"@liveblocks/node": "^1.11.0", "@liveblocks/node": "^1.11.0",
"@liveblocks/react": "^1.10.4", "@liveblocks/react": "^1.11.0",
"@microsoft/eslint-formatter-sarif": "^3.0.0", "@microsoft/eslint-formatter-sarif": "^3.0.0",
"@prisma/client": "^5.11.0", "@prisma/client": "^5.11.0",
"@prisma/extension-accelerate": "^1.0.0", "@prisma/extension-accelerate": "^1.0.0",