jassub 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jassub",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "libass Subtitle Renderer and Parser library for browsers",
5
5
  "main": "src/jassub.js",
6
6
  "files": [
package/src/jassub.js CHANGED
@@ -84,38 +84,41 @@ export default class JASSUB extends EventTarget {
84
84
  this._worker.onmessage = e => this._onmessage(e)
85
85
  this._worker.onerror = e => this._error(e)
86
86
 
87
- this._worker.postMessage({
88
- target: 'init',
89
- asyncRender,
90
- onDemandRender: this._onDemandRender,
91
- width: this._canvasctrl.width,
92
- height: this._canvasctrl.height,
93
- preMain: true,
94
- blendMode,
95
- subUrl: options.subUrl,
96
- subContent: options.subContent || null,
97
- fonts: options.fonts || [],
98
- availableFonts: options.availableFonts || { 'liberation sans': './default.woff2' },
99
- fallbackFont: options.fallbackFont || 'liberation sans',
100
- debug: this.debug,
101
- targetFps: options.targetFps || 24,
102
- dropAllAnimations: options.dropAllAnimations,
103
- libassMemoryLimit: options.libassMemoryLimit || 0,
104
- libassGlyphLimit: options.libassGlyphLimit || 0,
105
- hasAlphaBug: JASSUB._hasAlphaBug,
106
- useLocalFonts: ('queryLocalFonts' in self) && (options.useLocalFonts ?? true)
107
- })
108
- if (offscreenRender === true) this.sendMessage('offscreenCanvas', null, [this._canvasctrl])
87
+ this._init = () => {
88
+ if (this._destroyed) return
89
+ this._worker.postMessage({
90
+ target: 'init',
91
+ asyncRender,
92
+ onDemandRender: this._onDemandRender,
93
+ width: this._canvasctrl.width,
94
+ height: this._canvasctrl.height,
95
+ preMain: true,
96
+ blendMode,
97
+ subUrl: options.subUrl,
98
+ subContent: options.subContent || null,
99
+ fonts: options.fonts || [],
100
+ availableFonts: options.availableFonts || { 'liberation sans': './default.woff2' },
101
+ fallbackFont: options.fallbackFont || 'liberation sans',
102
+ debug: this.debug,
103
+ targetFps: options.targetFps || 24,
104
+ dropAllAnimations: options.dropAllAnimations,
105
+ libassMemoryLimit: options.libassMemoryLimit || 0,
106
+ libassGlyphLimit: options.libassGlyphLimit || 0,
107
+ hasAlphaBug: JASSUB._hasAlphaBug,
108
+ useLocalFonts: ('queryLocalFonts' in self) && (options.useLocalFonts ?? true)
109
+ })
110
+ if (offscreenRender === true) this.sendMessage('offscreenCanvas', null, [this._canvasctrl])
109
111
 
110
- this._boundResize = this.resize.bind(this)
111
- this._boundTimeUpdate = this._timeupdate.bind(this)
112
- this._boundSetRate = this.setRate.bind(this)
113
- if (this._video) this.setVideo(options.video)
112
+ this._boundResize = this.resize.bind(this)
113
+ this._boundTimeUpdate = this._timeupdate.bind(this)
114
+ this._boundSetRate = this.setRate.bind(this)
115
+ if (this._video) this.setVideo(options.video)
114
116
 
115
- if (this._onDemandRender) {
116
- this.busy = false
117
- this._lastDemandTime = null
118
- this._video?.requestVideoFrameCallback(this._handleRVFC.bind(this))
117
+ if (this._onDemandRender) {
118
+ this.busy = false
119
+ this._lastDemandTime = null
120
+ this._video?.requestVideoFrameCallback(this._handleRVFC.bind(this))
121
+ }
119
122
  }
120
123
  }
121
124
 
@@ -582,6 +585,7 @@ export default class JASSUB extends EventTarget {
582
585
  }
583
586
 
584
587
  _ready () {
588
+ this._init()
585
589
  this.dispatchEvent(new CustomEvent('ready'))
586
590
  }
587
591