react-native-stallion 2.3.0-alpha.3 → 2.3.0-alpha.5
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/android/build.gradle +25 -0
- package/android/src/main/cpp/CMakeLists.txt +19 -0
- package/android/src/main/cpp/stallion_signal_handler.cpp +62 -0
- package/android/src/main/java/com/stallion/Stallion.java +0 -2
- package/android/src/main/java/com/stallion/StallionModule.java +37 -1
- package/android/src/main/java/com/stallion/events/StallionEventConstants.java +1 -0
- package/android/src/main/java/com/stallion/events/StallionEventManager.java +23 -15
- package/android/src/main/java/com/stallion/networkmanager/StallionFileDownloader.java +8 -5
- package/android/src/main/java/com/stallion/networkmanager/StallionSyncHandler.java +18 -1
- package/android/src/main/java/com/stallion/storage/StallionConfig.java +0 -2
- package/android/src/main/java/com/stallion/storage/StallionMeta.java +52 -1
- package/android/src/main/java/com/stallion/storage/StallionStateManager.java +22 -1
- package/android/src/main/java/com/stallion/utils/StallionDeviceInfo.java +83 -0
- package/android/src/main/java/com/stallion/utils/StallionExceptionHandler.java +84 -7
- package/ios/Stallion.xcodeproj/project.pbxproj +6 -0
- package/ios/main/Stallion.swift +20 -0
- package/ios/main/StallionConstants.swift +1 -0
- package/ios/main/StallionDeviceInfo.swift +105 -0
- package/ios/main/StallionEventHandler.m +3 -1
- package/ios/main/StallionExceptionHandler.h +1 -0
- package/ios/main/StallionExceptionHandler.mm +293 -0
- package/ios/main/StallionFileDownloader.swift +9 -1
- package/ios/main/StallionMeta.h +11 -0
- package/ios/main/StallionMeta.m +76 -1
- package/ios/main/StallionSlotManager.m +1 -1
- package/ios/main/StallionSyncHandler.swift +14 -2
- package/package.json +1 -1
- package/react-native-stallion.podspec +22 -0
- package/src/main/components/modules/listing/components/BundleCardInfoSection.js +1 -1
- package/src/main/components/modules/listing/components/styles/index.js +18 -13
- package/src/main/components/modules/listing/components/styles/index.js.map +1 -1
- package/src/main/components/modules/listing/index.js +15 -15
- package/src/main/components/modules/listing/index.js.map +1 -1
- package/src/main/components/modules/listing/styles.js +2 -1
- package/src/main/components/modules/listing/styles.js.map +1 -1
- package/src/main/components/modules/login/index.js +8 -5
- package/src/main/components/modules/login/index.js.map +1 -1
- package/src/main/components/modules/login/styles/index.js +10 -4
- package/src/main/components/modules/login/styles/index.js.map +1 -1
- package/src/main/components/modules/modal/StallionModal.js +2 -2
- package/src/main/components/modules/modal/StallionModal.js.map +1 -1
- package/src/main/components/modules/prod/prod.js +5 -4
- package/src/main/components/modules/prod/prod.js.map +1 -1
- package/src/main/components/modules/prod/styles/index.js +7 -4
- package/src/main/components/modules/prod/styles/index.js.map +1 -1
- package/src/main/constants/appConstants.js +1 -0
- package/src/main/constants/appConstants.js.map +1 -1
- package/src/main/state/actionCreators/useUpdateMetaActions.js +2 -2
- package/src/main/state/actionCreators/useUpdateMetaActions.js.map +1 -1
- package/src/main/state/index.js +5 -3
- package/src/main/state/index.js.map +1 -1
- package/src/main/state/reducers/updateMetaReducer.js +8 -0
- package/src/main/state/reducers/updateMetaReducer.js.map +1 -1
- package/src/main/state/useStallionEvents.js +27 -4
- package/src/main/state/useStallionEvents.js.map +1 -1
- package/src/main/utils/ErrorBoundary.js +35 -9
- package/src/main/utils/ErrorBoundary.js.map +1 -1
- package/src/main/utils/crashState.js +16 -0
- package/src/main/utils/crashState.js.map +1 -0
- package/src/main/utils/useStallionUpdate.js +2 -2
- package/src/main/utils/useStallionUpdate.js.map +1 -1
- package/src/main/utils/withStallion.js +4 -2
- package/src/main/utils/withStallion.js.map +1 -1
- package/src/types/updateMeta.types.js +1 -0
- package/src/types/updateMeta.types.js.map +1 -1
- package/types/main/components/modules/listing/components/styles/index.d.ts +9 -4
- package/types/main/components/modules/listing/components/styles/index.d.ts.map +1 -1
- package/types/main/components/modules/listing/index.d.ts.map +1 -1
- package/types/main/components/modules/listing/styles.d.ts +1 -0
- package/types/main/components/modules/listing/styles.d.ts.map +1 -1
- package/types/main/components/modules/login/index.d.ts.map +1 -1
- package/types/main/components/modules/login/styles/index.d.ts +6 -0
- package/types/main/components/modules/login/styles/index.d.ts.map +1 -1
- package/types/main/components/modules/prod/prod.d.ts.map +1 -1
- package/types/main/components/modules/prod/styles/index.d.ts +5 -2
- package/types/main/components/modules/prod/styles/index.d.ts.map +1 -1
- package/types/main/constants/appConstants.d.ts +2 -0
- package/types/main/constants/appConstants.d.ts.map +1 -1
- package/types/main/index.d.ts +1 -1
- package/types/main/state/actionCreators/useUpdateMetaActions.d.ts.map +1 -1
- package/types/main/state/index.d.ts +4 -1
- package/types/main/state/index.d.ts.map +1 -1
- package/types/main/state/reducers/updateMetaReducer.d.ts +1 -0
- package/types/main/state/reducers/updateMetaReducer.d.ts.map +1 -1
- package/types/main/state/useStallionEvents.d.ts +4 -2
- package/types/main/state/useStallionEvents.d.ts.map +1 -1
- package/types/main/utils/ErrorBoundary.d.ts +1 -1
- package/types/main/utils/ErrorBoundary.d.ts.map +1 -1
- package/types/main/utils/crashState.d.ts +4 -0
- package/types/main/utils/crashState.d.ts.map +1 -0
- package/types/main/utils/useStallionUpdate.d.ts.map +1 -1
- package/types/main/utils/withStallion.d.ts +2 -1
- package/types/main/utils/withStallion.d.ts.map +1 -1
- package/types/types/updateMeta.types.d.ts +7 -2
- package/types/types/updateMeta.types.d.ts.map +1 -1
- package/types/types/utils.types.d.ts +1 -1
- package/types/types/utils.types.d.ts.map +1 -1
- package/ios/main/StallionExceptionHandler.m +0 -184
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// StallionExceptionHandler.m
|
|
3
|
-
// react-native-stallion
|
|
4
|
-
//
|
|
5
|
-
// Created by Thor963 on 29/01/25.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "StallionExceptionHandler.h"
|
|
9
|
-
#import "StallionStateManager.h"
|
|
10
|
-
#import "StallionEventHandler.h"
|
|
11
|
-
#import "StallionSlotManager.h"
|
|
12
|
-
#import "StallionMeta.h"
|
|
13
|
-
#import "StallionMetaConstants.h"
|
|
14
|
-
#import "StallionObjConstants.h"
|
|
15
|
-
#import <signal.h>
|
|
16
|
-
#import <execinfo.h>
|
|
17
|
-
|
|
18
|
-
// Forward declarations
|
|
19
|
-
void handleException(NSException *exception);
|
|
20
|
-
void handleSignal(int signal);
|
|
21
|
-
|
|
22
|
-
@implementation StallionExceptionHandler
|
|
23
|
-
|
|
24
|
-
NSUncaughtExceptionHandler *_defaultExceptionHandler;
|
|
25
|
-
BOOL exceptionAlertDismissed = FALSE;
|
|
26
|
-
|
|
27
|
-
+ (void)initExceptionHandler {
|
|
28
|
-
if (!_defaultExceptionHandler) {
|
|
29
|
-
_defaultExceptionHandler = NSGetUncaughtExceptionHandler();
|
|
30
|
-
}
|
|
31
|
-
NSSetUncaughtExceptionHandler(&handleException);
|
|
32
|
-
|
|
33
|
-
signal(SIGABRT, handleSignal);
|
|
34
|
-
signal(SIGILL, handleSignal);
|
|
35
|
-
signal(SIGSEGV, handleSignal);
|
|
36
|
-
signal(SIGFPE, handleSignal);
|
|
37
|
-
signal(SIGBUS, handleSignal);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@end
|
|
41
|
-
|
|
42
|
-
#pragma mark - Shared Rollback Logic
|
|
43
|
-
|
|
44
|
-
static void performStallionRollback(NSString *errorString) {
|
|
45
|
-
StallionStateManager *stateManager = [StallionStateManager sharedInstance];
|
|
46
|
-
StallionMeta *meta = stateManager.stallionMeta;
|
|
47
|
-
BOOL isAutoRollback = !stateManager.isMounted;
|
|
48
|
-
|
|
49
|
-
if (errorString.length > 900) {
|
|
50
|
-
errorString = [errorString substringToIndex:900];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (meta.switchState == SwitchStateProd) {
|
|
54
|
-
NSString *currentHash = [meta getActiveReleaseHash] ?: @"";
|
|
55
|
-
|
|
56
|
-
[[StallionEventHandler sharedInstance] cacheEvent:StallionObjConstants.exception_prod_event
|
|
57
|
-
eventPayload:@{
|
|
58
|
-
@"meta": errorString,
|
|
59
|
-
StallionObjConstants.release_hash_key: currentHash,
|
|
60
|
-
StallionObjConstants.is_auto_rollback_key: isAutoRollback ? @"true" : @"false"
|
|
61
|
-
}];
|
|
62
|
-
if (isAutoRollback) {
|
|
63
|
-
[StallionSlotManager rollbackProdWithAutoRollback:YES errorString:errorString];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
} else if (meta.switchState == SwitchStateStage) {
|
|
67
|
-
|
|
68
|
-
if(isAutoRollback) {
|
|
69
|
-
[StallionSlotManager rollbackStage];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
[[StallionEventHandler sharedInstance] cacheEvent:StallionObjConstants.exception_stage_event
|
|
73
|
-
eventPayload:@{
|
|
74
|
-
@"meta": errorString,
|
|
75
|
-
StallionObjConstants.release_hash_key: meta.stageNewHash,
|
|
76
|
-
StallionObjConstants.is_auto_rollback_key: isAutoRollback ? @"true" : @"false"
|
|
77
|
-
}];
|
|
78
|
-
|
|
79
|
-
if(!exceptionAlertDismissed) {
|
|
80
|
-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Stallion Exception Handler"
|
|
81
|
-
message:[NSString stringWithFormat:@"%@\n%@",
|
|
82
|
-
@"A crash occurred in the app. Build was rolled back. Check crash report below. Continue crash to invoke other exception handlers. \n \n",
|
|
83
|
-
errorString]
|
|
84
|
-
preferredStyle:UIAlertControllerStyleAlert];
|
|
85
|
-
|
|
86
|
-
[alert addAction:[UIAlertAction actionWithTitle:@"Continue Crash"
|
|
87
|
-
style:UIAlertActionStyleDefault
|
|
88
|
-
handler:^(UIAlertAction *action) {
|
|
89
|
-
exceptionAlertDismissed = TRUE;
|
|
90
|
-
}]];
|
|
91
|
-
|
|
92
|
-
UIApplication *app = [UIApplication sharedApplication];
|
|
93
|
-
UIViewController *rootViewController = app.delegate.window.rootViewController;
|
|
94
|
-
|
|
95
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
96
|
-
[rootViewController presentViewController:alert animated:YES completion:nil];
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
while (exceptionAlertDismissed == FALSE) {
|
|
100
|
-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (meta.switchState == SwitchStateProd) {
|
|
106
|
-
NSString *currentHash = [meta getActiveReleaseHash] ?: @"";
|
|
107
|
-
|
|
108
|
-
[[StallionEventHandler sharedInstance] cacheEvent:StallionObjConstants.exception_prod_event
|
|
109
|
-
eventPayload:@{
|
|
110
|
-
@"meta": errorString,
|
|
111
|
-
StallionObjConstants.release_hash_key: currentHash,
|
|
112
|
-
StallionObjConstants.is_auto_rollback_key: isAutoRollback ? @"true" : @"false"
|
|
113
|
-
}];
|
|
114
|
-
if (isAutoRollback) {
|
|
115
|
-
[StallionSlotManager rollbackProdWithAutoRollback:YES errorString:errorString];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
} else if (meta.switchState == SwitchStateStage) {
|
|
119
|
-
|
|
120
|
-
if(isAutoRollback) {
|
|
121
|
-
[StallionSlotManager rollbackStage];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
[[StallionEventHandler sharedInstance] cacheEvent:StallionObjConstants.exception_stage_event
|
|
125
|
-
eventPayload:@{
|
|
126
|
-
@"meta": errorString,
|
|
127
|
-
StallionObjConstants.release_hash_key: meta.stageNewHash,
|
|
128
|
-
StallionObjConstants.is_auto_rollback_key: isAutoRollback ? @"true" : @"false"
|
|
129
|
-
}];
|
|
130
|
-
|
|
131
|
-
if(!exceptionAlertDismissed) {
|
|
132
|
-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Stallion Exception Handler"
|
|
133
|
-
message:[NSString stringWithFormat:@"%@\n%@",
|
|
134
|
-
@"A crash occurred in the app. Build was rolled back. Check crash report below. Continue crash to invoke other exception handlers.\n\n",
|
|
135
|
-
errorString]
|
|
136
|
-
preferredStyle:UIAlertControllerStyleAlert];
|
|
137
|
-
|
|
138
|
-
[alert addAction:[UIAlertAction actionWithTitle:@"Continue Crash"
|
|
139
|
-
style:UIAlertActionStyleDefault
|
|
140
|
-
handler:^(UIAlertAction *action) {
|
|
141
|
-
exceptionAlertDismissed = TRUE;
|
|
142
|
-
}]];
|
|
143
|
-
|
|
144
|
-
UIApplication *app = [UIApplication sharedApplication];
|
|
145
|
-
UIViewController *rootViewController = app.delegate.window.rootViewController;
|
|
146
|
-
|
|
147
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
148
|
-
[rootViewController presentViewController:alert animated:YES completion:nil];
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
while (exceptionAlertDismissed == FALSE) {
|
|
152
|
-
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
void handleException(NSException *exception) {
|
|
159
|
-
NSString *readableError = [exception reason] ?: @"Unknown exception";
|
|
160
|
-
performStallionRollback(readableError);
|
|
161
|
-
|
|
162
|
-
// Call default exception handler if available
|
|
163
|
-
if (_defaultExceptionHandler) {
|
|
164
|
-
_defaultExceptionHandler(exception);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
void handleSignal(int signalVal) {
|
|
169
|
-
void *callstack[128];
|
|
170
|
-
int frames = backtrace(callstack, 128);
|
|
171
|
-
char **symbols = backtrace_symbols(callstack, frames);
|
|
172
|
-
|
|
173
|
-
NSMutableString *stackTrace = [NSMutableString stringWithFormat:@"Signal %d was raised.\n", signalVal];
|
|
174
|
-
for (int i = 0; i < frames; ++i) {
|
|
175
|
-
[stackTrace appendFormat:@"%s\n", symbols[i]];
|
|
176
|
-
}
|
|
177
|
-
free(symbols);
|
|
178
|
-
|
|
179
|
-
performStallionRollback(stackTrace);
|
|
180
|
-
|
|
181
|
-
// Restore default and raise to proceed with crash
|
|
182
|
-
signal(signalVal, SIG_DFL);
|
|
183
|
-
raise(signalVal);
|
|
184
|
-
}
|