refactor: saved all files with prettier formatting

This commit is contained in:
2026-04-26 23:24:09 +03:30
parent f248a293fa
commit affda9ccae
7 changed files with 30 additions and 30 deletions

View File

@@ -5,7 +5,7 @@
* creation: 23/4/2026
*/
import { AdapterAPI } from "../types";
import { AdapterAPI } from '../types';
export class NativeAdapter implements AdapterAPI {
private video: HTMLVideoElement;
@@ -22,7 +22,7 @@ export class NativeAdapter implements AdapterAPI {
}
play(): void {
this.video.play().catch((e) => console.warn("Play failed:", e));
this.video.play().catch((e) => console.warn('Play failed:', e));
}
pause(): void {

View File

@@ -1 +1 @@
export { NativeAdapter } from "./Native";
export { NativeAdapter } from './Native';

View File

@@ -5,9 +5,9 @@
* creation: 21/4/2026
*/
import { NativeAdapter } from "../adapters";
import { AdapterAPI, PlayerConfig } from "../types/index";
import { BaseUI } from "../ui";
import { NativeAdapter } from '../adapters';
import { AdapterAPI, PlayerConfig } from '../types/index';
import { BaseUI } from '../ui';
export class VP {
private video: HTMLVideoElement;
@@ -24,10 +24,10 @@ export class VP {
this.config = config;
this.video = this.videoElement(video);
this.videoSrc = this.video?.querySelectorAll<HTMLSourceElement>("source");
this.videoSrc = this.video?.querySelectorAll<HTMLSourceElement>('source');
if (!this.config.type) {
throw new Error("Type not specified in config.");
throw new Error('Type not specified in config.');
}
this.adapter = this.adapterInit(this.config.type);
@@ -65,17 +65,17 @@ https://git.db123.ir/db/VideoPlayer
return videoEl;
}
private adapterInit(type: string = "native"): AdapterAPI {
private adapterInit(type: string = 'native'): AdapterAPI {
switch (type) {
case "native": {
case 'native': {
return new NativeAdapter(this.video);
}
case "hls": {
case 'hls': {
throw new Error(`Adapter not implemented: ${type}`);
}
case "dash": {
case 'dash': {
throw new Error(`Adapter not implemented: ${type}`);
}

View File

@@ -1 +1 @@
export { VP } from "./VideoPlayer";
export { VP } from './VideoPlayer';

View File

@@ -1 +1 @@
export { EventManager } from "./EventManager";
export { EventManager } from './EventManager';

View File

@@ -5,8 +5,8 @@
* creation: 24/4/2026
*/
import { VP } from "../core";
import { EventManager } from "../events";
import { VP } from '../core';
import { EventManager } from '../events';
export class BaseUI {
private player: VP;
@@ -18,7 +18,7 @@ export class BaseUI {
private originalParent!: Node;
private nextSibling: ChildNode | null = null;
constructor(player: VP, video: HTMLVideoElement, prefixClass: string = "vp") {
constructor(player: VP, video: HTMLVideoElement, prefixClass: string = 'vp') {
this.player = player;
this.video = video;
this.prefixClass = prefixClass;
@@ -28,10 +28,10 @@ export class BaseUI {
}
private build(): void {
const wrapper = document.createElement("div");
wrapper.className = this.prefixClass + "-wrapper";
const controlsWrap = document.createElement("div");
controlsWrap.className = this.prefixClass + "-controls";
const wrapper = document.createElement('div');
wrapper.className = this.prefixClass + '-wrapper';
const controlsWrap = document.createElement('div');
controlsWrap.className = this.prefixClass + '-controls';
const videoParent = this.video.parentNode;
if (!videoParent) {
@@ -58,19 +58,19 @@ export class BaseUI {
}
private createPlayButton(): void {
const playButton = document.createElement("button");
playButton.className = this.prefixClass + "-playButton";
const playButton = document.createElement('button');
playButton.className = this.prefixClass + '-playButton';
if (this.video.paused) {
playButton.innerText = "play";
playButton.innerText = 'play';
} else {
playButton.innerText = "pause";
playButton.innerText = 'pause';
}
this.events.add(this.video, "play", function (): void {
playButton.innerText = "pause";
this.events.add(this.video, 'play', function (): void {
playButton.innerText = 'pause';
});
this.events.add(this.video, "pause", function (): void {
playButton.innerText = "play";
this.events.add(this.video, 'pause', function (): void {
playButton.innerText = 'play';
});
playButton.onclick = (): void => {

View File

@@ -1 +1 @@
export { BaseUI } from "./BaseUI";
export { BaseUI } from './BaseUI';