@assistant-ui/react 0.7.46 → 0.7.47
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 +5 -14
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs +5 -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 +5 -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 +43 -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
|
@@ -23,7 +23,6 @@ var AttachmentContext_exports = {};
|
|
|
23
23
|
__export(AttachmentContext_exports, {
|
|
24
24
|
AttachmentContext: () => AttachmentContext,
|
|
25
25
|
useAttachment: () => useAttachment,
|
|
26
|
-
useAttachmentContext: () => useAttachmentContext,
|
|
27
26
|
useAttachmentRuntime: () => useAttachmentRuntime,
|
|
28
27
|
useEditComposerAttachment: () => useEditComposerAttachment,
|
|
29
28
|
useEditComposerAttachmentRuntime: () => useEditComposerAttachmentRuntime,
|
|
@@ -34,80 +33,61 @@ __export(AttachmentContext_exports, {
|
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(AttachmentContext_exports);
|
|
36
35
|
var import_react = require("react");
|
|
37
|
-
var
|
|
36
|
+
var import_createContextHook = require("./utils/createContextHook.js");
|
|
37
|
+
var import_createStateHookForRuntime = require("./utils/createStateHookForRuntime.js");
|
|
38
38
|
var AttachmentContext = (0, import_react.createContext)(
|
|
39
39
|
null
|
|
40
40
|
);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
|
46
|
-
);
|
|
47
|
-
return context;
|
|
48
|
-
}
|
|
49
|
-
function useThreadComposerAttachmentContext(options) {
|
|
50
|
-
const context = useAttachmentContext(options);
|
|
51
|
-
if (!context) return null;
|
|
52
|
-
if (context.source !== "thread-composer")
|
|
53
|
-
throw new Error(
|
|
54
|
-
"This component must be used within a thread's ComposerPrimitive.Attachments component."
|
|
55
|
-
);
|
|
56
|
-
return context;
|
|
57
|
-
}
|
|
58
|
-
function useEditComposerAttachmentContext(options) {
|
|
59
|
-
const context = useAttachmentContext(options);
|
|
60
|
-
if (!context) return null;
|
|
61
|
-
if (context.source !== "edit-composer")
|
|
62
|
-
throw new Error(
|
|
63
|
-
"This component must be used within a messages's ComposerPrimitive.Attachments component."
|
|
64
|
-
);
|
|
65
|
-
return context;
|
|
66
|
-
}
|
|
67
|
-
function useMessageAttachmentContext(options) {
|
|
68
|
-
const context = useAttachmentContext(options);
|
|
69
|
-
if (!context) return null;
|
|
70
|
-
if (context.source !== "message")
|
|
71
|
-
throw new Error(
|
|
72
|
-
"This component must be used within a MessagePrimitive.Attachments component."
|
|
73
|
-
);
|
|
74
|
-
return context;
|
|
75
|
-
}
|
|
41
|
+
var useAttachmentContext = (0, import_createContextHook.createContextHook)(
|
|
42
|
+
AttachmentContext,
|
|
43
|
+
"a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component"
|
|
44
|
+
);
|
|
76
45
|
function useAttachmentRuntime(options) {
|
|
77
46
|
const attachmentRuntime = useAttachmentContext(options);
|
|
78
47
|
if (!attachmentRuntime) return null;
|
|
79
48
|
return attachmentRuntime.useAttachmentRuntime();
|
|
80
49
|
}
|
|
81
50
|
function useThreadComposerAttachmentRuntime(options) {
|
|
82
|
-
const attachmentRuntime =
|
|
51
|
+
const attachmentRuntime = useAttachmentRuntime(options);
|
|
83
52
|
if (!attachmentRuntime) return null;
|
|
84
|
-
|
|
53
|
+
if (attachmentRuntime.source !== "thread-composer")
|
|
54
|
+
throw new Error(
|
|
55
|
+
"This component must be used within a thread's ComposerPrimitive.Attachments component."
|
|
56
|
+
);
|
|
57
|
+
return attachmentRuntime;
|
|
85
58
|
}
|
|
86
59
|
function useEditComposerAttachmentRuntime(options) {
|
|
87
|
-
const attachmentRuntime =
|
|
60
|
+
const attachmentRuntime = useAttachmentRuntime(options);
|
|
88
61
|
if (!attachmentRuntime) return null;
|
|
89
|
-
|
|
62
|
+
if (attachmentRuntime.source !== "edit-composer")
|
|
63
|
+
throw new Error(
|
|
64
|
+
"This component must be used within a message's ComposerPrimitive.Attachments component."
|
|
65
|
+
);
|
|
66
|
+
return attachmentRuntime;
|
|
90
67
|
}
|
|
91
68
|
function useMessageAttachmentRuntime(options) {
|
|
92
|
-
const attachmentRuntime =
|
|
69
|
+
const attachmentRuntime = useAttachmentRuntime(options);
|
|
93
70
|
if (!attachmentRuntime) return null;
|
|
94
|
-
|
|
71
|
+
if (attachmentRuntime.source !== "message")
|
|
72
|
+
throw new Error(
|
|
73
|
+
"This component must be used within a MessagePrimitive.Attachments component."
|
|
74
|
+
);
|
|
75
|
+
return attachmentRuntime;
|
|
95
76
|
}
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
77
|
+
var useAttachment = (0, import_createStateHookForRuntime.createStateHookForRuntime)(useAttachmentRuntime);
|
|
78
|
+
var useThreadComposerAttachment = (0, import_createStateHookForRuntime.createStateHookForRuntime)(
|
|
79
|
+
useThreadComposerAttachmentRuntime
|
|
80
|
+
);
|
|
81
|
+
var useEditComposerAttachment = (0, import_createStateHookForRuntime.createStateHookForRuntime)(
|
|
82
|
+
useEditComposerAttachmentRuntime
|
|
99
83
|
);
|
|
100
|
-
var
|
|
101
|
-
|
|
102
|
-
var { useAttachment: useMessageAttachment } = (0, import_createContextStoreHook.createContextStoreHook)(
|
|
103
|
-
useMessageAttachmentContext,
|
|
104
|
-
"useAttachment"
|
|
84
|
+
var useMessageAttachment = (0, import_createStateHookForRuntime.createStateHookForRuntime)(
|
|
85
|
+
useMessageAttachmentRuntime
|
|
105
86
|
);
|
|
106
87
|
// Annotate the CommonJS export names for ESM import in node:
|
|
107
88
|
0 && (module.exports = {
|
|
108
89
|
AttachmentContext,
|
|
109
90
|
useAttachment,
|
|
110
|
-
useAttachmentContext,
|
|
111
91
|
useAttachmentRuntime,
|
|
112
92
|
useEditComposerAttachment,
|
|
113
93
|
useEditComposerAttachmentRuntime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext
|
|
1
|
+
{"version":3,"sources":["../../../src/context/react/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { AttachmentRuntime } from \"../../api/AttachmentRuntime\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type AttachmentContextValue = {\n useAttachmentRuntime: UseBoundStore<ReadonlyStore<AttachmentRuntime>>;\n};\n\nexport const AttachmentContext = createContext<AttachmentContextValue | null>(\n null,\n);\n\nconst useAttachmentContext = createContextHook(\n AttachmentContext,\n \"a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component\",\n);\n\nexport function useAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null {\n const attachmentRuntime = useAttachmentContext(options);\n if (!attachmentRuntime) return null;\n return attachmentRuntime.useAttachmentRuntime();\n}\n\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"thread-composer\">;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"thread-composer\")\n throw new Error(\n \"This component must be used within a thread's ComposerPrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"thread-composer\">;\n}\n\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"edit-composer\">;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"edit-composer\")\n throw new Error(\n \"This component must be used within a message's ComposerPrimitive.Attachments component.\",\n );\n\n return attachmentRuntime as AttachmentRuntime<\"edit-composer\">;\n}\n\nexport function useMessageAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"message\">;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"message\")\n throw new Error(\n \"This component must be used within a MessagePrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"message\">;\n}\n\nexport const useAttachment = createStateHookForRuntime(useAttachmentRuntime);\n\nexport const useThreadComposerAttachment = createStateHookForRuntime(\n useThreadComposerAttachmentRuntime,\n);\nexport const useEditComposerAttachment = createStateHookForRuntime(\n useEditComposerAttachmentRuntime,\n);\nexport const useMessageAttachment = createStateHookForRuntime(\n useMessageAttachmentRuntime,\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8B;AAI9B,+BAAkC;AAClC,uCAA0C;AAMnC,IAAM,wBAAoB;AAAA,EAC/B;AACF;AAEA,IAAM,2BAAuB;AAAA,EAC3B;AAAA,EACA;AACF;AAQO,SAAS,qBAAqB,SAER;AAC3B,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,SAAO,kBAAkB,qBAAqB;AAChD;AAQO,SAAS,mCAAmC,SAEH;AAC9C,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;AAQO,SAAS,iCAAiC,SAEH;AAC5C,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEF,SAAO;AACT;AAQO,SAAS,4BAA4B,SAEJ;AACtC,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;AAEO,IAAM,oBAAgB,4DAA0B,oBAAoB;AAEpE,IAAM,kCAA8B;AAAA,EACzC;AACF;AACO,IAAM,gCAA4B;AAAA,EACvC;AACF;AACO,IAAM,2BAAuB;AAAA,EAClC;AACF;","names":[]}
|
|
@@ -1,80 +1,61 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/context/react/AttachmentContext.ts
|
|
4
|
-
import { createContext
|
|
5
|
-
import {
|
|
4
|
+
import { createContext } from "react";
|
|
5
|
+
import { createContextHook } from "./utils/createContextHook.mjs";
|
|
6
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.mjs";
|
|
6
7
|
var AttachmentContext = createContext(
|
|
7
8
|
null
|
|
8
9
|
);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
|
14
|
-
);
|
|
15
|
-
return context;
|
|
16
|
-
}
|
|
17
|
-
function useThreadComposerAttachmentContext(options) {
|
|
18
|
-
const context = useAttachmentContext(options);
|
|
19
|
-
if (!context) return null;
|
|
20
|
-
if (context.source !== "thread-composer")
|
|
21
|
-
throw new Error(
|
|
22
|
-
"This component must be used within a thread's ComposerPrimitive.Attachments component."
|
|
23
|
-
);
|
|
24
|
-
return context;
|
|
25
|
-
}
|
|
26
|
-
function useEditComposerAttachmentContext(options) {
|
|
27
|
-
const context = useAttachmentContext(options);
|
|
28
|
-
if (!context) return null;
|
|
29
|
-
if (context.source !== "edit-composer")
|
|
30
|
-
throw new Error(
|
|
31
|
-
"This component must be used within a messages's ComposerPrimitive.Attachments component."
|
|
32
|
-
);
|
|
33
|
-
return context;
|
|
34
|
-
}
|
|
35
|
-
function useMessageAttachmentContext(options) {
|
|
36
|
-
const context = useAttachmentContext(options);
|
|
37
|
-
if (!context) return null;
|
|
38
|
-
if (context.source !== "message")
|
|
39
|
-
throw new Error(
|
|
40
|
-
"This component must be used within a MessagePrimitive.Attachments component."
|
|
41
|
-
);
|
|
42
|
-
return context;
|
|
43
|
-
}
|
|
10
|
+
var useAttachmentContext = createContextHook(
|
|
11
|
+
AttachmentContext,
|
|
12
|
+
"a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component"
|
|
13
|
+
);
|
|
44
14
|
function useAttachmentRuntime(options) {
|
|
45
15
|
const attachmentRuntime = useAttachmentContext(options);
|
|
46
16
|
if (!attachmentRuntime) return null;
|
|
47
17
|
return attachmentRuntime.useAttachmentRuntime();
|
|
48
18
|
}
|
|
49
19
|
function useThreadComposerAttachmentRuntime(options) {
|
|
50
|
-
const attachmentRuntime =
|
|
20
|
+
const attachmentRuntime = useAttachmentRuntime(options);
|
|
51
21
|
if (!attachmentRuntime) return null;
|
|
52
|
-
|
|
22
|
+
if (attachmentRuntime.source !== "thread-composer")
|
|
23
|
+
throw new Error(
|
|
24
|
+
"This component must be used within a thread's ComposerPrimitive.Attachments component."
|
|
25
|
+
);
|
|
26
|
+
return attachmentRuntime;
|
|
53
27
|
}
|
|
54
28
|
function useEditComposerAttachmentRuntime(options) {
|
|
55
|
-
const attachmentRuntime =
|
|
29
|
+
const attachmentRuntime = useAttachmentRuntime(options);
|
|
56
30
|
if (!attachmentRuntime) return null;
|
|
57
|
-
|
|
31
|
+
if (attachmentRuntime.source !== "edit-composer")
|
|
32
|
+
throw new Error(
|
|
33
|
+
"This component must be used within a message's ComposerPrimitive.Attachments component."
|
|
34
|
+
);
|
|
35
|
+
return attachmentRuntime;
|
|
58
36
|
}
|
|
59
37
|
function useMessageAttachmentRuntime(options) {
|
|
60
|
-
const attachmentRuntime =
|
|
38
|
+
const attachmentRuntime = useAttachmentRuntime(options);
|
|
61
39
|
if (!attachmentRuntime) return null;
|
|
62
|
-
|
|
40
|
+
if (attachmentRuntime.source !== "message")
|
|
41
|
+
throw new Error(
|
|
42
|
+
"This component must be used within a MessagePrimitive.Attachments component."
|
|
43
|
+
);
|
|
44
|
+
return attachmentRuntime;
|
|
63
45
|
}
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
46
|
+
var useAttachment = createStateHookForRuntime(useAttachmentRuntime);
|
|
47
|
+
var useThreadComposerAttachment = createStateHookForRuntime(
|
|
48
|
+
useThreadComposerAttachmentRuntime
|
|
49
|
+
);
|
|
50
|
+
var useEditComposerAttachment = createStateHookForRuntime(
|
|
51
|
+
useEditComposerAttachmentRuntime
|
|
67
52
|
);
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
var { useAttachment: useMessageAttachment } = createContextStoreHook(
|
|
71
|
-
useMessageAttachmentContext,
|
|
72
|
-
"useAttachment"
|
|
53
|
+
var useMessageAttachment = createStateHookForRuntime(
|
|
54
|
+
useMessageAttachmentRuntime
|
|
73
55
|
);
|
|
74
56
|
export {
|
|
75
57
|
AttachmentContext,
|
|
76
58
|
useAttachment,
|
|
77
|
-
useAttachmentContext,
|
|
78
59
|
useAttachmentRuntime,
|
|
79
60
|
useEditComposerAttachment,
|
|
80
61
|
useEditComposerAttachmentRuntime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext
|
|
1
|
+
{"version":3,"sources":["../../../src/context/react/AttachmentContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { AttachmentRuntime } from \"../../api/AttachmentRuntime\";\nimport { UseBoundStore } from \"zustand\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type AttachmentContextValue = {\n useAttachmentRuntime: UseBoundStore<ReadonlyStore<AttachmentRuntime>>;\n};\n\nexport const AttachmentContext = createContext<AttachmentContextValue | null>(\n null,\n);\n\nconst useAttachmentContext = createContextHook(\n AttachmentContext,\n \"a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component\",\n);\n\nexport function useAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null;\nexport function useAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime | null {\n const attachmentRuntime = useAttachmentContext(options);\n if (!attachmentRuntime) return null;\n return attachmentRuntime.useAttachmentRuntime();\n}\n\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"thread-composer\">;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null;\nexport function useThreadComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"thread-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"thread-composer\")\n throw new Error(\n \"This component must be used within a thread's ComposerPrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"thread-composer\">;\n}\n\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"edit-composer\">;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null;\nexport function useEditComposerAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"edit-composer\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"edit-composer\")\n throw new Error(\n \"This component must be used within a message's ComposerPrimitive.Attachments component.\",\n );\n\n return attachmentRuntime as AttachmentRuntime<\"edit-composer\">;\n}\n\nexport function useMessageAttachmentRuntime(options?: {\n optional?: false | undefined;\n}): AttachmentRuntime<\"message\">;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null;\nexport function useMessageAttachmentRuntime(options?: {\n optional?: boolean | undefined;\n}): AttachmentRuntime<\"message\"> | null {\n const attachmentRuntime = useAttachmentRuntime(options);\n if (!attachmentRuntime) return null;\n if (attachmentRuntime.source !== \"message\")\n throw new Error(\n \"This component must be used within a MessagePrimitive.Attachments component.\",\n );\n return attachmentRuntime as AttachmentRuntime<\"message\">;\n}\n\nexport const useAttachment = createStateHookForRuntime(useAttachmentRuntime);\n\nexport const useThreadComposerAttachment = createStateHookForRuntime(\n useThreadComposerAttachmentRuntime,\n);\nexport const useEditComposerAttachment = createStateHookForRuntime(\n useEditComposerAttachmentRuntime,\n);\nexport const useMessageAttachment = createStateHookForRuntime(\n useMessageAttachmentRuntime,\n);\n"],"mappings":";;;AAEA,SAAS,qBAAqB;AAI9B,SAAS,yBAAyB;AAClC,SAAS,iCAAiC;AAMnC,IAAM,oBAAoB;AAAA,EAC/B;AACF;AAEA,IAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AACF;AAQO,SAAS,qBAAqB,SAER;AAC3B,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,SAAO,kBAAkB,qBAAqB;AAChD;AAQO,SAAS,mCAAmC,SAEH;AAC9C,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;AAQO,SAAS,iCAAiC,SAEH;AAC5C,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEF,SAAO;AACT;AAQO,SAAS,4BAA4B,SAEJ;AACtC,QAAM,oBAAoB,qBAAqB,OAAO;AACtD,MAAI,CAAC,kBAAmB,QAAO;AAC/B,MAAI,kBAAkB,WAAW;AAC/B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;AAEO,IAAM,gBAAgB,0BAA0B,oBAAoB;AAEpE,IAAM,8BAA8B;AAAA,EACzC;AACF;AACO,IAAM,4BAA4B;AAAA,EACvC;AACF;AACO,IAAM,uBAAuB;AAAA,EAClC;AACF;","names":[]}
|
|
@@ -1,26 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ComposerRuntime, ComposerState } from "../../api/ComposerRuntime";
|
|
3
|
-
import { UseBoundStore } from "zustand";
|
|
4
|
-
export type ComposerContextValue = {
|
|
5
|
-
useComposer: UseBoundStore<ReadonlyStore<ComposerState>>;
|
|
6
|
-
type: "edit" | "new";
|
|
7
|
-
};
|
|
8
|
-
export declare const useComposerContext: () => ComposerContextValue;
|
|
9
|
-
export declare const useComposer: {
|
|
10
|
-
(): ComposerState;
|
|
11
|
-
<TSelected>(selector: (state: ComposerState) => TSelected): TSelected;
|
|
12
|
-
(options: {
|
|
13
|
-
optional: true;
|
|
14
|
-
}): ComposerState | null;
|
|
15
|
-
<TSelected>(options: {
|
|
16
|
-
optional: true;
|
|
17
|
-
selector?: (state: ComposerState) => TSelected;
|
|
18
|
-
}): TSelected | null;
|
|
19
|
-
};
|
|
1
|
+
import { ComposerRuntime } from "../../api/ComposerRuntime";
|
|
20
2
|
export declare function useComposerRuntime(options?: {
|
|
21
3
|
optional?: false | undefined;
|
|
22
4
|
}): ComposerRuntime;
|
|
23
5
|
export declare function useComposerRuntime(options?: {
|
|
24
6
|
optional?: boolean | undefined;
|
|
25
7
|
}): ComposerRuntime | null;
|
|
8
|
+
export declare const useComposer: {
|
|
9
|
+
(): import("../..").ComposerState;
|
|
10
|
+
<TSelected>(selector: (state: import("../..").ComposerState) => TSelected): TSelected;
|
|
11
|
+
<TSelected>(selector: ((state: import("../..").ComposerState) => TSelected) | undefined): import("../..").ComposerState | TSelected;
|
|
12
|
+
(options: {
|
|
13
|
+
optional?: false | undefined;
|
|
14
|
+
}): import("../..").ComposerState;
|
|
15
|
+
(options: {
|
|
16
|
+
optional?: boolean | undefined;
|
|
17
|
+
}): import("../..").ComposerState | null;
|
|
18
|
+
<TSelected>(options: {
|
|
19
|
+
optional?: false | undefined;
|
|
20
|
+
selector: (state: import("../..").ComposerState) => TSelected;
|
|
21
|
+
}): TSelected;
|
|
22
|
+
<TSelected>(options: {
|
|
23
|
+
optional?: false | undefined;
|
|
24
|
+
selector: ((state: import("../..").ComposerState) => TSelected) | undefined;
|
|
25
|
+
}): import("../..").ComposerState | TSelected;
|
|
26
|
+
<TSelected>(options: {
|
|
27
|
+
optional?: boolean | undefined;
|
|
28
|
+
selector: (state: import("../..").ComposerState) => TSelected;
|
|
29
|
+
}): TSelected | null;
|
|
30
|
+
<TSelected>(options: {
|
|
31
|
+
optional?: boolean | undefined;
|
|
32
|
+
selector: ((state: import("../..").ComposerState) => TSelected) | undefined;
|
|
33
|
+
}): import("../..").ComposerState | TSelected | null;
|
|
34
|
+
};
|
|
26
35
|
//# sourceMappingURL=ComposerContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/ComposerContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ComposerContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/ComposerContext.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE;IAC3C,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC9B,GAAG,eAAe,CAAC;AACpB,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE;IAC3C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,eAAe,GAAG,IAAI,CAAC;AAW3B,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;CAAgD,CAAC"}
|
|
@@ -22,38 +22,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var ComposerContext_exports = {};
|
|
23
23
|
__export(ComposerContext_exports, {
|
|
24
24
|
useComposer: () => useComposer,
|
|
25
|
-
useComposerContext: () => useComposerContext,
|
|
26
25
|
useComposerRuntime: () => useComposerRuntime
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(ComposerContext_exports);
|
|
29
|
-
var import_react = require("react");
|
|
30
28
|
var import_MessageContext = require("./MessageContext.js");
|
|
31
29
|
var import_ThreadContext = require("./ThreadContext.js");
|
|
32
|
-
var
|
|
33
|
-
var useComposerContext = () => {
|
|
34
|
-
const { useComposer: useThreadComposer } = (0, import_ThreadContext.useThreadContext)();
|
|
35
|
-
const { useEditComposer } = (0, import_MessageContext.useMessageContext)({ optional: true }) ?? {};
|
|
36
|
-
return (0, import_react.useMemo)(
|
|
37
|
-
() => ({
|
|
38
|
-
useComposer: useEditComposer ?? useThreadComposer,
|
|
39
|
-
type: useEditComposer ? "edit" : "new"
|
|
40
|
-
}),
|
|
41
|
-
[useEditComposer, useThreadComposer]
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
var { useComposer } = (0, import_createContextStoreHook.createContextStoreHook)(
|
|
45
|
-
useComposerContext,
|
|
46
|
-
"useComposer"
|
|
47
|
-
);
|
|
30
|
+
var import_createStateHookForRuntime = require("./utils/createStateHookForRuntime.js");
|
|
48
31
|
function useComposerRuntime(options) {
|
|
49
32
|
const messageRuntime = (0, import_MessageContext.useMessageRuntime)({ optional: true });
|
|
50
33
|
const threadRuntime = (0, import_ThreadContext.useThreadRuntime)(options);
|
|
51
34
|
return messageRuntime ? messageRuntime.composer : threadRuntime?.composer ?? null;
|
|
52
35
|
}
|
|
36
|
+
var useComposer = (0, import_createStateHookForRuntime.createStateHookForRuntime)(useComposerRuntime);
|
|
53
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
54
38
|
0 && (module.exports = {
|
|
55
39
|
useComposer,
|
|
56
|
-
useComposerContext,
|
|
57
40
|
useComposerRuntime
|
|
58
41
|
});
|
|
59
42
|
//# sourceMappingURL=ComposerContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/context/react/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useMessageRuntime } from \"./MessageContext\";\nimport { useThreadRuntime } from \"./ThreadContext\";\nimport { ComposerRuntime } from \"../../api/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport function useComposerRuntime(options?: {\n optional?: false | undefined;\n}): ComposerRuntime;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null {\n const messageRuntime = useMessageRuntime({ optional: true });\n const threadRuntime = useThreadRuntime(options);\n return messageRuntime\n ? messageRuntime.composer\n : (threadRuntime?.composer ?? null);\n}\n\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,4BAAkC;AAClC,2BAAiC;AAEjC,uCAA0C;AAQnC,SAAS,mBAAmB,SAER;AACzB,QAAM,qBAAiB,yCAAkB,EAAE,UAAU,KAAK,CAAC;AAC3D,QAAM,oBAAgB,uCAAiB,OAAO;AAC9C,SAAO,iBACH,eAAe,WACd,eAAe,YAAY;AAClC;AAEO,IAAM,kBAAc,4DAA0B,kBAAkB;","names":[]}
|
|
@@ -1,33 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/context/react/ComposerContext.ts
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { createContextStoreHook } from "./utils/createContextStoreHook.mjs";
|
|
8
|
-
var useComposerContext = () => {
|
|
9
|
-
const { useComposer: useThreadComposer } = useThreadContext();
|
|
10
|
-
const { useEditComposer } = useMessageContext({ optional: true }) ?? {};
|
|
11
|
-
return useMemo(
|
|
12
|
-
() => ({
|
|
13
|
-
useComposer: useEditComposer ?? useThreadComposer,
|
|
14
|
-
type: useEditComposer ? "edit" : "new"
|
|
15
|
-
}),
|
|
16
|
-
[useEditComposer, useThreadComposer]
|
|
17
|
-
);
|
|
18
|
-
};
|
|
19
|
-
var { useComposer } = createContextStoreHook(
|
|
20
|
-
useComposerContext,
|
|
21
|
-
"useComposer"
|
|
22
|
-
);
|
|
4
|
+
import { useMessageRuntime } from "./MessageContext.mjs";
|
|
5
|
+
import { useThreadRuntime } from "./ThreadContext.mjs";
|
|
6
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.mjs";
|
|
23
7
|
function useComposerRuntime(options) {
|
|
24
8
|
const messageRuntime = useMessageRuntime({ optional: true });
|
|
25
9
|
const threadRuntime = useThreadRuntime(options);
|
|
26
10
|
return messageRuntime ? messageRuntime.composer : threadRuntime?.composer ?? null;
|
|
27
11
|
}
|
|
12
|
+
var useComposer = createStateHookForRuntime(useComposerRuntime);
|
|
28
13
|
export {
|
|
29
14
|
useComposer,
|
|
30
|
-
useComposerContext,
|
|
31
15
|
useComposerRuntime
|
|
32
16
|
};
|
|
33
17
|
//# sourceMappingURL=ComposerContext.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/context/react/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useMessageRuntime } from \"./MessageContext\";\nimport { useThreadRuntime } from \"./ThreadContext\";\nimport { ComposerRuntime } from \"../../api/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport function useComposerRuntime(options?: {\n optional?: false | undefined;\n}): ComposerRuntime;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null {\n const messageRuntime = useMessageRuntime({ optional: true });\n const threadRuntime = useThreadRuntime(options);\n return messageRuntime\n ? messageRuntime.composer\n : (threadRuntime?.composer ?? null);\n}\n\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":";;;AAEA,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAEjC,SAAS,iCAAiC;AAQnC,SAAS,mBAAmB,SAER;AACzB,QAAM,iBAAiB,kBAAkB,EAAE,UAAU,KAAK,CAAC;AAC3D,QAAM,gBAAgB,iBAAiB,OAAO;AAC9C,SAAO,iBACH,eAAe,WACd,eAAe,YAAY;AAClC;AAEO,IAAM,cAAc,0BAA0B,kBAAkB;","names":[]}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { ReadonlyStore } from "../ReadonlyStore";
|
|
2
2
|
import { UseBoundStore } from "zustand";
|
|
3
3
|
import { ContentPartRuntime } from "../../api/ContentPartRuntime";
|
|
4
|
-
import { ContentPartState } from "../../api/ContentPartRuntime";
|
|
5
4
|
export type ContentPartContextValue = {
|
|
6
5
|
useContentPartRuntime: UseBoundStore<ReadonlyStore<ContentPartRuntime>>;
|
|
7
|
-
useContentPart: UseBoundStore<ReadonlyStore<ContentPartState>>;
|
|
8
6
|
};
|
|
9
7
|
export declare const ContentPartContext: import("react").Context<ContentPartContextValue | null>;
|
|
10
|
-
export declare const useContentPartContext: {
|
|
11
|
-
(options?: {
|
|
12
|
-
optional?: false | undefined;
|
|
13
|
-
} | undefined): ContentPartContextValue;
|
|
14
|
-
(options?: {
|
|
15
|
-
optional?: boolean | undefined;
|
|
16
|
-
} | undefined): ContentPartContextValue | null;
|
|
17
|
-
};
|
|
18
8
|
export declare function useContentPartRuntime(options?: {
|
|
19
9
|
optional?: false | undefined;
|
|
20
10
|
}): ContentPartRuntime;
|
|
@@ -22,14 +12,30 @@ export declare function useContentPartRuntime(options?: {
|
|
|
22
12
|
optional?: boolean | undefined;
|
|
23
13
|
}): ContentPartRuntime | null;
|
|
24
14
|
export declare const useContentPart: {
|
|
25
|
-
(): ContentPartState;
|
|
26
|
-
<TSelected>(selector: (state: ContentPartState) => TSelected): TSelected;
|
|
15
|
+
(): import("../..").ContentPartState;
|
|
16
|
+
<TSelected>(selector: (state: import("../..").ContentPartState) => TSelected): TSelected;
|
|
17
|
+
<TSelected>(selector: ((state: import("../..").ContentPartState) => TSelected) | undefined): import("../..").ContentPartState | TSelected;
|
|
27
18
|
(options: {
|
|
28
|
-
optional
|
|
29
|
-
}): ContentPartState
|
|
19
|
+
optional?: false | undefined;
|
|
20
|
+
}): import("../..").ContentPartState;
|
|
21
|
+
(options: {
|
|
22
|
+
optional?: boolean | undefined;
|
|
23
|
+
}): import("../..").ContentPartState | null;
|
|
30
24
|
<TSelected>(options: {
|
|
31
|
-
optional
|
|
32
|
-
selector
|
|
25
|
+
optional?: false | undefined;
|
|
26
|
+
selector: (state: import("../..").ContentPartState) => TSelected;
|
|
27
|
+
}): TSelected;
|
|
28
|
+
<TSelected>(options: {
|
|
29
|
+
optional?: false | undefined;
|
|
30
|
+
selector: ((state: import("../..").ContentPartState) => TSelected) | undefined;
|
|
31
|
+
}): import("../..").ContentPartState | TSelected;
|
|
32
|
+
<TSelected>(options: {
|
|
33
|
+
optional?: boolean | undefined;
|
|
34
|
+
selector: (state: import("../..").ContentPartState) => TSelected;
|
|
33
35
|
}): TSelected | null;
|
|
36
|
+
<TSelected>(options: {
|
|
37
|
+
optional?: boolean | undefined;
|
|
38
|
+
selector: ((state: import("../..").ContentPartState) => TSelected) | undefined;
|
|
39
|
+
}): import("../..").ContentPartState | TSelected | null;
|
|
34
40
|
};
|
|
35
41
|
//# sourceMappingURL=ContentPartContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentPartContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/ContentPartContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ContentPartContext.d.ts","sourceRoot":"","sources":["../../../src/context/react/ContentPartContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGlE,MAAM,MAAM,uBAAuB,GAAG;IACpC,qBAAqB,EAAE,aAAa,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC;CACzE,CAAC;AAEF,eAAO,MAAM,kBAAkB,yDAE9B,CAAC;AAOF,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;CAC9B,GAAG,kBAAkB,CAAC;AACvB,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE;IAC9C,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,kBAAkB,GAAG,IAAI,CAAC;AAS9B,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;CAAmD,CAAC"}
|
|
@@ -23,13 +23,12 @@ var ContentPartContext_exports = {};
|
|
|
23
23
|
__export(ContentPartContext_exports, {
|
|
24
24
|
ContentPartContext: () => ContentPartContext,
|
|
25
25
|
useContentPart: () => useContentPart,
|
|
26
|
-
useContentPartContext: () => useContentPartContext,
|
|
27
26
|
useContentPartRuntime: () => useContentPartRuntime
|
|
28
27
|
});
|
|
29
28
|
module.exports = __toCommonJS(ContentPartContext_exports);
|
|
30
29
|
var import_react = require("react");
|
|
31
|
-
var import_createContextStoreHook = require("./utils/createContextStoreHook.js");
|
|
32
30
|
var import_createContextHook = require("./utils/createContextHook.js");
|
|
31
|
+
var import_createStateHookForRuntime = require("./utils/createStateHookForRuntime.js");
|
|
33
32
|
var ContentPartContext = (0, import_react.createContext)(
|
|
34
33
|
null
|
|
35
34
|
);
|
|
@@ -42,15 +41,11 @@ function useContentPartRuntime(options) {
|
|
|
42
41
|
if (!context) return null;
|
|
43
42
|
return context.useContentPartRuntime();
|
|
44
43
|
}
|
|
45
|
-
var
|
|
46
|
-
useContentPartContext,
|
|
47
|
-
"useContentPart"
|
|
48
|
-
);
|
|
44
|
+
var useContentPart = (0, import_createStateHookForRuntime.createStateHookForRuntime)(useContentPartRuntime);
|
|
49
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
46
|
0 && (module.exports = {
|
|
51
47
|
ContentPartContext,
|
|
52
48
|
useContentPart,
|
|
53
|
-
useContentPartContext,
|
|
54
49
|
useContentPartRuntime
|
|
55
50
|
});
|
|
56
51
|
//# sourceMappingURL=ContentPartContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/context/react/ContentPartContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/context/react/ContentPartContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { ReadonlyStore } from \"../ReadonlyStore\";\nimport { createContextHook } from \"./utils/createContextHook\";\nimport { UseBoundStore } from \"zustand\";\nimport { ContentPartRuntime } from \"../../api/ContentPartRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport type ContentPartContextValue = {\n useContentPartRuntime: UseBoundStore<ReadonlyStore<ContentPartRuntime>>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nconst useContentPartContext = createContextHook(\n ContentPartContext,\n \"a component passed to <MessagePrimitive.Content components={...}>\",\n);\n\nexport function useContentPartRuntime(options?: {\n optional?: false | undefined;\n}): ContentPartRuntime;\nexport function useContentPartRuntime(options?: {\n optional?: boolean | undefined;\n}): ContentPartRuntime | null;\nexport function useContentPartRuntime(options?: {\n optional?: boolean | undefined;\n}) {\n const context = useContentPartContext(options);\n if (!context) return null;\n return context.useContentPartRuntime();\n}\n\nexport const useContentPart = createStateHookForRuntime(useContentPartRuntime);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8B;AAE9B,+BAAkC;AAGlC,uCAA0C;AAMnC,IAAM,yBAAqB;AAAA,EAChC;AACF;AAEA,IAAM,4BAAwB;AAAA,EAC5B;AAAA,EACA;AACF;AAQO,SAAS,sBAAsB,SAEnC;AACD,QAAM,UAAU,sBAAsB,OAAO;AAC7C,MAAI,CAAC,QAAS,QAAO;AACrB,SAAO,QAAQ,sBAAsB;AACvC;AAEO,IAAM,qBAAiB,4DAA0B,qBAAqB;","names":[]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// src/context/react/ContentPartContext.ts
|
|
4
4
|
import { createContext } from "react";
|
|
5
|
-
import { createContextStoreHook } from "./utils/createContextStoreHook.mjs";
|
|
6
5
|
import { createContextHook } from "./utils/createContextHook.mjs";
|
|
6
|
+
import { createStateHookForRuntime } from "./utils/createStateHookForRuntime.mjs";
|
|
7
7
|
var ContentPartContext = createContext(
|
|
8
8
|
null
|
|
9
9
|
);
|
|
@@ -16,14 +16,10 @@ function useContentPartRuntime(options) {
|
|
|
16
16
|
if (!context) return null;
|
|
17
17
|
return context.useContentPartRuntime();
|
|
18
18
|
}
|
|
19
|
-
var
|
|
20
|
-
useContentPartContext,
|
|
21
|
-
"useContentPart"
|
|
22
|
-
);
|
|
19
|
+
var useContentPart = createStateHookForRuntime(useContentPartRuntime);
|
|
23
20
|
export {
|
|
24
21
|
ContentPartContext,
|
|
25
22
|
useContentPart,
|
|
26
|
-
useContentPartContext,
|
|
27
23
|
useContentPartRuntime
|
|
28
24
|
};
|
|
29
25
|
//# sourceMappingURL=ContentPartContext.mjs.map
|