@assistant-ui/vue 0.0.0 → 0.0.2

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.
Files changed (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -2
  3. package/dist/AuiIf.d.ts +27 -0
  4. package/dist/AuiIf.d.ts.map +1 -0
  5. package/dist/AuiIf.js +30 -0
  6. package/dist/AuiIf.js.map +1 -0
  7. package/dist/AuiProvider.d.ts +41 -0
  8. package/dist/AuiProvider.d.ts.map +1 -0
  9. package/dist/AuiProvider.js +61 -0
  10. package/dist/AuiProvider.js.map +1 -0
  11. package/dist/context.d.ts +10 -0
  12. package/dist/context.d.ts.map +1 -0
  13. package/dist/context.js +17 -0
  14. package/dist/context.js.map +1 -0
  15. package/dist/index.d.ts +34 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +35 -0
  18. package/dist/primitives/AttachmentByIndexProvider.d.ts +30 -0
  19. package/dist/primitives/AttachmentByIndexProvider.d.ts.map +1 -0
  20. package/dist/primitives/AttachmentByIndexProvider.js +63 -0
  21. package/dist/primitives/AttachmentByIndexProvider.js.map +1 -0
  22. package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.d.ts +11 -0
  23. package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.d.ts.map +1 -0
  24. package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.js +31 -0
  25. package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.js.map +1 -0
  26. package/dist/primitives/ChainOfThoughtPrimitiveParts.d.ts +19 -0
  27. package/dist/primitives/ChainOfThoughtPrimitiveParts.d.ts.map +1 -0
  28. package/dist/primitives/ChainOfThoughtPrimitiveParts.js +85 -0
  29. package/dist/primitives/ChainOfThoughtPrimitiveParts.js.map +1 -0
  30. package/dist/primitives/ComposerPrimitiveCancel.d.ts +12 -0
  31. package/dist/primitives/ComposerPrimitiveCancel.d.ts.map +1 -0
  32. package/dist/primitives/ComposerPrimitiveCancel.js +33 -0
  33. package/dist/primitives/ComposerPrimitiveCancel.js.map +1 -0
  34. package/dist/primitives/ComposerPrimitiveInput.d.ts +26 -0
  35. package/dist/primitives/ComposerPrimitiveInput.d.ts.map +1 -0
  36. package/dist/primitives/ComposerPrimitiveInput.js +57 -0
  37. package/dist/primitives/ComposerPrimitiveInput.js.map +1 -0
  38. package/dist/primitives/ComposerPrimitiveSend.d.ts +13 -0
  39. package/dist/primitives/ComposerPrimitiveSend.d.ts.map +1 -0
  40. package/dist/primitives/ComposerPrimitiveSend.js +31 -0
  41. package/dist/primitives/ComposerPrimitiveSend.js.map +1 -0
  42. package/dist/primitives/MessageByIdProvider.d.ts +23 -0
  43. package/dist/primitives/MessageByIdProvider.d.ts.map +1 -0
  44. package/dist/primitives/MessageByIdProvider.js +70 -0
  45. package/dist/primitives/MessageByIdProvider.js.map +1 -0
  46. package/dist/primitives/MessagePrimitiveParts.d.ts +51 -0
  47. package/dist/primitives/MessagePrimitiveParts.d.ts.map +1 -0
  48. package/dist/primitives/MessagePrimitiveParts.js +93 -0
  49. package/dist/primitives/MessagePrimitiveParts.js.map +1 -0
  50. package/dist/primitives/PartByIndexProvider.d.ts +21 -0
  51. package/dist/primitives/PartByIndexProvider.d.ts.map +1 -0
  52. package/dist/primitives/PartByIndexProvider.js +50 -0
  53. package/dist/primitives/PartByIndexProvider.js.map +1 -0
  54. package/dist/primitives/ThreadListItemPrimitiveRoot.d.ts +7 -0
  55. package/dist/primitives/ThreadListItemPrimitiveRoot.d.ts.map +1 -0
  56. package/dist/primitives/ThreadListItemPrimitiveRoot.js +36 -0
  57. package/dist/primitives/ThreadListItemPrimitiveRoot.js.map +1 -0
  58. package/dist/primitives/ThreadListItemPrimitiveTrigger.d.ts +14 -0
  59. package/dist/primitives/ThreadListItemPrimitiveTrigger.d.ts.map +1 -0
  60. package/dist/primitives/ThreadListItemPrimitiveTrigger.js +58 -0
  61. package/dist/primitives/ThreadListItemPrimitiveTrigger.js.map +1 -0
  62. package/dist/primitives/ThreadListPrimitiveRoot.d.ts +7 -0
  63. package/dist/primitives/ThreadListPrimitiveRoot.d.ts.map +1 -0
  64. package/dist/primitives/ThreadListPrimitiveRoot.js +16 -0
  65. package/dist/primitives/ThreadListPrimitiveRoot.js.map +1 -0
  66. package/dist/primitives/ThreadPrimitiveMessages.d.ts +21 -0
  67. package/dist/primitives/ThreadPrimitiveMessages.d.ts.map +1 -0
  68. package/dist/primitives/ThreadPrimitiveMessages.js +35 -0
  69. package/dist/primitives/ThreadPrimitiveMessages.js.map +1 -0
  70. package/dist/primitives/ThreadPrimitiveScrollToBottom.d.ts +25 -0
  71. package/dist/primitives/ThreadPrimitiveScrollToBottom.d.ts.map +1 -0
  72. package/dist/primitives/ThreadPrimitiveScrollToBottom.js +43 -0
  73. package/dist/primitives/ThreadPrimitiveScrollToBottom.js.map +1 -0
  74. package/dist/primitives/ThreadPrimitiveViewport.d.ts +57 -0
  75. package/dist/primitives/ThreadPrimitiveViewport.d.ts.map +1 -0
  76. package/dist/primitives/ThreadPrimitiveViewport.js +99 -0
  77. package/dist/primitives/ThreadPrimitiveViewport.js.map +1 -0
  78. package/dist/primitives/ThreadPrimitiveViewportFooter.d.ts +13 -0
  79. package/dist/primitives/ThreadPrimitiveViewportFooter.d.ts.map +1 -0
  80. package/dist/primitives/ThreadPrimitiveViewportFooter.js +46 -0
  81. package/dist/primitives/ThreadPrimitiveViewportFooter.js.map +1 -0
  82. package/dist/primitives/actionBar.d.ts +41 -0
  83. package/dist/primitives/actionBar.d.ts.map +1 -0
  84. package/dist/primitives/actionBar.js +110 -0
  85. package/dist/primitives/actionBar.js.map +1 -0
  86. package/dist/primitives/attachment.d.ts +27 -0
  87. package/dist/primitives/attachment.d.ts.map +1 -0
  88. package/dist/primitives/attachment.js +63 -0
  89. package/dist/primitives/attachment.js.map +1 -0
  90. package/dist/primitives/attrDisabled.d.ts +2 -0
  91. package/dist/primitives/attrDisabled.d.ts.map +1 -0
  92. package/dist/primitives/attrDisabled.js +6 -0
  93. package/dist/primitives/attrDisabled.js.map +1 -0
  94. package/dist/primitives/branchPicker.d.ts +18 -0
  95. package/dist/primitives/branchPicker.d.ts.map +1 -0
  96. package/dist/primitives/branchPicker.js +48 -0
  97. package/dist/primitives/branchPicker.js.map +1 -0
  98. package/dist/primitives/composerAttachments.d.ts +57 -0
  99. package/dist/primitives/composerAttachments.d.ts.map +1 -0
  100. package/dist/primitives/composerAttachments.js +132 -0
  101. package/dist/primitives/composerAttachments.js.map +1 -0
  102. package/dist/primitives/error.d.ts +15 -0
  103. package/dist/primitives/error.d.ts.map +1 -0
  104. package/dist/primitives/error.js +29 -0
  105. package/dist/primitives/error.js.map +1 -0
  106. package/dist/primitives/lastValidCache.d.ts +6 -0
  107. package/dist/primitives/lastValidCache.d.ts.map +1 -0
  108. package/dist/primitives/lastValidCache.js +9 -0
  109. package/dist/primitives/lastValidCache.js.map +1 -0
  110. package/dist/primitives/message.d.ts +12 -0
  111. package/dist/primitives/message.d.ts.map +1 -0
  112. package/dist/primitives/message.js +44 -0
  113. package/dist/primitives/message.js.map +1 -0
  114. package/dist/primitives/messageAttachments.d.ts +12 -0
  115. package/dist/primitives/messageAttachments.d.ts.map +1 -0
  116. package/dist/primitives/messageAttachments.js +27 -0
  117. package/dist/primitives/messageAttachments.js.map +1 -0
  118. package/dist/primitives/stableKeys.d.ts +5 -0
  119. package/dist/primitives/stableKeys.d.ts.map +1 -0
  120. package/dist/primitives/stableKeys.js +14 -0
  121. package/dist/primitives/stableKeys.js.map +1 -0
  122. package/dist/primitives/suggestions.d.ts +66 -0
  123. package/dist/primitives/suggestions.d.ts.map +1 -0
  124. package/dist/primitives/suggestions.js +137 -0
  125. package/dist/primitives/suggestions.js.map +1 -0
  126. package/dist/primitives/thread.d.ts +11 -0
  127. package/dist/primitives/thread.d.ts.map +1 -0
  128. package/dist/primitives/thread.js +37 -0
  129. package/dist/primitives/thread.js.map +1 -0
  130. package/dist/primitives/threadList.d.ts +82 -0
  131. package/dist/primitives/threadList.d.ts.map +1 -0
  132. package/dist/primitives/threadList.js +128 -0
  133. package/dist/primitives/threadList.js.map +1 -0
  134. package/dist/primitives/threadListFocusGroup.d.ts +14 -0
  135. package/dist/primitives/threadListFocusGroup.d.ts.map +1 -0
  136. package/dist/primitives/threadListFocusGroup.js +32 -0
  137. package/dist/primitives/threadListFocusGroup.js.map +1 -0
  138. package/dist/primitives/threadListStructural.d.ts +29 -0
  139. package/dist/primitives/threadListStructural.d.ts.map +1 -0
  140. package/dist/primitives/threadListStructural.js +55 -0
  141. package/dist/primitives/threadListStructural.js.map +1 -0
  142. package/dist/primitives/useComposerSendState.d.ts +6 -0
  143. package/dist/primitives/useComposerSendState.d.ts.map +1 -0
  144. package/dist/primitives/useComposerSendState.js +15 -0
  145. package/dist/primitives/useComposerSendState.js.map +1 -0
  146. package/dist/primitives/viewportContext.d.ts +12 -0
  147. package/dist/primitives/viewportContext.d.ts.map +1 -0
  148. package/dist/primitives/viewportContext.js +6 -0
  149. package/dist/primitives/viewportContext.js.map +1 -0
  150. package/dist/useAui.d.ts +15 -0
  151. package/dist/useAui.d.ts.map +1 -0
  152. package/dist/useAui.js +21 -0
  153. package/dist/useAui.js.map +1 -0
  154. package/dist/useAuiEvent.d.ts +17 -0
  155. package/dist/useAuiEvent.d.ts.map +1 -0
  156. package/dist/useAuiEvent.js +52 -0
  157. package/dist/useAuiEvent.js.map +1 -0
  158. package/dist/useAuiState.d.ts +23 -0
  159. package/dist/useAuiState.d.ts.map +1 -0
  160. package/dist/useAuiState.js +42 -0
  161. package/dist/useAuiState.js.map +1 -0
  162. package/dist/useScrollLock.d.ts +3 -0
  163. package/dist/useScrollLock.d.ts.map +1 -0
  164. package/dist/useScrollLock.js +53 -0
  165. package/dist/useScrollLock.js.map +1 -0
  166. package/package.json +57 -6
  167. package/src/AuiIf.ts +34 -0
  168. package/src/AuiProvider.ts +90 -0
  169. package/src/__tests__/AuiIf.test.ts +54 -0
  170. package/src/__tests__/AuiProvider.test.ts +266 -0
  171. package/src/__tests__/byindex-shrink-race.test.ts +411 -0
  172. package/src/__tests__/dist-graph.test.ts +49 -0
  173. package/src/__tests__/fixtures.ts +51 -0
  174. package/src/__tests__/primitives-actionbar.test.ts +469 -0
  175. package/src/__tests__/primitives-attachment.test.ts +493 -0
  176. package/src/__tests__/primitives-content.test.ts +829 -0
  177. package/src/__tests__/primitives-keyed-items.test.ts +270 -0
  178. package/src/__tests__/primitives-keyed-messages.test.ts +264 -0
  179. package/src/__tests__/primitives-structural.test.ts +573 -0
  180. package/src/__tests__/primitives-suggestions.test.ts +374 -0
  181. package/src/__tests__/primitives-threadlist.test.ts +443 -0
  182. package/src/__tests__/primitives-tool-ui.test.ts +579 -0
  183. package/src/__tests__/primitives.test.ts +408 -0
  184. package/src/__tests__/useAuiEvent.test.ts +159 -0
  185. package/src/__tests__/useAuiState.test.ts +124 -0
  186. package/src/context.ts +31 -0
  187. package/src/index.ts +87 -0
  188. package/src/primitives/AttachmentByIndexProvider.ts +88 -0
  189. package/src/primitives/ChainOfThoughtPrimitiveAccordionTrigger.test.ts +105 -0
  190. package/src/primitives/ChainOfThoughtPrimitiveAccordionTrigger.ts +38 -0
  191. package/src/primitives/ChainOfThoughtPrimitiveParts.test.ts +254 -0
  192. package/src/primitives/ChainOfThoughtPrimitiveParts.ts +112 -0
  193. package/src/primitives/ComposerPrimitiveCancel.ts +41 -0
  194. package/src/primitives/ComposerPrimitiveInput.ts +70 -0
  195. package/src/primitives/ComposerPrimitiveSend.ts +39 -0
  196. package/src/primitives/MessageByIdProvider.ts +89 -0
  197. package/src/primitives/MessagePrimitiveParts.tool-interaction.test.ts +88 -0
  198. package/src/primitives/MessagePrimitiveParts.ts +167 -0
  199. package/src/primitives/PartByIndexProvider.ts +62 -0
  200. package/src/primitives/ThreadListItemPrimitiveRoot.ts +57 -0
  201. package/src/primitives/ThreadListItemPrimitiveTrigger.ts +74 -0
  202. package/src/primitives/ThreadListKeyboardNav.test.ts +298 -0
  203. package/src/primitives/ThreadListPrimitiveRoot.ts +18 -0
  204. package/src/primitives/ThreadPrimitiveMessages.ts +38 -0
  205. package/src/primitives/ThreadPrimitiveScrollToBottom.ts +65 -0
  206. package/src/primitives/ThreadPrimitiveViewport.ts +120 -0
  207. package/src/primitives/ThreadPrimitiveViewportFooter.test.ts +400 -0
  208. package/src/primitives/ThreadPrimitiveViewportFooter.ts +60 -0
  209. package/src/primitives/actionBar.ts +159 -0
  210. package/src/primitives/attachment.ts +76 -0
  211. package/src/primitives/attrDisabled.ts +6 -0
  212. package/src/primitives/branchPicker.ts +77 -0
  213. package/src/primitives/composerAttachments.ts +181 -0
  214. package/src/primitives/error.ts +36 -0
  215. package/src/primitives/lastValidCache.ts +12 -0
  216. package/src/primitives/message.ts +54 -0
  217. package/src/primitives/messageAttachments.ts +32 -0
  218. package/src/primitives/stableKeys.test.ts +19 -0
  219. package/src/primitives/stableKeys.ts +21 -0
  220. package/src/primitives/suggestions.ts +179 -0
  221. package/src/primitives/thread.ts +46 -0
  222. package/src/primitives/threadList.ts +163 -0
  223. package/src/primitives/threadListFocusGroup.ts +56 -0
  224. package/src/primitives/threadListStructural.ts +86 -0
  225. package/src/primitives/useComposerSendState.ts +13 -0
  226. package/src/primitives/viewportContext.ts +16 -0
  227. package/src/useAui.ts +18 -0
  228. package/src/useAuiEvent.ts +64 -0
  229. package/src/useAuiState.ts +55 -0
  230. package/src/useScrollLock.test.ts +207 -0
  231. package/src/useScrollLock.ts +79 -0
@@ -0,0 +1,29 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { defineComponent, h, mergeProps } from "vue";
3
+ import { messageErrorText } from "@assistant-ui/core/store/internal";
4
+ //#region src/primitives/error.ts
5
+ /** A wrapper element for the current message's error state. */
6
+ const ErrorPrimitiveRoot = defineComponent({
7
+ name: "ErrorPrimitiveRoot",
8
+ inheritAttrs: false,
9
+ slots: Object,
10
+ setup(_, { attrs, slots }) {
11
+ return () => h("div", mergeProps({ role: "alert" }, attrs), slots.default?.());
12
+ }
13
+ });
14
+ /**
15
+ * Renders the current assistant message's error text (raw text, slot
16
+ * override supported); renders nothing while the message has no error.
17
+ */
18
+ const ErrorPrimitiveMessage = defineComponent({
19
+ name: "ErrorPrimitiveMessage",
20
+ slots: Object,
21
+ setup(_, { slots }) {
22
+ const error = useAuiState(messageErrorText);
23
+ return () => error.value === void 0 ? null : slots.default?.() ?? String(error.value);
24
+ }
25
+ });
26
+ //#endregion
27
+ export { ErrorPrimitiveMessage, ErrorPrimitiveRoot };
28
+
29
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","names":[],"sources":["../../src/primitives/error.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { messageErrorText } from \"@assistant-ui/core/store/internal\";\nimport { useAuiState } from \"../useAuiState\";\n\n/** A wrapper element for the current message's error state. */\nexport const ErrorPrimitiveRoot = defineComponent({\n name: \"ErrorPrimitiveRoot\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n return () =>\n h(\"div\", mergeProps({ role: \"alert\" }, attrs), slots.default?.());\n },\n});\n\n/**\n * Renders the current assistant message's error text (raw text, slot\n * override supported); renders nothing while the message has no error.\n */\nexport const ErrorPrimitiveMessage = defineComponent({\n name: \"ErrorPrimitiveMessage\",\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { slots }) {\n const error = useAuiState(messageErrorText);\n return () =>\n error.value === undefined\n ? null\n : (slots.default?.() ?? String(error.value));\n },\n});\n"],"mappings":";;;;;AAWA,MAAa,qBAAqB,gBAAgB;CAChD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,aACE,EAAE,OAAO,WAAW,EAAE,MAAM,QAAQ,GAAG,KAAK,GAAG,MAAM,UAAU,CAAC;CACpE;AACF,CAAC;;;;;AAMD,MAAa,wBAAwB,gBAAgB;CACnD,MAAM;CACN,OAAO;CACP,MAAM,GAAG,EAAE,SAAS;EAClB,MAAM,QAAQ,YAAY,gBAAgB;EAC1C,aACE,MAAM,UAAU,KAAA,IACZ,OACC,MAAM,UAAU,KAAK,OAAO,MAAM,KAAK;CAChD;AACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { createStaleReporter } from "@assistant-ui/store/client";
2
+ export declare const createLastValidCache: <T>(reportStale: (() => void) | null) => {
3
+ resolve: (valid: boolean, resolveItem: () => T) => T;
4
+ };
5
+ export { createStaleReporter };
6
+ //# sourceMappingURL=lastValidCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lastValidCache.d.ts","sourceRoot":"","sources":["../../src/primitives/lastValidCache.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAIpC,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,aAAa,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI;;CACX,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { nextTick } from "vue";
2
+ import { createLastValidCache as createLastValidCache$1, createStaleReporter } from "@assistant-ui/store/client";
3
+ //#region src/primitives/lastValidCache.ts
4
+ const scheduleExpiry = (callback) => void nextTick(callback);
5
+ const createLastValidCache = (reportStale) => createLastValidCache$1(reportStale, scheduleExpiry);
6
+ //#endregion
7
+ export { createLastValidCache, createStaleReporter };
8
+
9
+ //# sourceMappingURL=lastValidCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lastValidCache.js","names":["createNeutralLastValidCache"],"sources":["../../src/primitives/lastValidCache.ts"],"sourcesContent":["import { nextTick } from \"vue\";\nimport {\n createLastValidCache as createNeutralLastValidCache,\n createStaleReporter,\n} from \"@assistant-ui/store/client\";\n\nconst scheduleExpiry = (callback: () => void) => void nextTick(callback);\n\nexport const createLastValidCache = <T>(reportStale: (() => void) | null) =>\n createNeutralLastValidCache<T>(reportStale, scheduleExpiry);\n\nexport { createStaleReporter };\n"],"mappings":";;;AAMA,MAAM,kBAAkB,aAAyB,KAAK,SAAS,QAAQ;AAEvE,MAAa,wBAA2B,gBACtCA,uBAA+B,aAAa,cAAc"}
@@ -0,0 +1,12 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /**
3
+ * A wrapper element for one message. Sets `data-message-id` and tracks
4
+ * pointer hover into `s.message.isHovering`, including an element already
5
+ * under the pointer when it mounts.
6
+ */
7
+ export declare const MessagePrimitiveRoot: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
8
+ [key: string]: any;
9
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
10
+ default?: () => VNodeChild[];
11
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/primitives/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAIb;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;cAGQ,MAAM,UAAU,EAAE;yEAkCzD,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { useAui } from "../useAui.js";
3
+ import { defineComponent, h, mergeProps, onScopeDispose } from "vue";
4
+ //#region src/primitives/message.ts
5
+ /**
6
+ * A wrapper element for one message. Sets `data-message-id` and tracks
7
+ * pointer hover into `s.message.isHovering`, including an element already
8
+ * under the pointer when it mounts.
9
+ */
10
+ const MessagePrimitiveRoot = defineComponent({
11
+ name: "MessagePrimitiveRoot",
12
+ inheritAttrs: false,
13
+ slots: Object,
14
+ setup(_, { attrs, slots }) {
15
+ const aui = useAui();
16
+ const messageId = useAuiState((s) => s.message.id);
17
+ const onMouseenter = () => {
18
+ aui.message.setIsHovering(true);
19
+ };
20
+ const onMouseleave = () => {
21
+ aui.message.setIsHovering(false);
22
+ };
23
+ let active = true;
24
+ onScopeDispose(() => {
25
+ active = false;
26
+ onMouseleave();
27
+ });
28
+ const hoverRef = (el) => {
29
+ if (el instanceof HTMLElement && el.matches(":hover")) queueMicrotask(() => {
30
+ if (active) onMouseenter();
31
+ });
32
+ };
33
+ return () => h("div", mergeProps(attrs, {
34
+ ref: hoverRef,
35
+ "data-message-id": messageId.value,
36
+ onMouseenter,
37
+ onMouseleave
38
+ }), slots.default?.());
39
+ }
40
+ });
41
+ //#endregion
42
+ export { MessagePrimitiveRoot };
43
+
44
+ //# sourceMappingURL=message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.js","names":[],"sources":["../../src/primitives/message.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n onScopeDispose,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\n\n/**\n * A wrapper element for one message. Sets `data-message-id` and tracks\n * pointer hover into `s.message.isHovering`, including an element already\n * under the pointer when it mounts.\n */\nexport const MessagePrimitiveRoot = defineComponent({\n name: \"MessagePrimitiveRoot\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const messageId = useAuiState((s) => s.message.id);\n const onMouseenter = () => {\n aui.message.setIsHovering(true);\n };\n const onMouseleave = () => {\n aui.message.setIsHovering(false);\n };\n let active = true;\n onScopeDispose(() => {\n active = false;\n onMouseleave();\n });\n const hoverRef = (el: unknown) => {\n if (el instanceof HTMLElement && el.matches(\":hover\")) {\n queueMicrotask(() => {\n if (active) onMouseenter();\n });\n }\n };\n return () =>\n h(\n \"div\",\n mergeProps(attrs, {\n ref: hoverRef,\n \"data-message-id\": messageId.value,\n onMouseenter,\n onMouseleave,\n }),\n slots.default?.(),\n );\n },\n});\n"],"mappings":";;;;;;;;;AAgBA,MAAa,uBAAuB,gBAAgB;CAClD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,MAAM,OAAO;EACnB,MAAM,YAAY,aAAa,MAAM,EAAE,QAAQ,EAAE;EACjD,MAAM,qBAAqB;GACzB,IAAI,QAAQ,cAAc,IAAI;EAChC;EACA,MAAM,qBAAqB;GACzB,IAAI,QAAQ,cAAc,KAAK;EACjC;EACA,IAAI,SAAS;EACb,qBAAqB;GACnB,SAAS;GACT,aAAa;EACf,CAAC;EACD,MAAM,YAAY,OAAgB;GAChC,IAAI,cAAc,eAAe,GAAG,QAAQ,QAAQ,GAClD,qBAAqB;IACnB,IAAI,QAAQ,aAAa;GAC3B,CAAC;EAEL;EACA,aACE,EACE,OACA,WAAW,OAAO;GAChB,KAAK;GACL,mBAAmB,UAAU;GAC7B;GACA;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /**
3
+ * Renders the current message's attachments in order, each scoped through
4
+ * {@link AttachmentByIndexProvider}; the `default` slot renders each
5
+ * attachment.
6
+ */
7
+ export declare const MessagePrimitiveAttachments: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
8
+ [key: string]: any;
9
+ }>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
10
+ default?: () => VNodeChild[];
11
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
+ //# sourceMappingURL=messageAttachments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageAttachments.d.ts","sourceRoot":"","sources":["../../src/primitives/messageAttachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAK1E;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;cAEC,MAAM,UAAU,EAAE;yEAmBzD,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { getAttachmentKeys, useStableKeys } from "./stableKeys.js";
3
+ import { AttachmentByIndexProvider } from "./AttachmentByIndexProvider.js";
4
+ import { defineComponent, h } from "vue";
5
+ //#region src/primitives/messageAttachments.ts
6
+ /**
7
+ * Renders the current message's attachments in order, each scoped through
8
+ * {@link AttachmentByIndexProvider}; the `default` slot renders each
9
+ * attachment.
10
+ */
11
+ const MessagePrimitiveAttachments = defineComponent({
12
+ name: "MessagePrimitiveAttachments",
13
+ slots: Object,
14
+ setup(_, { slots }) {
15
+ const attachments = useAuiState((s) => s.message.role === "user" ? s.message.submission?.attachments ?? s.message.attachments : void 0);
16
+ const attachmentKeys = useStableKeys(() => getAttachmentKeys(attachments.value ?? []));
17
+ return () => attachmentKeys.value.map((key, index) => h(AttachmentByIndexProvider, {
18
+ source: "message",
19
+ index,
20
+ key
21
+ }, { default: () => slots.default?.() }));
22
+ }
23
+ });
24
+ //#endregion
25
+ export { MessagePrimitiveAttachments };
26
+
27
+ //# sourceMappingURL=messageAttachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageAttachments.js","names":[],"sources":["../../src/primitives/messageAttachments.ts"],"sourcesContent":["import { defineComponent, h, type SlotsType, type VNodeChild } from \"vue\";\nimport { useAuiState } from \"../useAuiState\";\nimport { AttachmentByIndexProvider } from \"./AttachmentByIndexProvider\";\nimport { getAttachmentKeys, useStableKeys } from \"./stableKeys\";\n\n/**\n * Renders the current message's attachments in order, each scoped through\n * {@link AttachmentByIndexProvider}; the `default` slot renders each\n * attachment.\n */\nexport const MessagePrimitiveAttachments = defineComponent({\n name: \"MessagePrimitiveAttachments\",\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { slots }) {\n const attachments = useAuiState((s) =>\n s.message.role === \"user\"\n ? (s.message.submission?.attachments ?? s.message.attachments)\n : undefined,\n );\n const attachmentKeys = useStableKeys(() =>\n getAttachmentKeys(attachments.value ?? []),\n );\n return () =>\n attachmentKeys.value.map((key, index) =>\n h(\n AttachmentByIndexProvider,\n { source: \"message\", index, key },\n { default: () => slots.default?.() },\n ),\n );\n },\n});\n"],"mappings":";;;;;;;;;;AAUA,MAAa,8BAA8B,gBAAgB;CACzD,MAAM;CACN,OAAO;CACP,MAAM,GAAG,EAAE,SAAS;EAClB,MAAM,cAAc,aAAa,MAC/B,EAAE,QAAQ,SAAS,SACd,EAAE,QAAQ,YAAY,eAAe,EAAE,QAAQ,cAChD,KAAA,CACN;EACA,MAAM,iBAAiB,oBACrB,kBAAkB,YAAY,SAAS,CAAC,CAAC,CAC3C;EACA,aACE,eAAe,MAAM,KAAK,KAAK,UAC7B,EACE,2BACA;GAAE,QAAQ;GAAW;GAAO;EAAI,GAChC,EAAE,eAAe,MAAM,UAAU,EAAE,CACrC,CACF;CACJ;AACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const useStableKeys: (getKeys: () => string[]) => import("vue").ComputedRef<string[]>;
2
+ export declare const getAttachmentKeys: (attachments: readonly {
3
+ readonly id: string;
4
+ }[]) => string[];
5
+ //# sourceMappingURL=stableKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stableKeys.d.ts","sourceRoot":"","sources":["../../src/primitives/stableKeys.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,MAAM,EAAE,wCAOjD,CAAC;AAEL,eAAO,MAAM,iBAAiB,GAC5B,aAAa,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,aAQhD,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { computed } from "vue";
2
+ //#region src/primitives/stableKeys.ts
3
+ const useStableKeys = (getKeys) => computed((previous) => {
4
+ const keys = getKeys();
5
+ return previous?.length === keys.length && previous.every((key, index) => key === keys[index]) ? previous : keys;
6
+ });
7
+ const getAttachmentKeys = (attachments) => {
8
+ const ids = attachments.map((attachment) => attachment.id);
9
+ return ids.map((id, index) => ids.indexOf(id) === ids.lastIndexOf(id) ? `attachment:${id}` : `attachment@${index}`);
10
+ };
11
+ //#endregion
12
+ export { getAttachmentKeys, useStableKeys };
13
+
14
+ //# sourceMappingURL=stableKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stableKeys.js","names":[],"sources":["../../src/primitives/stableKeys.ts"],"sourcesContent":["import { computed } from \"vue\";\n\nexport const useStableKeys = (getKeys: () => string[]) =>\n computed<string[]>((previous) => {\n const keys = getKeys();\n return previous?.length === keys.length &&\n previous.every((key, index) => key === keys[index])\n ? previous\n : keys;\n });\n\nexport const getAttachmentKeys = (\n attachments: readonly { readonly id: string }[],\n) => {\n const ids = attachments.map((attachment) => attachment.id);\n return ids.map((id, index) =>\n ids.indexOf(id) === ids.lastIndexOf(id)\n ? `attachment:${id}`\n : `attachment@${index}`,\n );\n};\n"],"mappings":";;AAEA,MAAa,iBAAiB,YAC5B,UAAoB,aAAa;CAC/B,MAAM,OAAO,QAAQ;CACrB,OAAO,UAAU,WAAW,KAAK,UAC/B,SAAS,OAAO,KAAK,UAAU,QAAQ,KAAK,MAAM,IAChD,WACA;AACN,CAAC;AAEH,MAAa,qBACX,gBACG;CACH,MAAM,MAAM,YAAY,KAAK,eAAe,WAAW,EAAE;CACzD,OAAO,IAAI,KAAK,IAAI,UAClB,IAAI,QAAQ,EAAE,MAAM,IAAI,YAAY,EAAE,IAClC,cAAc,OACd,cAAc,OACpB;AACF"}
@@ -0,0 +1,66 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /**
3
+ * Scopes the subtree to the suggestion at `index`: descendants read it
4
+ * through `s.suggestion`.
5
+ */
6
+ export declare const SuggestionByIndexProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
+ index: {
8
+ type: NumberConstructor;
9
+ required: true;
10
+ };
11
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
12
+ [key: string]: any;
13
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
14
+ index: {
15
+ type: NumberConstructor;
16
+ required: true;
17
+ };
18
+ }>> & Readonly<{}>, {}, SlotsType<{
19
+ default?: () => VNodeChild[];
20
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
21
+ /**
22
+ * Renders the default slot once per thread suggestion, each instance scoped
23
+ * through {@link SuggestionByIndexProvider}.
24
+ */
25
+ export declare const ThreadPrimitiveSuggestions: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
26
+ [key: string]: any;
27
+ }>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
28
+ default?: () => VNodeChild[];
29
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
30
+ /**
31
+ * A button that triggers the current suggestion. With `send`, the prompt is
32
+ * appended as a message (queued sends never clear a draft the user is still
33
+ * composing); without it, the prompt replaces the composer text, or is
34
+ * appended to it when `clearComposer` is false.
35
+ */
36
+ export declare const SuggestionPrimitiveTrigger: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
37
+ send: {
38
+ type: BooleanConstructor;
39
+ default: boolean;
40
+ };
41
+ clearComposer: {
42
+ type: BooleanConstructor;
43
+ default: boolean;
44
+ };
45
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
46
+ [key: string]: any;
47
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
48
+ send: {
49
+ type: BooleanConstructor;
50
+ default: boolean;
51
+ };
52
+ clearComposer: {
53
+ type: BooleanConstructor;
54
+ default: boolean;
55
+ };
56
+ }>> & Readonly<{}>, {
57
+ send: boolean;
58
+ clearComposer: boolean;
59
+ }, SlotsType<{
60
+ default?: () => VNodeChild[];
61
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
62
+ /** Renders the current suggestion's title as text. */
63
+ export declare const SuggestionPrimitiveTitle: import("vue").DefineComponent<{}, () => string, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
64
+ /** Renders the current suggestion's label as text. */
65
+ export declare const SuggestionPrimitiveDescription: import("vue").DefineComponent<{}, () => string, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
66
+ //# sourceMappingURL=suggestions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../../src/primitives/suggestions.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAgBb;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;cAQG,MAAM,UAAU,EAAE;yEAoCzD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;cAEE,MAAM,UAAU,EAAE;yEAezD,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;cAaE,MAAM,UAAU,EAAE;yEA4CzD,CAAC;AAEH,sDAAsD;AACtD,eAAO,MAAM,wBAAwB,yRAMnC,CAAC;AAEH,sDAAsD;AACtD,eAAO,MAAM,8BAA8B,yRAMzC,CAAC"}
@@ -0,0 +1,137 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { AuiProvider } from "../AuiProvider.js";
3
+ import { useAui } from "../useAui.js";
4
+ import { createLastValidCache as createLastValidCache$1, createStaleReporter } from "./lastValidCache.js";
5
+ import { useStableKeys } from "./stableKeys.js";
6
+ import { isAttrDisabled } from "./attrDisabled.js";
7
+ import { computed, defineComponent, h, mergeProps, onScopeDispose } from "vue";
8
+ import { AuiConfig, Derived } from "@assistant-ui/store/client";
9
+ import { suggestionSendMode, suggestionTriggerDisabled } from "@assistant-ui/core/store/internal";
10
+ import { getSuggestionKeys } from "@assistant-ui/core/internal";
11
+ import { flushTapSync } from "@assistant-ui/tap";
12
+ //#region src/primitives/suggestions.ts
13
+ /**
14
+ * Scopes the subtree to the suggestion at `index`: descendants read it
15
+ * through `s.suggestion`.
16
+ */
17
+ const SuggestionByIndexProvider = defineComponent({
18
+ name: "SuggestionByIndexProvider",
19
+ props: { index: {
20
+ type: Number,
21
+ required: true
22
+ } },
23
+ slots: Object,
24
+ setup(props, { slots }) {
25
+ const aui = useAui();
26
+ let disposed = false;
27
+ onScopeDispose(() => {
28
+ disposed = true;
29
+ });
30
+ const config = computed(() => {
31
+ const index = props.index;
32
+ const cache = createLastValidCache$1(createStaleReporter({
33
+ name: "SuggestionByIndexProvider",
34
+ index,
35
+ isCurrent: () => !disposed && index === props.index,
36
+ isValid: () => index < aui.suggestions.getState().suggestions.length
37
+ }));
38
+ return AuiConfig({ suggestion: Derived({
39
+ source: "suggestions",
40
+ query: { index },
41
+ get: (aui) => cache.resolve(index < aui.suggestions.getState().suggestions.length, () => aui.suggestions.suggestion({ index }))
42
+ }) });
43
+ });
44
+ return () => h(AuiProvider, {
45
+ config: config.value,
46
+ extends: aui
47
+ }, { default: () => slots.default?.() });
48
+ }
49
+ });
50
+ /**
51
+ * Renders the default slot once per thread suggestion, each instance scoped
52
+ * through {@link SuggestionByIndexProvider}.
53
+ */
54
+ const ThreadPrimitiveSuggestions = defineComponent({
55
+ name: "ThreadPrimitiveSuggestions",
56
+ slots: Object,
57
+ setup(_, { slots }) {
58
+ const suggestions = useAuiState((s) => s.suggestions.suggestions);
59
+ const suggestionKeys = useStableKeys(() => getSuggestionKeys(suggestions.value));
60
+ return () => suggestionKeys.value.map((key, index) => h(SuggestionByIndexProvider, {
61
+ index,
62
+ key
63
+ }, { default: () => slots.default?.() }));
64
+ }
65
+ });
66
+ /**
67
+ * A button that triggers the current suggestion. With `send`, the prompt is
68
+ * appended as a message (queued sends never clear a draft the user is still
69
+ * composing); without it, the prompt replaces the composer text, or is
70
+ * appended to it when `clearComposer` is false.
71
+ */
72
+ const SuggestionPrimitiveTrigger = defineComponent({
73
+ name: "SuggestionPrimitiveTrigger",
74
+ inheritAttrs: false,
75
+ props: {
76
+ send: {
77
+ type: Boolean,
78
+ default: false
79
+ },
80
+ clearComposer: {
81
+ type: Boolean,
82
+ default: true
83
+ }
84
+ },
85
+ slots: Object,
86
+ setup(props, { attrs, slots }) {
87
+ const aui = useAui();
88
+ const prompt = useAuiState((s) => s.suggestion.prompt);
89
+ const disabled = useAuiState((s) => suggestionTriggerDisabled(s, props.send));
90
+ const onClick = (event) => {
91
+ if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
92
+ flushTapSync(() => {
93
+ if (props.send) {
94
+ const mode = suggestionSendMode(aui.thread.getState());
95
+ if (mode === "blocked") return;
96
+ aui.thread.append({
97
+ content: [{
98
+ type: "text",
99
+ text: prompt.value
100
+ }],
101
+ runConfig: aui.composer.getState().runConfig
102
+ });
103
+ if (props.clearComposer && mode === "now") aui.composer.setText("");
104
+ } else if (props.clearComposer) aui.composer.setText(prompt.value);
105
+ else {
106
+ const currentText = aui.composer.getState().text;
107
+ aui.composer.setText([currentText, prompt.value].filter((part) => part.trim()).join(" "));
108
+ }
109
+ });
110
+ };
111
+ return () => h("button", mergeProps(attrs, {
112
+ type: "button",
113
+ disabled: disabled.value || isAttrDisabled(attrs),
114
+ onClick
115
+ }), slots.default?.());
116
+ }
117
+ });
118
+ /** Renders the current suggestion's title as text. */
119
+ const SuggestionPrimitiveTitle = defineComponent({
120
+ name: "SuggestionPrimitiveTitle",
121
+ setup() {
122
+ const title = useAuiState((s) => s.suggestion.title);
123
+ return () => title.value;
124
+ }
125
+ });
126
+ /** Renders the current suggestion's label as text. */
127
+ const SuggestionPrimitiveDescription = defineComponent({
128
+ name: "SuggestionPrimitiveDescription",
129
+ setup() {
130
+ const label = useAuiState((s) => s.suggestion.label);
131
+ return () => label.value;
132
+ }
133
+ });
134
+ //#endregion
135
+ export { SuggestionByIndexProvider, SuggestionPrimitiveDescription, SuggestionPrimitiveTitle, SuggestionPrimitiveTrigger, ThreadPrimitiveSuggestions };
136
+
137
+ //# sourceMappingURL=suggestions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggestions.js","names":["createLastValidCache"],"sources":["../../src/primitives/suggestions.ts"],"sourcesContent":["import {\n computed,\n defineComponent,\n h,\n mergeProps,\n onScopeDispose,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { AuiConfig, Derived } from \"@assistant-ui/store/client\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport type { SuggestionMethods } from \"@assistant-ui/core/store\";\nimport { getSuggestionKeys } from \"@assistant-ui/core/internal\";\nimport {\n suggestionSendMode,\n suggestionTriggerDisabled,\n} from \"@assistant-ui/core/store/internal\";\nimport { AuiProvider } from \"../AuiProvider\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { createLastValidCache, createStaleReporter } from \"./lastValidCache\";\nimport { useStableKeys } from \"./stableKeys\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\n\n/**\n * Scopes the subtree to the suggestion at `index`: descendants read it\n * through `s.suggestion`.\n */\nexport const SuggestionByIndexProvider = defineComponent({\n name: \"SuggestionByIndexProvider\",\n props: {\n index: {\n type: Number,\n required: true,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { slots }) {\n const aui = useAui();\n let disposed = false;\n onScopeDispose(() => {\n disposed = true;\n });\n const config = computed(() => {\n const index = props.index;\n const cache = createLastValidCache<SuggestionMethods>(\n createStaleReporter({\n name: \"SuggestionByIndexProvider\",\n index,\n isCurrent: () => !disposed && index === props.index,\n isValid: () => index < aui.suggestions.getState().suggestions.length,\n }),\n );\n return AuiConfig({\n suggestion: Derived({\n source: \"suggestions\",\n query: { index },\n get: (aui) =>\n cache.resolve(\n index < aui.suggestions.getState().suggestions.length,\n () => aui.suggestions.suggestion({ index }),\n ),\n }),\n });\n });\n return () =>\n h(\n AuiProvider,\n { config: config.value, extends: aui },\n { default: () => slots.default?.() },\n );\n },\n});\n\n/**\n * Renders the default slot once per thread suggestion, each instance scoped\n * through {@link SuggestionByIndexProvider}.\n */\nexport const ThreadPrimitiveSuggestions = defineComponent({\n name: \"ThreadPrimitiveSuggestions\",\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { slots }) {\n const suggestions = useAuiState((s) => s.suggestions.suggestions);\n const suggestionKeys = useStableKeys(() =>\n getSuggestionKeys(suggestions.value),\n );\n return () =>\n suggestionKeys.value.map((key, index) =>\n h(\n SuggestionByIndexProvider,\n { index, key },\n { default: () => slots.default?.() },\n ),\n );\n },\n});\n\n/**\n * A button that triggers the current suggestion. With `send`, the prompt is\n * appended as a message (queued sends never clear a draft the user is still\n * composing); without it, the prompt replaces the composer text, or is\n * appended to it when `clearComposer` is false.\n */\nexport const SuggestionPrimitiveTrigger = defineComponent({\n name: \"SuggestionPrimitiveTrigger\",\n inheritAttrs: false,\n props: {\n send: {\n type: Boolean,\n default: false,\n },\n clearComposer: {\n type: Boolean,\n default: true,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { attrs, slots }) {\n const aui = useAui();\n const prompt = useAuiState((s) => s.suggestion.prompt);\n const disabled = useAuiState((s) =>\n suggestionTriggerDisabled(s, props.send),\n );\n\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n flushTapSync(() => {\n if (props.send) {\n const mode = suggestionSendMode(aui.thread.getState());\n if (mode === \"blocked\") return;\n aui.thread.append({\n content: [{ type: \"text\", text: prompt.value }],\n runConfig: aui.composer.getState().runConfig,\n });\n if (props.clearComposer && mode === \"now\") {\n aui.composer.setText(\"\");\n }\n } else if (props.clearComposer) {\n aui.composer.setText(prompt.value);\n } else {\n const currentText = aui.composer.getState().text;\n aui.composer.setText(\n [currentText, prompt.value].filter((part) => part.trim()).join(\" \"),\n );\n }\n });\n };\n\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: disabled.value || isAttrDisabled(attrs),\n onClick,\n }),\n slots.default?.(),\n );\n },\n});\n\n/** Renders the current suggestion's title as text. */\nexport const SuggestionPrimitiveTitle = defineComponent({\n name: \"SuggestionPrimitiveTitle\",\n setup() {\n const title = useAuiState((s) => s.suggestion.title);\n return () => title.value;\n },\n});\n\n/** Renders the current suggestion's label as text. */\nexport const SuggestionPrimitiveDescription = defineComponent({\n name: \"SuggestionPrimitiveDescription\",\n setup() {\n const label = useAuiState((s) => s.suggestion.label);\n return () => label.value;\n },\n});\n"],"mappings":"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"}
@@ -0,0 +1,11 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /**
3
+ * A wrapper element for the thread. While mounted, Escape stops an active
4
+ * speech synthesis run.
5
+ */
6
+ export declare const ThreadPrimitiveRoot: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
7
+ [key: string]: any;
8
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
9
+ default?: () => VNodeChild[];
10
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
11
+ //# sourceMappingURL=thread.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread.d.ts","sourceRoot":"","sources":["../../src/primitives/thread.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAGb;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;cAGS,MAAM,UAAU,EAAE;yEA2BzD,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { useAui } from "../useAui.js";
2
+ import { defineComponent, h, mergeProps, onMounted, onScopeDispose } from "vue";
3
+ //#region src/primitives/thread.ts
4
+ /**
5
+ * A wrapper element for the thread. While mounted, Escape stops an active
6
+ * speech synthesis run.
7
+ */
8
+ const ThreadPrimitiveRoot = defineComponent({
9
+ name: "ThreadPrimitiveRoot",
10
+ inheritAttrs: false,
11
+ slots: Object,
12
+ setup(_, { attrs, slots }) {
13
+ const aui = useAui();
14
+ const handleKeyDown = (event) => {
15
+ if (event.key !== "Escape" || event.defaultPrevented) return;
16
+ if (aui.thread.source === null) return;
17
+ if (aui.thread.getState().speech == null) return;
18
+ event.preventDefault();
19
+ try {
20
+ aui.thread.stopSpeaking();
21
+ } catch (error) {
22
+ if (!(error instanceof Error) || error.message !== "No message is being spoken") throw error;
23
+ }
24
+ };
25
+ onMounted(() => {
26
+ document.addEventListener("keydown", handleKeyDown);
27
+ });
28
+ onScopeDispose(() => {
29
+ document.removeEventListener("keydown", handleKeyDown);
30
+ });
31
+ return () => h("div", mergeProps(attrs, {}), slots.default?.());
32
+ }
33
+ });
34
+ //#endregion
35
+ export { ThreadPrimitiveRoot };
36
+
37
+ //# sourceMappingURL=thread.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread.js","names":[],"sources":["../../src/primitives/thread.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n onMounted,\n onScopeDispose,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { useAui } from \"../useAui\";\n\n/**\n * A wrapper element for the thread. While mounted, Escape stops an active\n * speech synthesis run.\n */\nexport const ThreadPrimitiveRoot = defineComponent({\n name: \"ThreadPrimitiveRoot\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || event.defaultPrevented) return;\n if (aui.thread.source === null) return;\n if (aui.thread.getState().speech == null) return;\n event.preventDefault();\n try {\n aui.thread.stopSpeaking();\n } catch (error) {\n if (\n !(error instanceof Error) ||\n error.message !== \"No message is being spoken\"\n ) {\n throw error;\n }\n }\n };\n onMounted(() => {\n document.addEventListener(\"keydown\", handleKeyDown);\n });\n onScopeDispose(() => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n });\n return () => h(\"div\", mergeProps(attrs, {}), slots.default?.());\n },\n});\n"],"mappings":";;;;;;;AAeA,MAAa,sBAAsB,gBAAgB;CACjD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,MAAM,OAAO;EACnB,MAAM,iBAAiB,UAAyB;GAC9C,IAAI,MAAM,QAAQ,YAAY,MAAM,kBAAkB;GACtD,IAAI,IAAI,OAAO,WAAW,MAAM;GAChC,IAAI,IAAI,OAAO,SAAS,CAAC,CAAC,UAAU,MAAM;GAC1C,MAAM,eAAe;GACrB,IAAI;IACF,IAAI,OAAO,aAAa;GAC1B,SAAS,OAAO;IACd,IACE,EAAE,iBAAiB,UACnB,MAAM,YAAY,8BAElB,MAAM;GAEV;EACF;EACA,gBAAgB;GACd,SAAS,iBAAiB,WAAW,aAAa;EACpD,CAAC;EACD,qBAAqB;GACnB,SAAS,oBAAoB,WAAW,aAAa;EACvD,CAAC;EACD,aAAa,EAAE,OAAO,WAAW,OAAO,CAAC,CAAC,GAAG,MAAM,UAAU,CAAC;CAChE;AACF,CAAC"}
@@ -0,0 +1,82 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ export { ThreadListItemPrimitiveTrigger } from "./ThreadListItemPrimitiveTrigger.js";
3
+ /**
4
+ * Scopes the subtree to the thread-list item at `index`: descendants read it
5
+ * through `s.threadListItem`.
6
+ */
7
+ export declare const ThreadListItemByIndexProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ index: {
9
+ type: NumberConstructor;
10
+ required: true;
11
+ };
12
+ archived: {
13
+ type: BooleanConstructor;
14
+ default: boolean;
15
+ };
16
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
17
+ [key: string]: any;
18
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
19
+ index: {
20
+ type: NumberConstructor;
21
+ required: true;
22
+ };
23
+ archived: {
24
+ type: BooleanConstructor;
25
+ default: boolean;
26
+ };
27
+ }>> & Readonly<{}>, {
28
+ archived: boolean;
29
+ }, SlotsType<{
30
+ default?: () => VNodeChild[];
31
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
32
+ /**
33
+ * Renders the default slot once per thread in the list (or per archived
34
+ * thread with `archived`), each instance scoped through
35
+ * {@link ThreadListItemByIndexProvider}.
36
+ */
37
+ export declare const ThreadListPrimitiveItems: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
38
+ archived: {
39
+ type: BooleanConstructor;
40
+ default: boolean;
41
+ };
42
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
43
+ [key: string]: any;
44
+ }>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
45
+ archived: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
49
+ }>> & Readonly<{}>, {
50
+ archived: boolean;
51
+ }, SlotsType<{
52
+ default?: () => VNodeChild[];
53
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
54
+ /**
55
+ * A button that switches to a new thread. Carries `data-active` and
56
+ * `aria-current` while the new thread is the main one.
57
+ */
58
+ export declare const ThreadListPrimitiveNew: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
59
+ [key: string]: any;
60
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
61
+ default?: () => VNodeChild[];
62
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
63
+ /**
64
+ * Renders the current thread-list item's title. When the title is empty,
65
+ * renders the default slot, or the `fallback` string.
66
+ */
67
+ export declare const ThreadListItemPrimitiveTitle: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
68
+ fallback: {
69
+ type: StringConstructor;
70
+ default: string;
71
+ };
72
+ }>, () => string | VNodeChild[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
73
+ fallback: {
74
+ type: StringConstructor;
75
+ default: string;
76
+ };
77
+ }>> & Readonly<{}>, {
78
+ fallback: string;
79
+ }, SlotsType<{
80
+ default?: () => VNodeChild[];
81
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
82
+ //# sourceMappingURL=threadList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threadList.d.ts","sourceRoot":"","sources":["../../src/primitives/threadList.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAQb,OAAO,EAAE,8BAA8B,EAAE,4CAAyC;AAElF;;;GAGG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;cAYD,MAAM,UAAU,EAAE;yEA6CzD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;cAQI,MAAM,UAAU,EAAE;yEAczD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;cAGM,MAAM,UAAU,EAAE;yEAyBzD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;cAQA,MAAM,UAAU,EAAE;yEAMzD,CAAC"}