summaryrefslogtreecommitdiff
path: root/apps/web/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/src/commands')
-rw-r--r--apps/web/src/commands/media/add-media-asset.ts25
-rw-r--r--apps/web/src/commands/media/remove-media-asset.ts16
-rw-r--r--apps/web/src/commands/scene/create-scene.ts16
-rw-r--r--apps/web/src/commands/scene/move-bookmark.ts16
-rw-r--r--apps/web/src/commands/scene/remove-bookmark.ts4
-rw-r--r--apps/web/src/commands/scene/rename-scene.ts16
-rw-r--r--apps/web/src/commands/scene/toggle-bookmark.ts4
-rw-r--r--apps/web/src/commands/scene/update-bookmark.ts16
-rw-r--r--apps/web/src/commands/timeline/track/add-track.ts16
-rw-r--r--apps/web/src/commands/timeline/tracks-snapshot.ts16
10 files changed, 108 insertions, 37 deletions
diff --git a/apps/web/src/commands/media/add-media-asset.ts b/apps/web/src/commands/media/add-media-asset.ts
index d22241a2..629bc3ee 100644
--- a/apps/web/src/commands/media/add-media-asset.ts
+++ b/apps/web/src/commands/media/add-media-asset.ts
@@ -16,14 +16,22 @@ export class AddMediaAssetCommand extends Command {
private previousProjectFps: FrameRate | null = null;
private appliedProjectFps: FrameRate | null = null;
- constructor(
- private projectId: string,
- private asset: Omit<MediaAsset, "id">,
- ) {
+ constructor({
+ projectId,
+ asset,
+ }: {
+ projectId: string;
+ asset: Omit<MediaAsset, "id">;
+ }) {
super();
+ this.projectId = projectId;
+ this.asset = asset;
this.assetId = generateUUID();
}
+ private projectId: string;
+ private asset: Omit<MediaAsset, "id">;
+
execute(): CommandResult | undefined {
const editor = EditorCore.getInstance();
this.savedAssets = [...editor.media.getAssets()];
@@ -117,7 +125,14 @@ export class AddMediaAssetCommand extends Command {
const activeProject = editor.project.getActiveOrNull();
if (!activeProject) return;
- if (!this.appliedProjectFps || !frameRatesEqual(activeProject.settings.fps, this.appliedProjectFps)) return;
+ if (
+ !this.appliedProjectFps ||
+ !frameRatesEqual({
+ a: activeProject.settings.fps,
+ b: this.appliedProjectFps,
+ })
+ )
+ return;
const highestRemainingVideoFps = getHighestImportedVideoFps({
mediaAssets: editor.media.getAssets(),
diff --git a/apps/web/src/commands/media/remove-media-asset.ts b/apps/web/src/commands/media/remove-media-asset.ts
index 8da62181..38ff79fe 100644
--- a/apps/web/src/commands/media/remove-media-asset.ts
+++ b/apps/web/src/commands/media/remove-media-asset.ts
@@ -13,13 +13,21 @@ export class RemoveMediaAssetCommand extends Command {
private savedTracks: SceneTracks | null = null;
private removedAsset: MediaAsset | null = null;
- constructor(
- private projectId: string,
- private assetId: string,
- ) {
+ constructor({
+ projectId,
+ assetId,
+ }: {
+ projectId: string;
+ assetId: string;
+ }) {
super();
+ this.projectId = projectId;
+ this.assetId = assetId;
}
+ private projectId: string;
+ private assetId: string;
+
execute(): CommandResult | undefined {
const editor = EditorCore.getInstance();
const assets = editor.media.getAssets();
diff --git a/apps/web/src/commands/scene/create-scene.ts b/apps/web/src/commands/scene/create-scene.ts
index b554fe90..3776467d 100644
--- a/apps/web/src/commands/scene/create-scene.ts
+++ b/apps/web/src/commands/scene/create-scene.ts
@@ -7,13 +7,21 @@ export class CreateSceneCommand extends Command {
private savedScenes: TScene[] | null = null;
private createdScene: TScene | null = null;
- constructor(
- private name: string,
- private isMain: boolean = false,
- ) {
+ constructor({
+ name,
+ isMain = false,
+ }: {
+ name: string;
+ isMain?: boolean;
+ }) {
super();
+ this.name = name;
+ this.isMain = isMain;
}
+ private name: string;
+ private isMain: boolean;
+
execute(): CommandResult | undefined {
const editor = EditorCore.getInstance();
this.savedScenes = [...editor.scenes.getScenes()];
diff --git a/apps/web/src/commands/scene/move-bookmark.ts b/apps/web/src/commands/scene/move-bookmark.ts
index f3628b28..45b7bda5 100644
--- a/apps/web/src/commands/scene/move-bookmark.ts
+++ b/apps/web/src/commands/scene/move-bookmark.ts
@@ -8,13 +8,21 @@ import type { MediaTime } from "@/wasm";
export class MoveBookmarkCommand extends Command {
private savedScenes: TScene[] | null = null;
- constructor(
- private fromTime: MediaTime,
- private toTime: MediaTime,
- ) {
+ constructor({
+ fromTime,
+ toTime,
+ }: {
+ fromTime: MediaTime;
+ toTime: MediaTime;
+ }) {
super();
+ this.fromTime = fromTime;
+ this.toTime = toTime;
}
+ private fromTime: MediaTime;
+ private toTime: MediaTime;
+
execute(): CommandResult | undefined {
const editor = EditorCore.getInstance();
const activeScene = editor.scenes.getActiveScene();
diff --git a/apps/web/src/commands/scene/remove-bookmark.ts b/apps/web/src/commands/scene/remove-bookmark.ts
index bff5c035..95403e0e 100644
--- a/apps/web/src/commands/scene/remove-bookmark.ts
+++ b/apps/web/src/commands/scene/remove-bookmark.ts
@@ -6,11 +6,11 @@ import {
getFrameTime,
removeBookmarkFromArray,
} from "@/timeline/bookmarks/index";
-import type { MediaTime } from "@/wasm";
+import { type MediaTime, ZERO_MEDIA_TIME } from "@/wasm";
export class RemoveBookmarkCommand extends Command {
private savedScenes: TScene[] | null = null;
- private frameTime: MediaTime = 0 as MediaTime;
+ private frameTime: MediaTime = ZERO_MEDIA_TIME;
constructor(private time: MediaTime) {
super();
diff --git a/apps/web/src/commands/scene/rename-scene.ts b/apps/web/src/commands/scene/rename-scene.ts
index 19d6bfd8..8bc8724b 100644
--- a/apps/web/src/commands/scene/rename-scene.ts
+++ b/apps/web/src/commands/scene/rename-scene.ts
@@ -7,13 +7,21 @@ export class RenameSceneCommand extends Command {
private savedScenes: TScene[] | null = null;
private previousName: string | null = null;
- constructor(
- private sceneId: string,
- private newName: string,
- ) {
+ constructor({
+ sceneId,
+ newName,
+ }: {
+ sceneId: string;
+ newName: string;
+ }) {
super();
+ this.sceneId = sceneId;
+ this.newName = newName;
}
+ private sceneId: string;
+ private newName: string;
+
execute(): CommandResult | undefined {
const editor = EditorCore.getInstance();
const scenes = editor.scenes.getScenes();
diff --git a/apps/web/src/commands/scene/toggle-bookmark.ts b/apps/web/src/commands/scene/toggle-bookmark.ts
index 9f318f80..31751be4 100644
--- a/apps/web/src/commands/scene/toggle-bookmark.ts
+++ b/apps/web/src/commands/scene/toggle-bookmark.ts
@@ -6,11 +6,11 @@ import {
getFrameTime,
toggleBookmarkInArray,
} from "@/timeline/bookmarks/index";
-import type { MediaTime } from "@/wasm";
+import { type MediaTime, ZERO_MEDIA_TIME } from "@/wasm";
export class ToggleBookmarkCommand extends Command {
private savedScenes: TScene[] | null = null;
- private frameTime: MediaTime = 0 as MediaTime;
+ private frameTime: MediaTime = ZERO_MEDIA_TIME;
constructor(private time: MediaTime) {
super();
diff --git a/apps/web/src/commands/scene/update-bookmark.ts b/apps/web/src/commands/scene/update-bookmark.ts
index 238bb3de..7208abc4 100644
--- a/apps/web/src/commands/scene/update-bookmark.ts
+++ b/apps/web/src/commands/scene/update-bookmark.ts
@@ -11,13 +11,21 @@ import type { MediaTime } from "@/wasm";
export class UpdateBookmarkCommand extends Command {
private savedScenes: TScene[] | null = null;
- constructor(
- private time: MediaTime,
- private updates: Partial<Omit<Bookmark, "time">>,
- ) {
+ constructor({
+ time,
+ updates,
+ }: {
+ time: MediaTime;
+ updates: Partial<Omit<Bookmark, "time">>;
+ }) {
super();
+ this.time = time;
+ this.updates = updates;
}
+ private time: MediaTime;
+ private updates: Partial<Omit<Bookmark, "time">>;
+
execute(): CommandResult | undefined {
const editor = EditorCore.getInstance();
const activeScene = editor.scenes.getActiveScene();
diff --git a/apps/web/src/commands/timeline/track/add-track.ts b/apps/web/src/commands/timeline/track/add-track.ts
index 6b58b687..90becf13 100644
--- a/apps/web/src/commands/timeline/track/add-track.ts
+++ b/apps/web/src/commands/timeline/track/add-track.ts
@@ -11,14 +11,22 @@ export class AddTrackCommand extends Command {
private trackId: string;
private savedState: SceneTracks | null = null;
- constructor(
- private type: TrackType,
- private index?: number,
- ) {
+ constructor({
+ type,
+ index,
+ }: {
+ type: TrackType;
+ index?: number;
+ }) {
super();
+ this.type = type;
+ this.index = index;
this.trackId = generateUUID();
}
+ private type: TrackType;
+ private index?: number;
+
execute(): CommandResult | undefined {
const editor = EditorCore.getInstance();
this.savedState = editor.scenes.getActiveScene().tracks;
diff --git a/apps/web/src/commands/timeline/tracks-snapshot.ts b/apps/web/src/commands/timeline/tracks-snapshot.ts
index 5b6d871a..8e55e602 100644
--- a/apps/web/src/commands/timeline/tracks-snapshot.ts
+++ b/apps/web/src/commands/timeline/tracks-snapshot.ts
@@ -3,13 +3,21 @@ import type { SceneTracks } from "@/timeline";
import { EditorCore } from "@/core";
export class TracksSnapshotCommand extends Command {
- constructor(
- private before: SceneTracks,
- private after: SceneTracks,
- ) {
+ constructor({
+ before,
+ after,
+ }: {
+ before: SceneTracks;
+ after: SceneTracks;
+ }) {
super();
+ this.before = before;
+ this.after = after;
}
+ private before: SceneTracks;
+ private after: SceneTracks;
+
execute(): CommandResult | undefined {
EditorCore.getInstance().timeline.updateTracks(this.after);
return undefined;