mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-17 00:18:41 -07:00
fix(anime): keep browser state in sync and alias HLS segments
- Toggle the player Anime Browser without losing its state - Share active playback state and support rotating fake segment extensions
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
export const ANIME_BROWSER_CLOSE_MESSAGE = 'subminer:anime-browser-close';
|
||||
|
||||
const ANIME_BROWSER_KEYDOWN_MESSAGE = 'subminer:anime-browser-keydown';
|
||||
|
||||
export interface AnimeBrowserKeydownMessage {
|
||||
type: typeof ANIME_BROWSER_KEYDOWN_MESSAGE;
|
||||
bindingKey: string;
|
||||
repeat: boolean;
|
||||
}
|
||||
|
||||
export function createAnimeBrowserKeydownMessage(
|
||||
event: Pick<KeyboardEvent, 'altKey' | 'code' | 'ctrlKey' | 'metaKey' | 'repeat' | 'shiftKey'>,
|
||||
): AnimeBrowserKeydownMessage {
|
||||
const parts: string[] = [];
|
||||
if (event.ctrlKey) parts.push('Ctrl');
|
||||
if (event.altKey) parts.push('Alt');
|
||||
if (event.shiftKey) parts.push('Shift');
|
||||
if (event.metaKey) parts.push('Meta');
|
||||
parts.push(event.code);
|
||||
return {
|
||||
type: ANIME_BROWSER_KEYDOWN_MESSAGE,
|
||||
bindingKey: parts.join('+'),
|
||||
repeat: event.repeat,
|
||||
};
|
||||
}
|
||||
|
||||
export function isAnimeBrowserKeydownMessage(value: unknown): value is AnimeBrowserKeydownMessage {
|
||||
if (!value || typeof value !== 'object') return false;
|
||||
const message = value as Partial<AnimeBrowserKeydownMessage>;
|
||||
return (
|
||||
message.type === ANIME_BROWSER_KEYDOWN_MESSAGE &&
|
||||
typeof message.bindingKey === 'string' &&
|
||||
message.bindingKey.length > 0 &&
|
||||
typeof message.repeat === 'boolean'
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user