@langchain/langgraph-sdk 0.1.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  3. package/dist/auth/error.cjs +76 -86
  4. package/dist/auth/error.cjs.map +1 -0
  5. package/dist/auth/error.d.cts +13 -0
  6. package/dist/auth/error.d.cts.map +1 -0
  7. package/dist/auth/error.d.ts +12 -8
  8. package/dist/auth/error.d.ts.map +1 -0
  9. package/dist/auth/error.js +76 -83
  10. package/dist/auth/error.js.map +1 -0
  11. package/dist/auth/index.cjs +36 -44
  12. package/dist/auth/index.cjs.map +1 -0
  13. package/dist/auth/index.d.cts +31 -0
  14. package/dist/auth/index.d.cts.map +1 -0
  15. package/dist/auth/index.d.ts +20 -15
  16. package/dist/auth/index.d.ts.map +1 -0
  17. package/dist/auth/index.js +35 -39
  18. package/dist/auth/index.js.map +1 -0
  19. package/dist/auth/types.d.cts +294 -0
  20. package/dist/auth/types.d.cts.map +1 -0
  21. package/dist/auth/types.d.ts +162 -165
  22. package/dist/auth/types.d.ts.map +1 -0
  23. package/dist/client.cjs +1108 -1294
  24. package/dist/client.cjs.map +1 -0
  25. package/dist/client.d.cts +688 -0
  26. package/dist/client.d.cts.map +1 -0
  27. package/dist/client.d.ts +647 -639
  28. package/dist/client.d.ts.map +1 -0
  29. package/dist/client.js +1099 -1281
  30. package/dist/client.js.map +1 -0
  31. package/dist/index.cjs +6 -8
  32. package/dist/index.d.cts +7 -0
  33. package/dist/index.d.ts +7 -7
  34. package/dist/index.js +4 -2
  35. package/dist/logging/index.cjs +30 -31
  36. package/dist/logging/index.cjs.map +1 -0
  37. package/dist/logging/index.d.cts +47 -0
  38. package/dist/logging/index.d.cts.map +1 -0
  39. package/dist/logging/index.d.ts +20 -16
  40. package/dist/logging/index.d.ts.map +1 -0
  41. package/dist/logging/index.js +31 -29
  42. package/dist/logging/index.js.map +1 -0
  43. package/dist/react/index.cjs +5 -7
  44. package/dist/react/index.d.cts +4 -0
  45. package/dist/react/index.d.ts +4 -3
  46. package/dist/react/index.js +4 -2
  47. package/dist/react/stream.cjs +14 -15
  48. package/dist/react/stream.cjs.map +1 -0
  49. package/dist/react/stream.custom.cjs +126 -145
  50. package/dist/react/stream.custom.cjs.map +1 -0
  51. package/dist/react/stream.custom.d.cts +39 -0
  52. package/dist/react/stream.custom.d.cts.map +1 -0
  53. package/dist/react/stream.custom.d.ts +35 -37
  54. package/dist/react/stream.custom.d.ts.map +1 -0
  55. package/dist/react/stream.custom.js +122 -137
  56. package/dist/react/stream.custom.js.map +1 -0
  57. package/dist/react/stream.d.cts +73 -0
  58. package/dist/react/stream.d.cts.map +1 -0
  59. package/dist/react/stream.d.ts +21 -15
  60. package/dist/react/stream.d.ts.map +1 -0
  61. package/dist/react/stream.js +12 -11
  62. package/dist/react/stream.js.map +1 -0
  63. package/dist/react/stream.lgp.cjs +438 -495
  64. package/dist/react/stream.lgp.cjs.map +1 -0
  65. package/dist/react/stream.lgp.js +433 -487
  66. package/dist/react/stream.lgp.js.map +1 -0
  67. package/dist/react/thread.cjs +18 -15
  68. package/dist/react/thread.cjs.map +1 -0
  69. package/dist/react/thread.js +19 -13
  70. package/dist/react/thread.js.map +1 -0
  71. package/dist/react/types.d.cts +355 -0
  72. package/dist/react/types.d.cts.map +1 -0
  73. package/dist/react/types.d.ts +333 -329
  74. package/dist/react/types.d.ts.map +1 -0
  75. package/dist/react-ui/client.cjs +123 -184
  76. package/dist/react-ui/client.cjs.map +1 -0
  77. package/dist/react-ui/client.d.cts +90 -0
  78. package/dist/react-ui/client.d.cts.map +1 -0
  79. package/dist/react-ui/client.d.ts +67 -51
  80. package/dist/react-ui/client.d.ts.map +1 -0
  81. package/dist/react-ui/client.js +118 -143
  82. package/dist/react-ui/client.js.map +1 -0
  83. package/dist/react-ui/index.cjs +14 -13
  84. package/dist/react-ui/index.cjs.map +1 -0
  85. package/dist/react-ui/index.d.cts +3 -0
  86. package/dist/react-ui/index.d.ts +3 -2
  87. package/dist/react-ui/index.js +8 -3
  88. package/dist/react-ui/index.js.map +1 -0
  89. package/dist/react-ui/server/index.cjs +5 -7
  90. package/dist/react-ui/server/index.d.cts +3 -0
  91. package/dist/react-ui/server/index.d.ts +3 -2
  92. package/dist/react-ui/server/index.js +4 -2
  93. package/dist/react-ui/server/server.cjs +53 -44
  94. package/dist/react-ui/server/server.cjs.map +1 -0
  95. package/dist/react-ui/server/server.d.cts +55 -0
  96. package/dist/react-ui/server/server.d.cts.map +1 -0
  97. package/dist/react-ui/server/server.d.ts +43 -39
  98. package/dist/react-ui/server/server.d.ts.map +1 -0
  99. package/dist/react-ui/server/server.js +54 -42
  100. package/dist/react-ui/server/server.js.map +1 -0
  101. package/dist/react-ui/types.cjs +32 -36
  102. package/dist/react-ui/types.cjs.map +1 -0
  103. package/dist/react-ui/types.d.cts +25 -0
  104. package/dist/react-ui/types.d.cts.map +1 -0
  105. package/dist/react-ui/types.d.ts +23 -19
  106. package/dist/react-ui/types.d.ts.map +1 -0
  107. package/dist/react-ui/types.js +32 -34
  108. package/dist/react-ui/types.js.map +1 -0
  109. package/dist/schema.d.cts +277 -0
  110. package/dist/schema.d.cts.map +1 -0
  111. package/dist/schema.d.ts +249 -242
  112. package/dist/schema.d.ts.map +1 -0
  113. package/dist/singletons/fetch.cjs +16 -20
  114. package/dist/singletons/fetch.cjs.map +1 -0
  115. package/dist/singletons/fetch.d.cts +14 -0
  116. package/dist/singletons/fetch.d.cts.map +1 -0
  117. package/dist/singletons/fetch.d.ts +5 -2
  118. package/dist/singletons/fetch.d.ts.map +1 -0
  119. package/dist/singletons/fetch.js +16 -17
  120. package/dist/singletons/fetch.js.map +1 -0
  121. package/dist/types.d.cts +187 -0
  122. package/dist/types.d.cts.map +1 -0
  123. package/dist/types.d.ts +178 -173
  124. package/dist/types.d.ts.map +1 -0
  125. package/dist/types.messages.d.cts +91 -0
  126. package/dist/types.messages.d.cts.map +1 -0
  127. package/dist/types.messages.d.ts +71 -66
  128. package/dist/types.messages.d.ts.map +1 -0
  129. package/dist/types.stream.d.cts +235 -0
  130. package/dist/types.stream.d.cts.map +1 -0
  131. package/dist/types.stream.d.ts +149 -142
  132. package/dist/types.stream.d.ts.map +1 -0
  133. package/dist/ui/branching.cjs +145 -141
  134. package/dist/ui/branching.cjs.map +1 -0
  135. package/dist/ui/branching.d.cts +22 -0
  136. package/dist/ui/branching.d.cts.map +1 -0
  137. package/dist/ui/branching.d.ts +17 -30
  138. package/dist/ui/branching.d.ts.map +1 -0
  139. package/dist/ui/branching.js +147 -139
  140. package/dist/ui/branching.js.map +1 -0
  141. package/dist/ui/errors.cjs +14 -12
  142. package/dist/ui/errors.cjs.map +1 -0
  143. package/dist/ui/errors.js +14 -9
  144. package/dist/ui/errors.js.map +1 -0
  145. package/dist/ui/manager.cjs +156 -232
  146. package/dist/ui/manager.cjs.map +1 -0
  147. package/dist/ui/manager.js +156 -228
  148. package/dist/ui/manager.js.map +1 -0
  149. package/dist/ui/messages.cjs +55 -69
  150. package/dist/ui/messages.cjs.map +1 -0
  151. package/dist/ui/messages.js +55 -66
  152. package/dist/ui/messages.js.map +1 -0
  153. package/dist/ui/utils.cjs +10 -10
  154. package/dist/ui/utils.cjs.map +1 -0
  155. package/dist/ui/utils.js +10 -8
  156. package/dist/ui/utils.js.map +1 -0
  157. package/dist/utils/async_caller.cjs +103 -185
  158. package/dist/utils/async_caller.cjs.map +1 -0
  159. package/dist/utils/async_caller.d.cts +53 -0
  160. package/dist/utils/async_caller.d.cts.map +1 -0
  161. package/dist/utils/async_caller.d.ts +36 -31
  162. package/dist/utils/async_caller.d.ts.map +1 -0
  163. package/dist/utils/async_caller.js +101 -177
  164. package/dist/utils/async_caller.js.map +1 -0
  165. package/dist/utils/env.cjs +11 -13
  166. package/dist/utils/env.cjs.map +1 -0
  167. package/dist/utils/env.js +11 -11
  168. package/dist/utils/env.js.map +1 -0
  169. package/dist/utils/signals.cjs +18 -19
  170. package/dist/utils/signals.cjs.map +1 -0
  171. package/dist/utils/signals.js +18 -17
  172. package/dist/utils/signals.js.map +1 -0
  173. package/dist/utils/sse.cjs +110 -140
  174. package/dist/utils/sse.cjs.map +1 -0
  175. package/dist/utils/sse.js +110 -138
  176. package/dist/utils/sse.js.map +1 -0
  177. package/dist/utils/stream.cjs +90 -114
  178. package/dist/utils/stream.cjs.map +1 -0
  179. package/dist/utils/stream.js +90 -111
  180. package/dist/utils/stream.js.map +1 -0
  181. package/package.json +72 -80
  182. package/auth.cjs +0 -1
  183. package/auth.d.cts +0 -1
  184. package/auth.d.ts +0 -1
  185. package/auth.js +0 -1
  186. package/client.cjs +0 -1
  187. package/client.d.cts +0 -1
  188. package/client.d.ts +0 -1
  189. package/client.js +0 -1
  190. package/dist/auth/types.cjs +0 -2
  191. package/dist/auth/types.js +0 -1
  192. package/dist/react/stream.lgp.d.ts +0 -7
  193. package/dist/react/thread.d.ts +0 -4
  194. package/dist/react/types.cjs +0 -2
  195. package/dist/react/types.js +0 -1
  196. package/dist/schema.cjs +0 -2
  197. package/dist/schema.js +0 -1
  198. package/dist/types.cjs +0 -2
  199. package/dist/types.js +0 -1
  200. package/dist/types.messages.cjs +0 -2
  201. package/dist/types.messages.js +0 -1
  202. package/dist/types.stream.cjs +0 -2
  203. package/dist/types.stream.js +0 -1
  204. package/dist/ui/branching.test.cjs +0 -370
  205. package/dist/ui/branching.test.d.ts +0 -1
  206. package/dist/ui/branching.test.js +0 -368
  207. package/dist/ui/errors.d.ts +0 -12
  208. package/dist/ui/manager.d.ts +0 -87
  209. package/dist/ui/messages.d.ts +0 -18
  210. package/dist/ui/utils.d.ts +0 -2
  211. package/dist/utils/env.d.ts +0 -1
  212. package/dist/utils/signals.d.ts +0 -1
  213. package/dist/utils/sse.d.ts +0 -8
  214. package/dist/utils/stream.d.ts +0 -13
  215. package/index.cjs +0 -1
  216. package/index.d.cts +0 -1
  217. package/index.d.ts +0 -1
  218. package/index.js +0 -1
  219. package/logging.cjs +0 -1
  220. package/logging.d.cts +0 -1
  221. package/logging.d.ts +0 -1
  222. package/logging.js +0 -1
  223. package/react-ui/server.cjs +0 -1
  224. package/react-ui/server.d.cts +0 -1
  225. package/react-ui/server.d.ts +0 -1
  226. package/react-ui/server.js +0 -1
  227. package/react-ui.cjs +0 -1
  228. package/react-ui.d.cts +0 -1
  229. package/react-ui.d.ts +0 -1
  230. package/react-ui.js +0 -1
  231. package/react.cjs +0 -1
  232. package/react.d.cts +0 -1
  233. package/react.d.ts +0 -1
  234. package/react.js +0 -1
