1 // Copyright 2015-present 650 Industries. All rights reserved.
2 //
3 //  Keeps track of experience error state, including between reloads, so that we can
4 //  pass error recovery info to an experience which just reloaded.
5 //
6 
7 #import "EXKernelService.h"
8 
9 @protocol EXErrorRecoveryScopedModuleDelegate
10 
11 - (void)setDeveloperInfo:(NSDictionary *)developerInfo forScopedModule:(id)scopedModule;
12 
13 @end
14 
15 @class EXKernelAppRecord;
16 
17 @interface EXErrorRecoveryManager : NSObject
18   <EXKernelService, EXErrorRecoveryScopedModuleDelegate>
19 
20 /**
21  *  Associate arbitrary developer info with this experience id. If the experience recovers from an
22  *  error, we can pass this info to the new instance of the experience.
23  */
24 - (void)setDeveloperInfo:(NSDictionary *)developerInfo forScopeKey:(NSString *)scopeKey;
25 - (NSDictionary *)developerInfoForScopeKey: (NSString *)scopeKey;
26 
27 /**
28  *  Associate an error with an experience id. This will never be cleared until the next
29  *  call to `experienceFinishedLoadingWithId:`.
30  */
31 - (void)setError: (NSError *)error forScopeKey:(NSString *)scopeKey;
32 
33 /**
34  *  Indicate that a JS bundle has successfully loaded for this experience.
35  */
36 - (void)experienceFinishedLoadingWithScopeKey:(NSString *)scopeKey;
37 
38 /**
39  *  True if any bridge for this experience had an error, and has not successfully loaded
40  *  since the error was reported.
41  */
42 - (BOOL)scopeKeyIsRecoveringFromError:(NSString *)scopeKey;
43 
44 /**
45  *  True if this error object (by `isEqual:`) has been registered for any experience.
46  */
47 - (BOOL)errorBelongsToExperience:(NSError *)error;
48 
49 /**
50  *  Returns any existing app record for this error. Since error state persists between reloads until cleared,
51  *  it's possible that there is no app record for this error.
52  */
53 - (EXKernelAppRecord *)appRecordForError: (NSError *)error;
54 
55 /**
56  *  Whether we want to auto-reload this experience if it encounters a fatal error.
57  */
58 - (BOOL)experienceShouldReloadOnError:(NSString *)scopeKey;
59 
60 /**
61  *  Back off to a less aggressive autoreload buffer time.
62  *  The longer the time, the longer a experience must wait before a fatal JS error triggers auto reload
63  *  via `experienceShouldReloadOnError:`.
64  */
65 - (void)increaseAutoReloadBuffer;
66 
67 @end
68