mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-15 22:32:13 +00:00
_**WAITING FOR THE SERVER UPDATE FOR END-TO-END TESTING**_ - created ui and queue communication for switching camera aspect ratio done - editor's render camera read queue to switch camera aspect ratio - letterbox now available in camera view mode for a better preview of the aspect ratios - updated ui to match figma design after design update - vertical camera styling updates (by bflat) - finalized our render resolutions at different aspect ratio --------- Co-authored-by: wil <wil@storyteller.ai>
85 lines
1.9 KiB
TypeScript
85 lines
1.9 KiB
TypeScript
import { fromEngineActions } from "~/pages/PageEnigma/Queue/fromEngineActions";
|
|
import { toEngineActions } from "~/pages/PageEnigma/Queue/toEngineActions";
|
|
|
|
import { CameraAspectRatio } from "../enums";
|
|
import {
|
|
QueueClip,
|
|
QueueKeyframe,
|
|
UpdateTime,
|
|
MediaItem,
|
|
} from "~/pages/PageEnigma/models";
|
|
import { toTimelineActions } from "./toTimelineActions";
|
|
|
|
import { ClipUI } from "../datastructures/clips/clip_ui";
|
|
import { GenerationOptions } from "../models/generationOptions";
|
|
import { ToastDataType } from "~/components";
|
|
|
|
export type UnionedActionTypes =
|
|
| fromEngineActions
|
|
| toEngineActions
|
|
| toTimelineActions;
|
|
|
|
export type UnionedDataTypes =
|
|
| QueueClip
|
|
| UpdateTime
|
|
| QueueKeyframe
|
|
| ClipUI[]
|
|
| MediaItem
|
|
| ToastDataType
|
|
| GenerationOptions
|
|
| CameraAspectRatio
|
|
| null;
|
|
|
|
export type QueueSubscribeType = {
|
|
action: UnionedActionTypes;
|
|
data: UnionedDataTypes;
|
|
};
|
|
|
|
class Queue {
|
|
private _queue: Record<
|
|
string,
|
|
{
|
|
action: UnionedActionTypes;
|
|
data: UnionedDataTypes;
|
|
}[]
|
|
> = {};
|
|
private _subscribers: Record<
|
|
string,
|
|
(entry: { action: UnionedActionTypes; data: UnionedDataTypes }) => void
|
|
> = {};
|
|
|
|
public publish({
|
|
queueName,
|
|
action,
|
|
data,
|
|
}: {
|
|
queueName: string;
|
|
action: UnionedActionTypes;
|
|
data: UnionedDataTypes;
|
|
}) {
|
|
if (!this._queue[queueName]) {
|
|
this._queue[queueName] = [];
|
|
}
|
|
this._queue[queueName].push({ action, data });
|
|
console.log("Queued", queueName, action, data);
|
|
|
|
if (this._subscribers[queueName]) {
|
|
this._subscribers[queueName](this._queue[queueName].splice(0, 1)[0]);
|
|
}
|
|
}
|
|
|
|
public subscribe(
|
|
queueName: string,
|
|
onMessage: (entry: QueueSubscribeType) => void,
|
|
) {
|
|
this._subscribers[queueName] = onMessage;
|
|
while (this._queue[queueName]?.length) {
|
|
this._subscribers[queueName](this._queue[queueName].splice(0, 1)[0]);
|
|
}
|
|
}
|
|
}
|
|
|
|
const queue = new Queue();
|
|
|
|
export default queue;
|