@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.
Files changed (209) hide show
  1. package/dist/api/AssistantRuntime.d.ts +1 -0
  2. package/dist/api/AssistantRuntime.d.ts.map +1 -1
  3. package/dist/api/AssistantRuntime.js +5 -0
  4. package/dist/api/AssistantRuntime.js.map +1 -1
  5. package/dist/api/AssistantRuntime.mjs +5 -0
  6. package/dist/api/AssistantRuntime.mjs.map +1 -1
  7. package/dist/api/AttachmentRuntime.d.ts +1 -0
  8. package/dist/api/AttachmentRuntime.d.ts.map +1 -1
  9. package/dist/api/AttachmentRuntime.js +5 -0
  10. package/dist/api/AttachmentRuntime.js.map +1 -1
  11. package/dist/api/AttachmentRuntime.mjs +5 -0
  12. package/dist/api/AttachmentRuntime.mjs.map +1 -1
  13. package/dist/api/ComposerRuntime.d.ts +2 -0
  14. package/dist/api/ComposerRuntime.d.ts.map +1 -1
  15. package/dist/api/ComposerRuntime.js +19 -0
  16. package/dist/api/ComposerRuntime.js.map +1 -1
  17. package/dist/api/ComposerRuntime.mjs +19 -0
  18. package/dist/api/ComposerRuntime.mjs.map +1 -1
  19. package/dist/api/ContentPartRuntime.d.ts +1 -0
  20. package/dist/api/ContentPartRuntime.d.ts.map +1 -1
  21. package/dist/api/ContentPartRuntime.js +5 -0
  22. package/dist/api/ContentPartRuntime.js.map +1 -1
  23. package/dist/api/ContentPartRuntime.mjs +5 -0
  24. package/dist/api/ContentPartRuntime.mjs.map +1 -1
  25. package/dist/api/MessageRuntime.d.ts +1 -0
  26. package/dist/api/MessageRuntime.d.ts.map +1 -1
  27. package/dist/api/MessageRuntime.js +13 -0
  28. package/dist/api/MessageRuntime.js.map +1 -1
  29. package/dist/api/MessageRuntime.mjs +13 -0
  30. package/dist/api/MessageRuntime.mjs.map +1 -1
  31. package/dist/api/ThreadListItemRuntime.d.ts +1 -0
  32. package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
  33. package/dist/api/ThreadListItemRuntime.js +11 -0
  34. package/dist/api/ThreadListItemRuntime.js.map +1 -1
  35. package/dist/api/ThreadListItemRuntime.mjs +11 -0
  36. package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
  37. package/dist/api/ThreadListRuntime.d.ts +1 -0
  38. package/dist/api/ThreadListRuntime.d.ts.map +1 -1
  39. package/dist/api/ThreadListRuntime.js +10 -0
  40. package/dist/api/ThreadListRuntime.js.map +1 -1
  41. package/dist/api/ThreadListRuntime.mjs +10 -0
  42. package/dist/api/ThreadListRuntime.mjs.map +1 -1
  43. package/dist/api/ThreadRuntime.d.ts +1 -1
  44. package/dist/api/ThreadRuntime.d.ts.map +1 -1
  45. package/dist/api/ThreadRuntime.js +14 -3
  46. package/dist/api/ThreadRuntime.js.map +1 -1
  47. package/dist/api/ThreadRuntime.mjs +14 -3
  48. package/dist/api/ThreadRuntime.mjs.map +1 -1
  49. package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
  50. package/dist/context/providers/AssistantRuntimeProvider.js +5 -14
  51. package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
  52. package/dist/context/providers/AssistantRuntimeProvider.mjs +5 -14
  53. package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
  54. package/dist/context/providers/AttachmentRuntimeProvider.d.ts.map +1 -1
  55. package/dist/context/providers/AttachmentRuntimeProvider.js +5 -16
  56. package/dist/context/providers/AttachmentRuntimeProvider.js.map +1 -1
  57. package/dist/context/providers/AttachmentRuntimeProvider.mjs +6 -21
  58. package/dist/context/providers/AttachmentRuntimeProvider.mjs.map +1 -1
  59. package/dist/context/providers/ContentPartRuntimeProvider.d.ts +0 -1
  60. package/dist/context/providers/ContentPartRuntimeProvider.d.ts.map +1 -1
  61. package/dist/context/providers/ContentPartRuntimeProvider.js +5 -15
  62. package/dist/context/providers/ContentPartRuntimeProvider.js.map +1 -1
  63. package/dist/context/providers/ContentPartRuntimeProvider.mjs +4 -13
  64. package/dist/context/providers/ContentPartRuntimeProvider.mjs.map +1 -1
  65. package/dist/context/providers/MessageRuntimeProvider.d.ts.map +1 -1
  66. package/dist/context/providers/MessageRuntimeProvider.js +3 -22
  67. package/dist/context/providers/MessageRuntimeProvider.js.map +1 -1
  68. package/dist/context/providers/MessageRuntimeProvider.mjs +3 -22
  69. package/dist/context/providers/MessageRuntimeProvider.mjs.map +1 -1
  70. package/dist/context/providers/TextContentPartProvider.d.ts.map +1 -1
  71. package/dist/context/providers/TextContentPartProvider.js +13 -12
  72. package/dist/context/providers/TextContentPartProvider.js.map +1 -1
  73. package/dist/context/providers/TextContentPartProvider.mjs +13 -12
  74. package/dist/context/providers/TextContentPartProvider.mjs.map +1 -1
  75. package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +0 -1
  76. package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
  77. package/dist/context/providers/ThreadListItemRuntimeProvider.js +5 -15
  78. package/dist/context/providers/ThreadListItemRuntimeProvider.js.map +1 -1
  79. package/dist/context/providers/ThreadListItemRuntimeProvider.mjs +4 -13
  80. package/dist/context/providers/ThreadListItemRuntimeProvider.mjs.map +1 -1
  81. package/dist/context/providers/ThreadRuntimeProvider.d.ts.map +1 -1
  82. package/dist/context/providers/ThreadRuntimeProvider.js +5 -24
  83. package/dist/context/providers/ThreadRuntimeProvider.js.map +1 -1
  84. package/dist/context/providers/ThreadRuntimeProvider.mjs +6 -25
  85. package/dist/context/providers/ThreadRuntimeProvider.mjs.map +1 -1
  86. package/dist/context/react/AssistantContext.d.ts +26 -17
  87. package/dist/context/react/AssistantContext.d.ts.map +1 -1
  88. package/dist/context/react/AssistantContext.js +3 -4
  89. package/dist/context/react/AssistantContext.js.map +1 -1
  90. package/dist/context/react/AssistantContext.mjs +3 -4
  91. package/dist/context/react/AssistantContext.mjs.map +1 -1
  92. package/dist/context/react/AttachmentContext.d.ts +558 -30
  93. package/dist/context/react/AttachmentContext.d.ts.map +1 -1
  94. package/dist/context/react/AttachmentContext.js +32 -52
  95. package/dist/context/react/AttachmentContext.js.map +1 -1
  96. package/dist/context/react/AttachmentContext.mjs +33 -52
  97. package/dist/context/react/AttachmentContext.mjs.map +1 -1
  98. package/dist/context/react/ComposerContext.d.ts +28 -19
  99. package/dist/context/react/ComposerContext.d.ts.map +1 -1
  100. package/dist/context/react/ComposerContext.js +2 -19
  101. package/dist/context/react/ComposerContext.js.map +1 -1
  102. package/dist/context/react/ComposerContext.mjs +4 -20
  103. package/dist/context/react/ComposerContext.mjs.map +1 -1
  104. package/dist/context/react/ContentPartContext.d.ts +22 -16
  105. package/dist/context/react/ContentPartContext.d.ts.map +1 -1
  106. package/dist/context/react/ContentPartContext.js +2 -7
  107. package/dist/context/react/ContentPartContext.js.map +1 -1
  108. package/dist/context/react/ContentPartContext.mjs +2 -6
  109. package/dist/context/react/ContentPartContext.mjs.map +1 -1
  110. package/dist/context/react/MessageContext.d.ts +49 -29
  111. package/dist/context/react/MessageContext.d.ts.map +1 -1
  112. package/dist/context/react/MessageContext.js +5 -9
  113. package/dist/context/react/MessageContext.js.map +1 -1
  114. package/dist/context/react/MessageContext.mjs +5 -8
  115. package/dist/context/react/MessageContext.mjs.map +1 -1
  116. package/dist/context/react/ThreadContext.d.ts +44 -24
  117. package/dist/context/react/ThreadContext.d.ts.map +1 -1
  118. package/dist/context/react/ThreadContext.js +5 -9
  119. package/dist/context/react/ThreadContext.js.map +1 -1
  120. package/dist/context/react/ThreadContext.mjs +5 -8
  121. package/dist/context/react/ThreadContext.mjs.map +1 -1
  122. package/dist/context/react/ThreadListItemContext.d.ts +22 -16
  123. package/dist/context/react/ThreadListItemContext.d.ts.map +1 -1
  124. package/dist/context/react/ThreadListItemContext.js +3 -6
  125. package/dist/context/react/ThreadListItemContext.js.map +1 -1
  126. package/dist/context/react/ThreadListItemContext.mjs +3 -5
  127. package/dist/context/react/ThreadListItemContext.mjs.map +1 -1
  128. package/dist/context/react/index.d.ts +1 -0
  129. package/dist/context/react/index.d.ts.map +1 -1
  130. package/dist/context/react/index.js +3 -0
  131. package/dist/context/react/index.js.map +1 -1
  132. package/dist/context/react/index.mjs +2 -0
  133. package/dist/context/react/index.mjs.map +1 -1
  134. package/dist/context/react/utils/createContextHook.d.ts +3 -8
  135. package/dist/context/react/utils/createContextHook.d.ts.map +1 -1
  136. package/dist/context/react/utils/createContextHook.js.map +1 -1
  137. package/dist/context/react/utils/createContextHook.mjs.map +1 -1
  138. package/dist/context/react/utils/createStateHookForRuntime.d.ts +31 -0
  139. package/dist/context/react/utils/createStateHookForRuntime.d.ts.map +1 -0
  140. package/dist/context/react/utils/createStateHookForRuntime.js +47 -0
  141. package/dist/context/react/utils/createStateHookForRuntime.js.map +1 -0
  142. package/dist/context/react/utils/createStateHookForRuntime.mjs +24 -0
  143. package/dist/context/react/utils/createStateHookForRuntime.mjs.map +1 -0
  144. package/dist/context/react/utils/ensureBinding.d.ts +2 -0
  145. package/dist/context/react/utils/ensureBinding.d.ts.map +1 -0
  146. package/dist/context/react/utils/ensureBinding.js +36 -0
  147. package/dist/context/react/utils/ensureBinding.js.map +1 -0
  148. package/dist/context/react/utils/ensureBinding.mjs +11 -0
  149. package/dist/context/react/utils/ensureBinding.mjs.map +1 -0
  150. package/dist/context/react/utils/useRuntimeState.d.ts +10 -0
  151. package/dist/context/react/utils/useRuntimeState.d.ts.map +1 -0
  152. package/dist/context/react/utils/useRuntimeState.js +48 -0
  153. package/dist/context/react/utils/useRuntimeState.js.map +1 -0
  154. package/dist/context/react/utils/useRuntimeState.mjs +22 -0
  155. package/dist/context/react/utils/useRuntimeState.mjs.map +1 -0
  156. package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts +1 -1
  157. package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts.map +1 -1
  158. package/dist/runtimes/adapters/attachment/AttachmentAdapter.js.map +1 -1
  159. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.d.ts +1 -1
  160. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.d.ts.map +1 -1
  161. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js +1 -1
  162. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js.map +1 -1
  163. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.mjs +1 -1
  164. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.mjs.map +1 -1
  165. package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.d.ts.map +1 -1
  166. package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.js.map +1 -1
  167. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
  168. package/dist/runtimes/composer/BaseComposerRuntimeCore.js +22 -2
  169. package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
  170. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +22 -2
  171. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
  172. package/dist/runtimes/local/useLocalRuntime.d.ts.map +1 -1
  173. package/dist/runtimes/local/useLocalRuntime.js +4 -0
  174. package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
  175. package/dist/runtimes/local/useLocalRuntime.mjs +4 -0
  176. package/dist/runtimes/local/useLocalRuntime.mjs.map +1 -1
  177. package/package.json +3 -3
  178. package/src/api/AssistantRuntime.ts +7 -0
  179. package/src/api/AttachmentRuntime.ts +6 -0
  180. package/src/api/ComposerRuntime.ts +21 -0
  181. package/src/api/ContentPartRuntime.ts +6 -0
  182. package/src/api/MessageRuntime.ts +15 -0
  183. package/src/api/ThreadListItemRuntime.ts +12 -0
  184. package/src/api/ThreadListRuntime.ts +11 -0
  185. package/src/api/ThreadRuntime.ts +15 -4
  186. package/src/context/providers/AssistantRuntimeProvider.tsx +5 -17
  187. package/src/context/providers/AttachmentRuntimeProvider.tsx +6 -24
  188. package/src/context/providers/ContentPartRuntimeProvider.tsx +4 -14
  189. package/src/context/providers/MessageRuntimeProvider.tsx +5 -31
  190. package/src/context/providers/TextContentPartProvider.tsx +26 -22
  191. package/src/context/providers/ThreadListItemRuntimeProvider.tsx +3 -14
  192. package/src/context/providers/ThreadRuntimeProvider.tsx +7 -33
  193. package/src/context/react/AssistantContext.ts +7 -7
  194. package/src/context/react/AttachmentContext.ts +45 -136
  195. package/src/context/react/ComposerContext.ts +6 -29
  196. package/src/context/react/ContentPartContext.ts +3 -8
  197. package/src/context/react/MessageContext.ts +10 -13
  198. package/src/context/react/ThreadContext.ts +9 -12
  199. package/src/context/react/ThreadListItemContext.ts +4 -7
  200. package/src/context/react/index.ts +2 -0
  201. package/src/context/react/utils/createContextHook.ts +1 -3
  202. package/src/context/react/utils/createStateHookForRuntime.ts +80 -0
  203. package/src/context/react/utils/ensureBinding.ts +45 -0
  204. package/src/context/react/utils/useRuntimeState.ts +43 -0
  205. package/src/runtimes/adapters/attachment/AttachmentAdapter.ts +3 -1
  206. package/src/runtimes/adapters/attachment/CompositeAttachmentAdapter.ts +1 -1
  207. package/src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts +1 -0
  208. package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +24 -2
  209. package/src/runtimes/local/useLocalRuntime.tsx +5 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/react/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EACL,aAAa,EACb,oBAAoB,GASrB,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/context/react/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,UAAU,EACV,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EACL,aAAa,EACb,oBAAoB,GASrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC"}
