mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 08:01:20 -08:00
refactor(jassub): [PKG-JASSUB-03] isolate registration and fix adapter cleanup
This commit is contained in:
1 parent
944e2cc9d0
commit
38e7b37878
21 files changed
+6553
-70
No files matched your search
@@ -141,6 +141,12 @@ export function jassubEnvironment(implementation, { script = false, simd = false
|
||||
listeners.set(name, [])
|
||||
listeners.get(name).push(callback)
|
||||
return art
|
||||
}, off(name, callback) {
|
||||
const callbacks = listeners.get(name)
|
||||
const index = callbacks?.indexOf(callback) ?? -1
|
||||
if (index >= 0)
|
||||
callbacks.splice(index, 1)
|
||||
return art
|
||||
} }
|
||||
const emit = name => listeners.get(name)?.forEach(callback => callback())
|
||||
const flush = async () => {
|
||||
@@ -154,5 +160,5 @@ export function jassubEnvironment(implementation, { script = false, simd = false
|
||||
workers.at(-1).onmessage({ data: { target: 'ready' } })
|
||||
await flush()
|
||||
}
|
||||
return { factory, exported, art, workers, parent, errors, listeners, emit, ready, flush, createVideo: () => parent.appendChild(new Video()) }
|
||||
return { factory, exported, art, workers, parent, errors, listeners, emit, ready, flush, createVideo: () => parent.appendChild(new Video()), createCanvas: () => new Canvas() }
|
||||
}
|
||||
Reference in new issue
Block a user