Added first works on the V2 of the partitionview

This commit is contained in:
Clément Le Bihan
2023-10-13 01:21:25 +02:00
parent 57cba61d1b
commit f91ab4c430
8 changed files with 8538 additions and 8 deletions
+68
View File
@@ -0,0 +1,68 @@
import * as yup from 'yup';
import ResponseHandler from './ResponseHandler';
export const SongCursorInfosValidator = yup.object({
pageWidth: yup.number().required(),
cursors: yup
.array()
.of(
yup.object({
x: yup.number().required(),
y: yup.number().required(),
width: yup.number().required(),
height: yup.number().required(),
timestamp: yup.number().required(),
timing: yup.number().required(),
note: yup
.object({
note: yup.number().required(),
gain: yup.number().required(),
duration: yup.number().required(),
})
.required(),
})
)
.required(),
});
export const SongCursorInfosHandler: ResponseHandler<
yup.InferType<typeof SongCursorInfosValidator>,
SongCursorInfos
> = {
validator: SongCursorInfosValidator,
transformer: (songCursorInfos: yup.InferType<typeof SongCursorInfosValidator>) => ({
pageWidth: songCursorInfos.pageWidth,
cursors: songCursorInfos.cursors.map((cursor) => ({
x: cursor.x,
y: cursor.y,
width: cursor.width,
height: cursor.height,
timestamp: cursor.timestamp,
timing: cursor.timing,
note: {
note: cursor.note.note,
gain: cursor.note.gain,
duration: cursor.note.duration,
},
})),
}),
};
export interface CursorInfoItem {
x: number;
y: number;
width: number;
height: number;
timestamp: number;
timing: number;
note: {
note: number;
gain: number;
duration: number;
};
}
export interface SongCursorInfos {
pageWidth: number;
cursors: CursorInfoItem[];
}