UNPKG

@assistant-ui/react

Version:

Typescript/React library for AI Chat

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