@@ -33,6 +33,7 @@ __export(react_exports, {
33
33
  useMessageRuntime: () => import_MessageContext.useMessageRuntime,
34
34
  useMessageUtils: () => import_MessageContext.useMessageUtils,
35
35
  useMessageUtilsStore: () => import_MessageContext.useMessageUtilsStore,
36
+ useRuntimeState: () => import_useRuntimeState.useRuntimeState,
36
37
  useThread: () => import_ThreadContext.useThread,
37
38
  useThreadComposer: () => import_ThreadContext.useThreadComposer,
38
39
  useThreadList: () => import_AssistantContext.useThreadList,
@@ -53,6 +54,7 @@ var import_MessageContext = require("./MessageContext.js");
53
54
  var import_ContentPartContext = require("./ContentPartContext.js");
54
55
  var import_ComposerContext = require("./ComposerContext.js");
55
56
  var import_AttachmentContext = require("./AttachmentContext.js");
57
+ var import_useRuntimeState = require("./utils/useRuntimeState.js");
56
58
  // Annotate the CommonJS export names for ESM import in node:
57
59
  0 && (module.exports = {
58
60
  useAssistantRuntime,
@@ -67,6 +69,7 @@ var import_AttachmentContext = require("./AttachmentContext.js");
67
69
  useMessageRuntime,
68
70
  useMessageUtils,
69
71
  useMessageUtilsStore,
72
+ useRuntimeState,
70
73
  useThread,
71
74
  useThreadComposer,
72
75
  useThreadList,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelConfig,\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAKO;AAEP,2BAOO;AAEP,mCAGO;AAEP,4BAMO;AACP,gCAAsD;AACtD,6BAAgD;AAEhD,+BAWO;","names":[]}
1
+ {"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelConfig,\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n\nexport { useRuntimeState } from \"./utils/useRuntimeState\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAKO;AAEP,2BAOO;AAEP,mCAGO;AAEP,4BAMO;AACP,gCAAsD;AACtD,6BAAgD;AAEhD,+BAWO;AAEP,6BAAgC;","names":[]}
@@ -32,6 +32,7 @@ import {
32
32
  useAttachment,
33
33
  useAttachmentRuntime
34
34
  } from "./AttachmentContext.mjs";
35
+ import { useRuntimeState } from "./utils/useRuntimeState.mjs";
35
36
  export {
36
37
  useAssistantRuntime,
37
38
  useAttachment,
@@ -45,6 +46,7 @@ export {
45
46
  useMessageRuntime,
46
47
  useMessageUtils,
47
48
  useMessageUtilsStore,
49
+ useRuntimeState,
48
50
  useThread,
49
51
  useThreadComposer,
50
52
  useThreadList,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelConfig,\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n"],"mappings":";;;AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB,sBAAsB;AACtD,SAAS,oBAAoB,mBAAmB;AAEhD;AAAA,EACE;AAAA,EACA;AAAA,OASK;","names":[]}
1
+ {"version":3,"sources":["../../../src/context/react/index.ts"],"sourcesContent":["\"use client\";\n// TODO createContextStoreHook does not work well with server-side nextjs bundler\n// use client necessary here for now\n\nexport {\n useAssistantRuntime,\n useThreadList,\n useToolUIs,\n useToolUIsStore,\n} from \"./AssistantContext\";\n\nexport {\n useThreadRuntime,\n useThread,\n useThreadComposer,\n useThreadModelConfig,\n useThreadViewport,\n useThreadViewportStore,\n} from \"./ThreadContext\";\n\nexport {\n useThreadListItemRuntime,\n useThreadListItem,\n} from \"./ThreadListItemContext\";\n\nexport {\n useMessageRuntime,\n useMessage,\n useEditComposer,\n useMessageUtils,\n useMessageUtilsStore,\n} from \"./MessageContext\";\nexport { useContentPartRuntime, useContentPart } from \"./ContentPartContext\";\nexport { useComposerRuntime, useComposer } from \"./ComposerContext\";\n\nexport {\n useAttachment,\n useAttachmentRuntime,\n\n // TODO decide if we want to export/drop these?\n // useEditComposerAttachment,\n // useEditComposerAttachmentRuntime,\n // useMessageAttachment,\n // useMessageAttachmentRuntime,\n // useThreadComposerAttachment,\n // useThreadComposerAttachmentRuntime,\n} from \"./AttachmentContext\";\n\nexport { useRuntimeState } from \"./utils/useRuntimeState\";\n"],"mappings":";;;AAIA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB,sBAAsB;AACtD,SAAS,oBAAoB,mBAAmB;AAEhD;AAAA,EACE;AAAA,EACA;AAAA,OASK;AAEP,SAAS,uBAAuB;","names":[]}
@@ -5,12 +5,7 @@ import { Context } from "react";
5
5
  * @param providerName - The name of the provider for error messages.
6
6
  * @returns A hook function that provides the context value.
7
7
  */
8
- export declare function createContextHook<T>(context: Context<T | null>, providerName: string): {
9
- (options?: {
10
- optional?: false | undefined;
11
- }): T;
12
- (options?: {
13
- optional?: boolean | undefined;
14
- }): T | null;
15
- };
8
+ export declare function createContextHook<T>(context: Context<T | null>, providerName: string): (options?: {
9
+ optional?: boolean | undefined;
10
+ }) => T | null;
16
11
  //# sourceMappingURL=createContextHook.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createContextHook.d.ts","sourceRoot":"","sources":["../../../../src/context/react/utils/createContextHook.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,OAAO,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,EAC1B,YAAY,EAAE,MAAM;eAEc;QAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;KAAE,GAAG,CAAC;eACpC;QAChC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAChC,GAAG,CAAC,GAAG,IAAI;EAUb"}
1
+ {"version":3,"file":"createContextHook.d.ts","sourceRoot":"","sources":["../../../../src/context/react/utils/createContextHook.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,OAAO,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,OAAO,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,EAC1B,YAAY,EAAE,MAAM,cAEc;IAChC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,KAAG,CAAC,GAAG,IAAI,CASb"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/context/react/utils/createContextHook.ts"],"sourcesContent":["\"use client\";\n\nimport { useContext, Context } from \"react\";\n\n/**\n * Creates a context hook with optional support.\n * @param context - The React context to consume.\n * @param providerName - The name of the provider for error messages.\n * @returns A hook function that provides the context value.\n */\nexport function createContextHook<T>(\n context: Context<T | null>,\n providerName: string,\n) {\n function useContextHook(options?: { optional?: false | undefined }): T;\n function useContextHook(options?: {\n optional?: boolean | undefined;\n }): T | null;\n function useContextHook(options?: { optional?: boolean | undefined }) {\n const contextValue = useContext(context);\n if (!options?.optional && !contextValue) {\n throw new Error(`This component must be used within ${providerName}.`);\n }\n return contextValue;\n }\n\n return useContextHook;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAoC;AAQ7B,SAAS,kBACd,SACA,cACA;AAKA,WAAS,eAAe,SAA8C;AACpE,UAAM,mBAAe,yBAAW,OAAO;AACvC,QAAI,CAAC,SAAS,YAAY,CAAC,cAAc;AACvC,YAAM,IAAI,MAAM,sCAAsC,YAAY,GAAG;AAAA,IACvE;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/context/react/utils/createContextHook.ts"],"sourcesContent":["\"use client\";\n\nimport { useContext, Context } from \"react\";\n\n/**\n * Creates a context hook with optional support.\n * @param context - The React context to consume.\n * @param providerName - The name of the provider for error messages.\n * @returns A hook function that provides the context value.\n */\nexport function createContextHook<T>(\n context: Context<T | null>,\n providerName: string,\n) {\n function useContextHook(options?: {\n optional?: boolean | undefined;\n }): T | null {\n const contextValue = useContext(context);\n if (!options?.optional && !contextValue) {\n throw new Error(`This component must be used within ${providerName}.`);\n }\n return contextValue;\n }\n\n return useContextHook;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAoC;AAQ7B,SAAS,kBACd,SACA,cACA;AACA,WAAS,eAAe,SAEX;AACX,UAAM,mBAAe,yBAAW,OAAO;AACvC,QAAI,CAAC,SAAS,YAAY,CAAC,cAAc;AACvC,YAAM,IAAI,MAAM,sCAAsC,YAAY,GAAG;AAAA,IACvE;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/context/react/utils/createContextHook.ts"],"sourcesContent":["\"use client\";\n\nimport { useContext, Context } from \"react\";\n\n/**\n * Creates a context hook with optional support.\n * @param context - The React context to consume.\n * @param providerName - The name of the provider for error messages.\n * @returns A hook function that provides the context value.\n */\nexport function createContextHook<T>(\n context: Context<T | null>,\n providerName: string,\n) {\n function useContextHook(options?: { optional?: false | undefined }): T;\n function useContextHook(options?: {\n optional?: boolean | undefined;\n }): T | null;\n function useContextHook(options?: { optional?: boolean | undefined }) {\n const contextValue = useContext(context);\n if (!options?.optional && !contextValue) {\n throw new Error(`This component must be used within ${providerName}.`);\n }\n return contextValue;\n }\n\n return useContextHook;\n}\n"],"mappings":";;;AAEA,SAAS,kBAA2B;AAQ7B,SAAS,kBACd,SACA,cACA;AAKA,WAAS,eAAe,SAA8C;AACpE,UAAM,eAAe,WAAW,OAAO;AACvC,QAAI,CAAC,SAAS,YAAY,CAAC,cAAc;AACvC,YAAM,IAAI,MAAM,sCAAsC,YAAY,GAAG;AAAA,IACvE;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/context/react/utils/createContextHook.ts"],"sourcesContent":["\"use client\";\n\nimport { useContext, Context } from \"react\";\n\n/**\n * Creates a context hook with optional support.\n * @param context - The React context to consume.\n * @param providerName - The name of the provider for error messages.\n * @returns A hook function that provides the context value.\n */\nexport function createContextHook<T>(\n context: Context<T | null>,\n providerName: string,\n) {\n function useContextHook(options?: {\n optional?: boolean | undefined;\n }): T | null {\n const contextValue = useContext(context);\n if (!options?.optional && !contextValue) {\n throw new Error(`This component must be used within ${providerName}.`);\n }\n return contextValue;\n }\n\n return useContextHook;\n}\n"],"mappings":";;;AAEA,SAAS,kBAA2B;AAQ7B,SAAS,kBACd,SACA,cACA;AACA,WAAS,eAAe,SAEX;AACX,UAAM,eAAe,WAAW,OAAO;AACvC,QAAI,CAAC,SAAS,YAAY,CAAC,cAAc;AACvC,YAAM,IAAI,MAAM,sCAAsC,YAAY,GAAG;AAAA,IACvE;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,31 @@
1
+ import { SubscribableRuntime } from "./useRuntimeState";
2
+ export declare function createStateHookForRuntime<TState>(useRuntime: (options: {
3
+ optional: boolean | undefined;
4
+ }) => SubscribableRuntime<TState> | null): {
5
+ (): TState;
6
+ <TSelected>(selector: (state: TState) => TSelected): TSelected;
7
+ <TSelected>(selector: ((state: TState) => TSelected) | undefined): TSelected | TState;
8
+ (options: {
9
+ optional?: false | undefined;
10
+ }): TState;
11
+ (options: {
12
+ optional?: boolean | undefined;
13
+ }): TState | null;
14
+ <TSelected>(options: {
15
+ optional?: false | undefined;
16
+ selector: (state: TState) => TSelected;
17
+ }): TSelected;
18
+ <TSelected>(options: {
19
+ optional?: false | undefined;
20
+ selector: ((state: TState) => TSelected) | undefined;
21
+ }): TSelected | TState;
22
+ <TSelected>(options: {
23
+ optional?: boolean | undefined;
24
+ selector: (state: TState) => TSelected;
25
+ }): TSelected | null;
26
+ <TSelected>(options: {
27
+ optional?: boolean | undefined;
28
+ selector: ((state: TState) => TSelected) | undefined;
29
+ }): TSelected | TState | null;
30
+ };
31
+ //# sourceMappingURL=createStateHookForRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createStateHookForRuntime.d.ts","sourceRoot":"","sources":["../../../../src/context/react/utils/createStateHookForRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AAE3B,wBAAgB,yBAAyB,CAAC,MAAM,EAC9C,UAAU,EAAE,CAAC,OAAO,EAAE;IACpB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B,KAAK,mBAAmB,CAAC,MAAM,CAAC,GAAG,IAAI;QAGf,MAAM;KAGT,SAAS,YACnB,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,GACrC,SAAS;KAGU,SAAS,YACnB,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,SAAS,GACnD,SAAS,GAAG,MAAM;cAGU;QAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;KAAE,GAAG,MAAM;cAGzC;QAC7B,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;KAChC,GAAG,MAAM,GAAG,IAAI;KAGK,SAAS,WAAW;QACxC,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;QAC7B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;KACxC,GAAG,SAAS;KAGS,SAAS,WAAW;QACxC,QAAQ,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC;QAC7B,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;KACtD,GAAG,SAAS,GAAG,MAAM;KAGA,SAAS,WAAW;QACxC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC/B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;KACxC,GAAG,SAAS,GAAG,IAAI;KAGE,SAAS,WAAW;QACxC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC/B,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;KACtD,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI;EA0B9B"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/context/react/utils/createStateHookForRuntime.ts
21
+ var createStateHookForRuntime_exports = {};
22
+ __export(createStateHookForRuntime_exports, {
23
+ createStateHookForRuntime: () => createStateHookForRuntime
24
+ });
25
+ module.exports = __toCommonJS(createStateHookForRuntime_exports);
26
+ var import_useRuntimeState = require("./useRuntimeState.js");
27
+ function createStateHookForRuntime(useRuntime) {
28
+ function useStoreHook(param) {
29
+ let optional = false;
30
+ let selector;
31
+ if (typeof param === "function") {
32
+ selector = param;
33
+ } else if (param) {
34
+ optional = !!param.optional;
35
+ selector = param.selector;
36
+ }
37
+ const store = useRuntime({ optional });
38
+ if (!store) return null;
39
+ return (0, import_useRuntimeState.useRuntimeStateInternal)(store, selector);
40
+ }
41
+ return useStoreHook;
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ createStateHookForRuntime
46
+ });
47
+ //# sourceMappingURL=createStateHookForRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/react/utils/createStateHookForRuntime.ts"],"sourcesContent":["import {\n SubscribableRuntime,\n useRuntimeStateInternal,\n} from \"./useRuntimeState\";\n\nexport function createStateHookForRuntime<TState>(\n useRuntime: (options: {\n optional: boolean | undefined;\n }) => SubscribableRuntime<TState> | null,\n) {\n // empty\n function useStoreHook(): TState;\n\n // selector\n function useStoreHook<TSelected>(\n selector: (state: TState) => TSelected,\n ): TSelected;\n\n // selector?\n function useStoreHook<TSelected>(\n selector: ((state: TState) => TSelected) | undefined,\n ): TSelected | TState;\n\n // optional=false\n function useStoreHook(options: { optional?: false | undefined }): TState;\n\n // optional?\n function useStoreHook(options: {\n optional?: boolean | undefined;\n }): TState | null;\n\n // optional=false, selector\n function useStoreHook<TSelected>(options: {\n optional?: false | undefined;\n selector: (state: TState) => TSelected;\n }): TSelected;\n\n // optional=false, selector?\n function useStoreHook<TSelected>(options: {\n optional?: false | undefined;\n selector: ((state: TState) => TSelected) | undefined;\n }): TSelected | TState;\n\n // optional?, selector\n function useStoreHook<TSelected>(options: {\n optional?: boolean | undefined;\n selector: (state: TState) => TSelected;\n }): TSelected | null;\n\n // optional?, selector?\n function useStoreHook<TSelected>(options: {\n optional?: boolean | undefined;\n selector: ((state: TState) => TSelected) | undefined;\n }): TSelected | TState | null;\n\n function useStoreHook<TSelected>(\n param?:\n | ((state: TState) => TSelected)\n | {\n optional?: boolean | undefined;\n selector?: ((state: TState) => TSelected) | undefined;\n },\n ): TSelected | TState | null {\n let optional = false;\n let selector: ((state: TState) => TSelected) | undefined;\n\n if (typeof param === \"function\") {\n selector = param;\n } else if (param) {\n optional = !!param.optional;\n selector = param.selector;\n }\n\n const store = useRuntime({ optional });\n if (!store) return null;\n return useRuntimeStateInternal(store, selector);\n }\n\n return useStoreHook;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAGO;AAEA,SAAS,0BACd,YAGA;AA8CA,WAAS,aACP,OAM2B;AAC3B,QAAI,WAAW;AACf,QAAI;AAEJ,QAAI,OAAO,UAAU,YAAY;AAC/B,iBAAW;AAAA,IACb,WAAW,OAAO;AAChB,iBAAW,CAAC,CAAC,MAAM;AACnB,iBAAW,MAAM;AAAA,IACnB;AAEA,UAAM,QAAQ,WAAW,EAAE,SAAS,CAAC;AACrC,QAAI,CAAC,MAAO,QAAO;AACnB,eAAO,gDAAwB,OAAO,QAAQ;AAAA,EAChD;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,24 @@
1
+ // src/context/react/utils/createStateHookForRuntime.ts
2
+ import {
3
+ useRuntimeStateInternal
4
+ } from "./useRuntimeState.mjs";
5
+ function createStateHookForRuntime(useRuntime) {
6
+ function useStoreHook(param) {
7
+ let optional = false;
8
+ let selector;
9
+ if (typeof param === "function") {
10
+ selector = param;
11
+ } else if (param) {
12
+ optional = !!param.optional;
13
+ selector = param.selector;
14
+ }
15
+ const store = useRuntime({ optional });
16
+ if (!store) return null;
17
+ return useRuntimeStateInternal(store, selector);
18
+ }
19
+ return useStoreHook;
20
+ }
21
+ export {
22
+ createStateHookForRuntime
23
+ };
24
+ //# sourceMappingURL=createStateHookForRuntime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/react/utils/createStateHookForRuntime.ts"],"sourcesContent":["import {\n SubscribableRuntime,\n useRuntimeStateInternal,\n} from \"./useRuntimeState\";\n\nexport function createStateHookForRuntime<TState>(\n useRuntime: (options: {\n optional: boolean | undefined;\n }) => SubscribableRuntime<TState> | null,\n) {\n // empty\n function useStoreHook(): TState;\n\n // selector\n function useStoreHook<TSelected>(\n selector: (state: TState) => TSelected,\n ): TSelected;\n\n // selector?\n function useStoreHook<TSelected>(\n selector: ((state: TState) => TSelected) | undefined,\n ): TSelected | TState;\n\n // optional=false\n function useStoreHook(options: { optional?: false | undefined }): TState;\n\n // optional?\n function useStoreHook(options: {\n optional?: boolean | undefined;\n }): TState | null;\n\n // optional=false, selector\n function useStoreHook<TSelected>(options: {\n optional?: false | undefined;\n selector: (state: TState) => TSelected;\n }): TSelected;\n\n // optional=false, selector?\n function useStoreHook<TSelected>(options: {\n optional?: false | undefined;\n selector: ((state: TState) => TSelected) | undefined;\n }): TSelected | TState;\n\n // optional?, selector\n function useStoreHook<TSelected>(options: {\n optional?: boolean | undefined;\n selector: (state: TState) => TSelected;\n }): TSelected | null;\n\n // optional?, selector?\n function useStoreHook<TSelected>(options: {\n optional?: boolean | undefined;\n selector: ((state: TState) => TSelected) | undefined;\n }): TSelected | TState | null;\n\n function useStoreHook<TSelected>(\n param?:\n | ((state: TState) => TSelected)\n | {\n optional?: boolean | undefined;\n selector?: ((state: TState) => TSelected) | undefined;\n },\n ): TSelected | TState | null {\n let optional = false;\n let selector: ((state: TState) => TSelected) | undefined;\n\n if (typeof param === \"function\") {\n selector = param;\n } else if (param) {\n optional = !!param.optional;\n selector = param.selector;\n }\n\n const store = useRuntime({ optional });\n if (!store) return null;\n return useRuntimeStateInternal(store, selector);\n }\n\n return useStoreHook;\n}\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,OACK;AAEA,SAAS,0BACd,YAGA;AA8CA,WAAS,aACP,OAM2B;AAC3B,QAAI,WAAW;AACf,QAAI;AAEJ,QAAI,OAAO,UAAU,YAAY;AAC/B,iBAAW;AAAA,IACb,WAAW,OAAO;AAChB,iBAAW,CAAC,CAAC,MAAM;AACnB,iBAAW,MAAM;AAAA,IACnB;AAEA,UAAM,QAAQ,WAAW,EAAE,SAAS,CAAC;AACrC,QAAI,CAAC,MAAO,QAAO;AACnB,WAAO,wBAAwB,OAAO,QAAQ;AAAA,EAChD;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,2 @@
1
+ export declare const ensureBinding: (r: unknown) => void;
2
+ //# sourceMappingURL=ensureBinding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureBinding.d.ts","sourceRoot":"","sources":["../../../../src/context/react/utils/ensureBinding.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,aAAa,MAAO,OAAO,SASvC,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/context/react/utils/ensureBinding.ts
21
+ var ensureBinding_exports = {};
22
+ __export(ensureBinding_exports, {
23
+ ensureBinding: () => ensureBinding
24
+ });
25
+ module.exports = __toCommonJS(ensureBinding_exports);
26
+ var ensureBinding = (r) => {
27
+ const runtime = r;
28
+ if (runtime.__isBound) return;
29
+ runtime.__internal_bindMethods?.();
30
+ runtime.__isBound = true;
31
+ };
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ ensureBinding
35
+ });
36
+ //# sourceMappingURL=ensureBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/react/utils/ensureBinding.ts"],"sourcesContent":["type Bindable = {\n __internal_bindMethods?: () => void;\n __isBound?: boolean;\n};\nconst debugVerifyPrototype = (\n runtime: Record<string, unknown>,\n prototype: any,\n) => {\n const unboundMethods = Object.getOwnPropertyNames(prototype).filter(\n (methodStr) => {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, methodStr);\n const isMethod = descriptor && typeof descriptor.value === \"function\";\n if (!isMethod) return false;\n\n const methodName = methodStr as keyof typeof runtime | \"constructor\";\n return (\n isMethod &&\n !methodName.startsWith(\"_\") &&\n methodName !== \"constructor\" &&\n prototype[methodName] === runtime[methodName]\n );\n },\n );\n\n if (unboundMethods.length > 0) {\n throw new Error(\n \"The following methods are not bound: \" + JSON.stringify(unboundMethods),\n );\n }\n\n const prototypePrototype = Object.getPrototypeOf(prototype);\n if (prototypePrototype && prototypePrototype !== Object.prototype) {\n debugVerifyPrototype(runtime, prototypePrototype);\n }\n};\nexport const ensureBinding = (r: unknown) => {\n const runtime = r as Bindable;\n if (runtime.__isBound) return;\n\n runtime.__internal_bindMethods?.();\n runtime.__isBound = true;\n\n // @ts-ignore - strip this out in production build\n DEV: debugVerifyPrototype(runtime, Object.getPrototypeOf(runtime));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCO,IAAM,gBAAgB,CAAC,MAAe;AAC3C,QAAM,UAAU;AAChB,MAAI,QAAQ,UAAW;AAEvB,UAAQ,yBAAyB;AACjC,UAAQ,YAAY;AAItB;","names":[]}
@@ -0,0 +1,11 @@
1
+ // src/context/react/utils/ensureBinding.ts
2
+ var ensureBinding = (r) => {
3
+ const runtime = r;
4
+ if (runtime.__isBound) return;
5
+ runtime.__internal_bindMethods?.();
6
+ runtime.__isBound = true;
7
+ };
8
+ export {
9
+ ensureBinding
10
+ };
11
+ //# sourceMappingURL=ensureBinding.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/react/utils/ensureBinding.ts"],"sourcesContent":["type Bindable = {\n __internal_bindMethods?: () => void;\n __isBound?: boolean;\n};\nconst debugVerifyPrototype = (\n runtime: Record<string, unknown>,\n prototype: any,\n) => {\n const unboundMethods = Object.getOwnPropertyNames(prototype).filter(\n (methodStr) => {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, methodStr);\n const isMethod = descriptor && typeof descriptor.value === \"function\";\n if (!isMethod) return false;\n\n const methodName = methodStr as keyof typeof runtime | \"constructor\";\n return (\n isMethod &&\n !methodName.startsWith(\"_\") &&\n methodName !== \"constructor\" &&\n prototype[methodName] === runtime[methodName]\n );\n },\n );\n\n if (unboundMethods.length > 0) {\n throw new Error(\n \"The following methods are not bound: \" + JSON.stringify(unboundMethods),\n );\n }\n\n const prototypePrototype = Object.getPrototypeOf(prototype);\n if (prototypePrototype && prototypePrototype !== Object.prototype) {\n debugVerifyPrototype(runtime, prototypePrototype);\n }\n};\nexport const ensureBinding = (r: unknown) => {\n const runtime = r as Bindable;\n if (runtime.__isBound) return;\n\n runtime.__internal_bindMethods?.();\n runtime.__isBound = true;\n\n // @ts-ignore - strip this out in production build\n DEV: debugVerifyPrototype(runtime, Object.getPrototypeOf(runtime));\n};\n"],"mappings":";AAmCO,IAAM,gBAAgB,CAAC,MAAe;AAC3C,QAAM,UAAU;AAChB,MAAI,QAAQ,UAAW;AAEvB,UAAQ,yBAAyB;AACjC,UAAQ,YAAY;AAItB;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { Unsubscribe } from "../../../types";
2
+ export type SubscribableRuntime<TState> = {
3
+ getState: () => TState;
4
+ subscribe: (callback: () => void) => Unsubscribe;
5
+ };
6
+ export declare function useRuntimeStateInternal<TState, TSelected>(runtime: SubscribableRuntime<TState>, selector?: ((state: TState) => TSelected) | undefined): TSelected | TState;
7
+ export declare function useRuntimeState<TState>(runtime: SubscribableRuntime<TState>): TState;
8
+ export declare function useRuntimeState<TState, TSelected>(runtime: SubscribableRuntime<TState>, selector: (state: TState) => TSelected): TSelected;
9
+ export declare function useRuntimeState<TState, TSelected>(runtime: SubscribableRuntime<TState>, selector: ((state: TState) => TSelected) | undefined): TSelected | TState;
10
+ //# sourceMappingURL=useRuntimeState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRuntimeState.d.ts","sourceRoot":"","sources":["../../../../src/context/react/utils/useRuntimeState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,MAAM,MAAM,mBAAmB,CAAC,MAAM,IAAI;IACxC,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,CAAC;CAClD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EACvD,OAAO,EAAE,mBAAmB,CAAC,MAAM,CAAC,EACpC,QAAQ,GAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,SAA2B,GACrE,SAAS,GAAG,MAAM,CAQpB;AAGD,wBAAgB,eAAe,CAAC,MAAM,EACpC,OAAO,EAAE,mBAAmB,CAAC,MAAM,CAAC,GACnC,MAAM,CAAC;AACV,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAC/C,OAAO,EAAE,mBAAmB,CAAC,MAAM,CAAC,EACpC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,GACrC,SAAS,CAAC;AACb,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAC/C,OAAO,EAAE,mBAAmB,CAAC,MAAM,CAAC,EACpC,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC,GAAG,SAAS,GACnD,SAAS,GAAG,MAAM,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/context/react/utils/useRuntimeState.ts
21
+ var useRuntimeState_exports = {};
22
+ __export(useRuntimeState_exports, {
23
+ useRuntimeState: () => useRuntimeState,
24
+ useRuntimeStateInternal: () => useRuntimeStateInternal
25
+ });
26
+ module.exports = __toCommonJS(useRuntimeState_exports);
27
+ var import_react = require("react");
28
+ var import_ensureBinding = require("./ensureBinding.js");
29
+ function useRuntimeStateInternal(runtime, selector = identity) {
30
+ const slice = (0, import_react.useSyncExternalStore)(
31
+ runtime.subscribe,
32
+ () => selector(runtime.getState()),
33
+ () => selector(runtime.getState())
34
+ );
35
+ (0, import_react.useDebugValue)(slice);
36
+ return slice;
37
+ }
38
+ var identity = (arg) => arg;
39
+ function useRuntimeState(runtime, selector) {
40
+ (0, import_ensureBinding.ensureBinding)(runtime);
41
+ return useRuntimeStateInternal(runtime, selector);
42
+ }
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ useRuntimeState,
46
+ useRuntimeStateInternal
47
+ });
48
+ //# sourceMappingURL=useRuntimeState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/react/utils/useRuntimeState.ts"],"sourcesContent":["import { useDebugValue, useSyncExternalStore } from \"react\";\nimport { Unsubscribe } from \"../../../types\";\nimport { ensureBinding } from \"./ensureBinding\";\n\nexport type SubscribableRuntime<TState> = {\n getState: () => TState;\n subscribe: (callback: () => void) => Unsubscribe;\n};\n\nexport function useRuntimeStateInternal<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected) | undefined = identity as any,\n): TSelected | TState {\n const slice = useSyncExternalStore(\n runtime.subscribe,\n () => selector(runtime.getState()),\n () => selector(runtime.getState()),\n );\n useDebugValue(slice);\n return slice;\n}\n\nconst identity = <T>(arg: T): T => arg;\nexport function useRuntimeState<TState>(\n runtime: SubscribableRuntime<TState>,\n): TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: (state: TState) => TSelected,\n): TSelected;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected) | undefined,\n): TSelected | TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector?: ((state: TState) => TSelected) | undefined,\n): TSelected | TState {\n // ensure that the runtime is bound\n ensureBinding(runtime);\n\n return useRuntimeStateInternal(runtime, selector);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoD;AAEpD,2BAA8B;AAOvB,SAAS,wBACd,SACA,WAAuD,UACnC;AACpB,QAAM,YAAQ;AAAA,IACZ,QAAQ;AAAA,IACR,MAAM,SAAS,QAAQ,SAAS,CAAC;AAAA,IACjC,MAAM,SAAS,QAAQ,SAAS,CAAC;AAAA,EACnC;AACA,kCAAc,KAAK;AACnB,SAAO;AACT;AAEA,IAAM,WAAW,CAAI,QAAc;AAY5B,SAAS,gBACd,SACA,UACoB;AAEpB,0CAAc,OAAO;AAErB,SAAO,wBAAwB,SAAS,QAAQ;AAClD;","names":[]}
@@ -0,0 +1,22 @@
1
+ // src/context/react/utils/useRuntimeState.ts
2
+ import { useDebugValue, useSyncExternalStore } from "react";
3
+ import { ensureBinding } from "./ensureBinding.mjs";
4
+ function useRuntimeStateInternal(runtime, selector = identity) {
5
+ const slice = useSyncExternalStore(
6
+ runtime.subscribe,
7
+ () => selector(runtime.getState()),
8
+ () => selector(runtime.getState())
9
+ );
10
+ useDebugValue(slice);
11
+ return slice;
12
+ }
13
+ var identity = (arg) => arg;
14
+ function useRuntimeState(runtime, selector) {
15
+ ensureBinding(runtime);
16
+ return useRuntimeStateInternal(runtime, selector);
17
+ }
18
+ export {
19
+ useRuntimeState,
20
+ useRuntimeStateInternal
21
+ };
22
+ //# sourceMappingURL=useRuntimeState.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/context/react/utils/useRuntimeState.ts"],"sourcesContent":["import { useDebugValue, useSyncExternalStore } from \"react\";\nimport { Unsubscribe } from \"../../../types\";\nimport { ensureBinding } from \"./ensureBinding\";\n\nexport type SubscribableRuntime<TState> = {\n getState: () => TState;\n subscribe: (callback: () => void) => Unsubscribe;\n};\n\nexport function useRuntimeStateInternal<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected) | undefined = identity as any,\n): TSelected | TState {\n const slice = useSyncExternalStore(\n runtime.subscribe,\n () => selector(runtime.getState()),\n () => selector(runtime.getState()),\n );\n useDebugValue(slice);\n return slice;\n}\n\nconst identity = <T>(arg: T): T => arg;\nexport function useRuntimeState<TState>(\n runtime: SubscribableRuntime<TState>,\n): TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: (state: TState) => TSelected,\n): TSelected;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector: ((state: TState) => TSelected) | undefined,\n): TSelected | TState;\nexport function useRuntimeState<TState, TSelected>(\n runtime: SubscribableRuntime<TState>,\n selector?: ((state: TState) => TSelected) | undefined,\n): TSelected | TState {\n // ensure that the runtime is bound\n ensureBinding(runtime);\n\n return useRuntimeStateInternal(runtime, selector);\n}\n"],"mappings":";AAAA,SAAS,eAAe,4BAA4B;AAEpD,SAAS,qBAAqB;AAOvB,SAAS,wBACd,SACA,WAAuD,UACnC;AACpB,QAAM,QAAQ;AAAA,IACZ,QAAQ;AAAA,IACR,MAAM,SAAS,QAAQ,SAAS,CAAC;AAAA,IACjC,MAAM,SAAS,QAAQ,SAAS,CAAC;AAAA,EACnC;AACA,gBAAc,KAAK;AACnB,SAAO;AACT;AAEA,IAAM,WAAW,CAAI,QAAc;AAY5B,SAAS,gBACd,SACA,UACoB;AAEpB,gBAAc,OAAO;AAErB,SAAO,wBAAwB,SAAS,QAAQ;AAClD;","names":[]}
@@ -3,7 +3,7 @@ export type AttachmentAdapter = {
3
3
  accept: string;
4
4
  add(state: {
5
5
  file: File;
6
- }): Promise<PendingAttachment>;
6
+ }): Promise<PendingAttachment> | AsyncGenerator<PendingAttachment, void>;
7
7
  remove(attachment: Attachment): Promise<void>;
