mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 05:26:15 -08:00
refactor(tooling): [MOD-PLUGIN-01] generate typed plugins with safe output handling
This commit is contained in:
1 parent
07d5bfef2e
commit
28c7abb2bb
32 files changed
+958
-161
No files matched your search
@@ -0,0 +1,4 @@
|
||||
declare module '*.less?inline' {
|
||||
const css: string
|
||||
export default css
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
import style from './style.less?inline';
|
||||
|
||||
export default function {{export}}(option) {
|
||||
return (art) => {
|
||||
return {
|
||||
name: '{{export}}',
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof document !== 'undefined') {
|
||||
const id = 'artplayer-plugin-{{name}}';
|
||||
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)
|
||||
}
|
||||
}
|
||||
$style.textContent = style
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
import type { Option, Result } from '../types/api.js'
|
||||
import './stylesheet'
|
||||
|
||||
function {{export}}(_option: Option = {}) {
|
||||
return (_art: Artplayer): Result => ({ name: '{{export}}' })
|
||||
}
|
||||
|
||||
export default Object.assign({{export}}, { default: {{export}} })
|
||||
@@ -1,3 +1,3 @@
|
||||
.artplayer-plugin-{{name}} {
|
||||
//
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import css from './style.less?inline'
|
||||
|
||||
// The stylesheet belongs to the module, not individual player instances.
|
||||
if (typeof document !== 'undefined') {
|
||||
const id = 'artplayer-plugin-{{name}}'
|
||||
if (!document.getElementById(id)) {
|
||||
const style = document.createElement('style')
|
||||
style.id = id
|
||||
style.textContent = css
|
||||
;(document.head || document.documentElement).appendChild(style)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user