Package not found. Please check the package name and try again.
@assistant-ui/react 0.7.46 → 0.7.48
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/api/AssistantRuntime.d.ts +1 -0
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +5 -0
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +5 -0
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/AttachmentRuntime.d.ts +1 -0
- package/dist/api/AttachmentRuntime.d.ts.map +1 -1
- package/dist/api/AttachmentRuntime.js +5 -0
- package/dist/api/AttachmentRuntime.js.map +1 -1
- package/dist/api/AttachmentRuntime.mjs +5 -0
- package/dist/api/AttachmentRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +2 -0
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js +19 -0
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.mjs +19 -0
- package/dist/api/ComposerRuntime.mjs.map +1 -1
- package/dist/api/ContentPartRuntime.d.ts +1 -0
- package/dist/api/ContentPartRuntime.d.ts.map +1 -1
- package/dist/api/ContentPartRuntime.js +5 -0
- package/dist/api/ContentPartRuntime.js.map +1 -1
- package/dist/api/ContentPartRuntime.mjs +5 -0
- package/dist/api/ContentPartRuntime.mjs.map +1 -1
- package/dist/api/MessageRuntime.d.ts +1 -0
- package/dist/api/MessageRuntime.d.ts.map +1 -1
- package/dist/api/MessageRuntime.js +13 -0
- package/dist/api/MessageRuntime.js.map +1 -1
- package/dist/api/MessageRuntime.mjs +13 -0
- package/dist/api/MessageRuntime.mjs.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +1 -0
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js +11 -0
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.mjs +11 -0
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +1 -0
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +10 -0
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs +10 -0
- package/dist/api/ThreadListRuntime.mjs.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +1 -1
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +14 -3
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +14 -3
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.js +6 -14
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs +6 -14
- package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.js +5 -16
- package/dist/context/providers/AttachmentRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AttachmentRuntimeProvider.mjs +6 -21
- package/dist/context/providers/AttachmentRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts +0 -1
- package/dist/context/providers/ContentPartRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.js +5 -15
- package/dist/context/providers/ContentPartRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ContentPartRuntimeProvider.mjs +4 -13
- package/dist/context/providers/ContentPartRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.js +3 -22
- package/dist/context/providers/MessageRuntimeProvider.js.map +1 -1
- package/dist/context/providers/MessageRuntimeProvider.mjs +3 -22
- package/dist/context/providers/MessageRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/TextContentPartProvider.d.ts.map +1 -1
- package/dist/context/providers/TextContentPartProvider.js +13 -12
- package/dist/context/providers/TextContentPartProvider.js.map +1 -1
- package/dist/context/providers/TextContentPartProvider.mjs +13 -12
- package/dist/context/providers/TextContentPartProvider.mjs.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +0 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.js +5 -15
- package/dist/context/providers/ThreadListItemRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ThreadListItemRuntimeProvider.mjs +4 -13
- package/dist/context/providers/ThreadListItemRuntimeProvider.mjs.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.js +5 -24
- package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
- package/dist/context/providers/ThreadRuntimeProvider.mjs +6 -25
- package/dist/context/providers/ThreadRuntimeProvider.mjs.map +1 -1
- package/dist/context/react/AssistantContext.d.ts +26 -17
- package/dist/context/react/AssistantContext.d.ts.map +1 -1
- package/dist/context/react/AssistantContext.js +3 -4
- package/dist/context/react/AssistantContext.js.map +1 -1
- package/dist/context/react/AssistantContext.mjs +3 -4
- package/dist/context/react/AssistantContext.mjs.map +1 -1
- package/dist/context/react/AttachmentContext.d.ts +558 -30
- package/dist/context/react/AttachmentContext.d.ts.map +1 -1
- package/dist/context/react/AttachmentContext.js +32 -52
- package/dist/context/react/AttachmentContext.js.map +1 -1
- package/dist/context/react/AttachmentContext.mjs +33 -52
- package/dist/context/react/AttachmentContext.mjs.map +1 -1
- package/dist/context/react/ComposerContext.d.ts +28 -19
- package/dist/context/react/ComposerContext.d.ts.map +1 -1
- package/dist/context/react/ComposerContext.js +2 -19
- package/dist/context/react/ComposerContext.js.map +1 -1
- package/dist/context/react/ComposerContext.mjs +4 -20
- package/dist/context/react/ComposerContext.mjs.map +1 -1
- package/dist/context/react/ContentPartContext.d.ts +22 -16
- package/dist/context/react/ContentPartContext.d.ts.map +1 -1
- package/dist/context/react/ContentPartContext.js +2 -7
- package/dist/context/react/ContentPartContext.js.map +1 -1
- package/dist/context/react/ContentPartContext.mjs +2 -6
- package/dist/context/react/ContentPartContext.mjs.map +1 -1
- package/dist/context/react/MessageContext.d.ts +49 -29
- package/dist/context/react/MessageContext.d.ts.map +1 -1
- package/dist/context/react/MessageContext.js +5 -9
- package/dist/context/react/MessageContext.js.map +1 -1
- package/dist/context/react/MessageContext.mjs +5 -8
- package/dist/context/react/MessageContext.mjs.map +1 -1
- package/dist/context/react/ThreadContext.d.ts +44 -24
- package/dist/context/react/ThreadContext.d.ts.map +1 -1
- package/dist/context/react/ThreadContext.js +5 -9
- package/dist/context/react/ThreadContext.js.map +1 -1
- package/dist/context/react/ThreadContext.mjs +5 -8
- package/dist/context/react/ThreadContext.mjs.map +1 -1
- package/dist/context/react/ThreadListItemContext.d.ts +22 -16
- package/dist/context/react/ThreadListItemContext.d.ts.map +1 -1
- package/dist/context/react/ThreadListItemContext.js +3 -6
- package/dist/context/react/ThreadListItemContext.js.map +1 -1
- package/dist/context/react/ThreadListItemContext.mjs +3 -5
- package/dist/context/react/ThreadListItemContext.mjs.map +1 -1
- package/dist/context/react/index.d.ts +1 -0
- package/dist/context/react/index.d.ts.map +1 -1
- package/dist/context/react/index.js +3 -0
- package/dist/context/react/index.js.map +1 -1
- package/dist/context/react/index.mjs +2 -0
- package/dist/context/react/index.mjs.map +1 -1
- package/dist/context/react/utils/createContextHook.d.ts +3 -8
- package/dist/context/react/utils/createContextHook.d.ts.map +1 -1
- package/dist/context/react/utils/createContextHook.js.map +1 -1
- package/dist/context/react/utils/createContextHook.mjs.map +1 -1
- package/dist/context/react/utils/createStateHookForRuntime.d.ts +31 -0
- package/dist/context/react/utils/createStateHookForRuntime.d.ts.map +1 -0
- package/dist/context/react/utils/createStateHookForRuntime.js +47 -0
- package/dist/context/react/utils/createStateHookForRuntime.js.map +1 -0
- package/dist/context/react/utils/createStateHookForRuntime.mjs +24 -0
- package/dist/context/react/utils/createStateHookForRuntime.mjs.map +1 -0
- package/dist/context/react/utils/ensureBinding.d.ts +2 -0
- package/dist/context/react/utils/ensureBinding.d.ts.map +1 -0
- package/dist/context/react/utils/ensureBinding.js +36 -0
- package/dist/context/react/utils/ensureBinding.js.map +1 -0
- package/dist/context/react/utils/ensureBinding.mjs +11 -0
- package/dist/context/react/utils/ensureBinding.mjs.map +1 -0
- package/dist/context/react/utils/useRuntimeState.d.ts +10 -0
- package/dist/context/react/utils/useRuntimeState.d.ts.map +1 -0
- package/dist/context/react/utils/useRuntimeState.js +48 -0
- package/dist/context/react/utils/useRuntimeState.js.map +1 -0
- package/dist/context/react/utils/useRuntimeState.mjs +22 -0
- package/dist/context/react/utils/useRuntimeState.mjs.map +1 -0
- package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts +1 -1
- package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts.map +1 -1
- package/dist/runtimes/adapters/attachment/AttachmentAdapter.js.map +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.d.ts +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.d.ts.map +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js.map +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.mjs +1 -1
- package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.mjs.map +1 -1
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.d.ts.map +1 -1
- package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +22 -2
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +22 -2
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.js +4 -0
- package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
- package/dist/runtimes/local/useLocalRuntime.mjs +4 -0
- package/dist/runtimes/local/useLocalRuntime.mjs.map +1 -1
- package/package.json +3 -3
- package/src/api/AssistantRuntime.ts +7 -0
- package/src/api/AttachmentRuntime.ts +6 -0
- package/src/api/ComposerRuntime.ts +21 -0
- package/src/api/ContentPartRuntime.ts +6 -0
- package/src/api/MessageRuntime.ts +15 -0
- package/src/api/ThreadListItemRuntime.ts +12 -0
- package/src/api/ThreadListRuntime.ts +11 -0
- package/src/api/ThreadRuntime.ts +15 -4
- package/src/context/providers/AssistantRuntimeProvider.tsx +6 -17
- package/src/context/providers/AttachmentRuntimeProvider.tsx +6 -24
- package/src/context/providers/ContentPartRuntimeProvider.tsx +4 -14
- package/src/context/providers/MessageRuntimeProvider.tsx +5 -31
- package/src/context/providers/TextContentPartProvider.tsx +26 -22
- package/src/context/providers/ThreadListItemRuntimeProvider.tsx +3 -14
- package/src/context/providers/ThreadRuntimeProvider.tsx +7 -33
- package/src/context/react/AssistantContext.ts +7 -7
- package/src/context/react/AttachmentContext.ts +45 -136
- package/src/context/react/ComposerContext.ts +6 -29
- package/src/context/react/ContentPartContext.ts +3 -8
- package/src/context/react/MessageContext.ts +10 -13
- package/src/context/react/ThreadContext.ts +9 -12
- package/src/context/react/ThreadListItemContext.ts +4 -7
- package/src/context/react/index.ts +2 -0
- package/src/context/react/utils/createContextHook.ts +1 -3
- package/src/context/react/utils/createStateHookForRuntime.ts +80 -0
- package/src/context/react/utils/ensureBinding.ts +45 -0
- package/src/context/react/utils/useRuntimeState.ts +46 -0
- package/src/runtimes/adapters/attachment/AttachmentAdapter.ts +3 -1
- package/src/runtimes/adapters/attachment/CompositeAttachmentAdapter.ts +1 -1
- package/src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts +1 -0
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +24 -2
- package/src/runtimes/local/useLocalRuntime.tsx +5 -0
|
@@ -6,47 +6,28 @@ import { create } from "zustand";
|
|
|
6
6
|
import { MessageContext } from "../react/MessageContext.mjs";
|
|
7
7
|
import { makeMessageUtilsStore } from "../stores/MessageUtils.mjs";
|
|
8
8
|
import { writableStore } from "../ReadonlyStore.mjs";
|
|
9
|
+
import { ensureBinding } from "../react/utils/ensureBinding.mjs";
|
|
9
10
|
import { jsx } from "react/jsx-runtime";
|
|
10
11
|
var useMessageRuntimeStore = (runtime) => {
|
|
11
12
|
const [store] = useState(() => create(() => runtime));
|
|
12
13
|
useEffect(() => {
|
|
14
|
+
ensureBinding(runtime);
|
|
13
15
|
writableStore(store).setState(runtime, true);
|
|
14
16
|
}, [runtime, store]);
|
|
15
17
|
return store;
|
|
16
18
|
};
|
|
17
|
-
var useMessageStore = (runtime) => {
|
|
18
|
-
const [store] = useState(() => create(() => runtime.getState()));
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
|
21
|
-
updateState();
|
|
22
|
-
return runtime.subscribe(updateState);
|
|
23
|
-
}, [runtime, store]);
|
|
24
|
-
return store;
|
|
25
|
-
};
|
|
26
19
|
var useMessageUtilsStore = () => {
|
|
27
20
|
const [store] = useState(() => makeMessageUtilsStore());
|
|
28
21
|
return store;
|
|
29
22
|
};
|
|
30
|
-
var useEditComposerStore = (useMessageRuntime) => {
|
|
31
|
-
const runtime = useMessageRuntime.getState().composer;
|
|
32
|
-
const [store] = useState(() => create(() => runtime.getState()));
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const updateState = () => writableStore(store).setState(runtime.getState());
|
|
35
|
-
updateState();
|
|
36
|
-
return runtime.subscribe(updateState);
|
|
37
|
-
}, [runtime, store]);
|
|
38
|
-
return store;
|
|
39
|
-
};
|
|
40
23
|
var MessageRuntimeProvider = ({
|
|
41
24
|
runtime,
|
|
42
25
|
children
|
|
43
26
|
}) => {
|
|
44
27
|
const useMessageRuntime = useMessageRuntimeStore(runtime);
|
|
45
|
-
const useMessage = useMessageStore(runtime);
|
|
46
28
|
const useMessageUtils = useMessageUtilsStore();
|
|
47
|
-
const useEditComposer = useEditComposerStore(useMessageRuntime);
|
|
48
29
|
const [context] = useState(() => {
|
|
49
|
-
return { useMessageRuntime,
|
|
30
|
+
return { useMessageRuntime, useMessageUtils };
|
|
50
31
|
});
|
|
51
32
|
return /* @__PURE__ */ jsx(MessageContext.Provider, { value: context, children });
|
|
52
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/MessageRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { create } from \"zustand\";\nimport { MessageContext } from \"../react/MessageContext\";\nimport type { MessageContextValue } from \"../react/MessageContext\";\nimport { makeMessageUtilsStore } from \"../stores/MessageUtils\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/MessageRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { create } from \"zustand\";\nimport { MessageContext } from \"../react/MessageContext\";\nimport type { MessageContextValue } from \"../react/MessageContext\";\nimport { makeMessageUtilsStore } from \"../stores/MessageUtils\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport { MessageRuntime } from \"../../api/MessageRuntime\";\nimport { ensureBinding } from \"../react/utils/ensureBinding\";\n\nexport namespace MessageRuntimeProvider {\n export type Props = PropsWithChildren<{\n runtime: MessageRuntime;\n }>;\n}\n\nconst useMessageRuntimeStore = (runtime: MessageRuntime) => {\n const [store] = useState(() => create(() => runtime));\n\n useEffect(() => {\n ensureBinding(runtime);\n\n writableStore(store).setState(runtime, true);\n }, [runtime, store]);\n\n return store;\n};\n\nconst useMessageUtilsStore = () => {\n const [store] = useState(() => makeMessageUtilsStore());\n return store;\n};\n\nexport const MessageRuntimeProvider: FC<MessageRuntimeProvider.Props> = ({\n runtime,\n children,\n}) => {\n const useMessageRuntime = useMessageRuntimeStore(runtime);\n const useMessageUtils = useMessageUtilsStore();\n const [context] = useState<MessageContextValue>(() => {\n return { useMessageRuntime, useMessageUtils };\n });\n\n return (\n <MessageContext.Provider value={context}>\n {children}\n </MessageContext.Provider>\n );\n};\n"],"mappings":";;;AAEA,SAA0C,WAAW,gBAAgB;AACrE,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAE/B,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAE9B,SAAS,qBAAqB;AAoC1B;AA5BJ,IAAM,yBAAyB,CAAC,YAA4B;AAC1D,QAAM,CAAC,KAAK,IAAI,SAAS,MAAM,OAAO,MAAM,OAAO,CAAC;AAEpD,YAAU,MAAM;AACd,kBAAc,OAAO;AAErB,kBAAc,KAAK,EAAE,SAAS,SAAS,IAAI;AAAA,EAC7C,GAAG,CAAC,SAAS,KAAK,CAAC;AAEnB,SAAO;AACT;AAEA,IAAM,uBAAuB,MAAM;AACjC,QAAM,CAAC,KAAK,IAAI,SAAS,MAAM,sBAAsB,CAAC;AACtD,SAAO;AACT;AAEO,IAAM,yBAA2D,CAAC;AAAA,EACvE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,oBAAoB,uBAAuB,OAAO;AACxD,QAAM,kBAAkB,qBAAqB;AAC7C,QAAM,CAAC,OAAO,IAAI,SAA8B,MAAM;AACpD,WAAO,EAAE,mBAAmB,gBAAgB;AAAA,EAC9C,CAAC;AAED,SACE,oBAAC,eAAe,UAAf,EAAwB,OAAO,SAC7B,UACH;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextContentPartProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/TextContentPartProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TextContentPartProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/TextContentPartProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAcnE,yBAAiB,uBAAuB,CAAC;IACvC,KAAY,KAAK,GAAG,iBAAiB,CAAC;QACpC,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KACjC,CAAC,CAAC;CACJ;AAUD,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,uBAAuB,CAAC,KAAK,CA0DrE,CAAC"}
|
|
@@ -29,6 +29,7 @@ var import_zustand = require("zustand");
|
|
|
29
29
|
var import_ContentPartContext = require("../react/ContentPartContext.js");
|
|
30
30
|
var import_ReadonlyStore = require("../ReadonlyStore.js");
|
|
31
31
|
var import_ContentPartRuntime = require("../../api/ContentPartRuntime.js");
|
|
32
|
+
var import_ensureBinding = require("../react/utils/ensureBinding.js");
|
|
32
33
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
34
|
var COMPLETE_STATUS = {
|
|
34
35
|
type: "complete"
|
|
@@ -47,18 +48,18 @@ var TextContentPartProvider = ({
|
|
|
47
48
|
type: "text",
|
|
48
49
|
text
|
|
49
50
|
}));
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
);
|
|
51
|
+
const contentPartRuntime = new import_ContentPartRuntime.ContentPartRuntimeImpl({
|
|
52
|
+
path: {
|
|
53
|
+
ref: "text",
|
|
54
|
+
threadSelector: { type: "main" },
|
|
55
|
+
messageSelector: { type: "messageId", messageId: "" },
|
|
56
|
+
contentPartSelector: { type: "index", index: 0 }
|
|
57
|
+
},
|
|
58
|
+
getState: useContentPart.getState,
|
|
59
|
+
subscribe: useContentPart.subscribe
|
|
60
|
+
});
|
|
61
|
+
(0, import_ensureBinding.ensureBinding)(contentPartRuntime);
|
|
62
|
+
const useContentPartRuntime = (0, import_zustand.create)(() => contentPartRuntime);
|
|
62
63
|
return { useContentPartRuntime, useContentPart };
|
|
63
64
|
});
|
|
64
65
|
(0, import_react.useEffect)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/TextContentPartProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, PropsWithChildren, useEffect, useState } from \"react\";\nimport { create } from \"zustand\";\nimport {\n ContentPartContext,\n ContentPartContextValue,\n} from \"../react/ContentPartContext\";\nimport { ContentPartStatus
|
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/TextContentPartProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, PropsWithChildren, useEffect, useState } from \"react\";\nimport { create, StoreApi, UseBoundStore } from \"zustand\";\nimport {\n ContentPartContext,\n ContentPartContextValue,\n} from \"../react/ContentPartContext\";\nimport { ContentPartStatus } from \"../../types/AssistantTypes\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport {\n ContentPartRuntimeImpl,\n ContentPartState,\n} from \"../../api/ContentPartRuntime\";\nimport { ensureBinding } from \"../react/utils/ensureBinding\";\n\nexport namespace TextContentPartProvider {\n export type Props = PropsWithChildren<{\n text: string;\n isRunning?: boolean | undefined;\n }>;\n}\n\nconst COMPLETE_STATUS: ContentPartStatus = {\n type: \"complete\",\n};\n\nconst RUNNING_STATUS: ContentPartStatus = {\n type: \"running\",\n};\n\nexport const TextContentPartProvider: FC<TextContentPartProvider.Props> = ({\n children,\n text,\n isRunning,\n}) => {\n const [context] = useState<\n ContentPartContextValue & {\n useContentPart: UseBoundStore<\n StoreApi<ContentPartState & { type: \"text\" }>\n >;\n }\n >(() => {\n const useContentPart = create<ContentPartState & { type: \"text\" }>(() => ({\n status: isRunning ? RUNNING_STATUS : COMPLETE_STATUS,\n type: \"text\",\n text,\n }));\n\n const contentPartRuntime = new ContentPartRuntimeImpl({\n path: {\n ref: \"text\",\n threadSelector: { type: \"main\" },\n messageSelector: { type: \"messageId\", messageId: \"\" },\n contentPartSelector: { type: \"index\", index: 0 },\n },\n getState: useContentPart.getState,\n subscribe: useContentPart.subscribe,\n });\n ensureBinding(contentPartRuntime);\n\n const useContentPartRuntime = create(() => contentPartRuntime);\n\n return { useContentPartRuntime, useContentPart };\n });\n\n useEffect(() => {\n const state = context.useContentPart.getState();\n const textUpdated = state.text !== text;\n const targetStatus = isRunning ? RUNNING_STATUS : COMPLETE_STATUS;\n const statusUpdated = state.status !== targetStatus;\n\n if (!textUpdated && !statusUpdated) return;\n\n writableStore(context.useContentPart).setState(\n {\n type: \"text\",\n text,\n status: targetStatus,\n } satisfies ContentPartState,\n true,\n );\n }, [context, isRunning, text]);\n\n return (\n <ContentPartContext.Provider value={context}>\n {children}\n </ContentPartContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA2D;AAC3D,qBAAgD;AAChD,gCAGO;AAEP,2BAA8B;AAC9B,gCAGO;AACP,2BAA8B;AAuE1B;AA9DJ,IAAM,kBAAqC;AAAA,EACzC,MAAM;AACR;AAEA,IAAM,iBAAoC;AAAA,EACxC,MAAM;AACR;AAEO,IAAM,0BAA6D,CAAC;AAAA,EACzE;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,OAAO,QAAI,uBAMhB,MAAM;AACN,UAAM,qBAAiB,uBAA4C,OAAO;AAAA,MACxE,QAAQ,YAAY,iBAAiB;AAAA,MACrC,MAAM;AAAA,MACN;AAAA,IACF,EAAE;AAEF,UAAM,qBAAqB,IAAI,iDAAuB;AAAA,MACpD,MAAM;AAAA,QACJ,KAAK;AAAA,QACL,gBAAgB,EAAE,MAAM,OAAO;AAAA,QAC/B,iBAAiB,EAAE,MAAM,aAAa,WAAW,GAAG;AAAA,QACpD,qBAAqB,EAAE,MAAM,SAAS,OAAO,EAAE;AAAA,MACjD;AAAA,MACA,UAAU,eAAe;AAAA,MACzB,WAAW,eAAe;AAAA,IAC5B,CAAC;AACD,4CAAc,kBAAkB;AAEhC,UAAM,4BAAwB,uBAAO,MAAM,kBAAkB;AAE7D,WAAO,EAAE,uBAAuB,eAAe;AAAA,EACjD,CAAC;AAED,8BAAU,MAAM;AACd,UAAM,QAAQ,QAAQ,eAAe,SAAS;AAC9C,UAAM,cAAc,MAAM,SAAS;AACnC,UAAM,eAAe,YAAY,iBAAiB;AAClD,UAAM,gBAAgB,MAAM,WAAW;AAEvC,QAAI,CAAC,eAAe,CAAC,cAAe;AAEpC,4CAAc,QAAQ,cAAc,EAAE;AAAA,MACpC;AAAA,QACE,MAAM;AAAA,QACN;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,SAAS,WAAW,IAAI,CAAC;AAE7B,SACE,4CAAC,6CAAmB,UAAnB,EAA4B,OAAO,SACjC,UACH;AAEJ;","names":[]}
|
|
@@ -10,6 +10,7 @@ import { writableStore } from "../ReadonlyStore.mjs";
|
|
|
10
10
|
import {
|
|
11
11
|
ContentPartRuntimeImpl
|
|
12
12
|
} from "../../api/ContentPartRuntime.mjs";
|
|
13
|
+
import { ensureBinding } from "../react/utils/ensureBinding.mjs";
|
|
13
14
|
import { jsx } from "react/jsx-runtime";
|
|
14
15
|
var COMPLETE_STATUS = {
|
|
15
16
|
type: "complete"
|
|
@@ -28,18 +29,18 @@ var TextContentPartProvider = ({
|
|
|
28
29
|
type: "text",
|
|
29
30
|
text
|
|
30
31
|
}));
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
32
|
+
const contentPartRuntime = new ContentPartRuntimeImpl({
|
|
33
|
+
path: {
|
|
34
|
+
ref: "text",
|
|
35
|
+
threadSelector: { type: "main" },
|
|
36
|
+
messageSelector: { type: "messageId", messageId: "" },
|
|
37
|
+
contentPartSelector: { type: "index", index: 0 }
|
|
38
|
+
},
|
|
39
|
+
getState: useContentPart.getState,
|
|
40
|
+
subscribe: useContentPart.subscribe
|
|
41
|
+
});
|
|
42
|
+
ensureBinding(contentPartRuntime);
|
|
43
|
+
const useContentPartRuntime = create(() => contentPartRuntime);
|
|
43
44
|
return { useContentPartRuntime, useContentPart };
|
|
44
45
|
});
|
|
45
46
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/TextContentPartProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, PropsWithChildren, useEffect, useState } from \"react\";\nimport { create } from \"zustand\";\nimport {\n ContentPartContext,\n ContentPartContextValue,\n} from \"../react/ContentPartContext\";\nimport { ContentPartStatus
|
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/TextContentPartProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { FC, PropsWithChildren, useEffect, useState } from \"react\";\nimport { create, StoreApi, UseBoundStore } from \"zustand\";\nimport {\n ContentPartContext,\n ContentPartContextValue,\n} from \"../react/ContentPartContext\";\nimport { ContentPartStatus } from \"../../types/AssistantTypes\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport {\n ContentPartRuntimeImpl,\n ContentPartState,\n} from \"../../api/ContentPartRuntime\";\nimport { ensureBinding } from \"../react/utils/ensureBinding\";\n\nexport namespace TextContentPartProvider {\n export type Props = PropsWithChildren<{\n text: string;\n isRunning?: boolean | undefined;\n }>;\n}\n\nconst COMPLETE_STATUS: ContentPartStatus = {\n type: \"complete\",\n};\n\nconst RUNNING_STATUS: ContentPartStatus = {\n type: \"running\",\n};\n\nexport const TextContentPartProvider: FC<TextContentPartProvider.Props> = ({\n children,\n text,\n isRunning,\n}) => {\n const [context] = useState<\n ContentPartContextValue & {\n useContentPart: UseBoundStore<\n StoreApi<ContentPartState & { type: \"text\" }>\n >;\n }\n >(() => {\n const useContentPart = create<ContentPartState & { type: \"text\" }>(() => ({\n status: isRunning ? RUNNING_STATUS : COMPLETE_STATUS,\n type: \"text\",\n text,\n }));\n\n const contentPartRuntime = new ContentPartRuntimeImpl({\n path: {\n ref: \"text\",\n threadSelector: { type: \"main\" },\n messageSelector: { type: \"messageId\", messageId: \"\" },\n contentPartSelector: { type: \"index\", index: 0 },\n },\n getState: useContentPart.getState,\n subscribe: useContentPart.subscribe,\n });\n ensureBinding(contentPartRuntime);\n\n const useContentPartRuntime = create(() => contentPartRuntime);\n\n return { useContentPartRuntime, useContentPart };\n });\n\n useEffect(() => {\n const state = context.useContentPart.getState();\n const textUpdated = state.text !== text;\n const targetStatus = isRunning ? RUNNING_STATUS : COMPLETE_STATUS;\n const statusUpdated = state.status !== targetStatus;\n\n if (!textUpdated && !statusUpdated) return;\n\n writableStore(context.useContentPart).setState(\n {\n type: \"text\",\n text,\n status: targetStatus,\n } satisfies ContentPartState,\n true,\n );\n }, [context, isRunning, text]);\n\n return (\n <ContentPartContext.Provider value={context}>\n {children}\n </ContentPartContext.Provider>\n );\n};\n"],"mappings":";;;AAEA,SAAgC,WAAW,gBAAgB;AAC3D,SAAS,cAAuC;AAChD;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,OAEK;AACP,SAAS,qBAAqB;AAuE1B;AA9DJ,IAAM,kBAAqC;AAAA,EACzC,MAAM;AACR;AAEA,IAAM,iBAAoC;AAAA,EACxC,MAAM;AACR;AAEO,IAAM,0BAA6D,CAAC;AAAA,EACzE;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,OAAO,IAAI,SAMhB,MAAM;AACN,UAAM,iBAAiB,OAA4C,OAAO;AAAA,MACxE,QAAQ,YAAY,iBAAiB;AAAA,MACrC,MAAM;AAAA,MACN;AAAA,IACF,EAAE;AAEF,UAAM,qBAAqB,IAAI,uBAAuB;AAAA,MACpD,MAAM;AAAA,QACJ,KAAK;AAAA,QACL,gBAAgB,EAAE,MAAM,OAAO;AAAA,QAC/B,iBAAiB,EAAE,MAAM,aAAa,WAAW,GAAG;AAAA,QACpD,qBAAqB,EAAE,MAAM,SAAS,OAAO,EAAE;AAAA,MACjD;AAAA,MACA,UAAU,eAAe;AAAA,MACzB,WAAW,eAAe;AAAA,IAC5B,CAAC;AACD,kBAAc,kBAAkB;AAEhC,UAAM,wBAAwB,OAAO,MAAM,kBAAkB;AAE7D,WAAO,EAAE,uBAAuB,eAAe;AAAA,EACjD,CAAC;AAED,YAAU,MAAM;AACd,UAAM,QAAQ,QAAQ,eAAe,SAAS;AAC9C,UAAM,cAAc,MAAM,SAAS;AACnC,UAAM,eAAe,YAAY,iBAAiB;AAClD,UAAM,gBAAgB,MAAM,WAAW;AAEvC,QAAI,CAAC,eAAe,CAAC,cAAe;AAEpC,kBAAc,QAAQ,cAAc,EAAE;AAAA,MACpC;AAAA,QACE,MAAM;AAAA,QACN;AAAA,QACA,QAAQ;AAAA,MACV;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,SAAS,WAAW,IAAI,CAAC;AAE7B,SACE,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACjC,UACH;AAEJ;","names":[]}
|
|
@@ -5,6 +5,5 @@ export declare namespace ThreadListItemRuntimeProvider {
|
|
|
5
5
|
runtime: ThreadListItemRuntime;
|
|
6
6
|
}>;
|
|
7
7
|
}
|
|
8
|
-
export declare const useThreadListItemStore: (runtime: ThreadListItemRuntime) => import("zustand").UseBoundStore<import("zustand").StoreApi<import("../..").ThreadListItemState>>;
|
|
9
8
|
export declare const ThreadListItemRuntimeProvider: FC<ThreadListItemRuntimeProvider.Props>;
|
|
10
9
|
//# sourceMappingURL=ThreadListItemRuntimeProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemRuntimeProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/ThreadListItemRuntimeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAO7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"ThreadListItemRuntimeProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/ThreadListItemRuntimeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAO7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,yBAAiB,6BAA6B,CAAC;IAC7C,KAAY,KAAK,GAAG,iBAAiB,CAAC;QACpC,OAAO,EAAE,qBAAqB,CAAC;KAChC,CAAC,CAAC;CACJ;AAaD,eAAO,MAAM,6BAA6B,EAAE,EAAE,CAC5C,6BAA6B,CAAC,KAAK,CAYpC,CAAC"}
|
|
@@ -21,42 +21,32 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/context/providers/ThreadListItemRuntimeProvider.tsx
|
|
22
22
|
var ThreadListItemRuntimeProvider_exports = {};
|
|
23
23
|
__export(ThreadListItemRuntimeProvider_exports, {
|
|
24
|
-
ThreadListItemRuntimeProvider: () => ThreadListItemRuntimeProvider
|
|
25
|
-
useThreadListItemStore: () => useThreadListItemStore
|
|
24
|
+
ThreadListItemRuntimeProvider: () => ThreadListItemRuntimeProvider
|
|
26
25
|
});
|
|
27
26
|
module.exports = __toCommonJS(ThreadListItemRuntimeProvider_exports);
|
|
28
27
|
var import_react = require("react");
|
|
29
28
|
var import_zustand = require("zustand");
|
|
30
29
|
var import_ThreadListItemContext = require("../react/ThreadListItemContext.js");
|
|
31
30
|
var import_ReadonlyStore = require("../ReadonlyStore.js");
|
|
31
|
+
var import_ensureBinding = require("../react/utils/ensureBinding.js");
|
|
32
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
33
|
var useThreadListItemRuntimeStore = (runtime) => {
|
|
34
34
|
const [store] = (0, import_react.useState)(() => (0, import_zustand.create)(() => runtime));
|
|
35
35
|
(0, import_react.useEffect)(() => {
|
|
36
|
+
(0, import_ensureBinding.ensureBinding)(runtime);
|
|
36
37
|
(0, import_ReadonlyStore.writableStore)(store).setState(runtime, true);
|
|
37
38
|
}, [runtime, store]);
|
|
38
39
|
return store;
|
|
39
40
|
};
|
|
40
|
-
var useThreadListItemStore = (runtime) => {
|
|
41
|
-
const [store] = (0, import_react.useState)(() => (0, import_zustand.create)(() => runtime.getState()));
|
|
42
|
-
(0, import_react.useEffect)(() => {
|
|
43
|
-
const updateState = () => (0, import_ReadonlyStore.writableStore)(store).setState(runtime.getState(), true);
|
|
44
|
-
updateState();
|
|
45
|
-
return runtime.subscribe(updateState);
|
|
46
|
-
}, [runtime, store]);
|
|
47
|
-
return store;
|
|
48
|
-
};
|
|
49
41
|
var ThreadListItemRuntimeProvider = ({ runtime, children }) => {
|
|
50
42
|
const useThreadListItemRuntime = useThreadListItemRuntimeStore(runtime);
|
|
51
|
-
const useThreadListItem = useThreadListItemStore(runtime);
|
|
52
43
|
const [context] = (0, import_react.useState)(() => {
|
|
53
|
-
return { useThreadListItemRuntime
|
|
44
|
+
return { useThreadListItemRuntime };
|
|
54
45
|
});
|
|
55
46
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThreadListItemContext.ThreadListItemContext.Provider, { value: context, children });
|
|
56
47
|
};
|
|
57
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
49
|
0 && (module.exports = {
|
|
59
|
-
ThreadListItemRuntimeProvider
|
|
60
|
-
useThreadListItemStore
|
|
50
|
+
ThreadListItemRuntimeProvider
|
|
61
51
|
});
|
|
62
52
|
//# sourceMappingURL=ThreadListItemRuntimeProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/ThreadListItemRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { create } from \"zustand\";\nimport {\n ThreadListItemContext,\n type ThreadListItemContextValue,\n} from \"../react/ThreadListItemContext\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport { ThreadListItemRuntime } from \"../../api/ThreadListItemRuntime\";\n\nexport namespace ThreadListItemRuntimeProvider {\n export type Props = PropsWithChildren<{\n runtime: ThreadListItemRuntime;\n }>;\n}\n\nconst useThreadListItemRuntimeStore = (runtime: ThreadListItemRuntime) => {\n const [store] = useState(() => create(() => runtime));\n\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/ThreadListItemRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { create } from \"zustand\";\nimport {\n ThreadListItemContext,\n type ThreadListItemContextValue,\n} from \"../react/ThreadListItemContext\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport { ThreadListItemRuntime } from \"../../api/ThreadListItemRuntime\";\nimport { ensureBinding } from \"../react/utils/ensureBinding\";\n\nexport namespace ThreadListItemRuntimeProvider {\n export type Props = PropsWithChildren<{\n runtime: ThreadListItemRuntime;\n }>;\n}\n\nconst useThreadListItemRuntimeStore = (runtime: ThreadListItemRuntime) => {\n const [store] = useState(() => create(() => runtime));\n\n useEffect(() => {\n ensureBinding(runtime);\n writableStore(store).setState(runtime, true);\n }, [runtime, store]);\n\n return store;\n};\n\nexport const ThreadListItemRuntimeProvider: FC<\n ThreadListItemRuntimeProvider.Props\n> = ({ runtime, children }) => {\n const useThreadListItemRuntime = useThreadListItemRuntimeStore(runtime);\n const [context] = useState<ThreadListItemContextValue>(() => {\n return { useThreadListItemRuntime };\n });\n\n return (\n <ThreadListItemContext.Provider value={context}>\n {children}\n </ThreadListItemContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAqE;AACrE,qBAAuB;AACvB,mCAGO;AACP,2BAA8B;AAE9B,2BAA8B;AA4B1B;AApBJ,IAAM,gCAAgC,CAAC,YAAmC;AACxE,QAAM,CAAC,KAAK,QAAI,uBAAS,UAAM,uBAAO,MAAM,OAAO,CAAC;AAEpD,8BAAU,MAAM;AACd,4CAAc,OAAO;AACrB,4CAAc,KAAK,EAAE,SAAS,SAAS,IAAI;AAAA,EAC7C,GAAG,CAAC,SAAS,KAAK,CAAC;AAEnB,SAAO;AACT;AAEO,IAAM,gCAET,CAAC,EAAE,SAAS,SAAS,MAAM;AAC7B,QAAM,2BAA2B,8BAA8B,OAAO;AACtE,QAAM,CAAC,OAAO,QAAI,uBAAqC,MAAM;AAC3D,WAAO,EAAE,yBAAyB;AAAA,EACpC,CAAC;AAED,SACE,4CAAC,mDAAsB,UAAtB,EAA+B,OAAO,SACpC,UACH;AAEJ;","names":[]}
|
|
@@ -7,33 +7,24 @@ import {
|
|
|
7
7
|
ThreadListItemContext
|
|
8
8
|
} from "../react/ThreadListItemContext.mjs";
|
|
9
9
|
import { writableStore } from "../ReadonlyStore.mjs";
|
|
10
|
+
import { ensureBinding } from "../react/utils/ensureBinding.mjs";
|
|
10
11
|
import { jsx } from "react/jsx-runtime";
|
|
11
12
|
var useThreadListItemRuntimeStore = (runtime) => {
|
|
12
13
|
const [store] = useState(() => create(() => runtime));
|
|
13
14
|
useEffect(() => {
|
|
15
|
+
ensureBinding(runtime);
|
|
14
16
|
writableStore(store).setState(runtime, true);
|
|
15
17
|
}, [runtime, store]);
|
|
16
18
|
return store;
|
|
17
19
|
};
|
|
18
|
-
var useThreadListItemStore = (runtime) => {
|
|
19
|
-
const [store] = useState(() => create(() => runtime.getState()));
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
|
22
|
-
updateState();
|
|
23
|
-
return runtime.subscribe(updateState);
|
|
24
|
-
}, [runtime, store]);
|
|
25
|
-
return store;
|
|
26
|
-
};
|
|
27
20
|
var ThreadListItemRuntimeProvider = ({ runtime, children }) => {
|
|
28
21
|
const useThreadListItemRuntime = useThreadListItemRuntimeStore(runtime);
|
|
29
|
-
const useThreadListItem = useThreadListItemStore(runtime);
|
|
30
22
|
const [context] = useState(() => {
|
|
31
|
-
return { useThreadListItemRuntime
|
|
23
|
+
return { useThreadListItemRuntime };
|
|
32
24
|
});
|
|
33
25
|
return /* @__PURE__ */ jsx(ThreadListItemContext.Provider, { value: context, children });
|
|
34
26
|
};
|
|
35
27
|
export {
|
|
36
|
-
ThreadListItemRuntimeProvider
|
|
37
|
-
useThreadListItemStore
|
|
28
|
+
ThreadListItemRuntimeProvider
|
|
38
29
|
};
|
|
39
30
|
//# sourceMappingURL=ThreadListItemRuntimeProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/ThreadListItemRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { create } from \"zustand\";\nimport {\n ThreadListItemContext,\n type ThreadListItemContextValue,\n} from \"../react/ThreadListItemContext\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport { ThreadListItemRuntime } from \"../../api/ThreadListItemRuntime\";\n\nexport namespace ThreadListItemRuntimeProvider {\n export type Props = PropsWithChildren<{\n runtime: ThreadListItemRuntime;\n }>;\n}\n\nconst useThreadListItemRuntimeStore = (runtime: ThreadListItemRuntime) => {\n const [store] = useState(() => create(() => runtime));\n\n useEffect(() => {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/ThreadListItemRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport { type FC, type PropsWithChildren, useEffect, useState } from \"react\";\nimport { create } from \"zustand\";\nimport {\n ThreadListItemContext,\n type ThreadListItemContextValue,\n} from \"../react/ThreadListItemContext\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport { ThreadListItemRuntime } from \"../../api/ThreadListItemRuntime\";\nimport { ensureBinding } from \"../react/utils/ensureBinding\";\n\nexport namespace ThreadListItemRuntimeProvider {\n export type Props = PropsWithChildren<{\n runtime: ThreadListItemRuntime;\n }>;\n}\n\nconst useThreadListItemRuntimeStore = (runtime: ThreadListItemRuntime) => {\n const [store] = useState(() => create(() => runtime));\n\n useEffect(() => {\n ensureBinding(runtime);\n writableStore(store).setState(runtime, true);\n }, [runtime, store]);\n\n return store;\n};\n\nexport const ThreadListItemRuntimeProvider: FC<\n ThreadListItemRuntimeProvider.Props\n> = ({ runtime, children }) => {\n const useThreadListItemRuntime = useThreadListItemRuntimeStore(runtime);\n const [context] = useState<ThreadListItemContextValue>(() => {\n return { useThreadListItemRuntime };\n });\n\n return (\n <ThreadListItemContext.Provider value={context}>\n {children}\n </ThreadListItemContext.Provider>\n );\n};\n"],"mappings":";;;AAEA,SAA0C,WAAW,gBAAgB;AACrE,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,OAEK;AACP,SAAS,qBAAqB;AAE9B,SAAS,qBAAqB;AA4B1B;AApBJ,IAAM,gCAAgC,CAAC,YAAmC;AACxE,QAAM,CAAC,KAAK,IAAI,SAAS,MAAM,OAAO,MAAM,OAAO,CAAC;AAEpD,YAAU,MAAM;AACd,kBAAc,OAAO;AACrB,kBAAc,KAAK,EAAE,SAAS,SAAS,IAAI;AAAA,EAC7C,GAAG,CAAC,SAAS,KAAK,CAAC;AAEnB,SAAO;AACT;AAEO,IAAM,gCAET,CAAC,EAAE,SAAS,SAAS,MAAM;AAC7B,QAAM,2BAA2B,8BAA8B,OAAO;AACtE,QAAM,CAAC,OAAO,IAAI,SAAqC,MAAM;AAC3D,WAAO,EAAE,yBAAyB;AAAA,EACpC,CAAC;AAED,SACE,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,SACpC,UACH;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadRuntimeProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/ThreadRuntimeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAMnD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"ThreadRuntimeProvider.d.ts","sourceRoot":"","sources":["../../../src/context/providers/ThreadRuntimeProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAMnD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAIxE,KAAK,mBAAmB,GAAG;IACzB,eAAe,EAAE,qBAAqB,CAAC;IACvC,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAeF,eAAO,MAAM,qBAAqB,EAAE,EAAE,CACpC,iBAAiB,CAAC,mBAAmB,CAAC,CAoBvC,CAAC"}
|
|
@@ -30,45 +30,26 @@ var import_ThreadViewport = require("../stores/ThreadViewport.js");
|
|
|
30
30
|
var import_ReadonlyStore = require("../ReadonlyStore.js");
|
|
31
31
|
var import_zustand = require("zustand");
|
|
32
32
|
var import_ThreadListItemRuntimeProvider = require("./ThreadListItemRuntimeProvider.js");
|
|
33
|
+
var import_ensureBinding = require("../react/utils/ensureBinding.js");
|
|
33
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
35
|
var useThreadRuntimeStore = (runtime) => {
|
|
35
36
|
const [store] = (0, import_react.useState)(() => (0, import_zustand.create)(() => runtime));
|
|
36
37
|
(0, import_react.useEffect)(() => {
|
|
38
|
+
(0, import_ensureBinding.ensureBinding)(runtime);
|
|
39
|
+
(0, import_ensureBinding.ensureBinding)(runtime.composer);
|
|
37
40
|
(0, import_ReadonlyStore.writableStore)(store).setState(runtime, true);
|
|
38
41
|
}, [runtime, store]);
|
|
39
42
|
return store;
|
|
40
43
|
};
|
|
41
|
-
var useThreadStore = (runtime) => {
|
|
42
|
-
const [store] = (0, import_react.useState)(() => (0, import_zustand.create)(() => runtime.getState()));
|
|
43
|
-
(0, import_react.useEffect)(() => {
|
|
44
|
-
const updateState = () => (0, import_ReadonlyStore.writableStore)(store).setState(runtime.getState(), true);
|
|
45
|
-
updateState();
|
|
46
|
-
return runtime.subscribe(updateState);
|
|
47
|
-
}, [runtime, store]);
|
|
48
|
-
return store;
|
|
49
|
-
};
|
|
50
|
-
var useThreadComposerStore = (runtime) => {
|
|
51
|
-
const [store] = (0, import_react.useState)(() => (0, import_zustand.create)(() => runtime.getState()));
|
|
52
|
-
(0, import_react.useEffect)(() => {
|
|
53
|
-
const updateState = () => (0, import_ReadonlyStore.writableStore)(store).setState(runtime.getState(), true);
|
|
54
|
-
updateState();
|
|
55
|
-
return runtime.subscribe(updateState);
|
|
56
|
-
}, [runtime, store]);
|
|
57
|
-
return store;
|
|
58
|
-
};
|
|
59
44
|
var ThreadRuntimeProvider = ({ children, listItemRuntime: threadListItemRuntime, runtime }) => {
|
|
60
45
|
const useThreadRuntime = useThreadRuntimeStore(runtime);
|
|
61
|
-
const
|
|
62
|
-
const useThreadComposer = useThreadComposerStore(runtime.composer);
|
|
63
|
-
const context = (0, import_react.useMemo)(() => {
|
|
46
|
+
const [context] = (0, import_react.useState)(() => {
|
|
64
47
|
const useViewport = (0, import_ThreadViewport.makeThreadViewportStore)();
|
|
65
48
|
return {
|
|
66
|
-
useThread,
|
|
67
49
|
useThreadRuntime,
|
|
68
|
-
useComposer: useThreadComposer,
|
|
69
50
|
useViewport
|
|
70
51
|
};
|
|
71
|
-
}
|
|
52
|
+
});
|
|
72
53
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThreadListItemRuntimeProvider.ThreadListItemRuntimeProvider, { runtime: threadListItemRuntime, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ThreadContext.ThreadContext.Provider, { value: context, children }) });
|
|
73
54
|
};
|
|
74
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/ThreadRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useEffect,
|
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/ThreadRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport type { ThreadContextValue } from \"../react/ThreadContext\";\nimport { ThreadContext } from \"../react/ThreadContext\";\nimport { makeThreadViewportStore } from \"../stores/ThreadViewport\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\nimport { create } from \"zustand\";\nimport { ThreadListItemRuntime } from \"../../api/ThreadListItemRuntime\";\nimport { ThreadListItemRuntimeProvider } from \"./ThreadListItemRuntimeProvider\";\nimport { ensureBinding } from \"../react/utils/ensureBinding\";\n\ntype ThreadProviderProps = {\n listItemRuntime: ThreadListItemRuntime;\n runtime: ThreadRuntime;\n};\n\nconst useThreadRuntimeStore = (runtime: ThreadRuntime) => {\n const [store] = useState(() => create(() => runtime));\n\n useEffect(() => {\n ensureBinding(runtime);\n ensureBinding(runtime.composer);\n\n writableStore(store).setState(runtime, true);\n }, [runtime, store]);\n\n return store;\n};\n\nexport const ThreadRuntimeProvider: FC<\n PropsWithChildren<ThreadProviderProps>\n> = ({ children, listItemRuntime: threadListItemRuntime, runtime }) => {\n const useThreadRuntime = useThreadRuntimeStore(runtime);\n\n const [context] = useState<ThreadContextValue>(() => {\n const useViewport = makeThreadViewportStore();\n\n return {\n useThreadRuntime,\n useViewport,\n };\n });\n\n return (\n <ThreadListItemRuntimeProvider runtime={threadListItemRuntime}>\n <ThreadContext.Provider value={context}>\n {children}\n </ThreadContext.Provider>\n </ThreadListItemRuntimeProvider>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAoC;AAEpC,2BAA8B;AAC9B,4BAAwC;AACxC,2BAA8B;AAE9B,qBAAuB;AAEvB,2CAA8C;AAC9C,2BAA8B;AAoCxB;AA7BN,IAAM,wBAAwB,CAAC,YAA2B;AACxD,QAAM,CAAC,KAAK,QAAI,uBAAS,UAAM,uBAAO,MAAM,OAAO,CAAC;AAEpD,8BAAU,MAAM;AACd,4CAAc,OAAO;AACrB,4CAAc,QAAQ,QAAQ;AAE9B,4CAAc,KAAK,EAAE,SAAS,SAAS,IAAI;AAAA,EAC7C,GAAG,CAAC,SAAS,KAAK,CAAC;AAEnB,SAAO;AACT;AAEO,IAAM,wBAET,CAAC,EAAE,UAAU,iBAAiB,uBAAuB,QAAQ,MAAM;AACrE,QAAM,mBAAmB,sBAAsB,OAAO;AAEtD,QAAM,CAAC,OAAO,QAAI,uBAA6B,MAAM;AACnD,UAAM,kBAAc,+CAAwB;AAE5C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,SACE,4CAAC,sEAA8B,SAAS,uBACtC,sDAAC,mCAAc,UAAd,EAAuB,OAAO,SAC5B,UACH,GACF;AAEJ;","names":[]}
|
|
@@ -1,51 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/context/providers/ThreadRuntimeProvider.tsx
|
|
4
|
-
import { useEffect,
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
5
|
import { ThreadContext } from "../react/ThreadContext.mjs";
|
|
6
6
|
import { makeThreadViewportStore } from "../stores/ThreadViewport.mjs";
|
|
7
7
|
import { writableStore } from "../ReadonlyStore.mjs";
|
|
8
8
|
import { create } from "zustand";
|
|
9
9
|
import { ThreadListItemRuntimeProvider } from "./ThreadListItemRuntimeProvider.mjs";
|
|
10
|
+
import { ensureBinding } from "../react/utils/ensureBinding.mjs";
|
|
10
11
|
import { jsx } from "react/jsx-runtime";
|
|
11
12
|
var useThreadRuntimeStore = (runtime) => {
|
|
12
13
|
const [store] = useState(() => create(() => runtime));
|
|
13
14
|
useEffect(() => {
|
|
15
|
+
ensureBinding(runtime);
|
|
16
|
+
ensureBinding(runtime.composer);
|
|
14
17
|
writableStore(store).setState(runtime, true);
|
|
15
18
|
}, [runtime, store]);
|
|
16
19
|
return store;
|
|
17
20
|
};
|
|
18
|
-
var useThreadStore = (runtime) => {
|
|
19
|
-
const [store] = useState(() => create(() => runtime.getState()));
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
|
22
|
-
updateState();
|
|
23
|
-
return runtime.subscribe(updateState);
|
|
24
|
-
}, [runtime, store]);
|
|
25
|
-
return store;
|
|
26
|
-
};
|
|
27
|
-
var useThreadComposerStore = (runtime) => {
|
|
28
|
-
const [store] = useState(() => create(() => runtime.getState()));
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
|
31
|
-
updateState();
|
|
32
|
-
return runtime.subscribe(updateState);
|
|
33
|
-
}, [runtime, store]);
|
|
34
|
-
return store;
|
|
35
|
-
};
|
|
36
21
|
var ThreadRuntimeProvider = ({ children, listItemRuntime: threadListItemRuntime, runtime }) => {
|
|
37
22
|
const useThreadRuntime = useThreadRuntimeStore(runtime);
|
|
38
|
-
const
|
|
39
|
-
const useThreadComposer = useThreadComposerStore(runtime.composer);
|
|
40
|
-
const context = useMemo(() => {
|
|
23
|
+
const [context] = useState(() => {
|
|
41
24
|
const useViewport = makeThreadViewportStore();
|
|
42
25
|
return {
|
|
43
|
-
useThread,
|
|
44
26
|
useThreadRuntime,
|
|
45
|
-
useComposer: useThreadComposer,
|
|
46
27
|
useViewport
|
|
47
28
|
};
|
|
48
|
-
}
|
|
29
|
+
});
|
|
49
30
|
return /* @__PURE__ */ jsx(ThreadListItemRuntimeProvider, { runtime: threadListItemRuntime, children: /* @__PURE__ */ jsx(ThreadContext.Provider, { value: context, children }) });
|
|
50
31
|
};
|
|
51
32
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/providers/ThreadRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useEffect,
|
|
1
|
+
{"version":3,"sources":["../../../src/context/providers/ThreadRuntimeProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport type { FC, PropsWithChildren } from \"react\";\nimport { useEffect, useState } from \"react\";\nimport type { ThreadContextValue } from \"../react/ThreadContext\";\nimport { ThreadContext } from \"../react/ThreadContext\";\nimport { makeThreadViewportStore } from \"../stores/ThreadViewport\";\nimport { writableStore } from \"../ReadonlyStore\";\nimport { ThreadRuntime } from \"../../api/ThreadRuntime\";\nimport { create } from \"zustand\";\nimport { ThreadListItemRuntime } from \"../../api/ThreadListItemRuntime\";\nimport { ThreadListItemRuntimeProvider } from \"./ThreadListItemRuntimeProvider\";\nimport { ensureBinding } from \"../react/utils/ensureBinding\";\n\ntype ThreadProviderProps = {\n listItemRuntime: ThreadListItemRuntime;\n runtime: ThreadRuntime;\n};\n\nconst useThreadRuntimeStore = (runtime: ThreadRuntime) => {\n const [store] = useState(() => create(() => runtime));\n\n useEffect(() => {\n ensureBinding(runtime);\n ensureBinding(runtime.composer);\n\n writableStore(store).setState(runtime, true);\n }, [runtime, store]);\n\n return store;\n};\n\nexport const ThreadRuntimeProvider: FC<\n PropsWithChildren<ThreadProviderProps>\n> = ({ children, listItemRuntime: threadListItemRuntime, runtime }) => {\n const useThreadRuntime = useThreadRuntimeStore(runtime);\n\n const [context] = useState<ThreadContextValue>(() => {\n const useViewport = makeThreadViewportStore();\n\n return {\n useThreadRuntime,\n useViewport,\n };\n });\n\n return (\n <ThreadListItemRuntimeProvider runtime={threadListItemRuntime}>\n <ThreadContext.Provider value={context}>\n {children}\n </ThreadContext.Provider>\n </ThreadListItemRuntimeProvider>\n );\n};\n"],"mappings":";;;AAGA,SAAS,WAAW,gBAAgB;AAEpC,SAAS,qBAAqB;AAC9B,SAAS,+BAA+B;AACxC,SAAS,qBAAqB;AAE9B,SAAS,cAAc;AAEvB,SAAS,qCAAqC;AAC9C,SAAS,qBAAqB;AAoCxB;AA7BN,IAAM,wBAAwB,CAAC,YAA2B;AACxD,QAAM,CAAC,KAAK,IAAI,SAAS,MAAM,OAAO,MAAM,OAAO,CAAC;AAEpD,YAAU,MAAM;AACd,kBAAc,OAAO;AACrB,kBAAc,QAAQ,QAAQ;AAE9B,kBAAc,KAAK,EAAE,SAAS,SAAS,IAAI;AAAA,EAC7C,GAAG,CAAC,SAAS,KAAK,CAAC;AAEnB,SAAO;AACT;AAEO,IAAM,wBAET,CAAC,EAAE,UAAU,iBAAiB,uBAAuB,QAAQ,MAAM;AACrE,QAAM,mBAAmB,sBAAsB,OAAO;AAEtD,QAAM,CAAC,OAAO,IAAI,SAA6B,MAAM;AACnD,UAAM,cAAc,wBAAwB;AAE5C,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,SACE,oBAAC,iCAA8B,SAAS,uBACtC,8BAAC,cAAc,UAAd,EAAuB,OAAO,SAC5B,UACH,GACF;AAEJ;","names":[]}
|
|
@@ -2,21 +2,14 @@ import type { AssistantToolUIsState } from "../stores/AssistantToolUIs";
|
|
|
2
2
|
import { ReadonlyStore } from "../ReadonlyStore";
|
|
3
3
|
import { UseBoundStore } from "zustand";
|
|
4
4
|
import { AssistantRuntime } from "../../api/AssistantRuntime";
|
|
5
|
-
import { ThreadListState } from "../../api/ThreadListRuntime";
|
|
6
5
|
export type AssistantContextValue = {
|
|
7
|
-
useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;
|
|
8
6
|
useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;
|
|
9
|
-
|
|
7
|
+
useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;
|
|
10
8
|
};
|
|
11
9
|
export declare const AssistantContext: import("react").Context<AssistantContextValue | null>;
|
|
12
|
-
export declare const useAssistantContext: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} | undefined): AssistantContextValue;
|
|
16
|
-
(options?: {
|
|
17
|
-
optional?: boolean | undefined;
|
|
18
|
-
} | undefined): AssistantContextValue | null;
|
|
19
|
-
};
|
|
10
|
+
export declare const useAssistantContext: (options?: {
|
|
11
|
+
optional?: boolean | undefined;
|
|
12
|
+
} | undefined) => AssistantContextValue | null;
|
|
20
13
|
export declare function useAssistantRuntime(options?: {
|
|
21
14
|
optional?: false | undefined;
|
|
22
15
|
}): AssistantRuntime;
|
|
@@ -40,14 +33,30 @@ export declare const useToolUIs: {
|
|
|
40
33
|
}): ReadonlyStore<AssistantToolUIsState> | null;
|
|
41
34
|
};
|
|
42
35
|
export declare const useThreadList: {
|
|
43
|
-
(): ThreadListState;
|
|
44
|
-
<TSelected>(selector: (state: ThreadListState) => TSelected): TSelected;
|
|
36
|
+
(): import("../..").ThreadListState;
|
|
37
|
+
<TSelected>(selector: (state: import("../..").ThreadListState) => TSelected): TSelected;
|
|
38
|
+
<TSelected>(selector: ((state: import("../..").ThreadListState) => TSelected) | undefined): import("../..").ThreadListState | TSelected;
|
|
45
39
|
(options: {
|
|
46
|
-
optional
|
|
47
|
-
}): ThreadListState
|
|
40
|
+
optional?: false | undefined;
|
|
41
|
+
}): import("../..").ThreadListState;
|
|
42
|
+
(options: {
|
|
43
|
+
optional?: boolean | undefined;
|
|
44
|
+
}): import("../..").ThreadListState | null;
|
|
48
45
|
<TSelected>(options: {
|
|
49
|
-
optional
|
|
50
|
-
selector
|
|
46
|
+
optional?: false | undefined;
|
|
47
|
+
selector: (state: import("../..").ThreadListState) => TSelected;
|
|
48
|
+
}): TSelected;
|
|
49
|
+
<TSelected>(options: {
|
|
50
|
+
optional?: false | undefined;
|
|
51
|
+
selector: ((state: import("../..").ThreadListState) => TSelected) | undefined;
|
|
52
|
+
}): import("../..").ThreadListState | TSelected;
|
|
53
|
+
<TSelected>(options: {
|
|
54
|
+
optional?: boolean | undefined;
|
|
55
|
+
selector: (state: import("../..").ThreadListState) => TSelected;
|
|
51
56
|
}): TSelected | null;
|
|
57
|
+
<TSelected>(options: {
|
|
58
|
+
optional?: boolean | undefined;
|
|
59
|
+
selector: ((state: import("../..").ThreadListState) => TSelected) | undefined;
|
|
60
|
+
}): import("../..").ThreadListState | TSelected | null;
|
|
52
61
|
};
|
|
53
62
|
//# sourceMappingURL=AssistantContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/AssistantContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"AssistantContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/AssistantContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,MAAM,MAAM,qBAAqB,GAAG;IAClC,mBAAmB,EAAE,aAAa,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACpE,UAAU,EAAE,aAAa,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF,eAAO,MAAM,gBAAgB,uDAE5B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;8CAG/B,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC9B,GAAG,gBAAgB,CAAC;AACrB,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE;IAC5C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,gBAAgB,GAAG,IAAI,CAAC;AAS5B,eAAO,MAAQ,UAAU;;;;;;;;;;GAAE,eAAe;;;;;CAGzC,CAAC;AAKF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;CAAkD,CAAC"}
|
|
@@ -32,6 +32,7 @@ module.exports = __toCommonJS(AssistantContext_exports);
|
|
|
32
32
|
var import_react = require("react");
|
|
33
33
|
var import_createContextHook = require("./utils/createContextHook.js");
|
|
34
34
|
var import_createContextStoreHook = require("./utils/createContextStoreHook.js");
|
|
35
|
+
var import_createStateHookForRuntime = require("./utils/createStateHookForRuntime.js");
|
|
35
36
|
var AssistantContext = (0, import_react.createContext)(
|
|
36
37
|
null
|
|
37
38
|
);
|
|
@@ -48,10 +49,8 @@ var { useToolUIs, useToolUIsStore } = (0, import_createContextStoreHook.createCo
|
|
|
48
49
|
useAssistantContext,
|
|
49
50
|
"useToolUIs"
|
|
50
51
|
);
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
"useThreadList"
|
|
54
|
-
);
|
|
52
|
+
var useThreadListRuntime = (opt) => useAssistantRuntime(opt)?.threads ?? null;
|
|
53
|
+
var useThreadList = (0, import_createStateHookForRuntime.createStateHookForRuntime)(useThreadListRuntime);
|
|
55
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56
55
|
0 && (module.exports = {
|
|
57
56
|
AssistantContext,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/AssistantContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport type { AssistantToolUIsState } from \"../stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { AssistantRuntime } from \"../../api/AssistantRuntime\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/context/react/AssistantContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport type { AssistantToolUIsState } from \"../stores/AssistantToolUIs\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createContextStoreHook } from \"./utils/createContextStoreHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { AssistantRuntime } from \"../../api/AssistantRuntime\";\nimport { ThreadListRuntime } from \"../../api/ThreadListRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type AssistantContextValue = {\n useAssistantRuntime: UseBoundStore<ReadonlyStore<AssistantRuntime>>;\n useToolUIs: UseBoundStore<ReadonlyStore<AssistantToolUIsState>>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport const useAssistantContext = createContextHook(\n AssistantContext,\n \"AssistantRuntimeProvider\",\n);\n\nexport function useAssistantRuntime(options?: {\n optional?: false | undefined;\n}): AssistantRuntime;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}): AssistantRuntime | null;\nexport function useAssistantRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const context = useAssistantContext(options);\n if (!context) return null;\n return context.useAssistantRuntime();\n}\n\nexport const { useToolUIs, useToolUIsStore } = createContextStoreHook(\n useAssistantContext,\n \"useToolUIs\",\n);\n\nconst useThreadListRuntime = (opt: {\n optional: boolean | undefined;\n}): ThreadListRuntime | null => useAssistantRuntime(opt)?.threads ?? null;\nexport const useThreadList = createStateHookForRuntime(useThreadListRuntime);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8B;AAG9B,+BAAkC;AAClC,oCAAuC;AAIvC,uCAA0C;AAOnC,IAAM,uBAAmB;AAAA,EAC9B;AACF;AAEO,IAAM,0BAAsB;AAAA,EACjC;AAAA,EACA;AACF;AAQO,SAAS,oBAAoB,SAEjC;AACD,QAAM,UAAU,oBAAoB,OAAO;AAC3C,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,oBAAoB;AACrC;AAEO,IAAM,EAAE,YAAY,gBAAgB,QAAI;AAAA,EAC7C;AAAA,EACA;AACF;AAEA,IAAM,uBAAuB,CAAC,QAEE,oBAAoB,GAAG,GAAG,WAAW;AAC9D,IAAM,oBAAgB,4DAA0B,oBAAoB;","names":[]}
|