8
8
  send(attachment: PendingAttachment): Promise<CompleteAttachment>;
9
9
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AttachmentAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/adapters/attachment/AttachmentAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IAEf,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACvD,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClE,CAAC"}
1
+ {"version":3,"file":"AttachmentAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/adapters/attachment/AttachmentAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,gCAAgC,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IAEf,GAAG,CAAC,KAAK,EAAE;QACT,IAAI,EAAE,IAAI,CAAC;KACZ,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,cAAc,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IACzE,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/adapters/attachment/AttachmentAdapter.ts"],"sourcesContent":["import {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n} from \"../../../types/AttachmentTypes\";\n\nexport type AttachmentAdapter = {\n accept: string;\n\n add(state: { file: File }): Promise<PendingAttachment>;\n remove(attachment: Attachment): Promise<void>;\n send(attachment: PendingAttachment): Promise<CompleteAttachment>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/adapters/attachment/AttachmentAdapter.ts"],"sourcesContent":["import {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n} from \"../../../types/AttachmentTypes\";\n\nexport type AttachmentAdapter = {\n accept: string;\n\n add(state: {\n file: File;\n }): Promise<PendingAttachment> | AsyncGenerator<PendingAttachment, void>;\n remove(attachment: Attachment): Promise<void>;\n send(attachment: PendingAttachment): Promise<CompleteAttachment>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -6,7 +6,7 @@ export declare class CompositeAttachmentAdapter implements AttachmentAdapter {
6
6
  constructor(adapters: AttachmentAdapter[]);
7
7
  add(state: {
8
8
  file: File;
9
- }): Promise<PendingAttachment>;
9
+ }): Promise<PendingAttachment> | AsyncGenerator<PendingAttachment, void, any>;
10
10
  send(attachment: PendingAttachment): Promise<import("../../..").CompleteAttachment>;
