PHP 7.4.33
Preview: RCTLogBox.mm Size: 3.02 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-native/React/CoreModules/RCTLogBox.mm
/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#import "RCTLogBox.h"

#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <React/RCTBridge.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTLog.h>
#import <React/RCTRedBoxSetEnabled.h>
#import <React/RCTSurface.h>
#import "CoreModulesPlugins.h"

#if RCT_DEV_MENU

@interface RCTLogBox () <NativeLogBoxSpec, RCTBridgeModule>
@end

@implementation RCTLogBox {
  RCTLogBoxView *_view;
  __weak id<RCTSurfacePresenterStub> _bridgelessSurfacePresenter;
}

@synthesize bridge = _bridge;

RCT_EXPORT_MODULE()

+ (BOOL)requiresMainQueueSetup
{
  return YES;
}

- (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
{
  _bridgelessSurfacePresenter = surfacePresenter;
}

RCT_EXPORT_METHOD(show)
{
  if (RCTRedBoxGetEnabled()) {
    __weak RCTLogBox *weakSelf = self;
    dispatch_async(dispatch_get_main_queue(), ^{
      __strong RCTLogBox *strongSelf = weakSelf;
      if (!strongSelf) {
        return;
      }

      if (strongSelf->_view) {
        [strongSelf->_view show];
        return;
      }

      if (strongSelf->_bridgelessSurfacePresenter) {
        strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
                                                 surfacePresenter:strongSelf->_bridgelessSurfacePresenter];
        [strongSelf->_view show];
      } else if (strongSelf->_bridge && strongSelf->_bridge.valid) {
        if (strongSelf->_bridge.surfacePresenter) {
          strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
                                                   surfacePresenter:strongSelf->_bridge.surfacePresenter];
        } else {
          strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow() bridge:strongSelf->_bridge];
        }
        [strongSelf->_view show];
      }
    });
  }
}

RCT_EXPORT_METHOD(hide)
{
  if (RCTRedBoxGetEnabled()) {
    __weak RCTLogBox *weakSelf = self;
    dispatch_async(dispatch_get_main_queue(), ^{
      __strong RCTLogBox *strongSelf = weakSelf;
      if (!strongSelf) {
        return;
      }
      [strongSelf->_view setHidden:YES];
      strongSelf->_view = nil;
    });
  }
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
    (const facebook::react::ObjCTurboModule::InitParams &)params
{
  return std::make_shared<facebook::react::NativeLogBoxSpecJSI>(params);
}

- (void)setRCTLogBoxView:(RCTLogBoxView *)view
{
  self->_view = view;
}

@end

#else // Disabled

@interface RCTLogBox () <NativeLogBoxSpec>
@end

@implementation RCTLogBox

+ (NSString *)moduleName
{
  return nil;
}

- (void)show
{
  // noop
}

- (void)hide
{
  // noop
}

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
    (const facebook::react::ObjCTurboModule::InitParams &)params
{
  return std::make_shared<facebook::react::NativeLogBoxSpecJSI>(params);
}
@end

#endif

Class RCTLogBoxCls(void)
{
  return RCTLogBox.class;
}

Directory Contents

Dirs: 1 × Files: 57
Name Size Perms Modified Actions
- drwxr-xr-x 2025-03-28 11:04:43
Edit Download
2.08 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.79 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
563 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.40 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
17.27 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
313 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
11.61 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
354 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.34 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
560 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
7.79 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
747 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
4.75 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
273 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
3.97 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
285 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.10 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
305 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
10.95 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
360 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
9.44 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
2.81 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
19.67 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
3.39 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
18.50 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
287 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.66 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
557 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
7.44 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
1.87 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
6.37 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
618 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
3.05 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
418 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.31 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
281 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
4.42 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
355 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
3.02 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
665 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
2.39 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
15.07 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
319 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
2.71 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
2.16 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
27.56 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
321 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
988 B lrw-r--r-- 2025-03-28 11:04:43
Edit Download
481 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
6.00 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
1.03 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
12.10 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
448 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
9.24 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
1.07 KB lrw-r--r-- 2025-03-28 11:04:41
Edit Download
6.25 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
3.01 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).