Refactor code structure for improved readability and maintainability

feat: add JASSUB type definitions and update common.js references

feat: add JASSUB plugin for advanced subtitle rendering in HTML5 video

- Implemented a new JASSUB class for handling subtitle rendering with options for video and canvas targets.
- Added support for both synchronous and asynchronous rendering modes.
- Integrated Web Worker for offloading rendering tasks, improving performance.
- Included methods for managing subtitle tracks, styles, and events.
- Added color space verification and handling to ensure accurate subtitle display.
- Implemented local font access for enhanced typography options in subtitles.
- Introduced a benchmarking feature to assess rendering performance.

refactor: update README and type definitions for artplayer-plugin-jassub

- Removed installation and usage instructions from README.md for clarity.
- Updated index.js to remove direct assignment of jassub instance to art.
- Enhanced type definitions in artplayer-plugin-jassub.d.ts to include detailed JassubOption and JassubInstance interfaces.
This commit is contained in:
Harvey Zhao committed 2026-01-03 18:56:06 +08:00
1 parent ce35026cb4
commit f4d99eb09e
27 files changed
+8315 -55

No files matched your search

+16 -22
View File
@@ -1,31 +1,25 @@
import style from 'bundle-text:./style.less';
import JASSUB from './jassub.es.js'
export default function artplayerPluginJassub(option) {
return (art) => {
return {
name: 'artplayerPluginJassub',
};
};
}
return (art) => {
const instance = new JASSUB({
video: art.video,
...option,
})
if (typeof document !== 'undefined') {
const id = 'artplayer-plugin-jassub';
let $style = document.getElementById(id)
if (!$style) {
$style = document.createElement('style')
$style.id = id
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
document.head.appendChild($style)
})
}
else {
(document.head || document.documentElement).appendChild($style)
instance._canvasParent.style.zIndex = 20
art.on('destroy', () => {
instance.destroy()
})
return {
name: 'artplayerPluginJassub',
instance,
}
}
$style.textContent = style
}
if (typeof window !== 'undefined') {
window.artplayerPluginJassub = artplayerPluginJassub;
window.artplayerPluginJassub = artplayerPluginJassub
}