11
11
  remove(attachment: Attachment): Promise<void>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CompositeAttachmentAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/adapters/attachment/CompositeAttachmentAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA6CxD,qBAAa,0BAA2B,YAAW,iBAAiB;IAClE,OAAO,CAAC,SAAS,CAAsB;IAEhC,MAAM,EAAE,MAAM,CAAC;gBAEV,QAAQ,EAAE,iBAAiB,EAAE;IAgB5B,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE;IASzB,IAAI,CAAC,UAAU,EAAE,iBAAiB;IAUlC,MAAM,CAAC,UAAU,EAAE,UAAU;CAiB3C"}
1
+ {"version":3,"file":"CompositeAttachmentAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/adapters/attachment/CompositeAttachmentAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AA6CxD,qBAAa,0BAA2B,YAAW,iBAAiB;IAClE,OAAO,CAAC,SAAS,CAAsB;IAEhC,MAAM,EAAE,MAAM,CAAC;gBAEV,QAAQ,EAAE,iBAAiB,EAAE;IAgBlC,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE;IASnB,IAAI,CAAC,UAAU,EAAE,iBAAiB;IAUlC,MAAM,CAAC,UAAU,EAAE,UAAU;CAiB3C"}
@@ -64,7 +64,7 @@ var CompositeAttachmentAdapter = class {
64
64
  this.accept = adapters.map((a) => a.accept).join(",");
65
65
  }
