UNPKG

@assistant-ui/react

Version:

Typescript/React library for AI Chat

31 lines 965 B
"use client"; import { jsx } from "react/jsx-runtime"; import { useEffect, useState } from "react"; import { create } from "zustand"; import { AttachmentContext } from "../react/AttachmentContext"; import { writableStore } from "../ReadonlyStore"; import { ensureBinding } from "../react/utils/ensureBinding"; const useAttachmentRuntimeStore = (runtime) => { const [store] = useState(() => create(() => runtime)); useEffect(() => { ensureBinding(runtime); writableStore(store).setState(runtime, true); }, [runtime, store]); return store; }; const AttachmentRuntimeProvider = ({ runtime, children }) => { const useAttachmentRuntime = useAttachmentRuntimeStore(runtime); const [context] = useState(() => { return { useAttachmentRuntime }; }); return /* @__PURE__ */ jsx(AttachmentContext.Provider, { value: context, children }); }; export { AttachmentRuntimeProvider }; //# sourceMappingURL=AttachmentRuntimeProvider.js.map