fix: resolve TypeScript build errors
- Add missing isShortcutKey type guard to keybinding.ts
- Add missing isActionWithOptionalArgs and isAction type guards to types.ts
- Fix IndexedDBAdapter constructor calls to use object params instead of positional args (runner.ts, v1-to-v2.ts)
- Fix StickersRegistry.register call to use object param { key, definition }
This commit is contained in:
parent
fbe3db74d7
commit
25549b8be2
|
|
@ -38,6 +38,22 @@ export type SingleCharacterShortcutKey = `${Key}`;
|
|||
|
||||
export type ShortcutKey = ModifierBasedShortcutKey | SingleCharacterShortcutKey;
|
||||
|
||||
const MODIFIER_KEYS_SET: ReadonlySet<string> = new Set([
|
||||
"ctrl", "alt", "shift",
|
||||
"ctrl+shift", "alt+shift", "ctrl+alt", "ctrl+alt+shift",
|
||||
]);
|
||||
|
||||
export function isShortcutKey(value: string): value is ShortcutKey {
|
||||
// Single key (e.g. "a", "enter")
|
||||
if (isKey(value)) return true;
|
||||
// Modifier+key (e.g. "ctrl+s", "ctrl+shift+z")
|
||||
const lastPlus = value.lastIndexOf("+");
|
||||
if (lastPlus === -1) return false;
|
||||
const modifier = value.slice(0, lastPlus);
|
||||
const key = value.slice(lastPlus + 1);
|
||||
return MODIFIER_KEYS_SET.has(modifier) && isKey(key);
|
||||
}
|
||||
|
||||
export type KeybindingConfig = {
|
||||
[key in ShortcutKey]?: TActionWithOptionalArgs;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import type { MutableRefObject } from "react";
|
||||
import type { TAction } from "./definitions";
|
||||
import { ACTIONS } from "./definitions";
|
||||
|
||||
export type { TAction };
|
||||
|
||||
|
|
@ -24,6 +25,22 @@ export type TActionWithOptionalArgs =
|
|||
|
||||
export type TActionWithNoArgs = Exclude<TAction, TActionWithArgs>;
|
||||
|
||||
const ACTION_KEYS_SET: ReadonlySet<string> = new Set(Object.keys(ACTIONS));
|
||||
|
||||
export function isAction(value: string): value is TAction {
|
||||
return ACTION_KEYS_SET.has(value);
|
||||
}
|
||||
|
||||
export function isActionWithOptionalArgs(value: string): value is TActionWithOptionalArgs {
|
||||
if (!isAction(value)) return false;
|
||||
// Actions that require mandatory (non-undefined) args cannot be used as keybindings
|
||||
const ACTIONS_WITH_REQUIRED_ARGS: ReadonlySet<string> = new Set([
|
||||
"remove-media-asset",
|
||||
"remove-media-assets",
|
||||
]);
|
||||
return !ACTIONS_WITH_REQUIRED_ARGS.has(value);
|
||||
}
|
||||
|
||||
export type TArgOfAction<A extends TAction> = A extends TActionWithArgs
|
||||
? TActionArgsMap[A]
|
||||
: undefined;
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ export async function runStorageMigrations({
|
|||
hasCleanedUpMetaDb = true;
|
||||
}
|
||||
|
||||
const projectsAdapter = new IndexedDBAdapter<ProjectRecord>(
|
||||
"video-editor-projects",
|
||||
"projects",
|
||||
1,
|
||||
);
|
||||
const projectsAdapter = new IndexedDBAdapter<ProjectRecord>({
|
||||
dbName: "video-editor-projects",
|
||||
storeName: "projects",
|
||||
version: 1,
|
||||
});
|
||||
|
||||
const projects = await projectsAdapter.getAll();
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ export async function runStorageMigrations({
|
|||
break;
|
||||
}
|
||||
|
||||
await projectsAdapter.set(projectId, result.project);
|
||||
await projectsAdapter.set({ key: projectId, value: result.project });
|
||||
migratedCount++;
|
||||
currentVersion = migration.to;
|
||||
projectRecord = result.project;
|
||||
|
|
|
|||
|
|
@ -121,20 +121,20 @@ async function loadLegacyTracksForScene({
|
|||
const sceneDbName = `video-editor-timelines-${projectId}-${sceneId}`;
|
||||
const projectDbName = `video-editor-timelines-${projectId}`;
|
||||
|
||||
const adapter = new IndexedDBAdapter<LegacyTimelineData>(
|
||||
sceneDbName,
|
||||
"timeline",
|
||||
1,
|
||||
);
|
||||
const adapter = new IndexedDBAdapter<LegacyTimelineData>({
|
||||
dbName: sceneDbName,
|
||||
storeName: "timeline",
|
||||
version: 1,
|
||||
});
|
||||
|
||||
let data = await adapter.get("timeline");
|
||||
|
||||
if (!data && isMain) {
|
||||
const projectAdapter = new IndexedDBAdapter<LegacyTimelineData>(
|
||||
projectDbName,
|
||||
"timeline",
|
||||
1,
|
||||
);
|
||||
const projectAdapter = new IndexedDBAdapter<LegacyTimelineData>({
|
||||
dbName: projectDbName,
|
||||
storeName: "timeline",
|
||||
version: 1,
|
||||
});
|
||||
data = await projectAdapter.get("timeline");
|
||||
}
|
||||
|
||||
|
|
@ -157,11 +157,11 @@ async function loadMediaTypesById({
|
|||
return {};
|
||||
}
|
||||
|
||||
const mediaMetadataAdapter = new IndexedDBAdapter<MediaAssetData>(
|
||||
`video-editor-media-${projectId}`,
|
||||
"media-metadata",
|
||||
1,
|
||||
);
|
||||
const mediaMetadataAdapter = new IndexedDBAdapter<MediaAssetData>({
|
||||
dbName: `video-editor-media-${projectId}`,
|
||||
storeName: "media-metadata",
|
||||
version: 1,
|
||||
});
|
||||
|
||||
const mediaEntries = await Promise.all(
|
||||
mediaIds.map(async (mediaId) => {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ export function registerDefaultStickerProviders({
|
|||
if (stickersRegistry.has(provider.id)) {
|
||||
continue;
|
||||
}
|
||||
stickersRegistry.register(provider.id, provider);
|
||||
stickersRegistry.register({ key: provider.id, definition: provider });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue