@assistant-ui/react
Version:
Typescript/React library for AI Chat
28 lines (27 loc) • 1.03 kB
JavaScript
"use client";
// src/context/providers/ContentPartRuntimeProvider.tsx
import { useEffect, useState } from "react";
import { create } from "zustand";
import { ContentPartContext } from "../react/ContentPartContext.mjs";
import { writableStore } from "../ReadonlyStore.mjs";
import { ensureBinding } from "../react/utils/ensureBinding.mjs";
import { jsx } from "react/jsx-runtime";
var useContentPartRuntimeStore = (runtime) => {
const [store] = useState(() => create(() => runtime));
useEffect(() => {
ensureBinding(runtime);
writableStore(store).setState(runtime, true);
}, [runtime, store]);
return store;
};
var ContentPartRuntimeProvider = ({ runtime, children }) => {
const useContentPartRuntime = useContentPartRuntimeStore(runtime);
const [context] = useState(() => {
return { useContentPartRuntime };
});
return /* @__PURE__ */ jsx(ContentPartContext.Provider, { value: context, children });
};
export {
ContentPartRuntimeProvider
};
//# sourceMappingURL=ContentPartRuntimeProvider.mjs.map