build all

Refactor utility functions for improved readability and consistency

- Updated compatibility.js to use consistent line endings and formatting.
- Refactored component.js for better readability and structure, including consistent use of arrow functions and binding.
- Simplified dom.js functions with consistent formatting and improved readability.
- Enhanced emitter.js with consistent formatting and arrow function usage.
- Streamlined error.js for improved readability and consistency.
- Refactored file.js to use consistent formatting and improved readability.
- Improved format.js functions for better readability and consistency.
- Updated index.js to maintain consistent export formatting.
- Refactored property.js for improved readability and consistency.
- Enhanced subtitle.js with consistent formatting and improved readability.
- Refactored time.js for better readability and consistent formatting.

fix: update lint script to target only source files for consistency

Revert "fix: restore export statements for various plugins and update type definitions for better clarity"

This reverts commit b5e969d81ec765cd8a34b06e6ef4f232ef25087f.

fix: restore export statements for various plugins and update type definitions for better clarity

Refactor type definitions to use interfaces instead of type aliases for better extensibility and clarity across i18n, icons, option, player, quality, setting, subtitle, template, and utils modules.
This commit is contained in:
Harvey Zack committed 2025-08-03 13:17:33 +08:00
1 parent 532dd67cfd
commit 35ad9883af
447 files changed
+18248 -17946

No files matched your search

+96 -92
View File
@@ -1,111 +1,115 @@
import { Player, PlayerOptions, loadImaSdk } from '@glomex/vast-ima-player';
import { loadImaSdk, Player, PlayerOptions } from '@glomex/vast-ima-player'
export default function artplayerPluginVast(callback) {
return async (art) => {
const { template, constructor } = art;
const { createElement, setStyles } = constructor.utils;
const { $video, $player } = template;
return async (art) => {
const { template, constructor } = art
const { createElement, setStyles } = constructor.utils
const { $video, $player } = template
await loadImaSdk();
const google = window.google;
const ima = google.ima;
await loadImaSdk()
const google = window.google
const ima = google.ima
const adsRenderingSettings = new ima.AdsRenderingSettings();
adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete = true;
adsRenderingSettings.enablePreloading = true;
const adsRenderingSettings = new ima.AdsRenderingSettings()
adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete = true
adsRenderingSettings.enablePreloading = true
const playerOptions = new PlayerOptions();
let isAdPlaying = false;
let imaPlayer = null;
let $container = null;
const playerOptions = new PlayerOptions()
let isAdPlaying = false
let imaPlayer = null
let $container = null
function createContainer() {
const container = createElement('div');
const id = `art-vast-${Date.now()}`;
container.id = id;
setStyles(container, {
position: 'absolute',
inset: '0',
width: '100%',
height: '100%',
zIndex: '150',
backgroundColor: 'black',
display: 'none',
pointerEvents: 'auto',
});
return container;
}
function createContainer() {
const container = createElement('div')
const id = `art-vast-${Date.now()}`
container.id = id
setStyles(container, {
position: 'absolute',
inset: '0',
width: '100%',
height: '100%',
zIndex: '150',
backgroundColor: 'black',
display: 'none',
pointerEvents: 'auto',
})
return container
}
function initPlayer() {
$container = createContainer();
$player.appendChild($container);
imaPlayer = new Player(ima, $video, $container, adsRenderingSettings, playerOptions);
function initPlayer() {
$container = createContainer()
$player.appendChild($container)
imaPlayer = new Player(ima, $video, $container, adsRenderingSettings, playerOptions)
// ✅ 事件绑定
imaPlayer.onAdStarted = () => {
isAdPlaying = true;
$container.style.display = 'block';
art.pause();
};
// ✅ 事件绑定
imaPlayer.onAdStarted = () => {
isAdPlaying = true
$container.style.display = 'block'
art.pause()
}
imaPlayer.onAdEnd = () => {
isAdPlaying = false;
$container.style.display = 'none';
art.play();
};
imaPlayer.onAdEnd = () => {
isAdPlaying = false
$container.style.display = 'none'
art.play()
}
imaPlayer.onAdError = (error) => {
console.error('VAST Ad Error:', error);
isAdPlaying = false;
$container.style.display = 'none';
art.play();
};
}
imaPlayer.onAdError = (error) => {
console.error('VAST Ad Error:', error)
isAdPlaying = false
$container.style.display = 'none'
art.play()
}
}
function destroyPlayer() {
if ($container && $container.parentNode) {
$container.parentNode.removeChild($container);
}
$container = null;
imaPlayer = null;
}
function destroyPlayer() {
if ($container && $container.parentNode) {
$container.parentNode.removeChild($container)
}
$container = null
imaPlayer = null
}
function playUrl(url) {
if (isAdPlaying) return;
if (!imaPlayer) initPlayer();
const request = new ima.AdsRequest();
request.adTagUrl = url;
imaPlayer.playAds(request);
}
function playUrl(url) {
if (isAdPlaying)
return
if (!imaPlayer)
initPlayer()
const request = new ima.AdsRequest()
request.adTagUrl = url
imaPlayer.playAds(request)
}
function playRes(res) {
if (isAdPlaying) return;
if (!imaPlayer) initPlayer();
const request = new ima.AdsRequest();
request.adsResponse = res;
imaPlayer.playAds(request);
}
function playRes(res) {
if (isAdPlaying)
return
if (!imaPlayer)
initPlayer()
const request = new ima.AdsRequest()
request.adsResponse = res
imaPlayer.playAds(request)
}
if (typeof callback === 'function') {
await callback({
art,
playUrl,
playRes,
ima,
imaPlayer,
get container() {
return $container;
},
});
}
if (typeof callback === 'function') {
await callback({
art,
playUrl,
playRes,
ima,
imaPlayer,
get container() {
return $container
},
})
}
return {
name: 'artplayerPluginVast',
destroy: destroyPlayer,
};
};
return {
name: 'artplayerPluginVast',
destroy: destroyPlayer,
}
}
}
if (typeof window !== 'undefined') {
window.artplayerPluginVast = artplayerPluginVast;
window.artplayerPluginVast = artplayerPluginVast
}