@@ -1,74 +1,90 @@
1
+ import { UIMessage } from "./types.js";
2
+ import { UseStream } from "../react/types.js";
3
+ import { useStream } from "../react/stream.js";
1
4
  import * as React from "react";
2
5
  import * as JsxRuntime from "react/jsx-runtime";
3
- import type { UIMessage } from "./types.js";
4
- import { useStream } from "../react/index.js";
5
- import type { UseStream } from "../react/types.js";
6
+
7
+ //#region src/react-ui/client.d.ts
6
8
  declare const UseStreamContext: React.Context<{
7
- stream: ReturnType<typeof useStream>;
8
- meta: unknown;
9
- }>;
10
- type BagTemplate = {
11
- ConfigurableType?: Record<string, unknown>;
9
+ stream: UseStream<Record<string, unknown>, {
10
+ ConfigurableType?: Record<string, unknown> | undefined;
12
11
  InterruptType?: unknown;
13
12
  CustomEventType?: unknown;
14
13
  UpdateType?: unknown;
15
- MetaType?: unknown;
14
+ }>;
15
+ meta: unknown;
16
+ }>;
17
+ type BagTemplate = {
18
+ ConfigurableType?: Record<string, unknown>;
19
+ InterruptType?: unknown;
20
+ CustomEventType?: unknown;
21
+ UpdateType?: unknown;
22
+ MetaType?: unknown;
16
23
  };
