UNPKG

@assistant-ui/react

Version:

Typescript/React library for AI Chat

1 lines 1.25 kB
{"version":3,"sources":["../../../src/context/react/ComposerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useMessageRuntime } from \"./MessageContext\";\nimport { useThreadRuntime } from \"./ThreadContext\";\nimport { ComposerRuntime } from \"../../api/ComposerRuntime\";\nimport { createStateHookForRuntime } from \"./utils/createStateHookForRuntime\";\n\nexport function useComposerRuntime(options?: {\n optional?: false | undefined;\n}): ComposerRuntime;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null;\nexport function useComposerRuntime(options?: {\n optional?: boolean | undefined;\n}): ComposerRuntime | null {\n const messageRuntime = useMessageRuntime({ optional: true });\n const threadRuntime = useThreadRuntime(options);\n return messageRuntime\n ? messageRuntime.composer\n : (threadRuntime?.composer ?? null);\n}\n\nexport const useComposer = createStateHookForRuntime(useComposerRuntime);\n"],"mappings":";;;AAEA,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAEjC,SAAS,iCAAiC;AAQnC,SAAS,mBAAmB,SAER;AACzB,QAAM,iBAAiB,kBAAkB,EAAE,UAAU,KAAK,CAAC;AAC3D,QAAM,gBAAgB,iBAAiB,OAAO;AAC9C,SAAO,iBACH,eAAe,WACd,eAAe,YAAY;AAClC;AAEO,IAAM,cAAc,0BAA0B,kBAAkB;","names":[]}