Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
export interface LayerActionRequest {
token: number;
signal: AbortSignal;
}
export interface LayerActionSession {
begin(): LayerActionRequest | null;
cancel(): void;
finish(token: number): void;
isCurrent(token: number): boolean;
}
export const createLayerActionSession = (): LayerActionSession => {
let nextToken = 0;
let active: { controller: AbortController; token: number } | null = null;
return {
begin: () => {
if (active) {
return null;
}
const controller = new AbortController();
const token = ++nextToken;
active = { controller, token };
return { signal: controller.signal, token };
},
cancel: () => {
nextToken += 1;
active?.controller.abort();
active = null;
},
finish: (token) => {
if (active?.token === token) {
active = null;
}
},
isCurrent: (token) => active?.token === token && !active.controller.signal.aborted,
};
};