17
24
  type GetMetaType<Bag extends BagTemplate> = Bag extends {
18
- MetaType: unknown;
25
+ MetaType: unknown;
19
26
  } ? Bag["MetaType"] : unknown;
20
27
  interface UseStreamContext<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> extends UseStream<StateType, Bag> {
21
- meta?: GetMetaType<Bag>;
28
+ meta?: GetMetaType<Bag>;
22
29
  }
23
- export declare function useStreamContext<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends {
24
- ConfigurableType?: Record<string, unknown>;
25
- InterruptType?: unknown;
26
- CustomEventType?: unknown;
27
- UpdateType?: unknown;
28
- MetaType?: unknown;
30
+ declare function useStreamContext<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends {
31
+ ConfigurableType?: Record<string, unknown>;
32
+ InterruptType?: unknown;
33
+ CustomEventType?: unknown;
34
+ UpdateType?: unknown;
35
+ MetaType?: unknown;
29
36
  } = BagTemplate>(): UseStreamContext<StateType, Bag>;
30
37
  interface ComponentTarget {
31
- comp: React.FunctionComponent | React.ComponentClass;
32
- target: HTMLElement;
38
+ comp: React.FunctionComponent | React.ComponentClass;
39
+ target: HTMLElement;
33
40
  }
34
41
  declare class ComponentStore {
35
- private cache;
36
- private boundCache;
37
- private callbacks;
38
- respond(shadowRootId: string, comp: React.FunctionComponent | React.ComponentClass, targetElement: HTMLElement): void;
39
- getBoundStore(shadowRootId: string): {
40
- subscribe: (onStoreChange: () => void) => () => void;
41
- getSnapshot: () => ComponentTarget | undefined;
42
- };
42
+ private cache;
43
+ private boundCache;
44
+ private callbacks;
45
+ respond(shadowRootId: string, comp: React.FunctionComponent | React.ComponentClass, targetElement: HTMLElement): void;
46
+ getBoundStore(shadowRootId: string): {
47
+ subscribe: (onStoreChange: () => void) => () => void;
48
+ getSnapshot: () => ComponentTarget | undefined;
49
+ };
43
50
  }
44
51
  declare const EXT_STORE_SYMBOL: unique symbol;
45
52
  declare const REQUIRE_SYMBOL: unique symbol;
46
53
  declare const REQUIRE_EXTRA_SYMBOL: unique symbol;
47
54
  interface LoadExternalComponentProps extends Pick<React.HTMLAttributes<HTMLDivElement>, "style" | "className"> {
48
- /** Stream of the assistant */
49
- stream: ReturnType<typeof useStream>;
50
- /** Namespace of UI components. Defaults to assistant ID. */
51
- namespace?: string;
52
- /** UI message to be rendered */
53
- message: UIMessage;
54
- /** Additional context to be passed to the child component */
55
- meta?: unknown;
56
- /** Fallback to be rendered when the component is loading */
57
- fallback?: React.ReactNode | Record<string, React.ReactNode>;
58
- /**
59
- * Map of components that can be rendered directly without fetching the UI code
60
- * from the server.
61
- */
62
- components?: Record<string, React.FunctionComponent | React.ComponentClass>;
55
+ /** Stream of the assistant */
56
+ stream: ReturnType<typeof useStream>;
57
+ /** Namespace of UI components. Defaults to assistant ID. */
58
+ namespace?: string;
59
+ /** UI message to be rendered */
60
+ message: UIMessage;
61
+ /** Additional context to be passed to the child component */
62
+ meta?: unknown;
63
+ /** Fallback to be rendered when the component is loading */
64
+ fallback?: React.ReactNode | Record<string, React.ReactNode>;
65
+ /**
66
+ * Map of components that can be rendered directly without fetching the UI code
67
+ * from the server.
68
+ */
69
+ components?: Record<string, React.FunctionComponent | React.ComponentClass>;
63
70
  }
64
- export declare function LoadExternalComponent({ stream, namespace, message, meta, fallback, components, ...props }: LoadExternalComponentProps): JsxRuntime.JSX.Element;
71
+ declare function LoadExternalComponent({
72
+ stream,
73
+ namespace,
74
+ message,
75
+ meta,
76
+ fallback,
77
+ components,
78
+ ...props
79
+ }: LoadExternalComponentProps): JsxRuntime.JSX.Element;
65
80
  declare global {
66
- interface Window {
67
- [EXT_STORE_SYMBOL]: ComponentStore;
68
- [REQUIRE_SYMBOL]: (name: string) => unknown;
69
- [REQUIRE_EXTRA_SYMBOL]: Record<string, unknown>;
70
- }
81
+ interface Window {
82
+ [EXT_STORE_SYMBOL]: ComponentStore;
83
+ [REQUIRE_SYMBOL]: (name: string) => unknown;
84
+ [REQUIRE_EXTRA_SYMBOL]: Record<string, unknown>;
85
+ }
71
86
  }
72
- export declare function experimental_loadShare(name: string, module: unknown): void;
73
- export declare function bootstrapUiContext(): void;
74
- export {};
87
+ declare function experimental_loadShare(name: string, module: unknown): void;
88
+ //#endregion
89
+ export { LoadExternalComponent, experimental_loadShare, useStreamContext };
90
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","names":["React","JsxRuntime","UIMessage","useStream","UseStream","UseStreamContext","Record","Context","BagTemplate","GetMetaType","Bag","StateType","useStreamContext","ComponentTarget","FunctionComponent","ComponentClass","HTMLElement","ComponentStore","EXT_STORE_SYMBOL","REQUIRE_SYMBOL","REQUIRE_EXTRA_SYMBOL","LoadExternalComponentProps","HTMLDivElement","HTMLAttributes","ReturnType","ReactNode","Pick","LoadExternalComponent","stream","namespace","message","meta","fallback","components","JSX","Element","_0","sideEffect","experimental_loadShare","bootstrapUiContext"],"sources":["../../src/react-ui/client.d.ts"],"sourcesContent":["import * as React from \"react\";\nimport * as JsxRuntime from \"react/jsx-runtime\";\nimport type { UIMessage } from \"./types.js\";\nimport { useStream } from \"../react/index.js\";\nimport type { UseStream } from \"../react/types.js\";\ndeclare const UseStreamContext: React.Context<{\n stream: UseStream<Record<string, unknown>, {\n ConfigurableType?: Record<string, unknown> | undefined;\n InterruptType?: unknown;\n CustomEventType?: unknown;\n UpdateType?: unknown;\n }>;\n meta: unknown;\n}>;\ntype BagTemplate = {\n ConfigurableType?: Record<string, unknown>;\n InterruptType?: unknown;\n CustomEventType?: unknown;\n UpdateType?: unknown;\n MetaType?: unknown;\n};\ntype GetMetaType<Bag extends BagTemplate> = Bag extends {\n MetaType: unknown;\n} ? Bag[\"MetaType\"] : unknown;\ninterface UseStreamContext<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends BagTemplate = BagTemplate> extends UseStream<StateType, Bag> {\n meta?: GetMetaType<Bag>;\n}\nexport declare function useStreamContext<StateType extends Record<string, unknown> = Record<string, unknown>, Bag extends {\n ConfigurableType?: Record<string, unknown>;\n InterruptType?: unknown;\n CustomEventType?: unknown;\n UpdateType?: unknown;\n MetaType?: unknown;\n} = BagTemplate>(): UseStreamContext<StateType, Bag>;\ninterface ComponentTarget {\n comp: React.FunctionComponent | React.ComponentClass;\n target: HTMLElement;\n}\ndeclare class ComponentStore {\n private cache;\n private boundCache;\n private callbacks;\n respond(shadowRootId: string, comp: React.FunctionComponent | React.ComponentClass, targetElement: HTMLElement): void;\n getBoundStore(shadowRootId: string): {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => ComponentTarget | undefined;\n };\n}\ndeclare const EXT_STORE_SYMBOL: unique symbol;\ndeclare const REQUIRE_SYMBOL: unique symbol;\ndeclare const REQUIRE_EXTRA_SYMBOL: unique symbol;\ninterface LoadExternalComponentProps extends Pick<React.HTMLAttributes<HTMLDivElement>, \"style\" | \"className\"> {\n /** Stream of the assistant */\n stream: ReturnType<typeof useStream>;\n /** Namespace of UI components. Defaults to assistant ID. */\n namespace?: string;\n /** UI message to be rendered */\n message: UIMessage;\n /** Additional context to be passed to the child component */\n meta?: unknown;\n /** Fallback to be rendered when the component is loading */\n fallback?: React.ReactNode | Record<string, React.ReactNode>;\n /**\n * Map of components that can be rendered directly without fetching the UI code\n * from the server.\n */\n components?: Record<string, React.FunctionComponent | React.ComponentClass>;\n}\nexport declare function LoadExternalComponent({ stream, namespace, message, meta, fallback, components, ...props }: LoadExternalComponentProps): JsxRuntime.JSX.Element;\ndeclare global {\n interface Window {\n [EXT_STORE_SYMBOL]: ComponentStore;\n [REQUIRE_SYMBOL]: (name: string) => unknown;\n [REQUIRE_EXTRA_SYMBOL]: Record<string, unknown>;\n }\n}\nexport declare function experimental_loadShare(name: string, module: unknown): void;\nexport declare function bootstrapUiContext(): void;\nexport {};\n"],"mappings":";;;;;;;cAKcK,kBAAkBL,KAAAA,CAAMO;UAC1BH,UAAUE;IADRD,gBAQZ,CAAA,EANyBC,MAMzB,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,SAAA;IAAA,aAAA,CAAA,EAAA,OAAA;IAPoBA,eAAAA,CAAAA,EAAAA,OAAAA;IACKA,UAAAA,CAAAA,EAAAA,OAAAA;;MAFKN,EAAAA,OAAMO;;AAAO,KASxCC,WAAAA,GAAW;EAOXC,gBAAW,CA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BAAAA,GAAuBd;EALRqB;;AAAwBC,iBAQxBU,sBAAAA,CARwBV,IAAAA,EAAAA,MAAAA,EAAAA,MAAAA,EAAAA,OAAAA,CAAAA,EAAAA,IAAAA"}
@@ -1,159 +1,134 @@
1
1
  "use client";
