PHP 7.4.33
Preview: DevSettings.js Size: 2.35 KB
/var/www/uibuilder.cmshelp.dk/httpdocs/node_modules/react-native/Libraries/Utilities/DevSettings.js
/**
 * 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.
 *
 * @flow strict-local
 * @format
 */

import type {EventSubscription} from '../vendor/emitter/EventEmitter';

import NativeEventEmitter from '../EventEmitter/NativeEventEmitter';
import NativeDevSettings from '../NativeModules/specs/NativeDevSettings';
import Platform from '../Utilities/Platform';

let DevSettings: {
  addMenuItem(title: string, handler: () => mixed): void,
  reload(reason?: string): void,
  onFastRefresh(): void,
} = {
  addMenuItem(title: string, handler: () => mixed): void {},
  reload(reason?: string): void {},
  onFastRefresh(): void {},
};

type DevSettingsEventDefinitions = {
  didPressMenuItem: [{title: string}],
};

if (__DEV__) {
  const emitter = new NativeEventEmitter<DevSettingsEventDefinitions>(
    // T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
    // If you want to use the native module on other platforms, please remove this condition and test its behavior
    Platform.OS !== 'ios' ? null : NativeDevSettings,
  );
  const subscriptions = new Map<string, EventSubscription>();

  DevSettings = {
    addMenuItem(title: string, handler: () => mixed): void {
      // Make sure items are not added multiple times. This can
      // happen when hot reloading the module that registers the
      // menu items. The title is used as the id which means we
      // don't support multiple items with the same name.
      let subscription = subscriptions.get(title);
      if (subscription != null) {
        subscription.remove();
      } else {
        NativeDevSettings.addMenuItem(title);
      }

      subscription = emitter.addListener('didPressMenuItem', event => {
        if (event.title === title) {
          handler();
        }
      });
      subscriptions.set(title, subscription);
    },
    reload(reason?: string): void {
      if (NativeDevSettings.reloadWithReason != null) {
        NativeDevSettings.reloadWithReason(reason ?? 'Uncategorized from JS');
      } else {
        NativeDevSettings.reload();
      }
    },
    onFastRefresh(): void {
      NativeDevSettings.onFastRefresh?.();
    },
  };
}

module.exports = DevSettings;

Directory Contents

Dirs: 2 × Files: 53
Name Size Perms Modified Actions
differ DIR
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
__mocks__ DIR
- drwxr-xr-x 2025-03-28 11:04:42
Edit Download
1.69 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
4.16 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.67 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.06 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
769 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
503 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
902 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
830 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.51 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
6.89 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
441 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.67 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.73 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
315 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.48 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
897 B lrw-r--r-- 2025-03-28 11:04:43
Edit Download
2.35 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.54 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
4.08 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
521 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.01 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
824 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
10.51 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
742 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
443 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.42 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
1.42 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
760 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
721 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
407 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
402 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
418 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
458 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
442 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.04 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.09 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
4.21 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.24 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.31 KB lrw-r--r-- 2025-03-28 11:04:43
Edit Download
2.21 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
2.45 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
304 B lrw-r--r-- 2025-03-28 11:04:41
Edit Download
1.70 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.35 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
7.26 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
899 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
3.72 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
466 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
701 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.84 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.39 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
1.37 KB lrw-r--r-- 2025-03-28 11:04:42
Edit Download
732 B lrw-r--r-- 2025-03-28 11:04:42
Edit Download
If ZipArchive is unavailable, a .tar will be created (no compression).