mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-25 06:49:23 +01:00
24 lines
628 B
TypeScript
24 lines
628 B
TypeScript
import { Container } from "@/models/Container";
|
|
|
|
type ContainerContext = {
|
|
container: Ref<Container>;
|
|
streamConfig: { stdout: boolean; stderr: boolean };
|
|
};
|
|
|
|
export const containerContext = Symbol("containerContext") as InjectionKey<ContainerContext>;
|
|
|
|
export const provideContainerContext = (container: Ref<Container>) => {
|
|
provide(containerContext, {
|
|
container,
|
|
streamConfig: reactive({ stdout: true, stderr: true }),
|
|
});
|
|
};
|
|
|
|
export const useContainerContext = () => {
|
|
const context = inject(containerContext);
|
|
if (!context) {
|
|
throw new Error("No container context provided");
|
|
}
|
|
return context;
|
|
};
|