2
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+
3
+
4
+ import { useStream } from "../react/stream.js";
5
+ import "../react/index.js";
3
6
  import * as React from "react";
4
7
  import * as ReactDOM from "react-dom";
5
8
  import * as JsxRuntime from "react/jsx-runtime";
6
- import { useStream } from "../react/index.js";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+
11
+ //#region src/react-ui/client.tsx
7
12
  const UseStreamContext = React.createContext(null);
8
- export function useStreamContext() {
9
- const ctx = React.useContext(UseStreamContext);
10
- if (!ctx) {
11
- throw new Error("useStreamContext must be used within a LoadExternalComponent");
12
- }
13
- return new Proxy(ctx, {
14
- get(target, prop) {
15
- if (prop === "meta")
16
- return target.meta;
17
- return target.stream[prop];
18
- },
19
- });
20
- }
21
- class ComponentStore {
22
- constructor() {
23
- Object.defineProperty(this, "cache", {
24
- enumerable: true,
25
- configurable: true,
26
- writable: true,
27
- value: {}
28
- });
29
- Object.defineProperty(this, "boundCache", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: {}
34
- });
35
- Object.defineProperty(this, "callbacks", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: {}
40
- });
41
- }
42
- respond(shadowRootId, comp, targetElement) {
43
- this.cache[shadowRootId] = { comp, target: targetElement };
44
- this.callbacks[shadowRootId]?.forEach((c) => c(comp, targetElement));
45
- }
46
- getBoundStore(shadowRootId) {
47
- this.boundCache[shadowRootId] ??= {
48
- subscribe: (onStoreChange) => {
49
- this.callbacks[shadowRootId] ??= [];
50
- this.callbacks[shadowRootId].push(onStoreChange);
51
- return () => {
52
- this.callbacks[shadowRootId] = this.callbacks[shadowRootId].filter((c) => c !== onStoreChange);
53
- };
54
- },
55
- getSnapshot: () => this.cache[shadowRootId],
56
- };
57
- return this.boundCache[shadowRootId];
58
- }
13
+ function useStreamContext() {
14
+ const ctx = React.useContext(UseStreamContext);
15
+ if (!ctx) throw new Error("useStreamContext must be used within a LoadExternalComponent");
16
+ return new Proxy(ctx, { get(target, prop) {
17
+ if (prop === "meta") return target.meta;
18
+ return target.stream[prop];
19
+ } });
59
20
  }
