@liveblocks/react 2.25.0-aiprivatebeta9 → 3.0.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/_private/package.json +2 -2
- package/dist/_private.cjs +19 -10
- package/dist/_private.cjs.map +1 -1
- package/dist/_private.d.cts +6 -3
- package/dist/_private.d.ts +6 -3
- package/dist/_private.js +15 -6
- package/dist/_private.js.map +1 -1
- package/dist/{chunk-TMKZ6U2Y.js → chunk-CS6KYNXH.js} +235 -274
- package/dist/chunk-CS6KYNXH.js.map +1 -0
- package/dist/{chunk-RB4LUCGL.cjs → chunk-UR7FENGR.cjs} +135 -174
- package/dist/chunk-UR7FENGR.cjs.map +1 -0
- package/dist/chunk-WMTIZOZ3.cjs +23 -0
- package/dist/chunk-WMTIZOZ3.cjs.map +1 -0
- package/dist/chunk-XVEMIR32.js +23 -0
- package/dist/chunk-XVEMIR32.js.map +1 -0
- package/dist/index.cjs +4 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -19
- package/dist/index.d.ts +32 -19
- package/dist/index.js +10 -12
- package/dist/index.js.map +1 -1
- package/dist/{room-BSt58hY4.d.cts → room-Du6_Cy1X.d.cts} +143 -124
- package/dist/{room-BSt58hY4.d.ts → room-Du6_Cy1X.d.ts} +143 -124
- package/dist/suspense.cjs +4 -8
- package/dist/suspense.cjs.map +1 -1
- package/dist/suspense.d.cts +2 -2
- package/dist/suspense.d.ts +2 -2
- package/dist/suspense.js +8 -12
- package/dist/suspense.js.map +1 -1
- package/package.json +13 -3
- package/suspense/package.json +2 -2
- package/dist/chunk-M6D2NTTI.cjs +0 -60
- package/dist/chunk-M6D2NTTI.cjs.map +0 -1
- package/dist/chunk-RB4LUCGL.cjs.map +0 -1
- package/dist/chunk-TMKZ6U2Y.js.map +0 -1
- package/dist/chunk-Z2N4O6IQ.js +0 -60
- package/dist/chunk-Z2N4O6IQ.js.map +0 -1
package/dist/suspense.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/suspense.ts"],"sourcesContent":["/* eslint-disable simple-import-sort/exports */\nimport { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport { ClientSideSuspense } from \"./ClientSideSuspense\";\nexport type {\n MutationContext,\n
|
|
1
|
+
{"version":3,"sources":["../src/suspense.ts"],"sourcesContent":["/* eslint-disable simple-import-sort/exports */\nimport { detectDupes } from \"@liveblocks/core\";\n\nimport { PKG_FORMAT, PKG_NAME, PKG_VERSION } from \"./version\";\ndetectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);\n\nexport { ClientSideSuspense } from \"./ClientSideSuspense\";\nexport type {\n MutationContext,\n UseSendAiMessageOptions,\n UseThreadsOptions,\n} from \"./types\";\n\n// Re-exports from @liveblocks/client, for convenience\nexport type { Json, JsonObject } from \"@liveblocks/client\";\nexport { shallow, isNotificationChannelEnabled } from \"@liveblocks/client\";\n\n// Export all the top-level hooks\nexport { ClientContext, RoomContext, useClient } from \"./contexts\";\nexport { RegisterAiKnowledge, RegisterAiTool } from \"./ai\";\nexport type { RegisterAiKnowledgeProps, RegisterAiToolProps } from \"./types/ai\";\nexport {\n LiveblocksProvider,\n useInboxNotificationThread,\n useMarkAllInboxNotificationsAsRead,\n useMarkInboxNotificationAsRead,\n useDeleteAllInboxNotifications,\n useDeleteInboxNotification,\n useUpdateNotificationSettings,\n useCreateAiChat,\n useDeleteAiChat,\n useSendAiMessage,\n useSyncStatus,\n useErrorListener,\n} from \"./liveblocks\";\nexport {\n RoomProvider,\n useAddReaction,\n useBroadcastEvent,\n useCanRedo,\n useCanUndo,\n useCreateComment,\n useCreateThread,\n useDeleteComment,\n useDeleteThread,\n useEditComment,\n useEditThreadMetadata,\n useMarkThreadAsResolved,\n useMarkThreadAsUnresolved,\n useSubscribeToThread,\n useUnsubscribeFromThread,\n useEventListener,\n useHistory,\n useIsInsideRoom,\n useLostConnectionListener,\n useMarkThreadAsRead,\n useMutation,\n useMyPresence,\n useOthersListener,\n useRedo,\n useRemoveReaction,\n useRoom,\n useStatus,\n useStorageRoot,\n useThreadSubscription,\n useUndo,\n useUpdateMyPresence,\n useUpdateRoomSubscriptionSettings,\n} from \"./room\";\n\n// Export the Suspense versions of our hooks\n// (This part differs from src/index.ts)\nexport {\n useOtherSuspense as useOther,\n useOthersSuspense as useOthers,\n useOthersConnectionIdsSuspense as useOthersConnectionIds,\n useOthersMappedSuspense as useOthersMapped,\n useSelfSuspense as useSelf,\n useStorageSuspense as useStorage,\n useThreadsSuspense as useThreads,\n useAttachmentUrlSuspense as useAttachmentUrl,\n useHistoryVersionsSuspense as useHistoryVersions,\n useRoomSubscriptionSettingsSuspense as useRoomSubscriptionSettings,\n} from \"./room\";\nexport {\n useInboxNotificationsSuspense as useInboxNotifications,\n useNotificationSettingsSuspense as useNotificationSettings,\n useRoomInfoSuspense as useRoomInfo,\n useUnreadInboxNotificationsCountSuspense as useUnreadInboxNotificationsCount,\n useUserSuspense as useUser,\n useUserThreadsSuspense_experimental as useUserThreads_experimental,\n useAiChatsSuspense as useAiChats,\n useAiChatMessagesSuspense as useAiChatMessages,\n useAiChatSuspense as useAiChat,\n} from \"./liveblocks\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,mBAAmB;AAc5B,SAAS,SAAS,oCAAoC;AAXtD,YAAY,UAAU,aAAa,UAAU;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A set of React hooks and providers to use Liveblocks declaratively. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -61,12 +61,22 @@
|
|
|
61
61
|
"showdeps": "depcruise src --include-only '^src' --exclude='__tests__' --output-type dot | dot -T svg > /tmp/dependency-graph.svg && open /tmp/dependency-graph.svg"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@liveblocks/client": "
|
|
65
|
-
"@liveblocks/core": "
|
|
64
|
+
"@liveblocks/client": "3.0.0",
|
|
65
|
+
"@liveblocks/core": "3.0.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
+
"@types/react": "*",
|
|
69
|
+
"@types/react-dom": "*",
|
|
68
70
|
"react": "^18 || ^19 || ^19.0.0-rc"
|
|
69
71
|
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"@types/react": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"@types/react-dom": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
70
80
|
"devDependencies": {
|
|
71
81
|
"@liveblocks/eslint-config": "*",
|
|
72
82
|
"@liveblocks/jest-config": "*",
|
package/suspense/package.json
CHANGED
package/dist/chunk-M6D2NTTI.cjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
var _chunkRB4LUCGLcjs = require('./chunk-RB4LUCGL.cjs');
|
|
4
|
-
|
|
5
|
-
// src/version.ts
|
|
6
|
-
var PKG_NAME = "@liveblocks/react";
|
|
7
|
-
var PKG_VERSION = "2.25.0-aiprivatebeta9";
|
|
8
|
-
var PKG_FORMAT = "cjs";
|
|
9
|
-
|
|
10
|
-
// src/ClientSideSuspense.tsx
|
|
11
|
-
var _react = require('react');
|
|
12
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
13
|
-
function ClientSideSuspense(props) {
|
|
14
|
-
const [mounted, setMounted] = _react.useState.call(void 0, false);
|
|
15
|
-
_react.useEffect.call(void 0, () => {
|
|
16
|
-
setMounted(true);
|
|
17
|
-
}, []);
|
|
18
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: props.fallback, children: mounted ? typeof props.children === "function" ? props.children() : props.children : props.fallback });
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// src/ai.tsx
|
|
22
|
-
var _core = require('@liveblocks/core');
|
|
23
|
-
|
|
24
|
-
function useAi() {
|
|
25
|
-
return _chunkRB4LUCGLcjs.useClient.call(void 0, )[_core.kInternal].ai;
|
|
26
|
-
}
|
|
27
|
-
function useRandom() {
|
|
28
|
-
return _react.useState.call(void 0, _core.nanoid)[0];
|
|
29
|
-
}
|
|
30
|
-
var RegisterAiKnowledge = _react.memo.call(void 0, function RegisterAiKnowledge2(props) {
|
|
31
|
-
const layerId = _react.useId.call(void 0, );
|
|
32
|
-
const ai = useAi();
|
|
33
|
-
const { description, value } = props;
|
|
34
|
-
const [layerKey, setLayerKey] = _react.useState.call(void 0, );
|
|
35
|
-
_react.useEffect.call(void 0, () => {
|
|
36
|
-
const layerKey2 = ai.registerKnowledgeLayer(layerId);
|
|
37
|
-
setLayerKey(layerKey2);
|
|
38
|
-
return () => {
|
|
39
|
-
ai.deregisterKnowledgeLayer(layerKey2);
|
|
40
|
-
setLayerKey(void 0);
|
|
41
|
-
};
|
|
42
|
-
}, [ai, layerId]);
|
|
43
|
-
const randomKey = useRandom();
|
|
44
|
-
const knowledgeKey = _nullishCoalesce(props.id, () => ( randomKey));
|
|
45
|
-
_react.useEffect.call(void 0, () => {
|
|
46
|
-
if (layerKey !== void 0) {
|
|
47
|
-
ai.updateKnowledge(layerKey, { description, value }, knowledgeKey);
|
|
48
|
-
}
|
|
49
|
-
}, [ai, layerKey, knowledgeKey, description, value]);
|
|
50
|
-
return null;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
exports.PKG_NAME = PKG_NAME; exports.PKG_VERSION = PKG_VERSION; exports.PKG_FORMAT = PKG_FORMAT; exports.ClientSideSuspense = ClientSideSuspense; exports.RegisterAiKnowledge = RegisterAiKnowledge;
|
|
60
|
-
//# sourceMappingURL=chunk-M6D2NTTI.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-M6D2NTTI.cjs","../src/version.ts","../src/ClientSideSuspense.tsx","../src/ai.tsx"],"names":["useState","RegisterAiKnowledge","useEffect","layerKey"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACDO,IAAM,SAAA,EAAW,mBAAA;AACjB,IAAM,YAAA,EAAiD,uBAAA;AACvD,IAAM,WAAA,EAAgD,KAAA;ADG7D;AACA;AERA,8BAA8C;AAkC1C,+CAAA;AAVG,SAAS,kBAAA,CAAmB,KAAA,EAAc;AAC/C,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,EAAA,EAAI,6BAAA,KAAc,CAAA;AAE5C,EAAA,8BAAA,CAAU,EAAA,GAAM;AAGd,IAAA,UAAA,CAAW,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,CAAC,CAAC,CAAA;AAEL,EAAA,uBACE,6BAAA,eAAC,EAAA,EAAS,QAAA,EAAU,KAAA,CAAM,QAAA,EACvB,QAAA,EAAA,QAAA,EACG,OAAO,KAAA,CAAM,SAAA,IAAa,WAAA,EACxB,KAAA,CAAM,QAAA,CAAS,EAAA,EACf,KAAA,CAAM,SAAA,EACR,KAAA,CAAM,SAAA,CACZ,CAAA;AAEJ;AFxBA;AACA;AGnBA,wCAAkC;AAClC;AAIA,SAAS,KAAA,CAAA,EAAQ;AACf,EAAA,OAAO,yCAAA,CAAU,CAAE,eA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;AACE;AACA;AACA;AACA;AACA;AACF,oMAAC","file":"/home/runner/work/liveblocks/liveblocks/packages/liveblocks-react/dist/chunk-M6D2NTTI.cjs","sourcesContent":[null,"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","import type { AiKnowledgeSource } from \"@liveblocks/core\";\nimport { kInternal, nanoid } from \"@liveblocks/core\";\nimport { memo, useEffect, useId, useState } from \"react\";\n\nimport { useClient } from \"./liveblocks\";\n\nfunction useAi() {\n return useClient()[kInternal].ai;\n}\n\nfunction useRandom() {\n return useState(nanoid)[0];\n}\n\n/**\n * Make knowledge about your application state available to any AI used in\n * a chat or a one-off request.\n *\n * For example:\n *\n * <RegisterAiKnowledge\n * description=\"The current mode of my application\"\n * value=\"dark\" />\n *\n * <RegisterAiKnowledge\n * description=\"The current list of todos\"\n * value={todos} />\n *\n * By mounting this component, the AI will get access to this knwoledge.\n * By unmounting this component, the AI will no longer have access to it.\n * It can choose to use or ignore this knowledge in its responses.\n */\nexport const RegisterAiKnowledge = memo(function RegisterAiKnowledge(\n props: AiKnowledgeSource & {\n /**\n * An optional unique key for this knowledge source. If multiple components\n * register knowledge under the same key, the last one to mount takes\n * precedence.\n */\n id?: string;\n }\n) {\n const layerId = useId();\n const ai = useAi();\n const { description, value } = props;\n\n const [layerKey, setLayerKey] = useState<\n ReturnType<typeof ai.registerKnowledgeLayer> | undefined\n >();\n\n // Executes at mount / unmount\n useEffect(() => {\n const layerKey = ai.registerKnowledgeLayer(layerId);\n setLayerKey(layerKey);\n return () => {\n ai.deregisterKnowledgeLayer(layerKey);\n setLayerKey(undefined);\n };\n }, [ai, layerId]);\n\n // Executes every render (if the props have changed)\n const randomKey = useRandom();\n const knowledgeKey = props.id ?? randomKey;\n useEffect(() => {\n if (layerKey !== undefined) {\n ai.updateKnowledge(layerKey, { description, value }, knowledgeKey);\n }\n }, [ai, layerKey, knowledgeKey, description, value]);\n\n return null;\n});\n"]}
|