@@ -12,6 +12,10 @@ var LibraryBrowser = {
12
12
'$safeSetTimeout' ,
13
13
'$warnOnce' ,
14
14
'emscripten_set_main_loop_timing' ,
15
+ '$preloadPlugins' ,
16
+ #if MAIN_MODULE
17
+ '$preloadedWasm' ,
18
+ #endif
15
19
] ,
16
20
$Browser__postset : `
17
21
// exports
@@ -25,9 +29,6 @@ var LibraryBrowser = {
25
29
Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };
26
30
Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() };
27
31
Module["createContext"] = function Module_createContext(canvas, useWebGL, setInModule, webGLContextAttributes) { return Browser.createContext(canvas, useWebGL, setInModule, webGLContextAttributes) };
28
- #if MAIN_MODULE
29
- var preloadedWasm = {};
30
- #endif
31
32
var preloadedImages = {};
32
33
var preloadedAudios = {};` ,
33
34
@@ -101,13 +102,11 @@ var LibraryBrowser = {
101
102
workers : [ ] ,
102
103
103
104
init : function ( ) {
104
- if ( ! Module [ "preloadPlugins" ] ) Module [ "preloadPlugins" ] = [ ] ; // needs to exist even in workers
105
-
106
105
if ( Browser . initted ) return ;
107
106
Browser . initted = true ;
108
107
109
108
// Support for plugins that can process preloaded files. You can add more of these to
110
- // your app by creating and appending to Module. preloadPlugins.
109
+ // your app by creating and appending to preloadPlugins.
111
110
//
112
111
// Each plugin is asked if it can handle a file based on the file's name. If it can,
113
112
// it is given the file's raw data. When it is done, it calls a callback with the file's
@@ -146,7 +145,7 @@ var LibraryBrowser = {
146
145
} ;
147
146
img . src = url ;
148
147
} ;
149
- Module [ ' preloadPlugins' ] . push ( imagePlugin ) ;
148
+ preloadPlugins . push ( imagePlugin ) ;
150
149
151
150
var audioPlugin = { } ;
152
151
audioPlugin [ 'canHandle' ] = function audioPlugin_canHandle ( name ) {
@@ -209,34 +208,7 @@ var LibraryBrowser = {
209
208
finish ( audio ) ; // try to use it even though it is not necessarily ready to play
210
209
} , 10000 ) ;
211
210
} ;
212
- Module [ 'preloadPlugins' ] . push ( audioPlugin ) ;
213
-
214
- #if MAIN_MODULE
215
- // Use string keys here to avoid minification since the plugin consumer
216
- // also uses string keys.
217
- var wasmPlugin = {
218
- 'promiseChainEnd' : Promise . resolve ( ) ,
219
- 'canHandle' : function ( name ) {
220
- return ! Module . noWasmDecoding && name . endsWith ( '.so' )
221
- } ,
222
- 'handle' : function ( byteArray , name , onload , onerror ) {
223
- // loadWebAssemblyModule can not load modules out-of-order, so rather
224
- // than just running the promises in parallel, this makes a chain of
225
- // promises to run in series.
226
- wasmPlugin [ 'promiseChainEnd' ] = wasmPlugin [ 'promiseChainEnd' ] . then (
227
- ( ) => loadWebAssemblyModule ( byteArray , { loadAsync : true , nodelete : true } ) ) . then (
228
- ( module ) => {
229
- preloadedWasm [ name ] = module ;
230
- onload ( ) ;
231
- } ,
232
- ( err ) => {
233
- console . warn ( "Couldn't instantiate wasm: " + name + " '" + err + "'" ) ;
234
- onerror ( ) ;
235
- } ) ;
236
- }
237
- } ;
238
- Module [ 'preloadPlugins' ] . push ( wasmPlugin ) ;
239
- #endif // MAIN_MODULE
211
+ preloadPlugins . push ( audioPlugin ) ;
240
212
241
213
// Canvas event setup
242
214
@@ -279,23 +251,6 @@ var LibraryBrowser = {
279
251
}
280
252
} ,
281
253
282
- // Tries to handle an input byteArray using preload plugins. Returns true if
283
- // it was handled.
284
- handledByPreloadPlugin : function ( byteArray , fullname , finish , onerror ) {
285
- // Ensure plugins are ready.
286
- Browser . init ( ) ;
287
-
288
- var handled = false ;
289
- Module [ 'preloadPlugins' ] . forEach ( ( plugin ) => {
290
- if ( handled ) return ;
291
- if ( plugin [ 'canHandle' ] ( fullname ) ) {
292
- plugin [ 'handle' ] ( byteArray , fullname , finish , onerror ) ;
293
- handled = true ;
294
- }
295
- } ) ;
296
- return handled ;
297
- } ,
298
-
299
254
createContext : function ( /** @type {HTMLCanvasElement } */ canvas , useWebGL , setInModule , webGLContextAttributes ) {
300
255
if ( useWebGL && Module . ctx && canvas == Module . canvas ) return Module . ctx ; // no need to recreate GL context if it's already been created for this canvas.
301
256
0 commit comments