21
+ var ComponentStore = class {
22
+ cache = {};
23
+ boundCache = {};
24
+ callbacks = {};
25
+ respond(shadowRootId, comp, targetElement) {
26
+ this.cache[shadowRootId] = {
27
+ comp,
28
+ target: targetElement
29
+ };
30
+ this.callbacks[shadowRootId]?.forEach((c) => c(comp, targetElement));
31
+ }
32
+ getBoundStore(shadowRootId) {
33
+ this.boundCache[shadowRootId] ??= {
34
+ subscribe: (onStoreChange) => {
35
+ this.callbacks[shadowRootId] ??= [];
36
+ this.callbacks[shadowRootId].push(onStoreChange);
37
+ return () => {
38
+ this.callbacks[shadowRootId] = this.callbacks[shadowRootId].filter((c) => c !== onStoreChange);
39
+ };
40
+ },
41
+ getSnapshot: () => this.cache[shadowRootId]
42
+ };
43
+ return this.boundCache[shadowRootId];
44
+ }
45
+ };
60
46
  const COMPONENT_STORE = new ComponentStore();
61
47
  const EXT_STORE_SYMBOL = Symbol.for("LGUI_EXT_STORE");
62
48
  const REQUIRE_SYMBOL = Symbol.for("LGUI_REQUIRE");
63
49
  const REQUIRE_EXTRA_SYMBOL = Symbol.for("LGUI_REQUIRE_EXTRA");
64
50
  const isIterable = (value) => value != null && typeof value === "object" && Symbol.iterator in value;
65
- const isPromise = (value) => value != null &&
66
- typeof value === "object" &&
67
- "then" in value &&
68
- typeof value.then === "function";
51
+ const isPromise = (value) => value != null && typeof value === "object" && "then" in value && typeof value.then === "function";
69
52
  const isReactNode = (value) => {
70
- if (React.isValidElement(value))
71
- return true;
72
- if (value == null)
73
- return true;
74
- if (typeof value === "string" ||
75
- typeof value === "number" ||
76
- typeof value === "bigint" ||
77
- typeof value === "boolean") {
78
- return true;
79
- }
80
- if (isIterable(value))
81
- return true;
82
- if (isPromise(value))
83
- return true;
84
- return false;
53
+ if (React.isValidElement(value)) return true;
54
+ if (value == null) return true;
55
+ if (typeof value === "string" || typeof value === "number" || typeof value === "bigint" || typeof value === "boolean") return true;
56
+ if (isIterable(value)) return true;
57
+ if (isPromise(value)) return true;
58
+ return false;
85
59
  };
86
- export function LoadExternalComponent({ stream, namespace, message, meta, fallback, components, ...props }) {
87
- const ref = React.useRef(null);
88
- const id = React.useId();
89
- const shadowRootId = `child-shadow-${id}`;
90
- const store = React.useMemo(() => COMPONENT_STORE.getBoundStore(shadowRootId), [shadowRootId]);
91
- const state = React.useSyncExternalStore(store.subscribe, store.getSnapshot);
92
- const clientComponent = components?.[message.name];
93
- const hasClientComponent = clientComponent != null;
94
- let fallbackComponent = null;
95
- if (isReactNode(fallback)) {
96
- fallbackComponent = fallback;
97
- }
98
- else if (typeof fallback === "object" && fallback != null) {
99
- fallbackComponent = fallback?.[message.name];
100
- }
101
- const uiNamespace = namespace ?? stream.assistantId;
102
- const uiClient = stream.client["~ui"];
103
- React.useEffect(() => {
104
- if (hasClientComponent)
105
- return;
106
- void uiClient.getComponent(uiNamespace, message.name).then((html) => {
107
- const dom = ref.current;
108
- if (!dom)
109
- return;
110
- const root = dom.shadowRoot ?? dom.attachShadow({ mode: "open" });
111
- const fragment = document
112
- .createRange()
113
- .createContextualFragment(html.replace("{{shadowRootId}}", shadowRootId));
114
- root.appendChild(fragment);
115
- });
116
- }, [uiClient, uiNamespace, message.name, shadowRootId, hasClientComponent]);
117
- if (hasClientComponent) {
118
- return (_jsx(UseStreamContext.Provider, { value: { stream, meta }, children: React.createElement(clientComponent, message.props) }));
119
- }
120
- return (_jsxs(_Fragment, { children: [_jsx("div", { id: shadowRootId, ref: ref, ...props }), _jsx(UseStreamContext.Provider, { value: { stream, meta }, children: state?.target != null
121
- ? ReactDOM.createPortal(React.createElement(state.comp, message.props), state.target)
122
- : fallbackComponent })] }));
60
+ function LoadExternalComponent({ stream, namespace, message, meta, fallback, components,...props }) {
61
+ const ref = React.useRef(null);
62
+ const id = React.useId();
63
+ const shadowRootId = `child-shadow-${id}`;
64
+ const store = React.useMemo(() => COMPONENT_STORE.getBoundStore(shadowRootId), [shadowRootId]);
65
+ const state = React.useSyncExternalStore(store.subscribe, store.getSnapshot);
66
+ const clientComponent = components?.[message.name];
67
+ const hasClientComponent = clientComponent != null;
68
+ let fallbackComponent = null;
69
+ if (isReactNode(fallback)) fallbackComponent = fallback;
70
+ else if (typeof fallback === "object" && fallback != null) fallbackComponent = fallback?.[message.name];
71
+ const uiNamespace = namespace ?? stream.assistantId;
72
+ const uiClient = stream.client["~ui"];
73
+ React.useEffect(() => {
74
+ if (hasClientComponent) return;
75
+ uiClient.getComponent(uiNamespace, message.name).then((html) => {
76
+ const dom = ref.current;
77
+ if (!dom) return;
78
+ const root = dom.shadowRoot ?? dom.attachShadow({ mode: "open" });
79
+ const fragment = document.createRange().createContextualFragment(html.replace("{{shadowRootId}}", shadowRootId));
80
+ root.appendChild(fragment);
81
+ });
82
+ }, [
83
+ uiClient,
84
+ uiNamespace,
85
+ message.name,
86
+ shadowRootId,
87
+ hasClientComponent
88
+ ]);
89
+ if (hasClientComponent) return /* @__PURE__ */ jsx(UseStreamContext.Provider, {
90
+ value: {
91
+ stream,
92
+ meta
93
+ },
94
+ children: React.createElement(clientComponent, message.props)
95
+ });
96
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
97
+ id: shadowRootId,
98
+ ref,
99
+ ...props
100
+ }), /* @__PURE__ */ jsx(UseStreamContext.Provider, {
101
+ value: {
102
+ stream,
103
+ meta
104
+ },
105
+ children: state?.target != null ? ReactDOM.createPortal(React.createElement(state.comp, message.props), state.target) : fallbackComponent
106
+ })] });
123
107
  }
