11
11
12
12
const BatchedBridge = require ( '../BatchedBridge/BatchedBridge' ) ;
13
13
const BugReporting = require ( '../BugReporting/BugReporting' ) ;
14
- const NativeModules = require ( '../BatchedBridge/NativeModules' ) ;
15
14
const ReactNative = require ( '../Renderer/shims/ReactNative' ) ;
16
15
const SceneTracker = require ( '../Utilities/SceneTracker' ) ;
17
16
@@ -21,6 +20,8 @@ const renderApplication = require('./renderApplication');
21
20
const createPerformanceLogger = require ( '../Utilities/createPerformanceLogger' ) ;
22
21
import type { IPerformanceLogger } from '../Utilities/createPerformanceLogger' ;
23
22
23
+ import NativeHeadlessJsTaskSupport from './NativeHeadlessJsTaskSupport' ;
24
+
24
25
type Task = ( taskData : any ) => Promise < void > ;
25
26
type TaskProvider = ( ) => Task ;
26
27
type TaskCanceller = ( ) => void ;
@@ -261,16 +262,22 @@ const AppRegistry = {
261
262
const taskProvider = taskProviders . get ( taskKey ) ;
262
263
if ( ! taskProvider ) {
263
264
console . warn ( `No task registered for key ${taskKey } `) ;
264
- NativeModules . HeadlessJsTaskSupport . notifyTaskFinished ( taskId ) ;
265
+ if ( NativeHeadlessJsTaskSupport ) {
266
+ NativeHeadlessJsTaskSupport . notifyTaskFinished ( taskId ) ;
267
+ }
265
268
return ;
266
269
}
267
270
taskProvider ( ) ( data )
268
- . then ( ( ) =>
269
- NativeModules . HeadlessJsTaskSupport . notifyTaskFinished ( taskId ) ,
270
- )
271
+ . then ( ( ) => {
272
+ if ( NativeHeadlessJsTaskSupport ) {
273
+ NativeHeadlessJsTaskSupport . notifyTaskFinished ( taskId ) ;
274
+ }
275
+ } )
271
276
. catch ( reason => {
272
277
console . error ( reason ) ;
273
- NativeModules . HeadlessJsTaskSupport . notifyTaskFinished ( taskId ) ;
278
+ if ( NativeHeadlessJsTaskSupport ) {
279
+ NativeHeadlessJsTaskSupport . notifyTaskFinished ( taskId ) ;
280
+ }
274
281
} ) ;
275
282
} ,
276
283
0 commit comments