@@ -235,34 +235,25 @@ RCTFatalExceptionHandler RCTGetFatalExceptionHandler(void)
235235// MARK: - New Architecture Validation - Enable Reporting
236236
237237#if RCT_ONLY_NEW_ARCHITECTURE
238- static RCTNotAllowedValidation validationReportingEnabled = RCTNotAllowedInBridgeless;
238+ static RCTNotAllowedValidation minValidationLevel = RCTNotAllowedInBridgeless;
239239#else
240- static RCTNotAllowedValidation validationReportingEnabled = RCTNotAllowedValidationDisabled;
240+ static RCTNotAllowedValidation minValidationLevel = RCTNotAllowedValidationDisabled;
241241#endif
242242
243- __attribute__ ((used)) RCT_EXTERN void RCTNewArchitectureValidationSetEnabled (RCTNotAllowedValidation type )
243+ __attribute__ ((used)) RCT_EXTERN void RCTNewArchitectureSetMinValidationLevel (RCTNotAllowedValidation level )
244244{
245245#if RCT_ONLY_NEW_ARCHITECTURE
246246 // Cannot disable the reporting in this mode.
247247#else
248- validationReportingEnabled = type ;
248+ minValidationLevel = level ;
249249#endif
250250}
251251
252252// MARK: - New Architecture Validation - Private
253253
254254static BOOL shouldEnforceValidation (RCTNotAllowedValidation type)
255255{
256- switch (type) {
257- case RCTNotAllowedInAppWideFabric:
258- return validationReportingEnabled == RCTNotAllowedInBridgeless ||
259- validationReportingEnabled == RCTNotAllowedInAppWideFabric;
260- case RCTNotAllowedInBridgeless:
261- return validationReportingEnabled == RCTNotAllowedInBridgeless;
262- case RCTNotAllowedValidationDisabled:
263- return NO ;
264- }
265- return NO ;
256+ return type >= minValidationLevel;
266257}
267258
268259static NSString *stringDescribingContext (id context)
@@ -284,7 +275,7 @@ static BOOL shouldEnforceValidation(RCTNotAllowedValidation type)
284275 switch (type) {
285276 case RCTNotAllowedValidationDisabled:
286277 RCTAssert (0 , @" RCTNotAllowedValidationDisabled not a validation type." );
287- break ;
278+ return nil ;
288279 case RCTNotAllowedInAppWideFabric:
289280 notAllowedType = @" Fabric" ;
290281 break ;
@@ -300,31 +291,55 @@ static BOOL shouldEnforceValidation(RCTNotAllowedValidation type)
300291 extra ?: @" " ];
301292}
302293
303- // MARK: - New Architecture Validation - Public
304-
305- void RCTEnforceNewArchitectureValidation (RCTNotAllowedValidation type, id context, NSString *extra)
294+ static void
295+ newArchitectureValidationInternal (RCTLogLevel level, RCTNotAllowedValidation type, id context, NSString *extra)
306296{
307297 if (!shouldEnforceValidation (type)) {
308298 return ;
309299 }
310300
311- RCTAssert (0 , @" %@ " , validationMessage (type, context, extra));
301+ NSString *msg = validationMessage (type, context, extra);
302+ if (msg) {
303+ switch (level) {
304+ case RCTLogLevelInfo:
305+ RCTLogInfo (@" %@ " , msg);
306+ break ;
307+ case RCTLogLevelError:
308+ RCTLogError (@" %@ " , msg);
309+ break ;
310+ case RCTLogLevelFatal:
311+ RCTAssert (0 , @" %@ " , msg);
312+ break ;
313+ default :
314+ RCTAssert (0 , @" New architecture validation is only for info, error, and fatal levels." );
315+ }
316+ }
312317}
313318
314- void RCTErrorNewArchitectureValidation (RCTNotAllowedValidation type, id context, NSString *extra)
319+ // MARK: - New Architecture Validation - Public
320+
321+ void RCTEnforceNewArchitectureValidation (RCTNotAllowedValidation type, id context, NSString *extra)
315322{
316- if (!shouldEnforceValidation (type)) {
317- return ;
318- }
323+ newArchitectureValidationInternal (RCTLogLevelFatal, type, context, extra);
324+ }
319325
320- RCTLogError (@" %@ " , validationMessage (type, context, extra));
326+ void RCTErrorNewArchitectureValidation (RCTNotAllowedValidation type, id context, NSString *extra)
327+ {
328+ #if RCT_ONLY_NEW_ARCHITECTURE
329+ newArchitectureValidationInternal (RCTLogLevelFatal, type, context, extra);
330+ #else
331+ newArchitectureValidationInternal (RCTLogLevelError, type, context, extra);
332+ #endif
321333}
322334
323335void RCTLogNewArchitectureValidation (RCTNotAllowedValidation type, id context, NSString *extra)
324336{
325- if (!shouldEnforceValidation (type)) {
326- return ;
327- }
337+ newArchitectureValidationInternal (RCTLogLevelInfo, type, context, extra);
338+ }
328339
329- RCTLogInfo (@" %@ " , validationMessage (type, context, extra));
340+ void RCTNewArchitectureValidationPlaceholder (RCTNotAllowedValidation type, id context, NSString *extra)
341+ {
342+ #if RCT_ONLY_NEW_ARCHITECTURE
343+ newArchitectureValidationInternal (RCTLogLevelInfo, type, context, extra);
344+ #endif
330345}
0 commit comments