124
- export function experimental_loadShare(name, module) {
125
- if (typeof window === "undefined")
126
- return;
127
- window[REQUIRE_EXTRA_SYMBOL] ??= {};
128
- window[REQUIRE_EXTRA_SYMBOL][name] = module;
108
+ function experimental_loadShare(name, module) {
109
+ if (typeof window === "undefined") return;
110
+ window[REQUIRE_EXTRA_SYMBOL] ??= {};
111
+ window[REQUIRE_EXTRA_SYMBOL][name] = module;
129
112
  }
130
- export function bootstrapUiContext() {
131
- if (typeof window === "undefined") {
132
- return;
133
- }
134
- window[EXT_STORE_SYMBOL] = COMPONENT_STORE;
135
- window[REQUIRE_SYMBOL] = (name) => {
136
- if (name === "react")
137
- return React;
138
- if (name === "react-dom")
139
- return ReactDOM;
140
- if (name === "react/jsx-runtime")
141
- return JsxRuntime;
142
- if (name === "@langchain/langgraph-sdk/react")
143
- return { useStream };
144
- if (name === "@langchain/langgraph-sdk/react-ui") {
145
- return {
146
- useStreamContext,
147
- LoadExternalComponent: () => {
148
- throw new Error("Nesting LoadExternalComponent is not supported");
149
- },
150
- };
151
- }
152
- if (window[REQUIRE_EXTRA_SYMBOL] != null &&
153
- typeof window[REQUIRE_EXTRA_SYMBOL] === "object" &&
154
- name in window[REQUIRE_EXTRA_SYMBOL]) {
155
- return window[REQUIRE_EXTRA_SYMBOL][name];
156
- }
157
- throw new Error(`Unknown module...: ${name}`);
158
- };
113
+ function bootstrapUiContext() {
114
+ if (typeof window === "undefined") return;
115
+ window[EXT_STORE_SYMBOL] = COMPONENT_STORE;
116
+ window[REQUIRE_SYMBOL] = (name) => {
117
+ if (name === "react") return React;
118
+ if (name === "react-dom") return ReactDOM;
119
+ if (name === "react/jsx-runtime") return JsxRuntime;
120
+ if (name === "@langchain/langgraph-sdk/react") return { useStream };
121
+ if (name === "@langchain/langgraph-sdk/react-ui") return {
122
+ useStreamContext,
123
+ LoadExternalComponent: () => {
124
+ throw new Error("Nesting LoadExternalComponent is not supported");
125
+ }
126
+ };
127
+ if (window[REQUIRE_EXTRA_SYMBOL] != null && typeof window[REQUIRE_EXTRA_SYMBOL] === "object" && name in window[REQUIRE_EXTRA_SYMBOL]) return window[REQUIRE_EXTRA_SYMBOL][name];
128
+ throw new Error(`Unknown module...: ${name}`);
129
+ };
159
130
  }
131
+
132
+ //#endregion
133
+ export { LoadExternalComponent, bootstrapUiContext, experimental_loadShare, useStreamContext };
134
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/react-ui/client.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport * as JsxRuntime from \"react/jsx-runtime\";\nimport type { UIMessage } from \"./types.js\";\nimport { useStream } from \"../react/index.js\";\nimport type { UseStream } from \"../react/types.js\";\n\nconst UseStreamContext = React.createContext<{\n stream: ReturnType<typeof useStream>;\n meta: unknown;\n}>(null!);\n\ntype BagTemplate = {\n ConfigurableType?: Record<string, unknown>;\n InterruptType?: unknown;\n CustomEventType?: unknown;\n UpdateType?: unknown;\n MetaType?: unknown;\n};\n\ntype GetMetaType<Bag extends BagTemplate> = Bag extends { MetaType: unknown }\n ? Bag[\"MetaType\"]\n : unknown;\n\ninterface UseStreamContext<\n StateType extends Record<string, unknown> = Record<string, unknown>,\n Bag extends BagTemplate = BagTemplate\n> extends UseStream<StateType, Bag> {\n meta?: GetMetaType<Bag>;\n}\n\nexport function useStreamContext<\n StateType extends Record<string, unknown> = Record<string, unknown>,\n Bag extends {\n ConfigurableType?: Record<string, unknown>;\n InterruptType?: unknown;\n CustomEventType?: unknown;\n UpdateType?: unknown;\n MetaType?: unknown;\n } = BagTemplate\n>(): UseStreamContext<StateType, Bag> {\n const ctx = React.useContext(UseStreamContext);\n if (!ctx) {\n throw new Error(\n \"useStreamContext must be used within a LoadExternalComponent\"\n );\n }\n\n return new Proxy(ctx, {\n get(target, prop: keyof UseStreamContext<StateType, Bag>) {\n if (prop === \"meta\") return target.meta;\n return target.stream[prop];\n },\n }) as unknown as UseStreamContext<StateType, Bag>;\n}\n\ninterface ComponentTarget {\n comp: React.FunctionComponent | React.ComponentClass;\n target: HTMLElement;\n}\n\nclass ComponentStore {\n private cache: Record<string, ComponentTarget> = {};\n\n private boundCache: Record<\n string,\n {\n subscribe: (onStoreChange: () => void) => () => void;\n getSnapshot: () => ComponentTarget | undefined;\n }\n > = {};\n\n private callbacks: Record<\n string,\n ((\n comp: React.FunctionComponent | React.ComponentClass,\n el: HTMLElement\n ) => void)[]\n > = {};\n\n respond(\n shadowRootId: string,\n comp: React.FunctionComponent | React.ComponentClass,\n targetElement: HTMLElement\n ) {\n this.cache[shadowRootId] = { comp, target: targetElement };\n this.callbacks[shadowRootId]?.forEach((c) => c(comp, targetElement));\n }\n\n getBoundStore(shadowRootId: string) {\n this.boundCache[shadowRootId] ??= {\n subscribe: (onStoreChange: () => void) => {\n this.callbacks[shadowRootId] ??= [];\n this.callbacks[shadowRootId].push(onStoreChange);\n return () => {\n this.callbacks[shadowRootId] = this.callbacks[shadowRootId].filter(\n (c) => c !== onStoreChange\n );\n };\n },\n getSnapshot: () => this.cache[shadowRootId],\n };\n\n return this.boundCache[shadowRootId];\n }\n}\n\nconst COMPONENT_STORE = new ComponentStore();\nconst EXT_STORE_SYMBOL = Symbol.for(\"LGUI_EXT_STORE\");\nconst REQUIRE_SYMBOL = Symbol.for(\"LGUI_REQUIRE\");\nconst REQUIRE_EXTRA_SYMBOL = Symbol.for(\"LGUI_REQUIRE_EXTRA\");\n\ninterface LoadExternalComponentProps\n extends Pick<React.HTMLAttributes<HTMLDivElement>, \"style\" | \"className\"> {\n /** Stream of the assistant */\n stream: ReturnType<typeof useStream>;\n\n /** Namespace of UI components. Defaults to assistant ID. */\n namespace?: string;\n\n /** UI message to be rendered */\n message: UIMessage;\n\n /** Additional context to be passed to the child component */\n meta?: unknown;\n\n /** Fallback to be rendered when the component is loading */\n fallback?: React.ReactNode | Record<string, React.ReactNode>;\n\n /**\n * Map of components that can be rendered directly without fetching the UI code\n * from the server.\n */\n components?: Record<string, React.FunctionComponent | React.ComponentClass>;\n}\n\nconst isIterable = (value: unknown): value is Iterable<unknown> =>\n value != null && typeof value === \"object\" && Symbol.iterator in value;\n\nconst isPromise = (value: unknown): value is Promise<unknown> =>\n value != null &&\n typeof value === \"object\" &&\n \"then\" in value &&\n typeof value.then === \"function\";\n\nconst isReactNode = (value: unknown): value is React.ReactNode => {\n if (React.isValidElement(value)) return true;\n if (value == null) return true;\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"bigint\" ||\n typeof value === \"boolean\"\n ) {\n return true;\n }\n\n if (isIterable(value)) return true;\n if (isPromise(value)) return true;\n\n return false;\n};\n\nexport function LoadExternalComponent({\n stream,\n namespace,\n message,\n meta,\n fallback,\n components,\n ...props\n}: LoadExternalComponentProps) {\n const ref = React.useRef<HTMLDivElement>(null);\n const id = React.useId();\n const shadowRootId = `child-shadow-${id}`;\n\n const store = React.useMemo(\n () => COMPONENT_STORE.getBoundStore(shadowRootId),\n [shadowRootId]\n );\n const state = React.useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n const clientComponent = components?.[message.name];\n const hasClientComponent = clientComponent != null;\n\n let fallbackComponent = null;\n if (isReactNode(fallback)) {\n fallbackComponent = fallback;\n } else if (typeof fallback === \"object\" && fallback != null) {\n fallbackComponent = fallback?.[message.name];\n }\n\n const uiNamespace = namespace ?? stream.assistantId;\n const uiClient = stream.client[\"~ui\"];\n React.useEffect(() => {\n if (hasClientComponent) return;\n void uiClient.getComponent(uiNamespace, message.name).then((html) => {\n const dom = ref.current;\n if (!dom) return;\n const root = dom.shadowRoot ?? dom.attachShadow({ mode: \"open\" });\n const fragment = document\n .createRange()\n .createContextualFragment(\n html.replace(\"{{shadowRootId}}\", shadowRootId)\n );\n root.appendChild(fragment);\n });\n }, [uiClient, uiNamespace, message.name, shadowRootId, hasClientComponent]);\n\n if (hasClientComponent) {\n return (\n <UseStreamContext.Provider value={{ stream, meta }}>\n {React.createElement(clientComponent, message.props)}\n </UseStreamContext.Provider>\n );\n }\n\n return (\n <>\n <div id={shadowRootId} ref={ref} {...props} />\n\n <UseStreamContext.Provider value={{ stream, meta }}>\n {state?.target != null\n ? ReactDOM.createPortal(\n React.createElement(state.comp, message.props),\n state.target\n )\n : fallbackComponent}\n </UseStreamContext.Provider>\n </>\n );\n}\n\ndeclare global {\n interface Window {\n [EXT_STORE_SYMBOL]: ComponentStore;\n [REQUIRE_SYMBOL]: (name: string) => unknown;\n [REQUIRE_EXTRA_SYMBOL]: Record<string, unknown>;\n }\n}\n\nexport function experimental_loadShare(name: string, module: unknown) {\n if (typeof window === \"undefined\") return;\n\n window[REQUIRE_EXTRA_SYMBOL] ??= {};\n window[REQUIRE_EXTRA_SYMBOL][name] = module;\n}\n\nexport function bootstrapUiContext() {\n if (typeof window === \"undefined\") {\n return;\n }\n\n window[EXT_STORE_SYMBOL] = COMPONENT_STORE;\n window[REQUIRE_SYMBOL] = (name: string) => {\n if (name === \"react\") return React;\n if (name === \"react-dom\") return ReactDOM;\n if (name === \"react/jsx-runtime\") return JsxRuntime;\n if (name === \"@langchain/langgraph-sdk/react\") return { useStream };\n if (name === \"@langchain/langgraph-sdk/react-ui\") {\n return {\n useStreamContext,\n LoadExternalComponent: () => {\n throw new Error(\"Nesting LoadExternalComponent is not supported\");\n },\n };\n }\n\n if (\n window[REQUIRE_EXTRA_SYMBOL] != null &&\n typeof window[REQUIRE_EXTRA_SYMBOL] === \"object\" &&\n name in window[REQUIRE_EXTRA_SYMBOL]\n ) {\n return window[REQUIRE_EXTRA_SYMBOL][name];\n }\n\n throw new Error(`Unknown module...: ${name}`);\n };\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAM,mBAAmB,MAAM,cAG5B;AAqBH,SAAgB,mBASsB;CACpC,MAAM,MAAM,MAAM,WAAW;AAC7B,KAAI,CAAC,IACH,OAAM,IAAI,MACR;AAIJ,QAAO,IAAI,MAAM,KAAK,EACpB,IAAI,QAAQ,MAA8C;AACxD,MAAI,SAAS,OAAQ,QAAO,OAAO;AACnC,SAAO,OAAO,OAAO;;;AAU3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AACxD,MAAI,SAAS,oCACX,QAAO;GACL;GACA,6BAA6B;AAC3B,UAAM,IAAI,MAAM;;;AAKtB,MACE,OAAO,yBAAyB,QAChC,OAAO,OAAO,0BAA0B,YACxC,QAAQ,OAAO,sBAEf,QAAO,OAAO,sBAAsB;AAGtC,QAAM,IAAI,MAAM,sBAAsB"}
@@ -1,13 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isRemoveUIMessage = exports.isUIMessage = exports.uiMessageReducer = exports.experimental_loadShare = exports.LoadExternalComponent = exports.useStreamContext = void 0;
4
- const client_js_1 = require("./client.cjs");
5
- (0, client_js_1.bootstrapUiContext)();
6
- var client_js_2 = require("./client.cjs");
7
- Object.defineProperty(exports, "useStreamContext", { enumerable: true, get: function () { return client_js_2.useStreamContext; } });
8
- Object.defineProperty(exports, "LoadExternalComponent", { enumerable: true, get: function () { return client_js_2.LoadExternalComponent; } });
9
- Object.defineProperty(exports, "experimental_loadShare", { enumerable: true, get: function () { return client_js_2.experimental_loadShare; } });
10
- var types_js_1 = require("./types.cjs");
11
- Object.defineProperty(exports, "uiMessageReducer", { enumerable: true, get: function () { return types_js_1.uiMessageReducer; } });
12
- Object.defineProperty(exports, "isUIMessage", { enumerable: true, get: function () { return types_js_1.isUIMessage; } });
13
- Object.defineProperty(exports, "isRemoveUIMessage", { enumerable: true, get: function () { return types_js_1.isRemoveUIMessage; } });
1
+ const require_client = require('./client.cjs');
2
+ const require_types = require('./types.cjs');
3
+
4
+ //#region src/react-ui/index.ts
5
+ require_client.bootstrapUiContext();
6
+
7
+ //#endregion
8
+ exports.LoadExternalComponent = require_client.LoadExternalComponent;
9
+ exports.experimental_loadShare = require_client.experimental_loadShare;
10
+ exports.isRemoveUIMessage = require_types.isRemoveUIMessage;
11
+ exports.isUIMessage = require_types.isUIMessage;
12
+ exports.uiMessageReducer = require_types.uiMessageReducer;
13
+ exports.useStreamContext = require_client.useStreamContext;
14
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["bootstrapUiContext"],"sources":["../../src/react-ui/index.ts"],"sourcesContent":["import { bootstrapUiContext } from \"./client.js\";\n\nbootstrapUiContext();\n\nexport {\n useStreamContext,\n LoadExternalComponent,\n experimental_loadShare,\n} from \"./client.js\";\nexport {\n uiMessageReducer,\n isUIMessage,\n isRemoveUIMessage,\n type UIMessage,\n type RemoveUIMessage,\n} from \"./types.js\";\n"],"mappings":";;;;AAEAA"}
@@ -0,0 +1,3 @@
1
+ import { RemoveUIMessage, UIMessage, isRemoveUIMessage, isUIMessage, uiMessageReducer } from "./types.cjs";
2
+ import { LoadExternalComponent, experimental_loadShare, useStreamContext } from "./client.cjs";
3
+ export { LoadExternalComponent, type RemoveUIMessage, type UIMessage, experimental_loadShare, isRemoveUIMessage, isUIMessage, uiMessageReducer, useStreamContext };
@@ -1,2 +1,3 @@
1
- export { useStreamContext, LoadExternalComponent, experimental_loadShare, } from "./client.js";
2
- export { uiMessageReducer, isUIMessage, isRemoveUIMessage, type UIMessage, type RemoveUIMessage, } from "./types.js";
1
+ import { RemoveUIMessage, UIMessage, isRemoveUIMessage, isUIMessage, uiMessageReducer } from "./types.js";
2
+ import { LoadExternalComponent, experimental_loadShare, useStreamContext } from "./client.js";
3
+ export { LoadExternalComponent, type RemoveUIMessage, type UIMessage, experimental_loadShare, isRemoveUIMessage, isUIMessage, uiMessageReducer, useStreamContext };
@@ -1,4 +1,9 @@
1
- import { bootstrapUiContext } from "./client.js";
1
+ import { LoadExternalComponent, bootstrapUiContext, experimental_loadShare, useStreamContext } from "./client.js";
2
+ import { isRemoveUIMessage, isUIMessage, uiMessageReducer } from "./types.js";
3
+
4
+ //#region src/react-ui/index.ts
2
5
  bootstrapUiContext();