66
66
  }
67
- async add(state) {
67
+ add(state) {
68
68
  for (const adapter of this._adapters) {
69
69
  if (fileMatchesAccept(state.file, adapter.accept)) {
70
70
  return adapter.add(state);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/adapters/attachment/CompositeAttachmentAdapter.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../../../types/AttachmentTypes\";\nimport { AttachmentAdapter } from \"./AttachmentAdapter\";\n\nfunction fileMatchesAccept(\n file: { name: string; type: string },\n acceptString: string,\n) {\n // Check if the accept string is \"*\", which allows any file\n if (acceptString === \"*\") {\n return true;\n }\n\n // Split the accept string into an array of allowed types\n const allowedTypes = acceptString\n .split(\",\")\n .map((type) => type.trim().toLowerCase());\n\n // Get the file's extension and MIME type\n const fileExtension = \".\" + file.name.split(\".\").pop()!.toLowerCase();\n const fileMimeType = file.type.toLowerCase();\n\n for (const type of allowedTypes) {\n // Check for file extension match\n if (type.startsWith(\".\") && type === fileExtension) {\n return true;\n }\n\n // Check for exact MIME type match\n if (type.includes(\"/\") && type === fileMimeType) {\n return true;\n }\n\n if (type === \"image/*\" || type === \"video/*\" || type === \"audio/*\") {\n // Check for wildcard MIME type match\n if (type.endsWith(\"/*\")) {\n const generalType = type.split(\"/\")[0]!;\n if (fileMimeType.startsWith(generalType + \"/\")) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nexport class CompositeAttachmentAdapter implements AttachmentAdapter {\n private _adapters: AttachmentAdapter[];\n\n public accept: string;\n\n constructor(adapters: AttachmentAdapter[]) {\n this._adapters = adapters;\n\n const wildcardIdx = adapters.findIndex((a) => a.accept === \"*\");\n if (wildcardIdx !== -1) {\n if (wildcardIdx !== adapters.length - 1)\n throw new Error(\n \"A wildcard adapter (handling all files) can only be specified as the last adapter.\",\n );\n\n this.accept = \"*\";\n } else {\n this.accept = adapters.map((a) => a.accept).join(\",\");\n }\n }\n\n public async add(state: { file: File }) {\n for (const adapter of this._adapters) {\n if (fileMatchesAccept(state.file, adapter.accept)) {\n return adapter.add(state);\n }\n }\n throw new Error(\"No matching adapter found for file\");\n }\n\n public async send(attachment: PendingAttachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (fileMatchesAccept(attachment.file, adapter.accept)) {\n return adapter.send(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n\n public async remove(attachment: Attachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (\n fileMatchesAccept(\n {\n name: attachment.name,\n type: attachment.contentType,\n },\n adapter.accept,\n )\n ) {\n return adapter.remove(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,SAAS,kBACP,MAC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ACA,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAAA,EAEA,MAAa,KAAK,YAA+B;AAC/C,UAAM,WAAW,KAAK,UAAU,MAAM;AACtC,eAAW,WAAW,UAAU;AAC9B,UAAI,kBAAkB,WAAW,MAAM,QAAQ,MAAM,GAAG;AACtD,eAAO,QAAQ,KAAK,UAAU;AAAA,MAChC;AAAA,IACF;AACA,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAAA,EAEA,MAAa,OAAO,YAAwB;AAC1C,UAAM,WAAW,KAAK,UAAU,MAAM;AACtC,eAAW,WAAW,UAAU;AAC9B,UACE;AAAA,QACE;AAAA,UACE,MAAM,WAAW;AAAA,UACjB,MAAM,WAAW;AAAA,QACnB;AAAA,QACA,QAAQ;AAAA,MACV,GACA;AACA,eAAO,QAAQ,OAAO,UAAU;AAAA,MAClC;AAAA,IACF;AACA,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/adapters/attachment/CompositeAttachmentAdapter.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../../../types/AttachmentTypes\";\nimport { AttachmentAdapter } from \"./AttachmentAdapter\";\n\nfunction fileMatchesAccept(\n file: { name: string; type: string },\n acceptString: string,\n) {\n // Check if the accept string is \"*\", which allows any file\n if (acceptString === \"*\") {\n return true;\n }\n\n // Split the accept string into an array of allowed types\n const allowedTypes = acceptString\n .split(\",\")\n .map((type) => type.trim().toLowerCase());\n\n // Get the file's extension and MIME type\n const fileExtension = \".\" + file.name.split(\".\").pop()!.toLowerCase();\n const fileMimeType = file.type.toLowerCase();\n\n for (const type of allowedTypes) {\n // Check for file extension match\n if (type.startsWith(\".\") && type === fileExtension) {\n return true;\n }\n\n // Check for exact MIME type match\n if (type.includes(\"/\") && type === fileMimeType) {\n return true;\n }\n\n if (type === \"image/*\" || type === \"video/*\" || type === \"audio/*\") {\n // Check for wildcard MIME type match\n if (type.endsWith(\"/*\")) {\n const generalType = type.split(\"/\")[0]!;\n if (fileMimeType.startsWith(generalType + \"/\")) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nexport class CompositeAttachmentAdapter implements AttachmentAdapter {\n private _adapters: AttachmentAdapter[];\n\n public accept: string;\n\n constructor(adapters: AttachmentAdapter[]) {\n this._adapters = adapters;\n\n const wildcardIdx = adapters.findIndex((a) => a.accept === \"*\");\n if (wildcardIdx !== -1) {\n if (wildcardIdx !== adapters.length - 1)\n throw new Error(\n \"A wildcard adapter (handling all files) can only be specified as the last adapter.\",\n );\n\n this.accept = \"*\";\n } else {\n this.accept = adapters.map((a) => a.accept).join(\",\");\n }\n }\n\n public add(state: { file: File }) {\n for (const adapter of this._adapters) {\n if (fileMatchesAccept(state.file, adapter.accept)) {\n return adapter.add(state);\n }\n }\n throw new Error(\"No matching adapter found for file\");\n }\n\n public async send(attachment: PendingAttachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (fileMatchesAccept(attachment.file, adapter.accept)) {\n return adapter.send(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n\n public async remove(attachment: Attachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (\n fileMatchesAccept(\n {\n name: attachment.name,\n type: attachment.contentType,\n },\n adapter.accept,\n )\n ) {\n return adapter.remove(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,SAAS,kBACP,MACA,cACA;AAEA,MAAI,iBAAiB,KAAK;AACxB,WAAO;AAAA,EACT;AAGA,QAAM,eAAe,aAClB,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE,YAAY,CAAC;AAG1C,QAAM,gBAAgB,MAAM,KAAK,KAAK,MAAM,GAAG,EAAE,IAAI,EAAG,YAAY;AACpE,QAAM,eAAe,KAAK,KAAK,YAAY;AAE3C,aA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AAAA,EAC5D;AAAA,EAEA,MAAa,OAAO,YAAwB;AAC1C,UAAM,WAAW,KAAK,UAAU,MAAM;AACtC,eAAW,WAAW,UAAU;AAC9B,UACE;AAAA,QACE;AAAA,UACE,MAAM,WAAW;AAAA,UACjB,MAAM,WAAW;AAAA,QACnB;AAAA,QACA,QAAQ;AAAA,MACV,GACA;AACA,eAAO,QAAQ,OAAO,UAAU;AAAA,MAClC;AAAA,IACF;AACA,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AACF;","names":[]}
@@ -40,7 +40,7 @@ var CompositeAttachmentAdapter = class {
40
40
  this.accept = adapters.map((a) => a.accept).join(",");
41
41
  }
42
42
  }
43
- async add(state) {
43
+ add(state) {
44
44
  for (const adapter of this._adapters) {
45
45
  if (fileMatchesAccept(state.file, adapter.accept)) {
46
46
  return adapter.add(state);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/adapters/attachment/CompositeAttachmentAdapter.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../../../types/AttachmentTypes\";\nimport { AttachmentAdapter } from \"./AttachmentAdapter\";\n\nfunction fileMatchesAccept(\n file: { name: string; type: string },\n acceptString: string,\n) {\n // Check if the accept string is \"*\", which allows any file\n if (acceptString === \"*\") {\n return true;\n }\n\n // Split the accept string into an array of allowed types\n const allowedTypes = acceptString\n .split(\",\")\n .map((type) => type.trim().toLowerCase());\n\n // Get the file's extension and MIME type\n const fileExtension = \".\" + file.name.split(\".\").pop()!.toLowerCase();\n const fileMimeType = file.type.toLowerCase();\n\n for (const type of allowedTypes) {\n // Check for file extension match\n if (type.startsWith(\".\") && type === fileExtension) {\n return true;\n }\n\n // Check for exact MIME type match\n if (type.includes(\"/\") && type === fileMimeType) {\n return true;\n }\n\n if (type === \"image/*\" || type === \"video/*\" || type === \"audio/*\") {\n // Check for wildcard MIME type match\n if (type.endsWith(\"/*\")) {\n const generalType = type.split(\"/\")[0]!;\n if (fileMimeType.startsWith(generalType + \"/\")) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nexport class CompositeAttachmentAdapter implements AttachmentAdapter {\n private _adapters: AttachmentAdapter[];\n\n public accept: string;\n\n constructor(adapters: AttachmentAdapter[]) {\n this._adapters = adapters;\n\n const wildcardIdx = adapters.findIndex((a) => a.accept === \"*\");\n if (wildcardIdx !== -1) {\n if (wildcardIdx !== adapters.length - 1)\n throw new Error(\n \"A wildcard adapter (handling all files) can only be specified as the last adapter.\",\n );\n\n this.accept = \"*\";\n } else {\n this.accept = adapters.map((a) => a.accept).join(\",\");\n }\n }\n\n public async add(state: { file: File }) {\n for (const adapter of this._adapters) {\n if (fileMatchesAccept(state.file, adapter.accept)) {\n return adapter.add(state);\n }\n }\n throw new Error(\"No matching adapter found for file\");\n }\n\n public async send(attachment: PendingAttachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (fileMatchesAccept(attachment.file, adapter.accept)) {\n return adapter.send(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n\n public async remove(attachment: Attachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (\n fileMatchesAccept(\n {\n name: attachment.name,\n type: attachment.contentType,\n },\n adapter.accept,\n )\n ) {\n return adapter.remove(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n}\n"],"mappings":";AAGA,SAAS,kBACP,MACA,cACA;AAEA,MAAI,iBAAiB,KAAK;AACxB,WAAO;AAAA,EACT;AAGA,QAAM,eAAe,aAClB,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE,YAAY,CAAC;AAG1C,QAAM,gBAAgB,MAAM,KAAK,KAAK,MAAM,GAAG,EAAE,IAAI,EAAG,YAAY;AACpE,QAAM,eAAe,KAAK,KAAK,YAAY;AAE3C,aAAW,QAAQ,cAAc;AAE/B,QAAI,KAAK,WAAW,GAAG,KAAK,SAAS,eAAe;AAClD,aAAO;AAAA,IACT;AAGA,QAAI,KAAK,SAAS,GA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9B,UACE;AAAA,QACE;AAAA,UACE,MAAM,WAAW;AAAA,UACjB,MAAM,WAAW;AAAA,QACnB;AAAA,QACA,QAAQ;AAAA,MACV,GACA;AACA,eAAO,QAAQ,OAAO,UAAU;AAAA,MAClC;AAAA,IACF;AACA,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/adapters/attachment/CompositeAttachmentAdapter.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../../../types/AttachmentTypes\";\nimport { AttachmentAdapter } from \"./AttachmentAdapter\";\n\nfunction fileMatchesAccept(\n file: { name: string; type: string },\n acceptString: string,\n) {\n // Check if the accept string is \"*\", which allows any file\n if (acceptString === \"*\") {\n return true;\n }\n\n // Split the accept string into an array of allowed types\n const allowedTypes = acceptString\n .split(\",\")\n .map((type) => type.trim().toLowerCase());\n\n // Get the file's extension and MIME type\n const fileExtension = \".\" + file.name.split(\".\").pop()!.toLowerCase();\n const fileMimeType = file.type.toLowerCase();\n\n for (const type of allowedTypes) {\n // Check for file extension match\n if (type.startsWith(\".\") && type === fileExtension) {\n return true;\n }\n\n // Check for exact MIME type match\n if (type.includes(\"/\") && type === fileMimeType) {\n return true;\n }\n\n if (type === \"image/*\" || type === \"video/*\" || type === \"audio/*\") {\n // Check for wildcard MIME type match\n if (type.endsWith(\"/*\")) {\n const generalType = type.split(\"/\")[0]!;\n if (fileMimeType.startsWith(generalType + \"/\")) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\nexport class CompositeAttachmentAdapter implements AttachmentAdapter {\n private _adapters: AttachmentAdapter[];\n\n public accept: string;\n\n constructor(adapters: AttachmentAdapter[]) {\n this._adapters = adapters;\n\n const wildcardIdx = adapters.findIndex((a) => a.accept === \"*\");\n if (wildcardIdx !== -1) {\n if (wildcardIdx !== adapters.length - 1)\n throw new Error(\n \"A wildcard adapter (handling all files) can only be specified as the last adapter.\",\n );\n\n this.accept = \"*\";\n } else {\n this.accept = adapters.map((a) => a.accept).join(\",\");\n }\n }\n\n public add(state: { file: File }) {\n for (const adapter of this._adapters) {\n if (fileMatchesAccept(state.file, adapter.accept)) {\n return adapter.add(state);\n }\n }\n throw new Error(\"No matching adapter found for file\");\n }\n\n public async send(attachment: PendingAttachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (fileMatchesAccept(attachment.file, adapter.accept)) {\n return adapter.send(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n\n public async remove(attachment: Attachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (\n fileMatchesAccept(\n {\n name: attachment.name,\n type: attachment.contentType,\n },\n adapter.accept,\n )\n ) {\n return adapter.remove(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n}\n"],"mappings":";AAGA,SAAS,kBACP,MACA,cACA;AAEA,MAAI,iBAAiB,KAAK;AACxB,WAAO;AAAA,EACT;AAGA,QAAM,eAAe,aAClB,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE,YAAY,CAAC;AAG1C,QAAM,gBAAgB,MAAM,KAAK,KAAK,MAAM,GAAG,EAAE,IAAI,EAAG,YAAY;AACpE,QAAM,eAAe,KAAK,KAAK,YAAY;AAE3C,aAAW,QAAQ,cAAc;AAE/B,QAAI,KAAK,WAAW,GAAG,KAAK,SAAS,eAAe;AAClD,aAAO;AAAA,IACT;AAGA,QAAI,KAAK,SAAS,GAAG,KAAK,SAAS,cAAc;AAC/C,aAAO;AAAA,IACT;AAEA,QAAI,SAAS,aAAa,SAAS,aAAa,SAAS,WAAW;AAElE,UAAI,KAAK,SAAS,IAAI,GAAG;AACvB,cAAM,cAAc,KAAK,MAAM,GAAG,EAAE,CAAC;AACrC,YAAI,aAAa,WAAW,cAAc,GAAG,GAAG;AAC9C,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,IAAM,6BAAN,MAA8D;AAAA,EAC3D;AAAA,EAED;AAAA,EAEP,YAAY,UAA+B;AACzC,SAAK,YAAY;AAEjB,UAAM,cAAc,SAAS,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG;AAC9D,QAAI,gBAAgB,IAAI;AACtB,UAAI,gBAAgB,SAAS,SAAS;AACpC,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAEF,WAAK,SAAS;AAAA,IAChB,OAAO;AACL,WAAK,SAAS,SAAS,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAG;AAAA,IACtD;AAAA,EACF;AAAA,EAEO,IAAI,OAAuB;AAChC,eAAW,WAAW,KAAK,WAAW;AACpC,UAAI,kBAAkB,MAAM,MAAM,QAAQ,MAAM,GAAG;AACjD,eAAO,QAAQ,IAAI,KAAK;AAAA,MAC1B;AAAA,IACF;AACA,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AAAA,EAEA,MAAa,KAAK,YAA+B;AAC/C,UAAM,WAAW,KAAK,UAAU,MAAM;AACtC,eAAW,WAAW,UAAU;AAC9B,UAAI,kBAAkB,WAAW,MAAM,QAAQ,MAAM,GAAG;AACtD,eAAO,QAAQ,KAAK,UAAU;AAAA,MAChC;AAAA,IACF;AACA,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AAAA,EAEA,MAAa,OAAO,YAAwB;AAC1C,UAAM,WAAW,KAAK,UAAU,MAAM;AACtC,eAAW,WAAW,UAAU;AAC9B,UACE;AAAA,QACE;AAAA,UACE,MAAM,WAAW;AAAA,UACjB,MAAM,WAAW;AAAA,QACnB;AAAA,QACA,QAAQ;AAAA,MACV,GACA;AACA,eAAO,QAAQ,OAAO,UAAU;AAAA,MAClC;AAAA,IACF;AACA,UAAM,IAAI,MAAM,0CAA0C;AAAA,EAC5D;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadHistoryAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC3C,MAAM,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D,CAAC"}
1
+ {"version":3,"file":"ThreadHistoryAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AAGvC,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC3C,MAAM,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts"],"sourcesContent":["import {\n ExportedMessageRepository,\n ExportedMessageRepositoryItem,\n} from \"../../utils/MessageRepository\";\n\nexport type ThreadHistoryAdapter = {\n load(): Promise<ExportedMessageRepository>;\n append(item: ExportedMessageRepositoryItem): Promise<void>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts"],"sourcesContent":["import {\n ExportedMessageRepository,\n ExportedMessageRepositoryItem,\n} from \"../../utils/MessageRepository\";\n\n// TODO external store - which version to save? how to restore?\nexport type ThreadHistoryAdapter = {\n load(): Promise<ExportedMessageRepository>;\n append(item: ExportedMessageRepositoryItem): Promise<void>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"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AI,gBAEP;IAED,OAAO,CAAC,UAAU,CAAiB;IAEnC,IAAI,SAAS,cAEZ;IAEM,OAAO,CAAC,KAAK,EAAE,MAAM;IAOrB,OAAO,CAAC,IAAI,EAAE,WAAW;IAOzB,YAAY,CAAC,SAAS,EAAE,SAAS;IAOxC,OAAO,CAAC,wBAAwB;YAMlB,mBAAmB;IAOpB,KAAK;IAkBL,gBAAgB;IAOhB,IAAI;IAyBV,MAAM;IAIb,SAAS,CAAC,QAAQ,CAAC,UAAU,CAC3B,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC,GACpD,IAAI;IACP,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI;IAEjC,aAAa,CAAC,IAAI,EAAE,IAAI;IAiCxB,gBAAgB,CAAC,YAAY,EAAE,MAAM;IAkB3C,OAAO,CAAC,iBAAiB,CAGrB;IAEJ,SAAS,CAAC,uBAAuB,CAAC,KAAK,EAAE,wBAAwB;IAO1D,WAAW,CAAC,KAAK,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,IAAI;CAczE"}
@@ -119,8 +119,28 @@ var BaseComposerRuntimeCore = class extends import_BaseSubscribable.BaseSubscrib
119
119
  async addAttachment(file) {
120
120
  const adapter = this.getAttachmentAdapter();
121
121
  if (!adapter) throw new Error("Attachments are not supported");
122
- const attachment = await adapter.add({ file });
123
- this._attachments = [...this._attachments, attachment];
122
+ const upsertAttachment = (a) => {
123
+ const idx = this._attachments.findIndex((attachment) => attachment.id === a.id);
124
+ if (idx !== -1)
125
+ this._attachments = [
126
+ ...this._attachments.slice(0, idx),
127
+ a,
128
+ ...this._attachments.slice(idx + 1)
129
+ ];
130
+ else {
131
+ this._attachments = [...this._attachments, a];
132
+ this._notifyEventSubscribers("attachment_add");
133
+ }
134
+ this._notifySubscribers();
135
+ };
136
+ const promiseOrGenerator = adapter.add({ file });
137
+ if (Symbol.asyncIterator in promiseOrGenerator) {
138
+ for await (const r of promiseOrGenerator) {
139
+ upsertAttachment(r);
140
+ }
141
+ } else {
142
+ upsertAttachment(await promiseOrGenerator);
143
+ }
124
144
  this._notifyEventSubscribers("attachment_add");
125
145
  this._notifySubscribers();
126
146
  }