mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 00:31:20 -08:00
fix(vast): [PKG-VAST-03] preserve npm initialization with explicit workspace mode
This commit is contained in:
1 parent
314a1c3163
commit
c162d2b3b3
27 files changed
+13189
-191
No files matched your search
@@ -1,9 +1,13 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
import type { Callback, Result } from './types'
|
||||
import type { Callback, CompatibilityOptions, Result } from './types'
|
||||
import { loadImaSdk } from './sdk'
|
||||
import { createSession } from './session'
|
||||
|
||||
function artplayerPluginVast(callback?: Callback) {
|
||||
function artplayerPluginVast(callback?: Callback, options: CompatibilityOptions = {}) {
|
||||
const compatibility = options.compatibility
|
||||
if (compatibility !== undefined && compatibility !== 'workspace-1.2')
|
||||
throw new TypeError('Unsupported VAST compatibility mode')
|
||||
const workspaceMode = compatibility === 'workspace-1.2'
|
||||
return async (art: Artplayer): Promise<Result> => {
|
||||
let disposed = false
|
||||
let session: ReturnType<typeof createSession> | undefined
|
||||
@@ -28,11 +32,16 @@ function artplayerPluginVast(callback?: Callback) {
|
||||
if (closed())
|
||||
return result
|
||||
const utils = (art.constructor as typeof Artplayer).utils
|
||||
session = createSession(art, ima, utils, closed)
|
||||
session = createSession(art, ima, utils, closed, workspaceMode)
|
||||
if (closed()) {
|
||||
dispose()
|
||||
return result
|
||||
}
|
||||
if (!workspaceMode) {
|
||||
session.context.init()
|
||||
if (closed())
|
||||
return result
|
||||
}
|
||||
if (typeof callback === 'function')
|
||||
await callback(session.context)
|
||||
return result
|
||||
|
||||
Reference in new issue
Block a user