3
- export { useStreamContext, LoadExternalComponent, experimental_loadShare, } from "./client.js";
4
- export { uiMessageReducer, isUIMessage, isRemoveUIMessage, } from "./types.js";
6
+
7
+ //#endregion
8
+ export { LoadExternalComponent, experimental_loadShare, isRemoveUIMessage, isUIMessage, uiMessageReducer, useStreamContext };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/react-ui/index.ts"],"sourcesContent":["import { bootstrapUiContext } from \"./client.js\";\n\nbootstrapUiContext();\n\nexport {\n useStreamContext,\n LoadExternalComponent,\n experimental_loadShare,\n} from \"./client.js\";\nexport {\n uiMessageReducer,\n isUIMessage,\n isRemoveUIMessage,\n type UIMessage,\n type RemoveUIMessage,\n} from \"./types.js\";\n"],"mappings":";;;;AAEA"}
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uiMessageReducer = exports.typedUi = void 0;
4
- var server_js_1 = require("./server.cjs");
5
- Object.defineProperty(exports, "typedUi", { enumerable: true, get: function () { return server_js_1.typedUi; } });
6
- var types_js_1 = require("../types.cjs");
7
- Object.defineProperty(exports, "uiMessageReducer", { enumerable: true, get: function () { return types_js_1.uiMessageReducer; } });
1
+ const require_types = require('../types.cjs');
2
+ const require_server = require('./server.cjs');
3
+
4
+ exports.typedUi = require_server.typedUi;
5
+ exports.uiMessageReducer = require_types.uiMessageReducer;
@@ -0,0 +1,3 @@
1
+ import { RemoveUIMessage, UIMessage, uiMessageReducer } from "../types.cjs";
2
+ import { typedUi } from "./server.cjs";
3
+ export { type RemoveUIMessage, type UIMessage, typedUi, uiMessageReducer };
@@ -1,2 +1,3 @@
1
- export { typedUi } from "./server.js";
2
- export { uiMessageReducer, type UIMessage, type RemoveUIMessage, } from "../types.js";
1
+ import { RemoveUIMessage, UIMessage, uiMessageReducer } from "../types.js";
2
+ import { typedUi } from "./server.js";
3
+ export { type RemoveUIMessage, type UIMessage, typedUi, uiMessageReducer };
@@ -1,2 +1,4 @@
1
- export { typedUi } from "./server.js";
2
- export { uiMessageReducer, } from "../types.js";
1
+ import { uiMessageReducer } from "../types.js";
2
+ import { typedUi } from "./server.js";
3
+
4
+ export { typedUi, uiMessageReducer };