0) {
269 | println "android.packagingOptions.$prop += $options ($options.length)"
270 | // Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
271 | options.each {
272 | android.packagingOptions[prop] += it
273 | }
274 | }
275 | }
276 |
277 | dependencies {
278 | implementation fileTree(dir: "libs", include: ["*.jar"])
279 |
280 | //noinspection GradleDynamicVersion
281 | implementation "com.facebook.react:react-native:+" // From node_modules
282 |
283 | def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
284 | def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
285 | def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
286 | def frescoVersion = rootProject.ext.frescoVersion
287 |
288 | // If your app supports Android versions before Ice Cream Sandwich (API level 14)
289 | if (isGifEnabled || isWebpEnabled) {
290 | implementation "com.facebook.fresco:fresco:${frescoVersion}"
291 | implementation "com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}"
292 | }
293 |
294 | if (isGifEnabled) {
295 | // For animated gif support
296 | implementation "com.facebook.fresco:animated-gif:${frescoVersion}"
297 | }
298 |
299 | if (isWebpEnabled) {
300 | // For webp support
301 | implementation "com.facebook.fresco:webpsupport:${frescoVersion}"
302 | if (isWebpAnimatedEnabled) {
303 | // Animated webp support
304 | implementation "com.facebook.fresco:animated-webp:${frescoVersion}"
305 | }
306 | }
307 |
308 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
309 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
310 | exclude group:'com.facebook.fbjni'
311 | }
312 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
313 | exclude group:'com.facebook.flipper'
314 | exclude group:'com.squareup.okhttp3', module:'okhttp'
315 | }
316 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
317 | exclude group:'com.facebook.flipper'
318 | }
319 |
320 | if (enableHermes) {
321 | //noinspection GradleDynamicVersion
322 | implementation("com.facebook.react:hermes-engine:+") { // From node_modules
323 | exclude group:'com.facebook.fbjni'
324 | }
325 | } else {
326 | implementation jscFlavor
327 | }
328 | }
329 |
330 | if (isNewArchitectureEnabled()) {
331 | // If new architecture is enabled, we let you build RN from source
332 | // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
333 | // This will be applied to all the imported transtitive dependency.
334 | configurations.all {
335 | resolutionStrategy.dependencySubstitution {
336 | substitute(module("com.facebook.react:react-native"))
337 | .using(project(":ReactAndroid"))
338 | .because("On New Architecture we're building React Native from source")
339 | substitute(module("com.facebook.react:hermes-engine"))
340 | .using(project(":ReactAndroid:hermes-engine"))
341 | .because("On New Architecture we're building Hermes from source")
342 | }
343 | }
344 | }
345 |
346 | // Run this once to be able to run the application with BUCK
347 | // puts all compile dependencies into folder libs for BUCK to use
348 | task copyDownloadableDepsToLibs(type: Copy) {
349 | from configurations.implementation
350 | into 'libs'
351 | }
352 |
353 | apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
354 | applyNativeModulesAppBuildGradle(project)
355 |
356 | def isNewArchitectureEnabled() {
357 | // To opt-in for the New Architecture, you can either:
358 | // - Set `newArchEnabled` to true inside the `gradle.properties` file
359 | // - Invoke gradle with `-newArchEnabled=true`
360 | // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
361 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
362 | }
363 |
--------------------------------------------------------------------------------
/example/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/example/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/debug.keystore
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # react-native-reanimated
11 | -keep class com.swmansion.reanimated.** { *; }
12 | -keep class com.facebook.react.turbomodule.** { *; }
13 |
14 | # Add any project specific keep options here:
15 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/java/expo/modules/keys/example/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the LICENSE file in the root
5 | * directory of this source tree.
6 | */
7 | package expo.modules.keys.example;
8 |
9 | import android.content.Context;
10 | import com.facebook.flipper.android.AndroidFlipperClient;
11 | import com.facebook.flipper.android.utils.FlipperUtils;
12 | import com.facebook.flipper.core.FlipperClient;
13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22 | import com.facebook.react.ReactInstanceManager;
23 | import com.facebook.react.bridge.ReactContext;
24 | import com.facebook.react.modules.network.NetworkingModule;
25 | import okhttp3.OkHttpClient;
26 |
27 | public class ReactNativeFlipper {
28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29 | if (FlipperUtils.shouldEnableFlipper(context)) {
30 | final FlipperClient client = AndroidFlipperClient.getInstance(context);
31 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
32 | client.addPlugin(new ReactFlipperPlugin());
33 | client.addPlugin(new DatabasesFlipperPlugin(context));
34 | client.addPlugin(new SharedPreferencesFlipperPlugin(context));
35 | client.addPlugin(CrashReporterPlugin.getInstance());
36 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
37 | NetworkingModule.setCustomClientBuilder(
38 | new NetworkingModule.CustomClientBuilder() {
39 | @Override
40 | public void apply(OkHttpClient.Builder builder) {
41 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
42 | }
43 | });
44 | client.addPlugin(networkFlipperPlugin);
45 | client.start();
46 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
47 | // Hence we run if after all native modules have been initialized
48 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
49 | if (reactContext == null) {
50 | reactInstanceManager.addReactInstanceEventListener(
51 | new ReactInstanceManager.ReactInstanceEventListener() {
52 | @Override
53 | public void onReactContextInitialized(ReactContext reactContext) {
54 | reactInstanceManager.removeReactInstanceEventListener(this);
55 | reactContext.runOnNativeModulesQueueThread(
56 | new Runnable() {
57 | @Override
58 | public void run() {
59 | client.addPlugin(new FrescoFlipperPlugin());
60 | }
61 | });
62 | }
63 | });
64 | } else {
65 | client.addPlugin(new FrescoFlipperPlugin());
66 | }
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/expo/modules/keys/example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package expo.modules.keys.example;
2 |
3 | import android.os.Build;
4 | import android.os.Bundle;
5 |
6 | import com.facebook.react.ReactActivity;
7 | import com.facebook.react.ReactActivityDelegate;
8 | import com.facebook.react.ReactRootView;
9 |
10 | import expo.modules.ReactActivityDelegateWrapper;
11 |
12 | public class MainActivity extends ReactActivity {
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | // Set the theme to AppTheme BEFORE onCreate to support
16 | // coloring the background, status bar, and navigation bar.
17 | // This is required for expo-splash-screen.
18 | setTheme(R.style.AppTheme);
19 | super.onCreate(null);
20 | }
21 |
22 | /**
23 | * Returns the name of the main component registered from JavaScript.
24 | * This is used to schedule rendering of the component.
25 | */
26 | @Override
27 | protected String getMainComponentName() {
28 | return "main";
29 | }
30 |
31 | /**
32 | * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
33 | * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
34 | * (Paper).
35 | */
36 | @Override
37 | protected ReactActivityDelegate createReactActivityDelegate() {
38 | return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
39 | new MainActivityDelegate(this, getMainComponentName())
40 | );
41 | }
42 |
43 | /**
44 | * Align the back button behavior with Android S
45 | * where moving root activities to background instead of finishing activities.
46 | * @see onBackPressed
47 | */
48 | @Override
49 | public void invokeDefaultOnBackPressed() {
50 | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
51 | if (!moveTaskToBack(false)) {
52 | // For non-root activities, use the default implementation to finish them.
53 | super.invokeDefaultOnBackPressed();
54 | }
55 | return;
56 | }
57 |
58 | // Use the default back button implementation on Android S
59 | // because it's doing more than {@link Activity#moveTaskToBack} in fact.
60 | super.invokeDefaultOnBackPressed();
61 | }
62 |
63 | public static class MainActivityDelegate extends ReactActivityDelegate {
64 | public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
65 | super(activity, mainComponentName);
66 | }
67 |
68 | @Override
69 | protected ReactRootView createRootView() {
70 | ReactRootView reactRootView = new ReactRootView(getContext());
71 | // If you opted-in for the New Architecture, we enable the Fabric Renderer.
72 | reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
73 | return reactRootView;
74 | }
75 |
76 | @Override
77 | protected boolean isConcurrentRootEnabled() {
78 | // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
79 | // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
80 | return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/expo/modules/keys/example/MainApplication.java:
--------------------------------------------------------------------------------
1 | package expo.modules.keys.example;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.content.res.Configuration;
6 | import androidx.annotation.NonNull;
7 |
8 | import com.facebook.react.PackageList;
9 | import com.facebook.react.ReactApplication;
10 | import com.facebook.react.ReactInstanceManager;
11 | import com.facebook.react.ReactNativeHost;
12 | import com.facebook.react.ReactPackage;
13 | import com.facebook.react.config.ReactFeatureFlags;
14 | import com.facebook.soloader.SoLoader;
15 | import expo.modules.keys.example.newarchitecture.MainApplicationReactNativeHost;
16 |
17 | import expo.modules.ApplicationLifecycleDispatcher;
18 | import expo.modules.ReactNativeHostWrapper;
19 |
20 | import java.lang.reflect.InvocationTargetException;
21 | import java.util.List;
22 |
23 | public class MainApplication extends Application implements ReactApplication {
24 | private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
25 | this,
26 | new ReactNativeHost(this) {
27 | @Override
28 | public boolean getUseDeveloperSupport() {
29 | return BuildConfig.DEBUG;
30 | }
31 |
32 | @Override
33 | protected List getPackages() {
34 | @SuppressWarnings("UnnecessaryLocalVariable")
35 | List packages = new PackageList(this).getPackages();
36 | // Packages that cannot be autolinked yet can be added manually here, for example:
37 | // packages.add(new MyReactNativePackage());
38 | return packages;
39 | }
40 |
41 | @Override
42 | protected String getJSMainModuleName() {
43 | return "index";
44 | }
45 | });
46 |
47 | private final ReactNativeHost mNewArchitectureNativeHost =
48 | new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));
49 |
50 | @Override
51 | public ReactNativeHost getReactNativeHost() {
52 | if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
53 | return mNewArchitectureNativeHost;
54 | } else {
55 | return mReactNativeHost;
56 | }
57 | }
58 |
59 | @Override
60 | public void onCreate() {
61 | super.onCreate();
62 | // If you opted-in for the New Architecture, we enable the TurboModule system
63 | ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
64 | SoLoader.init(this, /* native exopackage */ false);
65 |
66 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
67 | ApplicationLifecycleDispatcher.onApplicationCreate(this);
68 | }
69 |
70 | @Override
71 | public void onConfigurationChanged(@NonNull Configuration newConfig) {
72 | super.onConfigurationChanged(newConfig);
73 | ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
74 | }
75 |
76 | /**
77 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like
78 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
79 | *
80 | * @param context
81 | * @param reactInstanceManager
82 | */
83 | private static void initializeFlipper(
84 | Context context, ReactInstanceManager reactInstanceManager) {
85 | if (BuildConfig.DEBUG) {
86 | try {
87 | /*
88 | We use reflection here to pick up the class that initializes Flipper,
89 | since Flipper library is not available in release mode
90 | */
91 | Class> aClass = Class.forName("expo.modules.keys.example.ReactNativeFlipper");
92 | aClass
93 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
94 | .invoke(null, context, reactInstanceManager);
95 | } catch (ClassNotFoundException e) {
96 | e.printStackTrace();
97 | } catch (NoSuchMethodException e) {
98 | e.printStackTrace();
99 | } catch (IllegalAccessException e) {
100 | e.printStackTrace();
101 | } catch (InvocationTargetException e) {
102 | e.printStackTrace();
103 | }
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/expo/modules/keys/example/newarchitecture/MainApplicationReactNativeHost.java:
--------------------------------------------------------------------------------
1 | package expo.modules.keys.example.newarchitecture;
2 |
3 | import android.app.Application;
4 | import androidx.annotation.NonNull;
5 | import com.facebook.react.PackageList;
6 | import com.facebook.react.ReactInstanceManager;
7 | import com.facebook.react.ReactNativeHost;
8 | import com.facebook.react.ReactPackage;
9 | import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
10 | import com.facebook.react.bridge.JSIModulePackage;
11 | import com.facebook.react.bridge.JSIModuleProvider;
12 | import com.facebook.react.bridge.JSIModuleSpec;
13 | import com.facebook.react.bridge.JSIModuleType;
14 | import com.facebook.react.bridge.JavaScriptContextHolder;
15 | import com.facebook.react.bridge.ReactApplicationContext;
16 | import com.facebook.react.bridge.UIManager;
17 | import com.facebook.react.fabric.ComponentFactory;
18 | import com.facebook.react.fabric.CoreComponentsRegistry;
19 | import com.facebook.react.fabric.EmptyReactNativeConfig;
20 | import com.facebook.react.fabric.FabricJSIModuleProvider;
21 | import com.facebook.react.fabric.ReactNativeConfig;
22 | import com.facebook.react.uimanager.ViewManagerRegistry;
23 | import expo.modules.keys.example.BuildConfig;
24 | import expo.modules.keys.example.newarchitecture.components.MainComponentsRegistry;
25 | import expo.modules.keys.example.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
26 | import java.util.ArrayList;
27 | import java.util.List;
28 |
29 | /**
30 | * A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
31 | * TurboModule delegates and the Fabric Renderer.
32 | *
33 | * Please note that this class is used ONLY if you opt-in for the New Architecture (see the
34 | * `newArchEnabled` property). Is ignored otherwise.
35 | */
36 | public class MainApplicationReactNativeHost extends ReactNativeHost {
37 | public MainApplicationReactNativeHost(Application application) {
38 | super(application);
39 | }
40 |
41 | @Override
42 | public boolean getUseDeveloperSupport() {
43 | return BuildConfig.DEBUG;
44 | }
45 |
46 | @Override
47 | protected List getPackages() {
48 | List packages = new PackageList(this).getPackages();
49 | // Packages that cannot be autolinked yet can be added manually here, for example:
50 | // packages.add(new MyReactNativePackage());
51 | // TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
52 | // packages.add(new TurboReactPackage() { ... });
53 | // If you have custom Fabric Components, their ViewManagers should also be loaded here
54 | // inside a ReactPackage.
55 | return packages;
56 | }
57 |
58 | @Override
59 | protected String getJSMainModuleName() {
60 | return "index";
61 | }
62 |
63 | @NonNull
64 | @Override
65 | protected ReactPackageTurboModuleManagerDelegate.Builder
66 | getReactPackageTurboModuleManagerDelegateBuilder() {
67 | // Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
68 | // for the new architecture and to use TurboModules correctly.
69 | return new MainApplicationTurboModuleManagerDelegate.Builder();
70 | }
71 |
72 | @Override
73 | protected JSIModulePackage getJSIModulePackage() {
74 | return new JSIModulePackage() {
75 | @Override
76 | public List getJSIModules(
77 | final ReactApplicationContext reactApplicationContext,
78 | final JavaScriptContextHolder jsContext) {
79 | final List specs = new ArrayList<>();
80 |
81 | // Here we provide a new JSIModuleSpec that will be responsible of providing the
82 | // custom Fabric Components.
83 | specs.add(
84 | new JSIModuleSpec() {
85 | @Override
86 | public JSIModuleType getJSIModuleType() {
87 | return JSIModuleType.UIManager;
88 | }
89 |
90 | @Override
91 | public JSIModuleProvider getJSIModuleProvider() {
92 | final ComponentFactory componentFactory = new ComponentFactory();
93 | CoreComponentsRegistry.register(componentFactory);
94 |
95 | // Here we register a Components Registry.
96 | // The one that is generated with the template contains no components
97 | // and just provides you the one from React Native core.
98 | MainComponentsRegistry.register(componentFactory);
99 |
100 | final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
101 |
102 | ViewManagerRegistry viewManagerRegistry =
103 | new ViewManagerRegistry(
104 | reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
105 |
106 | return new FabricJSIModuleProvider(
107 | reactApplicationContext,
108 | componentFactory,
109 | ReactNativeConfig.DEFAULT_CONFIG,
110 | viewManagerRegistry);
111 | }
112 | });
113 | return specs;
114 | }
115 | };
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/expo/modules/keys/example/newarchitecture/components/MainComponentsRegistry.java:
--------------------------------------------------------------------------------
1 | package expo.modules.keys.example.newarchitecture.components;
2 |
3 | import com.facebook.jni.HybridData;
4 | import com.facebook.proguard.annotations.DoNotStrip;
5 | import com.facebook.react.fabric.ComponentFactory;
6 | import com.facebook.soloader.SoLoader;
7 |
8 | /**
9 | * Class responsible to load the custom Fabric Components. This class has native methods and needs a
10 | * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
11 | * folder for you).
12 | *
13 | * Please note that this class is used ONLY if you opt-in for the New Architecture (see the
14 | * `newArchEnabled` property). Is ignored otherwise.
15 | */
16 | @DoNotStrip
17 | public class MainComponentsRegistry {
18 | static {
19 | SoLoader.loadLibrary("fabricjni");
20 | }
21 |
22 | @DoNotStrip private final HybridData mHybridData;
23 |
24 | @DoNotStrip
25 | private native HybridData initHybrid(ComponentFactory componentFactory);
26 |
27 | @DoNotStrip
28 | private MainComponentsRegistry(ComponentFactory componentFactory) {
29 | mHybridData = initHybrid(componentFactory);
30 | }
31 |
32 | @DoNotStrip
33 | public static MainComponentsRegistry register(ComponentFactory componentFactory) {
34 | return new MainComponentsRegistry(componentFactory);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/expo/modules/keys/example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java:
--------------------------------------------------------------------------------
1 | package expo.modules.keys.example.newarchitecture.modules;
2 |
3 | import com.facebook.jni.HybridData;
4 | import com.facebook.react.ReactPackage;
5 | import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
6 | import com.facebook.react.bridge.ReactApplicationContext;
7 | import com.facebook.soloader.SoLoader;
8 | import java.util.List;
9 |
10 | /**
11 | * Class responsible to load the TurboModules. This class has native methods and needs a
12 | * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
13 | * folder for you).
14 | *
15 | *
Please note that this class is used ONLY if you opt-in for the New Architecture (see the
16 | * `newArchEnabled` property). Is ignored otherwise.
17 | */
18 | public class MainApplicationTurboModuleManagerDelegate
19 | extends ReactPackageTurboModuleManagerDelegate {
20 |
21 | private static volatile boolean sIsSoLibraryLoaded;
22 |
23 | protected MainApplicationTurboModuleManagerDelegate(
24 | ReactApplicationContext reactApplicationContext, List packages) {
25 | super(reactApplicationContext, packages);
26 | }
27 |
28 | protected native HybridData initHybrid();
29 |
30 | native boolean canCreateTurboModule(String moduleName);
31 |
32 | public static class Builder extends ReactPackageTurboModuleManagerDelegate.Builder {
33 | protected MainApplicationTurboModuleManagerDelegate build(
34 | ReactApplicationContext context, List packages) {
35 | return new MainApplicationTurboModuleManagerDelegate(context, packages);
36 | }
37 | }
38 |
39 | @Override
40 | protected synchronized void maybeLoadOtherSoLibraries() {
41 | if (!sIsSoLibraryLoaded) {
42 | // If you change the name of your application .so file in the Android.mk file,
43 | // make sure you update the name here as well.
44 | SoLoader.loadLibrary("reactnativekeysexample_appmodules");
45 | sIsSoLibraryLoaded = true;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/example/android/app/src/main/jni/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.13)
2 |
3 | # Define the library name here.
4 | project(reactnativekeysexample_appmodules)
5 |
6 | # This file includes all the necessary to let you build your application with the New Architecture.
7 | include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/jni/MainApplicationModuleProvider.cpp:
--------------------------------------------------------------------------------
1 | #include "MainApplicationModuleProvider.h"
2 |
3 | #include
4 | #include
5 |
6 | namespace facebook {
7 | namespace react {
8 |
9 | std::shared_ptr MainApplicationModuleProvider(
10 | const std::string &moduleName,
11 | const JavaTurboModule::InitParams ¶ms) {
12 | // Here you can provide your own module provider for TurboModules coming from
13 | // either your application or from external libraries. The approach to follow
14 | // is similar to the following (for a library called `samplelibrary`:
15 | //
16 | // auto module = samplelibrary_ModuleProvider(moduleName, params);
17 | // if (module != nullptr) {
18 | // return module;
19 | // }
20 | // return rncore_ModuleProvider(moduleName, params);
21 |
22 | // Module providers autolinked by RN CLI
23 | auto rncli_module = rncli_ModuleProvider(moduleName, params);
24 | if (rncli_module != nullptr) {
25 | return rncli_module;
26 | }
27 |
28 | return rncore_ModuleProvider(moduleName, params);
29 | }
30 |
31 | } // namespace react
32 | } // namespace facebook
33 |
--------------------------------------------------------------------------------
/example/android/app/src/main/jni/MainApplicationModuleProvider.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include
7 |
8 | namespace facebook {
9 | namespace react {
10 |
11 | std::shared_ptr MainApplicationModuleProvider(
12 | const std::string &moduleName,
13 | const JavaTurboModule::InitParams ¶ms);
14 |
15 | } // namespace react
16 | } // namespace facebook
17 |
--------------------------------------------------------------------------------
/example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp:
--------------------------------------------------------------------------------
1 | #include "MainApplicationTurboModuleManagerDelegate.h"
2 | #include "MainApplicationModuleProvider.h"
3 |
4 | namespace facebook {
5 | namespace react {
6 |
7 | jni::local_ref
8 | MainApplicationTurboModuleManagerDelegate::initHybrid(
9 | jni::alias_ref) {
10 | return makeCxxInstance();
11 | }
12 |
13 | void MainApplicationTurboModuleManagerDelegate::registerNatives() {
14 | registerHybrid({
15 | makeNativeMethod(
16 | "initHybrid", MainApplicationTurboModuleManagerDelegate::initHybrid),
17 | makeNativeMethod(
18 | "canCreateTurboModule",
19 | MainApplicationTurboModuleManagerDelegate::canCreateTurboModule),
20 | });
21 | }
22 |
23 | std::shared_ptr
24 | MainApplicationTurboModuleManagerDelegate::getTurboModule(
25 | const std::string &name,
26 | const std::shared_ptr &jsInvoker) {
27 | // Not implemented yet: provide pure-C++ NativeModules here.
28 | return nullptr;
29 | }
30 |
31 | std::shared_ptr
32 | MainApplicationTurboModuleManagerDelegate::getTurboModule(
33 | const std::string &name,
34 | const JavaTurboModule::InitParams ¶ms) {
35 | return MainApplicationModuleProvider(name, params);
36 | }
37 |
38 | bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
39 | const std::string &name) {
40 | return getTurboModule(name, nullptr) != nullptr ||
41 | getTurboModule(name, {.moduleName = name}) != nullptr;
42 | }
43 |
44 | } // namespace react
45 | } // namespace facebook
46 |
--------------------------------------------------------------------------------
/example/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include
5 | #include
6 |
7 | namespace facebook {
8 | namespace react {
9 |
10 | class MainApplicationTurboModuleManagerDelegate
11 | : public jni::HybridClass<
12 | MainApplicationTurboModuleManagerDelegate,
13 | TurboModuleManagerDelegate> {
14 | public:
15 | // Adapt it to the package you used for your Java class.
16 | static constexpr auto kJavaDescriptor =
17 | "Lexpo/modules/keys/example/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate;";
18 |
19 | static jni::local_ref initHybrid(jni::alias_ref);
20 |
21 | static void registerNatives();
22 |
23 | std::shared_ptr getTurboModule(
24 | const std::string &name,
25 | const std::shared_ptr &jsInvoker) override;
26 | std::shared_ptr getTurboModule(
27 | const std::string &name,
28 | const JavaTurboModule::InitParams ¶ms) override;
29 |
30 | /**
31 | * Test-only method. Allows user to verify whether a TurboModule can be
32 | * created by instances of this class.
33 | */
34 | bool canCreateTurboModule(const std::string &name);
35 | };
36 |
37 | } // namespace react
38 | } // namespace facebook
39 |
--------------------------------------------------------------------------------
/example/android/app/src/main/jni/MainComponentsRegistry.cpp:
--------------------------------------------------------------------------------
1 | #include "MainComponentsRegistry.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace facebook {
10 | namespace react {
11 |
12 | MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {}
13 |
14 | std::shared_ptr
15 | MainComponentsRegistry::sharedProviderRegistry() {
16 | auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
17 |
18 | // Autolinked providers registered by RN CLI
19 | rncli_registerProviders(providerRegistry);
20 |
21 | // Custom Fabric Components go here. You can register custom
22 | // components coming from your App or from 3rd party libraries here.
23 | //
24 | // providerRegistry->add(concreteComponentDescriptorProvider<
25 | // AocViewerComponentDescriptor>());
26 | return providerRegistry;
27 | }
28 |
29 | jni::local_ref
30 | MainComponentsRegistry::initHybrid(
31 | jni::alias_ref,
32 | ComponentFactory *delegate) {
33 | auto instance = makeCxxInstance(delegate);
34 |
35 | auto buildRegistryFunction =
36 | [](EventDispatcher::Weak const &eventDispatcher,
37 | ContextContainer::Shared const &contextContainer)
38 | -> ComponentDescriptorRegistry::Shared {
39 | auto registry = MainComponentsRegistry::sharedProviderRegistry()
40 | ->createComponentDescriptorRegistry(
41 | {eventDispatcher, contextContainer});
42 |
43 | auto mutableRegistry =
44 | std::const_pointer_cast(registry);
45 |
46 | mutableRegistry->setFallbackComponentDescriptor(
47 | std::make_shared(
48 | ComponentDescriptorParameters{
49 | eventDispatcher, contextContainer, nullptr}));
50 |
51 | return registry;
52 | };
53 |
54 | delegate->buildRegistryFunction = buildRegistryFunction;
55 | return instance;
56 | }
57 |
58 | void MainComponentsRegistry::registerNatives() {
59 | registerHybrid({
60 | makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid),
61 | });
62 | }
63 |
64 | } // namespace react
65 | } // namespace facebook
66 |
--------------------------------------------------------------------------------
/example/android/app/src/main/jni/MainComponentsRegistry.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | namespace facebook {
9 | namespace react {
10 |
11 | class MainComponentsRegistry
12 | : public facebook::jni::HybridClass {
13 | public:
14 | // Adapt it to the package you used for your Java class.
15 | constexpr static auto kJavaDescriptor =
16 | "Lexpo/modules/keys/example/newarchitecture/components/MainComponentsRegistry;";
17 |
18 | static void registerNatives();
19 |
20 | MainComponentsRegistry(ComponentFactory *delegate);
21 |
22 | private:
23 | static std::shared_ptr
24 | sharedProviderRegistry();
25 |
26 | static jni::local_ref initHybrid(
27 | jni::alias_ref,
28 | ComponentFactory *delegate);
29 | };
30 |
31 | } // namespace react
32 | } // namespace facebook
33 |
--------------------------------------------------------------------------------
/example/android/app/src/main/jni/OnLoad.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "MainApplicationTurboModuleManagerDelegate.h"
3 | #include "MainComponentsRegistry.h"
4 |
5 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
6 | return facebook::jni::initialize(vm, [] {
7 | facebook::react::MainApplicationTurboModuleManagerDelegate::
8 | registerNatives();
9 | facebook::react::MainComponentsRegistry::registerNatives();
10 | });
11 | }
12 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-hdpi/splashscreen_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/drawable-hdpi/splashscreen_image.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-mdpi/splashscreen_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/drawable-mdpi/splashscreen_image.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/drawable-xhdpi/splashscreen_image.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/drawable-xxhdpi/splashscreen_image.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/drawable-xxxhdpi/splashscreen_image.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/rn_edit_text_material.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
21 |
22 |
23 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/splashscreen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values-night/colors.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 | #ffffff
3 | #FFFFFF
4 | #023c69
5 | #ffffff
6 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | react-native-keys-example
3 | contain
4 | false
5 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
14 |
17 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext {
5 | buildToolsVersion = findProperty('android.buildToolsVersion') ?: '31.0.0'
6 | minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
7 | compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '31')
8 | targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '31')
9 | if (findProperty('android.kotlinVersion')) {
10 | kotlinVersion = findProperty('android.kotlinVersion')
11 | }
12 | frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
13 |
14 | if (System.properties['os.arch'] == 'aarch64') {
15 | // For M1 Users we need to use the NDK 24 which added support for aarch64
16 | ndkVersion = '24.0.8215888'
17 | } else {
18 | // Otherwise we default to the side-by-side NDK version from AGP.
19 | ndkVersion = '21.4.7075529'
20 | }
21 | }
22 | repositories {
23 | google()
24 | mavenCentral()
25 | }
26 | dependencies {
27 | classpath('com.android.tools.build:gradle:7.2.1')
28 | classpath('com.facebook.react:react-native-gradle-plugin')
29 | classpath('de.undercouch:gradle-download-task:5.0.1')
30 | // NOTE: Do not place your application dependencies here; they belong
31 | // in the individual module build.gradle files
32 | }
33 | }
34 |
35 | def REACT_NATIVE_VERSION = new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
36 |
37 | allprojects {
38 | configurations.all {
39 | resolutionStrategy {
40 | force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
41 | }
42 | }
43 |
44 | repositories {
45 | mavenLocal()
46 | maven {
47 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
48 | url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
49 | }
50 | maven {
51 | // Android JSC is installed from npm
52 | url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
53 | }
54 |
55 | google()
56 | mavenCentral {
57 | // We don't want to fetch react-native from Maven Central as there are
58 | // older versions over there.
59 | content {
60 | excludeGroup 'com.facebook.react'
61 | }
62 | }
63 | maven { url 'https://www.jitpack.io' }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 |
25 | # Automatically convert third-party libraries to use AndroidX
26 | android.enableJetifier=true
27 |
28 | # Version of flipper SDK to use with React Native
29 | FLIPPER_VERSION=0.125.0
30 |
31 | # Use this property to specify which architecture you want to build.
32 | # You can also override it from the CLI using
33 | # ./gradlew -PreactNativeArchitectures=x86_64
34 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
35 |
36 | # Use this property to enable support to the new architecture.
37 | # This will allow you to use TurboModules and the Fabric render in
38 | # your application. You should enable this flag either if you want
39 | # to write custom TurboModules/Fabric components OR use libraries that
40 | # are providing them.
41 | newArchEnabled=false
42 |
43 | # The hosted JavaScript engine
44 | # Supported values: expo.jsEngine = "hermes" | "jsc"
45 | expo.jsEngine=jsc
46 |
47 | # Enable GIF support in React Native images (~200 B increase)
48 | expo.gif.enabled=true
49 | # Enable webp support in React Native images (~85 KB increase)
50 | expo.webp.enabled=true
51 | # Enable animated webp support (~3.4 MB increase)
52 | # Disabled by default because iOS doesn't support animated webp
53 | expo.webp.animated=false
54 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/example/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Stop when "xargs" is not available.
209 | if ! command -v xargs >/dev/null 2>&1
210 | then
211 | die "xargs is not available"
212 | fi
213 |
214 | # Use "xargs" to parse quoted args.
215 | #
216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
217 | #
218 | # In Bash we could simply go:
219 | #
220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
221 | # set -- "${ARGS[@]}" "$@"
222 | #
223 | # but POSIX shell has neither arrays nor command substitution, so instead we
224 | # post-process each arg (as a line of input to sed) to backslash-escape any
225 | # character that might be a shell metacharacter, then use eval to reverse
226 | # that process (while maintaining the separation between arguments), and wrap
227 | # the whole thing up as a single "set" statement.
228 | #
229 | # This will of course break if any of these variables contains a newline or
230 | # an unmatched quote.
231 | #
232 |
233 | eval "set -- $(
234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
235 | xargs -n1 |
236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
237 | tr '\n' ' '
238 | )" '"$@"'
239 |
240 | exec "$JAVACMD" "$@"
241 |
--------------------------------------------------------------------------------
/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if %ERRORLEVEL% equ 0 goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if %ERRORLEVEL% equ 0 goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | set EXIT_CODE=%ERRORLEVEL%
84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86 | exit /b %EXIT_CODE%
87 |
88 | :mainEnd
89 | if "%OS%"=="Windows_NT" endlocal
90 |
91 | :omega
92 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'react-native-keys-example'
2 |
3 | apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
4 | useExpoModules()
5 |
6 | apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
7 | applyNativeModulesSettingsGradle(settings)
8 |
9 | include ':app'
10 | includeBuild(new File(["node", "--print", "require.resolve('react-native-gradle-plugin/package.json')"].execute(null, rootDir).text.trim()).getParentFile())
11 |
12 | if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") {
13 | include(":ReactAndroid")
14 | project(":ReactAndroid").projectDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../ReactAndroid");
15 | include(":ReactAndroid:hermes-engine")
16 | project(":ReactAndroid:hermes-engine").projectDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../ReactAndroid/hermes-engine");
17 | }
18 |
--------------------------------------------------------------------------------
/example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo": {
3 | "name": "react-native-keys-example",
4 | "slug": "react-native-keys-example",
5 | "version": "1.0.0",
6 | "orientation": "portrait",
7 | "icon": "./assets/icon.png",
8 | "userInterfaceStyle": "light",
9 | "splash": {
10 | "image": "./assets/splash.png",
11 | "resizeMode": "contain",
12 | "backgroundColor": "#ffffff"
13 | },
14 | "updates": {
15 | "fallbackToCacheTimeout": 0
16 | },
17 | "assetBundlePatterns": [
18 | "**/*"
19 | ],
20 | "ios": {
21 | "supportsTablet": true,
22 | "bundleIdentifier": "expo.modules.keys.example"
23 | },
24 | "android": {
25 | "adaptiveIcon": {
26 | "foregroundImage": "./assets/adaptive-icon.png",
27 | "backgroundColor": "#FFFFFF"
28 | },
29 | "package": "expo.modules.keys.example"
30 | },
31 | "web": {
32 | "favicon": "./assets/favicon.png",
33 | "bundler": "metro"
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/example/assets/adaptive-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/assets/adaptive-icon.png
--------------------------------------------------------------------------------
/example/assets/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/assets/favicon.png
--------------------------------------------------------------------------------
/example/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/assets/icon.png
--------------------------------------------------------------------------------
/example/assets/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/assets/splash.png
--------------------------------------------------------------------------------
/example/babel.config.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 |
3 | const pak = require('../package.json')
4 |
5 | module.exports = function (api) {
6 | api.cache(true)
7 | return {
8 | presets: ['babel-preset-expo'],
9 | plugins: [
10 | [
11 | 'module-resolver',
12 | {
13 | extensions: [
14 | '.tsx', '.ts', '.js', '.json',
15 | ],
16 | alias: {
17 | // For development, we want to alias the library to the source
18 | [pak.name]: path.join(__dirname, '..', 'src'),
19 | },
20 | },
21 | ],
22 | ],
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | import { registerRootComponent } from 'expo'
2 |
3 | import App from './App'
4 |
5 | // registerRootComponent calls AppRegistry.registerComponent('main', () => App);
6 | // It also ensures that whether you load the app in Expo Go or in a native build,
7 | // the environment is set up appropriately
8 | registerRootComponent(App)
9 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 | project.xcworkspace
24 | .xcode.env.local
25 |
26 | # Bundle artifacts
27 | *.jsbundle
28 |
29 | # CocoaPods
30 | /Pods/
31 |
--------------------------------------------------------------------------------
/example/ios/.xcode.env:
--------------------------------------------------------------------------------
1 | # This `.xcode.env` file is versioned and is used to source the environment
2 | # used when running script phases inside Xcode.
3 | # To customize your local environment, you can create an `.xcode.env.local`
4 | # file that is not versioned.
5 |
6 | # NODE_BINARY variable contains the PATH to the node executable.
7 | #
8 | # Customize the NODE_BINARY variable here.
9 | # For example, to use nvm with brew, add the following line
10 | # . "$(brew --prefix nvm)/nvm.sh" --no-use
11 | export NODE_BINARY=$(command -v node)
12 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
2 | require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
3 | require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")
4 |
5 | require 'json'
6 | podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
7 |
8 | platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
9 | install! 'cocoapods',
10 | :deterministic_uuids => false
11 |
12 | target 'reactnativekeysexample' do
13 | use_expo_modules!
14 | config = use_native_modules!
15 |
16 | use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
17 |
18 | # Flags change depending on the env values.
19 | flags = get_default_flags()
20 |
21 | use_react_native!(
22 | :path => config[:reactNativePath],
23 | :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes',
24 | :fabric_enabled => flags[:fabric_enabled],
25 | # An absolute path to your application root.
26 | :app_path => "#{Pod::Config.instance.installation_root}/..",
27 | #
28 | # Uncomment to opt-in to using Flipper
29 | # Note that if you have use_frameworks! enabled, Flipper will not work
30 | # :flipper_configuration => !ENV['CI'] ? FlipperConfiguration.enabled : FlipperConfiguration.disabled,
31 | )
32 |
33 | post_install do |installer|
34 | react_native_post_install(
35 | installer,
36 | # Set `mac_catalyst_enabled` to `true` in order to apply patches
37 | # necessary for Mac Catalyst builds
38 | :mac_catalyst_enabled => false
39 | )
40 | __apply_Xcode_12_5_M1_post_install_workaround(installer)
41 |
42 | # This is necessary for Xcode 14, because it signs resource bundles by default
43 | # when building for devices.
44 | installer.target_installation_results.pod_target_installation_results
45 | .each do |pod_name, target_installation_result|
46 | target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
47 | resource_bundle_target.build_configurations.each do |config|
48 | config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
49 | end
50 | end
51 | end
52 | end
53 |
54 | post_integrate do |installer|
55 | begin
56 | expo_patch_react_imports!(installer)
57 | rescue => e
58 | Pod::UI.warn e
59 | end
60 | end
61 | end
62 |
--------------------------------------------------------------------------------
/example/ios/Podfile.lock:
--------------------------------------------------------------------------------
1 | PODS:
2 | - boost (1.76.0)
3 | - DoubleConversion (1.1.6)
4 | - EXApplication (5.1.1):
5 | - ExpoModulesCore
6 | - EXConstants (14.2.1):
7 | - ExpoModulesCore
8 | - EXFileSystem (15.2.2):
9 | - ExpoModulesCore
10 | - EXFont (11.1.1):
11 | - ExpoModulesCore
12 | - Expo (48.0.5):
13 | - ExpoModulesCore
14 | - ExpoKeepAwake (12.0.1):
15 | - ExpoModulesCore
16 | - ExpoModulesCore (1.2.4):
17 | - React-Core
18 | - React-RCTAppDelegate
19 | - ReactCommon/turbomodule/core
20 | - FBLazyVector (0.71.3)
21 | - FBReactNativeSpec (0.71.3):
22 | - RCT-Folly (= 2021.07.22.00)
23 | - RCTRequired (= 0.71.3)
24 | - RCTTypeSafety (= 0.71.3)
25 | - React-Core (= 0.71.3)
26 | - React-jsi (= 0.71.3)
27 | - ReactCommon/turbomodule/core (= 0.71.3)
28 | - fmt (6.2.1)
29 | - glog (0.3.5)
30 | - RCT-Folly (2021.07.22.00):
31 | - boost
32 | - DoubleConversion
33 | - fmt (~> 6.2.1)
34 | - glog
35 | - RCT-Folly/Default (= 2021.07.22.00)
36 | - RCT-Folly/Default (2021.07.22.00):
37 | - boost
38 | - DoubleConversion
39 | - fmt (~> 6.2.1)
40 | - glog
41 | - RCTRequired (0.71.3)
42 | - RCTTypeSafety (0.71.3):
43 | - FBLazyVector (= 0.71.3)
44 | - RCTRequired (= 0.71.3)
45 | - React-Core (= 0.71.3)
46 | - React (0.71.3):
47 | - React-Core (= 0.71.3)
48 | - React-Core/DevSupport (= 0.71.3)
49 | - React-Core/RCTWebSocket (= 0.71.3)
50 | - React-RCTActionSheet (= 0.71.3)
51 | - React-RCTAnimation (= 0.71.3)
52 | - React-RCTBlob (= 0.71.3)
53 | - React-RCTImage (= 0.71.3)
54 | - React-RCTLinking (= 0.71.3)
55 | - React-RCTNetwork (= 0.71.3)
56 | - React-RCTSettings (= 0.71.3)
57 | - React-RCTText (= 0.71.3)
58 | - React-RCTVibration (= 0.71.3)
59 | - React-callinvoker (0.71.3)
60 | - React-Codegen (0.71.3):
61 | - FBReactNativeSpec
62 | - RCT-Folly
63 | - RCTRequired
64 | - RCTTypeSafety
65 | - React-Core
66 | - React-jsc
67 | - React-jsi
68 | - React-jsiexecutor
69 | - ReactCommon/turbomodule/bridging
70 | - ReactCommon/turbomodule/core
71 | - React-Core (0.71.3):
72 | - glog
73 | - RCT-Folly (= 2021.07.22.00)
74 | - React-Core/Default (= 0.71.3)
75 | - React-cxxreact (= 0.71.3)
76 | - React-jsc
77 | - React-jsi (= 0.71.3)
78 | - React-jsiexecutor (= 0.71.3)
79 | - React-perflogger (= 0.71.3)
80 | - Yoga
81 | - React-Core/CoreModulesHeaders (0.71.3):
82 | - glog
83 | - RCT-Folly (= 2021.07.22.00)
84 | - React-Core/Default
85 | - React-cxxreact (= 0.71.3)
86 | - React-jsc
87 | - React-jsi (= 0.71.3)
88 | - React-jsiexecutor (= 0.71.3)
89 | - React-perflogger (= 0.71.3)
90 | - Yoga
91 | - React-Core/Default (0.71.3):
92 | - glog
93 | - RCT-Folly (= 2021.07.22.00)
94 | - React-cxxreact (= 0.71.3)
95 | - React-jsc
96 | - React-jsi (= 0.71.3)
97 | - React-jsiexecutor (= 0.71.3)
98 | - React-perflogger (= 0.71.3)
99 | - Yoga
100 | - React-Core/DevSupport (0.71.3):
101 | - glog
102 | - RCT-Folly (= 2021.07.22.00)
103 | - React-Core/Default (= 0.71.3)
104 | - React-Core/RCTWebSocket (= 0.71.3)
105 | - React-cxxreact (= 0.71.3)
106 | - React-jsc
107 | - React-jsi (= 0.71.3)
108 | - React-jsiexecutor (= 0.71.3)
109 | - React-jsinspector (= 0.71.3)
110 | - React-perflogger (= 0.71.3)
111 | - Yoga
112 | - React-Core/RCTActionSheetHeaders (0.71.3):
113 | - glog
114 | - RCT-Folly (= 2021.07.22.00)
115 | - React-Core/Default
116 | - React-cxxreact (= 0.71.3)
117 | - React-jsc
118 | - React-jsi (= 0.71.3)
119 | - React-jsiexecutor (= 0.71.3)
120 | - React-perflogger (= 0.71.3)
121 | - Yoga
122 | - React-Core/RCTAnimationHeaders (0.71.3):
123 | - glog
124 | - RCT-Folly (= 2021.07.22.00)
125 | - React-Core/Default
126 | - React-cxxreact (= 0.71.3)
127 | - React-jsc
128 | - React-jsi (= 0.71.3)
129 | - React-jsiexecutor (= 0.71.3)
130 | - React-perflogger (= 0.71.3)
131 | - Yoga
132 | - React-Core/RCTBlobHeaders (0.71.3):
133 | - glog
134 | - RCT-Folly (= 2021.07.22.00)
135 | - React-Core/Default
136 | - React-cxxreact (= 0.71.3)
137 | - React-jsc
138 | - React-jsi (= 0.71.3)
139 | - React-jsiexecutor (= 0.71.3)
140 | - React-perflogger (= 0.71.3)
141 | - Yoga
142 | - React-Core/RCTImageHeaders (0.71.3):
143 | - glog
144 | - RCT-Folly (= 2021.07.22.00)
145 | - React-Core/Default
146 | - React-cxxreact (= 0.71.3)
147 | - React-jsc
148 | - React-jsi (= 0.71.3)
149 | - React-jsiexecutor (= 0.71.3)
150 | - React-perflogger (= 0.71.3)
151 | - Yoga
152 | - React-Core/RCTLinkingHeaders (0.71.3):
153 | - glog
154 | - RCT-Folly (= 2021.07.22.00)
155 | - React-Core/Default
156 | - React-cxxreact (= 0.71.3)
157 | - React-jsc
158 | - React-jsi (= 0.71.3)
159 | - React-jsiexecutor (= 0.71.3)
160 | - React-perflogger (= 0.71.3)
161 | - Yoga
162 | - React-Core/RCTNetworkHeaders (0.71.3):
163 | - glog
164 | - RCT-Folly (= 2021.07.22.00)
165 | - React-Core/Default
166 | - React-cxxreact (= 0.71.3)
167 | - React-jsc
168 | - React-jsi (= 0.71.3)
169 | - React-jsiexecutor (= 0.71.3)
170 | - React-perflogger (= 0.71.3)
171 | - Yoga
172 | - React-Core/RCTSettingsHeaders (0.71.3):
173 | - glog
174 | - RCT-Folly (= 2021.07.22.00)
175 | - React-Core/Default
176 | - React-cxxreact (= 0.71.3)
177 | - React-jsc
178 | - React-jsi (= 0.71.3)
179 | - React-jsiexecutor (= 0.71.3)
180 | - React-perflogger (= 0.71.3)
181 | - Yoga
182 | - React-Core/RCTTextHeaders (0.71.3):
183 | - glog
184 | - RCT-Folly (= 2021.07.22.00)
185 | - React-Core/Default
186 | - React-cxxreact (= 0.71.3)
187 | - React-jsc
188 | - React-jsi (= 0.71.3)
189 | - React-jsiexecutor (= 0.71.3)
190 | - React-perflogger (= 0.71.3)
191 | - Yoga
192 | - React-Core/RCTVibrationHeaders (0.71.3):
193 | - glog
194 | - RCT-Folly (= 2021.07.22.00)
195 | - React-Core/Default
196 | - React-cxxreact (= 0.71.3)
197 | - React-jsc
198 | - React-jsi (= 0.71.3)
199 | - React-jsiexecutor (= 0.71.3)
200 | - React-perflogger (= 0.71.3)
201 | - Yoga
202 | - React-Core/RCTWebSocket (0.71.3):
203 | - glog
204 | - RCT-Folly (= 2021.07.22.00)
205 | - React-Core/Default (= 0.71.3)
206 | - React-cxxreact (= 0.71.3)
207 | - React-jsc
208 | - React-jsi (= 0.71.3)
209 | - React-jsiexecutor (= 0.71.3)
210 | - React-perflogger (= 0.71.3)
211 | - Yoga
212 | - React-CoreModules (0.71.3):
213 | - RCT-Folly (= 2021.07.22.00)
214 | - RCTTypeSafety (= 0.71.3)
215 | - React-Codegen (= 0.71.3)
216 | - React-Core/CoreModulesHeaders (= 0.71.3)
217 | - React-jsi (= 0.71.3)
218 | - React-RCTBlob
219 | - React-RCTImage (= 0.71.3)
220 | - ReactCommon/turbomodule/core (= 0.71.3)
221 | - React-cxxreact (0.71.3):
222 | - boost (= 1.76.0)
223 | - DoubleConversion
224 | - glog
225 | - RCT-Folly (= 2021.07.22.00)
226 | - React-callinvoker (= 0.71.3)
227 | - React-jsi (= 0.71.3)
228 | - React-jsinspector (= 0.71.3)
229 | - React-logger (= 0.71.3)
230 | - React-perflogger (= 0.71.3)
231 | - React-runtimeexecutor (= 0.71.3)
232 | - React-jsc (0.71.3):
233 | - React-jsc/Fabric (= 0.71.3)
234 | - React-jsi (= 0.71.3)
235 | - React-jsc/Fabric (0.71.3):
236 | - React-jsi (= 0.71.3)
237 | - React-jsi (0.71.3):
238 | - boost (= 1.76.0)
239 | - DoubleConversion
240 | - glog
241 | - RCT-Folly (= 2021.07.22.00)
242 | - React-jsiexecutor (0.71.3):
243 | - DoubleConversion
244 | - glog
245 | - RCT-Folly (= 2021.07.22.00)
246 | - React-cxxreact (= 0.71.3)
247 | - React-jsi (= 0.71.3)
248 | - React-perflogger (= 0.71.3)
249 | - React-jsinspector (0.71.3)
250 | - React-logger (0.71.3):
251 | - glog
252 | - React-perflogger (0.71.3)
253 | - React-RCTActionSheet (0.71.3):
254 | - React-Core/RCTActionSheetHeaders (= 0.71.3)
255 | - React-RCTAnimation (0.71.3):
256 | - RCT-Folly (= 2021.07.22.00)
257 | - RCTTypeSafety (= 0.71.3)
258 | - React-Codegen (= 0.71.3)
259 | - React-Core/RCTAnimationHeaders (= 0.71.3)
260 | - React-jsi (= 0.71.3)
261 | - ReactCommon/turbomodule/core (= 0.71.3)
262 | - React-RCTAppDelegate (0.71.3):
263 | - RCT-Folly
264 | - RCTRequired
265 | - RCTTypeSafety
266 | - React-Core
267 | - ReactCommon/turbomodule/core
268 | - React-RCTBlob (0.71.3):
269 | - RCT-Folly (= 2021.07.22.00)
270 | - React-Codegen (= 0.71.3)
271 | - React-Core/RCTBlobHeaders (= 0.71.3)
272 | - React-Core/RCTWebSocket (= 0.71.3)
273 | - React-jsi (= 0.71.3)
274 | - React-RCTNetwork (= 0.71.3)
275 | - ReactCommon/turbomodule/core (= 0.71.3)
276 | - React-RCTImage (0.71.3):
277 | - RCT-Folly (= 2021.07.22.00)
278 | - RCTTypeSafety (= 0.71.3)
279 | - React-Codegen (= 0.71.3)
280 | - React-Core/RCTImageHeaders (= 0.71.3)
281 | - React-jsi (= 0.71.3)
282 | - React-RCTNetwork (= 0.71.3)
283 | - ReactCommon/turbomodule/core (= 0.71.3)
284 | - React-RCTLinking (0.71.3):
285 | - React-Codegen (= 0.71.3)
286 | - React-Core/RCTLinkingHeaders (= 0.71.3)
287 | - React-jsi (= 0.71.3)
288 | - ReactCommon/turbomodule/core (= 0.71.3)
289 | - React-RCTNetwork (0.71.3):
290 | - RCT-Folly (= 2021.07.22.00)
291 | - RCTTypeSafety (= 0.71.3)
292 | - React-Codegen (= 0.71.3)
293 | - React-Core/RCTNetworkHeaders (= 0.71.3)
294 | - React-jsi (= 0.71.3)
295 | - ReactCommon/turbomodule/core (= 0.71.3)
296 | - React-RCTSettings (0.71.3):
297 | - RCT-Folly (= 2021.07.22.00)
298 | - RCTTypeSafety (= 0.71.3)
299 | - React-Codegen (= 0.71.3)
300 | - React-Core/RCTSettingsHeaders (= 0.71.3)
301 | - React-jsi (= 0.71.3)
302 | - ReactCommon/turbomodule/core (= 0.71.3)
303 | - React-RCTText (0.71.3):
304 | - React-Core/RCTTextHeaders (= 0.71.3)
305 | - React-RCTVibration (0.71.3):
306 | - RCT-Folly (= 2021.07.22.00)
307 | - React-Codegen (= 0.71.3)
308 | - React-Core/RCTVibrationHeaders (= 0.71.3)
309 | - React-jsi (= 0.71.3)
310 | - ReactCommon/turbomodule/core (= 0.71.3)
311 | - React-runtimeexecutor (0.71.3):
312 | - React-jsi (= 0.71.3)
313 | - ReactCommon/turbomodule/bridging (0.71.3):
314 | - DoubleConversion
315 | - glog
316 | - RCT-Folly (= 2021.07.22.00)
317 | - React-callinvoker (= 0.71.3)
318 | - React-Core (= 0.71.3)
319 | - React-cxxreact (= 0.71.3)
320 | - React-jsi (= 0.71.3)
321 | - React-logger (= 0.71.3)
322 | - React-perflogger (= 0.71.3)
323 | - ReactCommon/turbomodule/core (0.71.3):
324 | - DoubleConversion
325 | - glog
326 | - RCT-Folly (= 2021.07.22.00)
327 | - React-callinvoker (= 0.71.3)
328 | - React-Core (= 0.71.3)
329 | - React-cxxreact (= 0.71.3)
330 | - React-jsi (= 0.71.3)
331 | - React-logger (= 0.71.3)
332 | - React-perflogger (= 0.71.3)
333 | - ReactNativeKeys (0.5.3):
334 | - ExpoModulesCore
335 | - Yoga (1.14.0)
336 |
337 | DEPENDENCIES:
338 | - boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
339 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
340 | - EXApplication (from `../node_modules/expo-application/ios`)
341 | - EXConstants (from `../node_modules/expo-constants/ios`)
342 | - EXFileSystem (from `../node_modules/expo-file-system/ios`)
343 | - EXFont (from `../node_modules/expo-font/ios`)
344 | - Expo (from `../node_modules/expo`)
345 | - ExpoKeepAwake (from `../node_modules/expo-keep-awake/ios`)
346 | - ExpoModulesCore (from `../node_modules/expo-modules-core`)
347 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
348 | - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
349 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
350 | - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
351 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
352 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
353 | - React (from `../node_modules/react-native/`)
354 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`)
355 | - React-Codegen (from `build/generated/ios`)
356 | - React-Core (from `../node_modules/react-native/`)
357 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`)
358 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`)
359 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`)
360 | - React-jsc (from `../node_modules/react-native/ReactCommon/jsc`)
361 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
362 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
363 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
364 | - React-logger (from `../node_modules/react-native/ReactCommon/logger`)
365 | - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
366 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
367 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
368 | - React-RCTAppDelegate (from `../node_modules/react-native/Libraries/AppDelegate`)
369 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
370 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`)
371 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`)
372 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`)
373 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`)
374 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`)
375 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
376 | - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
377 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
378 | - ReactNativeKeys (from `../../ios`)
379 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
380 |
381 | SPEC REPOS:
382 | trunk:
383 | - fmt
384 |
385 | EXTERNAL SOURCES:
386 | boost:
387 | :podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec"
388 | DoubleConversion:
389 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
390 | EXApplication:
391 | :path: "../node_modules/expo-application/ios"
392 | EXConstants:
393 | :path: "../node_modules/expo-constants/ios"
394 | EXFileSystem:
395 | :path: "../node_modules/expo-file-system/ios"
396 | EXFont:
397 | :path: "../node_modules/expo-font/ios"
398 | Expo:
399 | :path: "../node_modules/expo"
400 | ExpoKeepAwake:
401 | :path: "../node_modules/expo-keep-awake/ios"
402 | ExpoModulesCore:
403 | :path: "../node_modules/expo-modules-core"
404 | FBLazyVector:
405 | :path: "../node_modules/react-native/Libraries/FBLazyVector"
406 | FBReactNativeSpec:
407 | :path: "../node_modules/react-native/React/FBReactNativeSpec"
408 | glog:
409 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
410 | RCT-Folly:
411 | :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec"
412 | RCTRequired:
413 | :path: "../node_modules/react-native/Libraries/RCTRequired"
414 | RCTTypeSafety:
415 | :path: "../node_modules/react-native/Libraries/TypeSafety"
416 | React:
417 | :path: "../node_modules/react-native/"
418 | React-callinvoker:
419 | :path: "../node_modules/react-native/ReactCommon/callinvoker"
420 | React-Codegen:
421 | :path: build/generated/ios
422 | React-Core:
423 | :path: "../node_modules/react-native/"
424 | React-CoreModules:
425 | :path: "../node_modules/react-native/React/CoreModules"
426 | React-cxxreact:
427 | :path: "../node_modules/react-native/ReactCommon/cxxreact"
428 | React-jsc:
429 | :path: "../node_modules/react-native/ReactCommon/jsc"
430 | React-jsi:
431 | :path: "../node_modules/react-native/ReactCommon/jsi"
432 | React-jsiexecutor:
433 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor"
434 | React-jsinspector:
435 | :path: "../node_modules/react-native/ReactCommon/jsinspector"
436 | React-logger:
437 | :path: "../node_modules/react-native/ReactCommon/logger"
438 | React-perflogger:
439 | :path: "../node_modules/react-native/ReactCommon/reactperflogger"
440 | React-RCTActionSheet:
441 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS"
442 | React-RCTAnimation:
443 | :path: "../node_modules/react-native/Libraries/NativeAnimation"
444 | React-RCTAppDelegate:
445 | :path: "../node_modules/react-native/Libraries/AppDelegate"
446 | React-RCTBlob:
447 | :path: "../node_modules/react-native/Libraries/Blob"
448 | React-RCTImage:
449 | :path: "../node_modules/react-native/Libraries/Image"
450 | React-RCTLinking:
451 | :path: "../node_modules/react-native/Libraries/LinkingIOS"
452 | React-RCTNetwork:
453 | :path: "../node_modules/react-native/Libraries/Network"
454 | React-RCTSettings:
455 | :path: "../node_modules/react-native/Libraries/Settings"
456 | React-RCTText:
457 | :path: "../node_modules/react-native/Libraries/Text"
458 | React-RCTVibration:
459 | :path: "../node_modules/react-native/Libraries/Vibration"
460 | React-runtimeexecutor:
461 | :path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
462 | ReactCommon:
463 | :path: "../node_modules/react-native/ReactCommon"
464 | ReactNativeKeys:
465 | :path: "../../ios"
466 | Yoga:
467 | :path: "../node_modules/react-native/ReactCommon/yoga"
468 |
469 | SPEC CHECKSUMS:
470 | boost: 57d2868c099736d80fcd648bf211b4431e51a558
471 | DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
472 | EXApplication: d8f53a7eee90a870a75656280e8d4b85726ea903
473 | EXConstants: f348da07e21b23d2b085e270d7b74f282df1a7d9
474 | EXFileSystem: 844e86ca9b5375486ecc4ef06d3838d5597d895d
475 | EXFont: 6ea3800df746be7233208d80fe379b8ed74f4272
476 | Expo: ac2226798ad1f7db860107a4f309303e7a1b4434
477 | ExpoKeepAwake: 69f5f627670d62318410392d03e0b5db0f85759a
478 | ExpoModulesCore: 1667335d4f4c9b7801990930e6f0eea42c916a21
479 | FBLazyVector: 60195509584153283780abdac5569feffb8f08cc
480 | FBReactNativeSpec: 9c191fb58d06dc05ab5559a5505fc32139e9e4a2
481 | fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
482 | glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
483 | RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
484 | RCTRequired: bec48f07daf7bcdc2655a0cde84e07d24d2a9e2a
485 | RCTTypeSafety: 171394eebacf71e1cfad79dbfae7ee8fc16ca80a
486 | React: d7433ccb6a8c36e4cbed59a73c0700fc83c3e98a
487 | React-callinvoker: 15f165009bd22ae829b2b600e50bcc98076ce4b8
488 | React-Codegen: df9d3975a10b29c1dfa4baa7678449e9d9648ca7
489 | React-Core: 882014e745cdad5788c5c8aa1a0f4661880aad69
490 | React-CoreModules: e0cbc1a4f4f3f60e23c476fef7ab37be363ea8c1
491 | React-cxxreact: bde3dde79b6d8e2dae76197ad75c11883f7d152d
492 | React-jsc: 30670396f92f5f9bab121bf8c303f5a0a507061b
493 | React-jsi: 103a8ff6586095e0e6853522f8eea37ca0226f99
494 | React-jsiexecutor: 891dad49e50d35fba97eeb43a35ae7470a8e10b2
495 | React-jsinspector: 9f7c9137605e72ca0343db4cea88006cb94856dd
496 | React-logger: 957e5dc96d9dbffc6e0f15e0ee4d2b42829ff207
497 | React-perflogger: af8a3d31546077f42d729b949925cc4549f14def
498 | React-RCTActionSheet: 57cc5adfefbaaf0aae2cf7e10bccd746f2903673
499 | React-RCTAnimation: 11c61e94da700c4dc915cf134513764d87fc5e2b
500 | React-RCTAppDelegate: 3057d5a551fbe3ac8bac361761f4c74ba2e5ab17
501 | React-RCTBlob: 0e49a4ecd4d5276c79bea13d1c4b21f99da45121
502 | React-RCTImage: 7a9226b0944f1e76e8e01e35a9245c2477cdbabb
503 | React-RCTLinking: bbe8cc582046a9c04f79c235b73c93700263e8b4
504 | React-RCTNetwork: fc2ca322159dc54e06508d4f5c3e934da63dc013
505 | React-RCTSettings: f1e9db2cdf946426d3f2b210e4ff4ce0f0d842ef
506 | React-RCTText: 1c41dd57e5d742b1396b4eeb251851ce7ff0fca1
507 | React-RCTVibration: 5199a180d04873366a83855de55ac33ce60fe4d5
508 | React-runtimeexecutor: 7bf0dafc7b727d93c8cb94eb00a9d3753c446c3e
509 | ReactCommon: 5768a505f0bc7b798dc2becdd3ee6442224f796c
510 | ReactNativeKeys: 0a9f34df1804a812c2bb80a19f7d4fabd839fb0a
511 | Yoga: 5ed1699acbba8863755998a4245daa200ff3817b
512 |
513 | PODFILE CHECKSUM: 2f4270bc708bd398e6be06b58f7a2dec23d99d17
514 |
515 | COCOAPODS: 1.11.3
516 |
--------------------------------------------------------------------------------
/example/ios/Podfile.properties.json:
--------------------------------------------------------------------------------
1 | {
2 | "expo.jsEngine": "jsc"
3 | }
4 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample.xcodeproj/xcshareddata/xcschemes/reactnativekeysexample.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import
4 |
5 | #import
6 |
7 | @interface AppDelegate : EXAppDelegateWrapper
8 |
9 | @end
10 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/AppDelegate.mm:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 | #import
5 | #import
6 | #import
7 | #import
8 |
9 | #import
10 |
11 | #if RCT_NEW_ARCH_ENABLED
12 | #import
13 | #import
14 | #import
15 | #import
16 | #import
17 | #import
18 |
19 | #import
20 |
21 | static NSString *const kRNConcurrentRoot = @"concurrentRoot";
22 |
23 | @interface AppDelegate () {
24 | RCTTurboModuleManager *_turboModuleManager;
25 | RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
26 | std::shared_ptr _reactNativeConfig;
27 | facebook::react::ContextContainer::Shared _contextContainer;
28 | }
29 | @end
30 | #endif
31 |
32 | @implementation AppDelegate
33 |
34 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
35 | {
36 | self.moduleName = @"main";
37 | // You can add your custom initial props in the dictionary below.
38 | // They will be passed down to the ViewController used by React Native.
39 | self.initialProps = @{};
40 |
41 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
42 | }
43 |
44 | - (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge
45 | {
46 | // If you'd like to export some custom RCTBridgeModules, add them here!
47 | return @[];
48 | }
49 |
50 | /// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
51 | ///
52 | /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
53 | /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
54 | /// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
55 | - (BOOL)concurrentRootEnabled
56 | {
57 | // Switch this bool to turn on and off the concurrent root
58 | return true;
59 | }
60 |
61 | - (NSDictionary *)prepareInitialProps
62 | {
63 | NSMutableDictionary *initProps = [NSMutableDictionary new];
64 | #if RCT_NEW_ARCH_ENABLED
65 | initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]);
66 | #endif
67 | return initProps;
68 | }
69 |
70 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
71 | {
72 | #if DEBUG
73 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
74 | #else
75 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
76 | #endif
77 | }
78 |
79 | // Linking API
80 | - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options {
81 | return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options];
82 | }
83 |
84 | // Universal Links
85 | - (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler {
86 | BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler];
87 | return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result;
88 | }
89 |
90 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
91 | - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
92 | {
93 | return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
94 | }
95 |
96 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
97 | - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
98 | {
99 | return [super application:application didFailToRegisterForRemoteNotificationsWithError:error];
100 | }
101 |
102 | // Explicitly define remote notification delegates to ensure compatibility with some third-party libraries
103 | - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
104 | {
105 | return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
106 | }
107 |
108 | #if RCT_NEW_ARCH_ENABLED
109 |
110 | #pragma mark - RCTCxxBridgeDelegate
111 |
112 | - (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge
113 | {
114 | _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
115 | delegate:self
116 | jsInvoker:bridge.jsCallInvoker];
117 | return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
118 | }
119 |
120 | #pragma mark RCTTurboModuleManagerDelegate
121 |
122 | - (Class)getModuleClassFromName:(const char *)name
123 | {
124 | return RCTCoreModulesClassProvider(name);
125 | }
126 |
127 | - (std::shared_ptr)getTurboModule:(const std::string &)name
128 | jsInvoker:(std::shared_ptr)jsInvoker
129 | {
130 | return nullptr;
131 | }
132 |
133 | - (std::shared_ptr)getTurboModule:(const std::string &)name
134 | initParams:
135 | (const facebook::react::ObjCTurboModule::InitParams &)params
136 | {
137 | return nullptr;
138 | }
139 |
140 | - (id)getModuleInstanceFromClass:(Class)moduleClass
141 | {
142 | return RCTAppSetupDefaultModuleFromClass(moduleClass);
143 | }
144 |
145 | #endif
146 |
147 | @end
148 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/App-Icon-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "idiom": "iphone",
5 | "size": "20x20",
6 | "scale": "2x",
7 | "filename": "App-Icon-20x20@2x.png"
8 | },
9 | {
10 | "idiom": "iphone",
11 | "size": "20x20",
12 | "scale": "3x",
13 | "filename": "App-Icon-20x20@3x.png"
14 | },
15 | {
16 | "idiom": "iphone",
17 | "size": "29x29",
18 | "scale": "1x",
19 | "filename": "App-Icon-29x29@1x.png"
20 | },
21 | {
22 | "idiom": "iphone",
23 | "size": "29x29",
24 | "scale": "2x",
25 | "filename": "App-Icon-29x29@2x.png"
26 | },
27 | {
28 | "idiom": "iphone",
29 | "size": "29x29",
30 | "scale": "3x",
31 | "filename": "App-Icon-29x29@3x.png"
32 | },
33 | {
34 | "idiom": "iphone",
35 | "size": "40x40",
36 | "scale": "2x",
37 | "filename": "App-Icon-40x40@2x.png"
38 | },
39 | {
40 | "idiom": "iphone",
41 | "size": "40x40",
42 | "scale": "3x",
43 | "filename": "App-Icon-40x40@3x.png"
44 | },
45 | {
46 | "idiom": "iphone",
47 | "size": "60x60",
48 | "scale": "2x",
49 | "filename": "App-Icon-60x60@2x.png"
50 | },
51 | {
52 | "idiom": "iphone",
53 | "size": "60x60",
54 | "scale": "3x",
55 | "filename": "App-Icon-60x60@3x.png"
56 | },
57 | {
58 | "idiom": "ipad",
59 | "size": "20x20",
60 | "scale": "1x",
61 | "filename": "App-Icon-20x20@1x.png"
62 | },
63 | {
64 | "idiom": "ipad",
65 | "size": "20x20",
66 | "scale": "2x",
67 | "filename": "App-Icon-20x20@2x.png"
68 | },
69 | {
70 | "idiom": "ipad",
71 | "size": "29x29",
72 | "scale": "1x",
73 | "filename": "App-Icon-29x29@1x.png"
74 | },
75 | {
76 | "idiom": "ipad",
77 | "size": "29x29",
78 | "scale": "2x",
79 | "filename": "App-Icon-29x29@2x.png"
80 | },
81 | {
82 | "idiom": "ipad",
83 | "size": "40x40",
84 | "scale": "1x",
85 | "filename": "App-Icon-40x40@1x.png"
86 | },
87 | {
88 | "idiom": "ipad",
89 | "size": "40x40",
90 | "scale": "2x",
91 | "filename": "App-Icon-40x40@2x.png"
92 | },
93 | {
94 | "idiom": "ipad",
95 | "size": "76x76",
96 | "scale": "1x",
97 | "filename": "App-Icon-76x76@1x.png"
98 | },
99 | {
100 | "idiom": "ipad",
101 | "size": "76x76",
102 | "scale": "2x",
103 | "filename": "App-Icon-76x76@2x.png"
104 | },
105 | {
106 | "idiom": "ipad",
107 | "size": "83.5x83.5",
108 | "scale": "2x",
109 | "filename": "App-Icon-83.5x83.5@2x.png"
110 | },
111 | {
112 | "idiom": "ios-marketing",
113 | "size": "1024x1024",
114 | "scale": "1x",
115 | "filename": "ItunesArtwork@2x.png"
116 | }
117 | ],
118 | "info": {
119 | "version": 1,
120 | "author": "expo"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/AppIcon.appiconset/ItunesArtwork@2x.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "expo"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/SplashScreen.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "idiom": "universal",
5 | "filename": "image.png",
6 | "scale": "1x"
7 | },
8 | {
9 | "idiom": "universal",
10 | "scale": "2x"
11 | },
12 | {
13 | "idiom": "universal",
14 | "scale": "3x"
15 | }
16 | ],
17 | "info": {
18 | "version": 1,
19 | "author": "expo"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/SplashScreen.imageset/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/SplashScreen.imageset/image.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/SplashScreenBackground.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "idiom": "universal",
5 | "filename": "image.png",
6 | "scale": "1x"
7 | },
8 | {
9 | "idiom": "universal",
10 | "scale": "2x"
11 | },
12 | {
13 | "idiom": "universal",
14 | "scale": "3x"
15 | }
16 | ],
17 | "info": {
18 | "version": 1,
19 | "author": "expo"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Images.xcassets/SplashScreenBackground.imageset/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingstinct/react-native-hotkeys/1b033cb3867b06fc2fdeb1ecadc2d64d893d406e/example/ios/reactnativekeysexample/Images.xcassets/SplashScreenBackground.imageset/image.png
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | react-native-keys-example
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
19 | CFBundleShortVersionString
20 | 1.0.0
21 | CFBundleSignature
22 | ????
23 | CFBundleURLTypes
24 |
25 |
26 | CFBundleURLSchemes
27 |
28 | expo.modules.keys.example
29 |
30 |
31 |
32 | CFBundleVersion
33 | 1
34 | LSRequiresIPhoneOS
35 |
36 | NSAppTransportSecurity
37 |
38 | NSAllowsArbitraryLoads
39 |
40 | NSExceptionDomains
41 |
42 | localhost
43 |
44 | NSExceptionAllowsInsecureHTTPLoads
45 |
46 |
47 |
48 |
49 | UILaunchStoryboardName
50 | SplashScreen
51 | UIRequiredDeviceCapabilities
52 |
53 | armv7
54 |
55 | UIRequiresFullScreen
56 |
57 | UIStatusBarStyle
58 | UIStatusBarStyleDefault
59 | UISupportedInterfaceOrientations
60 |
61 | UIInterfaceOrientationPortrait
62 | UIInterfaceOrientationPortraitUpsideDown
63 |
64 | UISupportedInterfaceOrientations~ipad
65 |
66 | UIInterfaceOrientationPortrait
67 | UIInterfaceOrientationPortraitUpsideDown
68 | UIInterfaceOrientationLandscapeLeft
69 | UIInterfaceOrientationLandscapeRight
70 |
71 | UIUserInterfaceStyle
72 | Light
73 | UIViewControllerBasedStatusBarAppearance
74 |
75 |
76 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/SplashScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/Supporting/Expo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | EXUpdatesCheckOnLaunch
6 | ALWAYS
7 | EXUpdatesEnabled
8 |
9 | EXUpdatesLaunchWaitMs
10 | 0
11 | EXUpdatesSDKVersion
12 | 47.0.0
13 | EXUpdatesURL
14 | https://exp.host/@robertherber/react-native-keys-example
15 |
16 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char * argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/noop-file.swift:
--------------------------------------------------------------------------------
1 | //
2 | // @generated
3 | // A blank Swift file must be created for native modules with Swift files to work correctly.
4 | //
5 |
--------------------------------------------------------------------------------
/example/ios/reactnativekeysexample/reactnativekeysexample.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | aps-environment
6 | development
7 |
8 |
--------------------------------------------------------------------------------
/example/metro.config.js:
--------------------------------------------------------------------------------
1 | // Learn more https://docs.expo.io/guides/customizing-metro
2 | const { getDefaultConfig } = require('expo/metro-config')
3 | const path = require('path')
4 |
5 | const config = getDefaultConfig(__dirname)
6 |
7 | // npm v7+ will install ../node_modules/react-native because of peerDependencies.
8 | // To prevent the incompatible react-native bewtween ./node_modules/react-native and ../node_modules/react-native,
9 | // excludes the one from the parent folder when bundling.
10 | config.resolver.blockList = [
11 | ...Array.from(config.resolver.blockList ?? []),
12 | new RegExp(path.resolve('..', 'node_modules', 'react-native')),
13 | new RegExp(path.resolve('..', 'node_modules', 'react-native-web')),
14 | ]
15 |
16 | config.resolver.nodeModulesPaths = [
17 | path.resolve(__dirname, './node_modules'),
18 | path.resolve(__dirname, '../node_modules'),
19 | ]
20 |
21 | config.watchFolders = [path.resolve(__dirname, '..')]
22 |
23 | config.transformer.getTransformOptions = async () => ({
24 | transform: {
25 | experimentalImportSupport: false,
26 | inlineRequires: true,
27 | },
28 | })
29 |
30 | module.exports = config
31 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-keys-example",
3 | "version": "1.0.0",
4 | "scripts": {
5 | "start": "expo start --dev-client",
6 | "android": "expo run:android",
7 | "ios": "expo run:ios",
8 | "web": "expo start --web",
9 | "lint-only": "eslint .",
10 | "typecheck": "tsc --noEmit",
11 | "lint": "yarn lint-only && yarn typecheck"
12 | },
13 | "dependencies": {
14 | "expo": "^48.0.5",
15 | "react": "18.2",
16 | "react-dom": "18.2",
17 | "react-native": "0.71",
18 | "react-native-web": "0.18",
19 | "@expo/webpack-config": "^18.0.1"
20 | },
21 | "devDependencies": {
22 | "@babel/core": "^7.20.2",
23 | "@graphql-eslint/eslint-plugin": "^3.13.1",
24 | "@types/jest": "^29.2.3",
25 | "@types/react": "~18.0.14",
26 | "@typescript-eslint/eslint-plugin": "^5.43.0",
27 | "@typescript-eslint/parser": "^5.43.0",
28 | "eslint": "^8.28.0",
29 | "eslint-config-airbnb": "^19.0.4",
30 | "eslint-config-airbnb-base": "^15.0.0",
31 | "eslint-config-kingstinct": "^5.1.1",
32 | "eslint-import-resolver-typescript": "^3.5.2",
33 | "eslint-plugin-comment-length": "^0.9.2",
34 | "eslint-plugin-functional": "^5.0.5",
35 | "eslint-plugin-import": "^2.26.0",
36 | "eslint-plugin-jest": "^27.1.5",
37 | "eslint-plugin-jsonc": "^2.5.0",
38 | "eslint-plugin-jsx-a11y": "^6.6.1",
39 | "eslint-plugin-react": "^7.31.11",
40 | "eslint-plugin-react-hooks": "^4.6.0",
41 | "eslint-plugin-react-native": "^4.0.0",
42 | "eslint-plugin-react-native-a11y": "^3.3.0",
43 | "eslint-plugin-unicorn": "^46.0.0",
44 | "eslint-plugin-yml": "^1.2.0",
45 | "graphql": "^16.6.0",
46 | "jest": "^29.3.1",
47 | "ts-node": "^10.9.1",
48 | "typescript": "^4.9.3"
49 | },
50 | "private": true,
51 | "expo": {
52 | "autolinking": {
53 | "nativeModulesDir": ".."
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "expo/tsconfig.base",
3 | "compilerOptions": {
4 | "forceConsistentCasingInFileNames": true,
5 | "strict": true,
6 | "paths": {
7 | "react-native-hotkeys": [ "../src/index" ],
8 | "react-native-hotkeys/*": [ "../src/*" ]
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/expo-module.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "platforms": [
3 | "ios",
4 | "web"
5 | ],
6 | "ios": {
7 | "modules": [ "ReactNativeKeysModule" ]
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ios/AppLifecycleDelegate.swift:
--------------------------------------------------------------------------------
1 | import ExpoModulesCore
2 |
3 | var hello: [UIMenu] = []
4 |
5 | // seems not to be possible quite yet - because it might cause side effects
6 | public class AppLifecycleDelegate: ExpoAppDelegateSubscriber {
7 | func openMenu() -> UIMenu {
8 | let openCommand =
9 | UIKeyCommand(title: "My custom menu item",
10 | image: nil,
11 | action: #selector(self.openAction),
12 | input: "o",
13 | modifierFlags: .command)
14 | let openMenu =
15 | UIMenu(title: "yo",
16 | image: nil,
17 | identifier: nil,
18 | options: .displayInline,
19 | children: [openCommand])
20 | return openMenu
21 | }
22 |
23 | @objc func openAction(){
24 |
25 | }
26 |
27 | public override func buildMenu(with builder: UIMenuBuilder) {
28 | builder.insertChild(openMenu(), atEndOfMenu: UIMenu.Identifier.edit)
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ios/ReactNativeKeys.podspec:
--------------------------------------------------------------------------------
1 | require 'json'
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4 |
5 | Pod::Spec.new do |s|
6 | s.name = 'ReactNativeKeys'
7 | s.version = package['version']
8 | s.summary = package['description']
9 | s.description = package['description']
10 | s.license = package['license']
11 | s.author = package['author']
12 | s.homepage = package['homepage']
13 | s.platform = :ios, '13.0'
14 | s.swift_version = '5.4'
15 | s.source = { git: 'https://github.com/robertherber/kingstinct-react-native-keys' }
16 | s.static_framework = true
17 |
18 | s.dependency 'ExpoModulesCore'
19 |
20 | # Swift/Objective-C compatibility
21 | s.pod_target_xcconfig = {
22 | 'DEFINES_MODULE' => 'YES',
23 | 'SWIFT_COMPILATION_MODE' => 'wholemodule'
24 | }
25 |
26 | s.source_files = "**/*.{h,m,swift}"
27 | end
28 |
--------------------------------------------------------------------------------
/ios/ReactNativeKeysModule.swift:
--------------------------------------------------------------------------------
1 | import ExpoModulesCore
2 |
3 | enum Modifier: String, Enumerable {
4 | case alphaShift
5 | case shift
6 | case control
7 | case alternate
8 | case command
9 | case numericPad
10 | }
11 |
12 | struct CommandArgs: Record {
13 | @Field
14 | var input: String;
15 |
16 | @Field
17 | var title: String?;
18 |
19 | @Field
20 | var modifiers: [Modifier] = []
21 | }
22 |
23 | public class ReactNativeKeysModule: Module {
24 | // Each module class must implement the definition function. The definition consists of components
25 | // that describes the module's functionality and behavior.
26 | // See https://docs.expo.dev/modules/module-api for more details about available components.
27 | public func definition() -> ModuleDefinition {
28 | // Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
29 | // Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
30 | // The module will be accessible from `requireNativeModule('ReactNativeKeys')` in JavaScript.
31 | Name("ReactNativeKeys")
32 |
33 | // Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
34 | Constants([
35 | "PI": Double.pi
36 | ])
37 |
38 | // Defines event names that the module can send to JavaScript.
39 | Events("keyup", "keydown", "command")
40 |
41 | // Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
42 | Function("hello") {
43 | return "Hello world! 👋"
44 | }
45 |
46 | // Defines a JavaScript function that always returns a Promise and whose native code
47 | // is by default dispatched on the different thread than the JavaScript runtime runs on.
48 | AsyncFunction("setValueAsync") { (value: String) in
49 | // Send an event to JavaScript.
50 | self.sendEvent("onChange", [
51 | "value": value
52 | ])
53 | }
54 |
55 |
56 |
57 | // Enables the module to be used as a native view. Definition components that are accepted as part of the
58 | // view definition: Prop, Events.
59 | View(ReactNativeKeysView.self) {
60 | // Defines a setter for the `name` prop.
61 | Prop("commands") { (view: ReactNativeKeysView, prop: [CommandArgs]) in
62 | view.setCommands(commands: prop)
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/ios/ReactNativeKeysView.swift:
--------------------------------------------------------------------------------
1 | import ExpoModulesCore
2 | import UIKit
3 |
4 | // This view will be used as a native component. Make sure to inherit from `ExpoView`
5 | // to apply the proper styling (e.g. border radius and shadows).
6 | class ReactNativeKeysView: ExpoView {
7 | override func pressesBegan(_ presses: Set, with event: UIPressesEvent?) {
8 | self.appContext?.eventEmitter?.sendEvent(withName: "keydown", body: [
9 | "type": event?.type.rawValue,
10 | "subtype": event?.subtype.rawValue,
11 | "timestamp": event?.timestamp,
12 | "touches": event?.allTouches.map({ touch in
13 | return [
14 | "force": touch.first?.force,
15 | "timestamp": touch.first?.timestamp,
16 | "type": touch.first?.type.rawValue,
17 | "tapCount": touch.first?.tapCount,
18 | "altitudeAngle": touch.first?.altitudeAngle,
19 | "majorRadius": touch.first?.majorRadius,
20 | ]
21 | }),
22 | "presses": presses.map({ press in
23 | return [
24 | "force": press.force,
25 | "timestamp": press.timestamp,
26 | "phase": press.phase.rawValue,
27 | "type": press.type.rawValue,
28 | "characters": press.key?.characters,
29 | "charactersIgnoringModifiers": press.key?.charactersIgnoringModifiers,
30 | "keyCode": press.key?.keyCode.rawValue,
31 | "modifierFlags": [
32 | "shift": press.key?.modifierFlags.contains(UIKeyModifierFlags.shift),
33 | "command": press.key?.modifierFlags.contains(UIKeyModifierFlags.command),
34 | "control": press.key?.modifierFlags.contains(UIKeyModifierFlags.control),
35 | "alphaShift": press.key?.modifierFlags.contains(UIKeyModifierFlags.alphaShift),
36 | "alternate": press.key?.modifierFlags.contains(UIKeyModifierFlags.alternate),
37 | "numericPad": press.key?.modifierFlags.contains(UIKeyModifierFlags.numericPad),
38 | ],
39 | ]
40 | })
41 | ])
42 |
43 | let shouldPassEventForward = event!.allPresses.contains(where: { press in
44 | guard let key = press.key else {
45 | return false
46 | }
47 |
48 | if #available(iOS 13.4, *) {
49 | return key.keyCode != UIKeyboardHIDUsage.keyboardEscape // dont let escape pass, since it produces an annoying sound, and not passing it doesnt prevent focus to change (would like to add arrow keys as well, but that would break arrow keys in TextInputs
50 | } else {
51 | return true
52 | }
53 |
54 | })
55 |
56 | if(shouldPassEventForward){
57 | super.pressesBegan(presses, with: event)
58 | }
59 | }
60 |
61 |
62 | override func pressesEnded(_ presses: Set, with event: UIPressesEvent?) {
63 | self.appContext?.eventEmitter?.sendEvent(withName: "keyup", body: [
64 | "type": event?.type.rawValue,
65 | "subtype": event?.subtype.rawValue,
66 | "timestamp": event?.timestamp,
67 | "touches": event?.allTouches.map({ touch in
68 | return [
69 | "force": touch.first?.force,
70 | "timestamp": touch.first?.timestamp,
71 | "type": touch.first?.type.rawValue,
72 | "tapCount": touch.first?.tapCount,
73 | "altitudeAngle": touch.first?.altitudeAngle,
74 | "majorRadius": touch.first?.majorRadius,
75 | ]
76 | }),
77 | "presses": presses.map({ press in
78 | return [
79 | "force": press.force,
80 | "timestamp": press.timestamp,
81 | "phase": press.phase.rawValue,
82 | "type": press.type.rawValue,
83 | "characters": press.key?.characters,
84 | "charactersIgnoringModifiers": press.key?.charactersIgnoringModifiers,
85 | "keyCode": press.key?.keyCode.rawValue,
86 | "modifierFlags": [
87 | "shift": press.key?.modifierFlags.contains(UIKeyModifierFlags.shift),
88 | "command": press.key?.modifierFlags.contains(UIKeyModifierFlags.command),
89 | "control": press.key?.modifierFlags.contains(UIKeyModifierFlags.control),
90 | "alphaShift": press.key?.modifierFlags.contains(UIKeyModifierFlags.alphaShift),
91 | "alternate": press.key?.modifierFlags.contains(UIKeyModifierFlags.alternate),
92 | "numericPad": press.key?.modifierFlags.contains(UIKeyModifierFlags.numericPad),
93 | ],
94 | ]
95 | })
96 | ])
97 | super.pressesEnded(presses, with: event)
98 | }
99 |
100 | var _keyCommands: [UIKeyCommand]? = []
101 |
102 |
103 | override var keyCommands: [UIKeyCommand]? {
104 | return _keyCommands
105 | }
106 |
107 |
108 | func setCommands(commands: [CommandArgs]){
109 | _keyCommands?.removeAll()
110 | _keyCommands?.append(contentsOf: commands.map({ command in
111 |
112 | let modifierFlags = UIKeyModifierFlags(command.modifiers.map({ el in
113 | switch el {
114 | case .command: return UIKeyModifierFlags.command
115 | case .control: return UIKeyModifierFlags.control
116 | case .alphaShift: return UIKeyModifierFlags.alphaShift
117 | case .shift: return UIKeyModifierFlags.shift
118 | case .alternate: return UIKeyModifierFlags.alternate
119 | case .numericPad: return UIKeyModifierFlags.numericPad
120 | }
121 | }))
122 |
123 | guard let title = command.title else {
124 | return UIKeyCommand(
125 | input: command.input,
126 | modifierFlags: modifierFlags,
127 | action: #selector(onCommand)
128 | );
129 | }
130 |
131 |
132 |
133 | return UIKeyCommand(
134 | title: title, /*image: UIImage.init(systemName: "square.and.arrow.up"),*/
135 | action: #selector(onCommand),
136 | input: command.input,
137 | modifierFlags: modifierFlags,
138 | discoverabilityTitle: title
139 | )
140 |
141 | }))
142 | }
143 |
144 | @objc func onCommand(sender: UIKeyCommand) {
145 | appContext?.eventEmitter?.sendEvent(withName: "command", body: [
146 | "input": sender.input!,
147 | "modifierFlags": [
148 | "shift": sender.modifierFlags.contains(UIKeyModifierFlags.shift),
149 | "command": sender.modifierFlags.contains(UIKeyModifierFlags.command),
150 | "control": sender.modifierFlags.contains(UIKeyModifierFlags.control),
151 | "alphaShift": sender.modifierFlags.contains(UIKeyModifierFlags.alphaShift),
152 | "alternate": sender.modifierFlags.contains(UIKeyModifierFlags.alternate),
153 | "numericPad": sender.modifierFlags.contains(UIKeyModifierFlags.numericPad),
154 | ],
155 | ])
156 | }
157 |
158 | required init(appContext: AppContext? = nil) {
159 | super.init(appContext: appContext)
160 | self.becomeFirstResponder()
161 |
162 | }
163 |
164 | override func pressesChanged(_ presses: Set, with event: UIPressesEvent?) {
165 |
166 | }
167 |
168 | override func pressesCancelled(_ presses: Set, with event: UIPressesEvent?) {
169 |
170 | }
171 |
172 |
173 | override var canBecomeFocused: Bool {
174 | get{
175 | return true
176 | }
177 | }
178 |
179 | override var canBecomeFirstResponder: Bool {
180 | return true
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/lefthook.yml:
--------------------------------------------------------------------------------
1 | pre-push:
2 | parallel: true
3 | commands:
4 | lint:
5 | run: npm run lint
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-hotkeys",
3 | "version": "0.5.8",
4 | "description": "Hotkeys support for React Native (iOS and web)",
5 | "main": "build/index.js",
6 | "types": "build/index.d.ts",
7 | "scripts": {
8 | "build": "tsc",
9 | "clean": "expo-module clean",
10 | "lint": "expo-module lint",
11 | "test": "expo-module test",
12 | "prepare": "expo-module prepare",
13 | "prepublishOnly": "expo-module prepublishOnly && yarn build",
14 | "expo-module": "expo-module",
15 | "open:ios": "open -a \"Xcode\" example/ios",
16 | "open:android": "open -a \"Android Studio\" example/android"
17 | },
18 | "keywords": [
19 | "react-native",
20 | "expo",
21 | "react-native-hotkeys",
22 | "ReactNativeKeys"
23 | ],
24 | "private": false,
25 | "repository": "https://github.com/robertherber/kingstinct-react-native-keys",
26 | "bugs": {
27 | "url": "https://github.com/robertherber/kingstinct-react-native-keys/issues"
28 | },
29 | "author": "Robert Herber (https://github.com/robertherber)",
30 | "license": "MIT",
31 | "homepage": "https://github.com/robertherber/kingstinct-react-native-keys#readme",
32 | "dependencies": {
33 | "ts-key-enum": "^2.0.12"
34 | },
35 | "devDependencies": {
36 | "@babel/core": "^7.20.2",
37 | "@evilmartians/lefthook": "^1.2.1",
38 | "@graphql-eslint/eslint-plugin": "^3.13.1",
39 | "@types/jest": "^29.2.3",
40 | "@types/react": "^18.0.25",
41 | "@typescript-eslint/eslint-plugin": "^5.43.0",
42 | "@typescript-eslint/parser": "^5.43.0",
43 | "airbnb": "^0.0.2",
44 | "eslint": "^8.28.0",
45 | "eslint-config-airbnb": "^19.0.4",
46 | "eslint-config-airbnb-base": "^15.0.0",
47 | "eslint-config-kingstinct": "^5.1.1",
48 | "eslint-import-resolver-typescript": "^3.5.2",
49 | "eslint-plugin-comment-length": "^0.9.2",
50 | "eslint-plugin-functional": "^5.0.5",
51 | "eslint-plugin-import": "^2.26.0",
52 | "eslint-plugin-jest": "^27.1.5",
53 | "eslint-plugin-jsonc": "^2.5.0",
54 | "eslint-plugin-jsx-a11y": "^6.6.1",
55 | "eslint-plugin-react": "^7.31.11",
56 | "eslint-plugin-react-hooks": "^4.6.0",
57 | "eslint-plugin-react-native": "^4.0.0",
58 | "eslint-plugin-react-native-a11y": "^3.3.0",
59 | "eslint-plugin-unicorn": "^46.0.0",
60 | "eslint-plugin-yml": "^1.2.0",
61 | "expo": "^48.0.5",
62 | "expo-module-scripts": "^3.0.3",
63 | "expo-modules-core": "^1.0.3",
64 | "graphql": "^16.6.0",
65 | "jest": "^29.3.1",
66 | "react-native": "^0.71.4",
67 | "typescript": "^4.9.3"
68 | },
69 | "peerDependencies": {
70 | "expo": "*",
71 | "react": "*",
72 | "react-dom": "*",
73 | "react-native": "*"
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/ReactNativeKeysModule.ts:
--------------------------------------------------------------------------------
1 | import { requireNativeModule } from 'expo-modules-core'
2 |
3 | // It loads the native module object from the JSI or falls back to
4 | // the bridge module (from NativeModulesProxy) if the remote debugger is on.
5 | export default requireNativeModule('ReactNativeKeys')
6 |
--------------------------------------------------------------------------------
/src/ReactNativeKeysModule.web.ts:
--------------------------------------------------------------------------------
1 | export default {}
2 |
--------------------------------------------------------------------------------
/src/ReactNativeKeysView.tsx:
--------------------------------------------------------------------------------
1 | import { requireNativeViewManager } from 'expo-modules-core'
2 | import * as React from 'react'
3 |
4 | import type { ReactNativeKeysViewProps } from './types'
5 |
6 | const NativeView: React.ComponentType = requireNativeViewManager('ReactNativeKeys')
7 |
8 | export default function ReactNativeKeysView(props: ReactNativeKeysViewProps) {
9 | return
10 | }
11 |
--------------------------------------------------------------------------------
/src/ReactNativeKeysView.web.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react'
2 | import { View } from 'react-native'
3 |
4 | import type { ReactNativeKeysViewProps } from './types'
5 |
6 | export default function ReactNativeKeysView(props: ReactNativeKeysViewProps) {
7 | return
8 | }
9 |
--------------------------------------------------------------------------------
/src/contexts/KeysContext.tsx:
--------------------------------------------------------------------------------
1 | import React, {
2 | useCallback, useEffect, useMemo, useRef, useState, createContext,
3 | } from 'react'
4 | import { StyleSheet } from 'react-native'
5 |
6 | import ReactNativeKeysView from '../ReactNativeKeysView'
7 | import { MapKeyArgToIos } from '../types'
8 | import addEventListener from '../utils/addEventListener'
9 | import { keyMap } from '../utils/mapWebKeyCode'
10 |
11 | import type {
12 | CommandModifiers, ReactNativeKeysEvent, KeyCode, Command,
13 | } from '../types'
14 | import type { Subscription } from 'expo-modules-core'
15 | import type { PropsWithChildren } from 'react'
16 |
17 | export type OnPressCallback = (
18 | event: ReactNativeKeysEvent
19 | ) => PromiseLike | boolean | void;
20 |
21 | type RegisterCallback = (
22 | key: KeyCode,
23 | modifiers: readonly CommandModifiers[],
24 | callback: OnPressCallback,
25 | priority: number,
26 | id: string,
27 | title?: string
28 | ) => Subscription
29 |
30 | type KeyHandlerCallback = {
31 | readonly keyCode: KeyCode,
32 | readonly modifiers: readonly CommandModifiers[],
33 | readonly callback: OnPressCallback,
34 | readonly priority: number,
35 | readonly title?: string
36 | readonly id: string
37 | }
38 |
39 | type KeysProviderProps = PropsWithChildren<{
40 | readonly defaultHandler?: (event: ReactNativeKeysEvent) => void
41 | }>
42 |
43 | export const KeysContext = createContext({
44 | setCommands: (() => {}) as (React.Dispatch>),
45 | addCallback: (() => ({ remove: () => {} })) as RegisterCallback,
46 | })
47 |
48 | export const KeysProvider: React.FC = ({ children, defaultHandler }) => {
49 | const [commands, setCommands] = useState([])
50 | // eslint-disable-next-line functional/prefer-readonly-type
51 | const callbacks = useRef([])
52 | const addCallback = useCallback((
53 | keyCode, modifiers, callback, priority, id, title,
54 | ) => {
55 | callbacks.current.push({
56 | callback, keyCode, priority, modifiers, id, title,
57 | })
58 | const mappedModifiers = modifiers.map((m) => MapKeyArgToIos[m])
59 | setCommands((c) => [
60 | ...c, {
61 | input: keyMap[keyCode] as string,
62 | modifiers: mappedModifiers,
63 | id,
64 | title,
65 | },
66 | ])
67 | return ({
68 | remove: () => {
69 | setCommands((c) => c.filter((a) => a.id !== id))
70 | callbacks.current = callbacks.current.filter((c) => id !== c.id)
71 | },
72 | })
73 | }, [])
74 |
75 | const onPress = useCallback(async (event: ReactNativeKeysEvent) => {
76 | const sortedCallbacks = callbacks.current
77 | .filter((c) => c.keyCode === event.keyCode)
78 | .sort((a, b) => b.priority - a.priority)
79 |
80 | const wasHandled = await sortedCallbacks.reduce(async (prev, { callback }) => {
81 | if (await prev) {
82 | return true
83 | }
84 | const value = await callback(event)
85 | return value !== false
86 | }, Promise.resolve(false))
87 |
88 | if (!wasHandled) {
89 | defaultHandler?.(event)
90 | }
91 | }, [defaultHandler])
92 |
93 | useEffect(() => {
94 | const subscription = addEventListener('keyup', (event) => {
95 | void onPress(event)
96 | }, {
97 | capture: true,
98 | passive: true,
99 | })
100 | return () => {
101 | subscription.remove()
102 | }
103 | }, [onPress])
104 |
105 | return (
106 | ({ setCommands, addCallback }), [addCallback])}
108 | >
109 |
113 | {children}
114 |
115 |
116 | )
117 | }
118 |
119 | const styles = StyleSheet.create({
120 | keysView: { flex: 1 },
121 | })
122 |
123 | export default KeysContext
124 |
--------------------------------------------------------------------------------
/src/hooks/useHotkey.ts:
--------------------------------------------------------------------------------
1 | import {
2 | useCallback, useContext, useEffect, useId, useMemo, useRef, useState,
3 | } from 'react'
4 |
5 | import KeysContext from '../contexts/KeysContext'
6 | import dealWithEvent from '../utils/dealWithEvent'
7 |
8 | import type { OnPressCallback } from '../contexts/KeysContext'
9 | import type { CommandModifiers, KeyCode } from '../types'
10 |
11 | const modifiersAsArray = (
12 | modifiers: CommandModifiers | readonly CommandModifiers[],
13 | ): readonly CommandModifiers[] => (
14 | Array.isArray(modifiers) ? modifiers : [modifiers]
15 | )
16 |
17 | const useHotkey = (
18 | key: KeyCode,
19 | onPress: OnPressCallback,
20 | opts: { readonly priority?: number, readonly title?: string, readonly isEnabled?: boolean, readonly modifiers?: CommandModifiers | readonly CommandModifiers[] } = {},
21 | ) => {
22 | const modifiers = useMemo(() => opts?.modifiers || [], [opts?.modifiers]),
23 | { addCallback } = useContext(KeysContext),
24 | [modifiersSafe, setModifiersSafe] = useState(modifiersAsArray(modifiers))
25 |
26 | useEffect(() => {
27 | const mods = modifiersAsArray(modifiers)
28 | if (mods.some((m, i) => m !== modifiersSafe[i])) {
29 | setModifiersSafe(modifiersAsArray(modifiers))
30 | }
31 | }, [modifiers, modifiersSafe])
32 |
33 | const callbackRef = useRef(onPress)
34 |
35 | useEffect(() => {
36 | callbackRef.current = onPress
37 | }, [onPress])
38 |
39 | const safeCallback = useCallback((event) => dealWithEvent(event, modifiersSafe, key, callbackRef.current), [key, modifiersSafe])
40 |
41 | const isEnabled = opts?.isEnabled ?? true
42 | const priority = opts?.priority ?? 0
43 |
44 | const id = useId()
45 |
46 | useEffect(() => {
47 | if (isEnabled) {
48 | const listener = addCallback(key, modifiersSafe, safeCallback, priority, id)
49 | return () => listener.remove()
50 | }
51 | return () => {}
52 | }, [
53 | addCallback, safeCallback, priority, isEnabled, key, modifiersSafe, id,
54 | ])
55 | }
56 |
57 | export default useHotkey
58 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import KeysContext, { KeysProvider } from './contexts/KeysContext'
2 | import useHotkey from './hooks/useHotkey'
3 | import { ModifiersType, KeyCode, CommandKeyModifiers } from './types'
4 | import addEventListener from './utils/addEventListener'
5 |
6 | import type { CommandModifiers } from './types'
7 |
8 | export type { CommandModifiers as CommandKeyArgs }
9 | export {
10 | addEventListener,
11 | useHotkey,
12 | KeysContext,
13 | KeysProvider,
14 | CommandKeyModifiers as KeyModifiers,
15 | KeyCode as ReactNativeKeysKeyCode,
16 | ModifiersType,
17 | }
18 |
--------------------------------------------------------------------------------
/src/types.ts:
--------------------------------------------------------------------------------
1 | import type { Subscription } from 'expo-modules-core'
2 | import type { PropsWithChildren } from 'react'
3 | import type { StyleProp, ViewStyle } from 'react-native'
4 |
5 | export enum ModifiersType {
6 | 'Alt' = 'Alt',
7 | 'AltGraph' = 'AltGraph',
8 | 'CapsLock' = 'CapsLock',
9 | 'Control' = 'Control',
10 | 'Fn' = 'Fn',
11 | 'FnLock' = 'FnLock',
12 | 'Hyper' = 'Hyper',
13 | 'Meta' = 'Meta',
14 | 'NumLock' = 'NumLock',
15 | 'OS' = 'OS',
16 | 'ScrollLock' = 'ScrollLock',
17 | 'Shift' = 'Shift',
18 | 'Super' = 'Super',
19 | 'Symbol' = 'Symbol',
20 | 'SymbolLock' = 'SymbolLock',
21 | }
22 |
23 | export enum CommandKeyModifiers {
24 | alphaShift = 'alphaShift',
25 | shift = 'shift',
26 | control = 'control',
27 | alternate = 'alternate',
28 | command = 'command',
29 | numericPad = 'numericPad',
30 | }
31 |
32 | export type Command = {
33 | readonly id: string,
34 | readonly input: string;
35 | readonly title?: string;
36 | readonly modifiers: readonly (CommandKeyModifiers | `${CommandKeyModifiers}`)[]
37 | }
38 |
39 | export type ReactNativeKeysViewProps = PropsWithChildren<{
40 | readonly commands?: readonly Command[],
41 | readonly style?: StyleProp
42 | }>;
43 |
44 | export type Modifiers = ModifiersType | `${ModifiersType}`
45 |
46 | export const MapIosToModifier: Record = {
47 | alternate: ModifiersType.Alt,
48 | alphaShift: ModifiersType.Shift,
49 | command: ModifiersType.Hyper,
50 | control: ModifiersType.Control,
51 | numericPad: ModifiersType.NumLock,
52 | shift: ModifiersType.Shift,
53 | }
54 |
55 | type CommandModifiersEnum = ModifiersType.Alt | ModifiersType.Control | ModifiersType.Hyper | ModifiersType.NumLock | ModifiersType.Shift
56 | export type CommandModifiers = CommandModifiersEnum | `${CommandModifiersEnum}`
57 |
58 | export const MapKeyArgToIos: Record = {
59 | [ModifiersType.Alt]: CommandKeyModifiers.alternate,
60 | [ModifiersType.Hyper]: CommandKeyModifiers.command,
61 | [ModifiersType.Control]: CommandKeyModifiers.control,
62 | [ModifiersType.NumLock]: CommandKeyModifiers.numericPad,
63 | [ModifiersType.Shift]: CommandKeyModifiers.shift,
64 | }
65 |
66 | export enum UIPressPhase {
67 | began = 0,
68 | changed = 1,
69 | stationary = 2,
70 | ended = 3,
71 | cancelled = 4,
72 | }
73 |
74 | export enum UIPressType {
75 | upArrow = 0,
76 | downArrow = 1,
77 | leftArrow = 2,
78 | rightArrow = 3,
79 | select = 4,
80 | menu = 5,
81 | playPause = 6,
82 | }
83 |
84 | export type IosModifierFlags = {
85 | readonly shift: boolean;
86 | readonly command: boolean;
87 | readonly control: boolean;
88 | readonly alphaShift: boolean;
89 | readonly alternate: boolean;
90 | readonly numericPad: boolean;
91 | };
92 |
93 | export type IOSPress = {
94 | readonly force: number;
95 | readonly phase: UIPressPhase;
96 | readonly type: UIPressType;
97 | readonly characters: string;
98 | readonly charactersIgnoringModifiers: string;
99 | readonly keyCode: UIKeyboardHIDUsage;
100 | readonly modifierFlags: IosModifierFlags;
101 | };
102 |
103 | enum UIEventType {
104 | touches = 0,
105 | motion = 1,
106 | remoteControl = 2,
107 | presses = 3,
108 | scroll = 10,
109 | hover = 11,
110 | transform = 14,
111 | }
112 |
113 | enum UIEventSubtype {
114 | // available in iPhone OS 3.0
115 | none = 0,
116 |
117 | // for UIEventTypeMotion, available in iPhone OS 3.0
118 | motionShake = 1,
119 |
120 | // for UIEventTypeRemoteControl, available in iOS 4.0
121 | remoteControlPlay = 100,
122 |
123 | remoteControlPause = 101,
124 |
125 | remoteControlStop = 102,
126 |
127 | remoteControlTogglePlayPause = 103,
128 |
129 | remoteControlNextTrack = 104,
130 |
131 | remoteControlPreviousTrack = 105,
132 |
133 | remoteControlBeginSeekingBackward = 106,
134 |
135 | remoteControlEndSeekingBackward = 107,
136 |
137 | remoteControlBeginSeekingForward = 108,
138 |
139 | remoteControlEndSeekingForward = 109,
140 | }
141 |
142 | export type IOSKeyboardEvent = {
143 | readonly type: UIEventType;
144 | readonly subtype: UIEventSubtype;
145 | readonly presses: readonly IOSPress[];
146 | };
147 |
148 | export type ReactNativeKeysEvent = {
149 | readonly altKey: boolean;
150 | // readonly code: string;
151 | readonly ctrlKey: boolean;
152 | // readonly isComposing: boolean;
153 | readonly key?: string;
154 | // readonly location: number;
155 | readonly metaKey: boolean;
156 | // readonly repeat: boolean;
157 | readonly shiftKey: boolean;
158 | getModifierState(keyArg: Modifiers): boolean;
159 | readonly nativeEvent: IOSKeyboardEvent | KeyboardEvent;
160 | readonly keyCode: KeyCode | null;
161 | };
162 |
163 | export type CallbackFn = (event: ReactNativeKeysEvent) => void;
164 |
165 | export type CommandPayload = { readonly input: string, readonly modifierFlags: IosModifierFlags }
166 |
167 | export type CommandCallback = (payload: CommandPayload) => void
168 |
169 | export type EventTypes = 'command' | 'keydown' | 'keyup';
170 |
171 | export type ReactNativeKeysEventListener = ((
172 | eventType: TEventType,
173 | callback: TEventType extends 'command' ? CommandCallback : CallbackFn,
174 | options?: {
175 | /** Web Only */
176 | readonly passive?: boolean;
177 | readonly once?: boolean;
178 | /** Web Only */
179 | readonly capture?: boolean;
180 | }
181 | ) => Subscription);
182 |
183 | // All keys in
184 | export enum KeyCode {
185 | // Comma = 'Comma',
186 | // Period = 'Period',
187 | Alt = 'Alt',
188 | AltGraph = 'AltGraph',
189 | ArrowDown = 'ArrowDown',
190 | ArrowLeft = 'ArrowLeft',
191 | ArrowRight = 'ArrowRight',
192 | ArrowUp = 'ArrowUp',
193 | Backspace = 'Backspace',
194 | CapsLock = 'CapsLock',
195 | Control = 'Control',
196 | Copy = 'Copy' /* Copy */,
197 | Cut = 'Cut' /* Cut */,
198 | Delete = 'Delete',
199 | End = 'End',
200 | Enter = 'Enter',
201 | Escape = 'Escape',
202 | F1 = 'F1',
203 | F10 = 'F10',
204 | F11 = 'F11',
205 | F12 = 'F12',
206 | F13 = 'F13',
207 | F14 = 'F14',
208 | F15 = 'F15',
209 | F16 = 'F16',
210 | F17 = 'F17',
211 | F18 = 'F18',
212 | F19 = 'F19',
213 | F2 = 'F2',
214 | F20 = 'F20',
215 | F3 = 'F3',
216 | F4 = 'F4',
217 | F5 = 'F5',
218 | F6 = 'F6',
219 | F7 = 'F7',
220 | F8 = 'F8',
221 | F9 = 'F9',
222 | Find = 'Find' /* Find */,
223 | Help = 'Help',
224 | Home = 'Home',
225 | Insert = 'Insert',
226 | // This is better done with the string/regex
227 | Key0 = 'Key0',
228 | Key1 = 'Key1',
229 | Key2 = 'Key2',
230 | Key3 = 'Key3',
231 | Key4 = 'Key4',
232 | Key5 = 'Key5',
233 | Key6 = 'Key6',
234 | Key7 = 'Key7',
235 | Key8 = 'Key8',
236 | Key9 = 'Key9',
237 | KeyA = 'KeyA',
238 | KeyB = 'KeyB',
239 | KeyC = 'KeyC',
240 | KeyD = 'KeyD',
241 | KeyE = 'KeyE',
242 | KeyF = 'KeyF',
243 | KeyG = 'KeyG',
244 | KeyH = 'KeyH',
245 | KeyI = 'KeyI',
246 | KeyJ = 'KeyJ',
247 | KeyK = 'KeyK',
248 | KeyL = 'KeyL',
249 | KeyM = 'KeyM',
250 | KeyN = 'KeyN',
251 | KeyO = 'KeyO',
252 | KeyP = 'KeyP',
253 | KeyQ = 'KeyQ',
254 | KeyR = 'KeyR',
255 | KeyS = 'KeyS',
256 | KeyT = 'KeyT',
257 | KeyU = 'KeyU',
258 | KeyV = 'KeyV',
259 | KeyW = 'KeyW',
260 | KeyX = 'KeyX',
261 | KeyY = 'KeyY',
262 | KeyZ = 'KeyZ',
263 | Meta = 'Meta',
264 | Mute = 'Mute',
265 | NumberPadPlus = 'NumberPadPlus',
266 | NumLock = 'NumLock',
267 | PageDown = 'PageDown',
268 | PageUp = 'PageUp',
269 | Paste = 'Paste' /* Paste */,
270 | Pause = 'Pause',
271 | PrintScreen = 'PrintScreen',
272 | Redo = 'Redo',
273 | ScrollLock = 'ScrollLock',
274 | Shift = 'Shift',
275 | Stop = 'Stop' /* Stop */,
276 | Tab = 'Tab',
277 | Undo = 'Undo' /* Undo */,
278 | VolumeDown = 'VolumeDown',
279 | VolumeUp = 'VolumeUp',
280 | }
281 |
282 | // as per https://developer.apple.com/documentation/uikit/uikeyboardhidusage
283 | export enum UIKeyboardHIDUsage {
284 | keyboardErrorRollOver = 1 /* ErrorRollOver */,
285 | keyboardPOSTFail = 2 /* POSTFail */,
286 | keyboardErrorUndefined = 3 /* ErrorUndefined */,
287 | keyboardA = 4 /* a or A */,
288 | keyboardB = 5 /* b or B */,
289 | keyboardC = 6 /* c or C */,
290 | keyboardD = 7 /* d or D */,
291 | keyboardE = 8 /* e or E */,
292 | keyboardF = 9 /* f or F */,
293 | keyboardG = 10 /* g or G */,
294 | keyboardH = 11 /* h or H */,
295 | keyboardI = 12 /* i or I */,
296 | keyboardJ = 13 /* j or J */,
297 | keyboardK = 14 /* k or K */,
298 | keyboardL = 15 /* l or L */,
299 | keyboardM = 16 /* m or M */,
300 |
301 | keyboardN = 17 /* n or N */,
302 |
303 | keyboardO = 18 /* o or O */,
304 |
305 | keyboardP = 19 /* p or P */,
306 |
307 | keyboardQ = 20 /* q or Q */,
308 |
309 | keyboardR = 21 /* r or R */,
310 |
311 | keyboardS = 22 /* s or S */,
312 |
313 | keyboardT = 23 /* t or T */,
314 |
315 | keyboardU = 24 /* u or U */,
316 |
317 | keyboardV = 25 /* v or V */,
318 |
319 | keyboardW = 26 /* w or W */,
320 |
321 | keyboardX = 27 /* x or X */,
322 |
323 | keyboardY = 28 /* y or Y */,
324 |
325 | keyboardZ = 29 /* z or Z */,
326 |
327 | keyboard1 = 30 /* 1 or ! */,
328 |
329 | keyboard2 = 31 /* 2 or @ */,
330 |
331 | keyboard3 = 32 /* 3 or # */,
332 |
333 | keyboard4 = 33 /* 4 or $ */,
334 |
335 | keyboard5 = 34 /* 5 or % */,
336 |
337 | keyboard6 = 35 /* 6 or ^ */,
338 |
339 | keyboard7 = 36 /* 7 or & */,
340 |
341 | keyboard8 = 37 /* 8 or * */,
342 |
343 | keyboard9 = 38 /* 9 or ( */,
344 |
345 | keyboard0 = 39 /* 0 or ) */,
346 |
347 | keyboardReturnOrEnter = 40 /* Return (Enter) */,
348 |
349 | keyboardEscape = 41 /* Escape */,
350 |
351 | keyboardDeleteOrBackspace = 42 /* Delete (Backspace) */,
352 |
353 | keyboardTab = 43 /* Tab */,
354 |
355 | keyboardSpacebar = 44 /* Spacebar */,
356 |
357 | keyboardHyphen = 45 /* - or _ */,
358 |
359 | keyboardEqualSign = 46 /* = or + */,
360 |
361 | keyboardOpenBracket = 47 /* [ or { */,
362 |
363 | keyboardCloseBracket = 48 /* ] or } */,
364 |
365 | keyboardBackslash = 49 /* \ or | */,
366 |
367 | keyboardNonUSPound = 50 /* Non-US # or _ */,
368 |
369 | /* Typical language mappings: US: \| Belg: μ`£ FrCa: <}> Dan:’* Dutch: <> Fren:*μ
370 | Ger: #’ Ital: ù§ LatAm: }`] Nor:,* Span: }Ç Swed: ,*
371 | Swiss: $£ UK: #~. */
372 | keyboardSemicolon = 51 /* ; or : */,
373 |
374 | keyboardQuote = 52 /* ' or " */,
375 |
376 | keyboardGraveAccentAndTilde = 53 /* Grave Accent and Tilde */,
377 |
378 | keyboardComma = 54 /* , or < */,
379 |
380 | keyboardPeriod = 55 /* . or > */,
381 |
382 | keyboardSlash = 56 /* / or ? */,
383 |
384 | keyboardCapsLock = 57 /* Caps Lock */,
385 |
386 | /* Function keys */
387 | keyboardF1 = 58 /* F1 */,
388 |
389 | keyboardF2 = 59 /* F2 */,
390 |
391 | keyboardF3 = 60 /* F3 */,
392 |
393 | keyboardF4 = 61 /* F4 */,
394 |
395 | keyboardF5 = 62 /* F5 */,
396 |
397 | keyboardF6 = 63 /* F6 */,
398 |
399 | keyboardF7 = 64 /* F7 */,
400 |
401 | keyboardF8 = 65 /* F8 */,
402 |
403 | keyboardF9 = 66 /* F9 */,
404 |
405 | keyboardF10 = 67 /* F10 */,
406 |
407 | keyboardF11 = 68 /* F11 */,
408 |
409 | keyboardF12 = 69 /* F12 */,
410 |
411 | keyboardPrintScreen = 70 /* Print Screen */,
412 |
413 | keyboardScrollLock = 71 /* Scroll Lock */,
414 |
415 | keyboardPause = 72 /* Pause */,
416 |
417 | keyboardInsert = 73 /* Insert */,
418 |
419 | keyboardHome = 74 /* Home */,
420 |
421 | keyboardPageUp = 75 /* Page Up */,
422 |
423 | keyboardDeleteForward = 76 /* Delete Forward */,
424 |
425 | keyboardEnd = 77 /* End */,
426 |
427 | keyboardPageDown = 78 /* Page Down */,
428 |
429 | keyboardRightArrow = 79 /* Right Arrow */,
430 |
431 | keyboardLeftArrow = 80 /* Left Arrow */,
432 |
433 | keyboardDownArrow = 81 /* Down Arrow */,
434 |
435 | keyboardUpArrow = 82 /* Up Arrow */,
436 |
437 | /* Keypad (numpad) keys */
438 | keypadNumLock = 83 /* Keypad NumLock or Clear */,
439 |
440 | keypadSlash = 84 /* Keypad / */,
441 |
442 | keypadAsterisk = 85 /* Keypad * */,
443 |
444 | keypadHyphen = 86 /* Keypad - */,
445 |
446 | keypadPlus = 87 /* Keypad + */,
447 |
448 | keypadEnter = 88 /* Keypad Enter */,
449 |
450 | keypad1 = 89 /* Keypad 1 or End */,
451 |
452 | keypad2 = 90 /* Keypad 2 or Down Arrow */,
453 |
454 | keypad3 = 91 /* Keypad 3 or Page Down */,
455 |
456 | keypad4 = 92 /* Keypad 4 or Left Arrow */,
457 |
458 | keypad5 = 93 /* Keypad 5 */,
459 |
460 | keypad6 = 94 /* Keypad 6 or Right Arrow */,
461 |
462 | keypad7 = 95 /* Keypad 7 or Home */,
463 |
464 | keypad8 = 96 /* Keypad 8 or Up Arrow */,
465 |
466 | keypad9 = 97 /* Keypad 9 or Page Up */,
467 |
468 | keypad0 = 98 /* Keypad 0 or Insert */,
469 |
470 | keypadPeriod = 99 /* Keypad . or Delete */,
471 |
472 | keyboardNonUSBackslash = 100 /* Non-US \ or | */,
473 |
474 | /* On Apple ISO keyboards, this is the section symbol (§/±) */
475 | /* Typical language mappings: Belg:<\> FrCa:«°» Dan:<\> Dutch:]|[ Fren:<> Ger:<|>
476 | Ital:<> LatAm:<> Nor:<> Span:<> Swed:<|> Swiss:<\>
477 | UK:\| Brazil: \|. */
478 | keyboardApplication = 101 /* Application */,
479 |
480 | keyboardPower = 102 /* Power */,
481 |
482 | keypadEqualSign = 103 /* Keypad = */,
483 |
484 | /* Additional keys */
485 | keyboardF13 = 104 /* F13 */,
486 |
487 | keyboardF14 = 105 /* F14 */,
488 |
489 | keyboardF15 = 106 /* F15 */,
490 |
491 | keyboardF16 = 107 /* F16 */,
492 |
493 | keyboardF17 = 108 /* F17 */,
494 |
495 | keyboardF18 = 109 /* F18 */,
496 |
497 | keyboardF19 = 110 /* F19 */,
498 |
499 | keyboardF20 = 111 /* F20 */,
500 |
501 | keyboardF21 = 112 /* F21 */,
502 |
503 | keyboardF22 = 113 /* F22 */,
504 |
505 | keyboardF23 = 114 /* F23 */,
506 |
507 | keyboardF24 = 115 /* F24 */,
508 |
509 | keyboardExecute = 116 /* Execute */,
510 |
511 | keyboardHelp = 117 /* Help */,
512 |
513 | keyboardMenu = 118 /* Menu */,
514 |
515 | keyboardSelect = 119 /* Select */,
516 |
517 | keyboardStop = 120 /* Stop */,
518 |
519 | keyboardAgain = 121 /* Again */,
520 |
521 | keyboardUndo = 122 /* Undo */,
522 |
523 | keyboardCut = 123 /* Cut */,
524 |
525 | keyboardCopy = 124 /* Copy */,
526 |
527 | keyboardPaste = 125 /* Paste */,
528 |
529 | keyboardFind = 126 /* Find */,
530 |
531 | keyboardMute = 127 /* Mute */,
532 |
533 | keyboardVolumeUp = 128 /* Volume Up */,
534 |
535 | keyboardVolumeDown = 129 /* Volume Down */,
536 |
537 | keyboardLockingCapsLock = 130 /* Locking Caps Lock */,
538 |
539 | keyboardLockingNumLock = 131 /* Locking Num Lock */,
540 |
541 | /* Implemented as a locking key; sent as a toggle button. Available for legacy support;
542 | however, most systems should use the non-locking version of this key. */
543 | keyboardLockingScrollLock = 132 /* Locking Scroll Lock */,
544 |
545 | keypadComma = 133 /* Keypad Comma */,
546 |
547 | keypadEqualSignAS400 = 134 /* Keypad Equal Sign for AS/400 */,
548 |
549 | /* See the footnotes in the USB specification for what keys these are commonly mapped to.
550 | * https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf */
551 | keyboardInternational1 = 135 /* International1 */,
552 |
553 | keyboardInternational2 = 136 /* International2 */,
554 |
555 | keyboardInternational3 = 137 /* International3 */,
556 |
557 | keyboardInternational4 = 138 /* International4 */,
558 |
559 | keyboardInternational5 = 139 /* International5 */,
560 |
561 | keyboardInternational6 = 140 /* International6 */,
562 |
563 | keyboardInternational7 = 141 /* International7 */,
564 |
565 | keyboardInternational8 = 142 /* International8 */,
566 |
567 | keyboardInternational9 = 143 /* International9 */,
568 |
569 | /* LANG1: On Apple keyboard for Japanese, this is the kana switch (かな) key */
570 | /* On Korean keyboards, this is the Hangul/English toggle key. */
571 | keyboardLANG1 = 144 /* LANG1 */,
572 |
573 | /* LANG2: On Apple keyboards for Japanese, this is the alphanumeric (英数) key */
574 | /* On Korean keyboards, this is the Hanja conversion key. */
575 | keyboardLANG2 = 145 /* LANG2 */,
576 |
577 | /* LANG3: Defines the Katakana key for Japanese USB word-processing keyboards. */
578 | keyboardLANG3 = 146 /* LANG3 */,
579 |
580 | /* LANG4: Defines the Hiragana key for Japanese USB word-processing keyboards. */
581 | keyboardLANG4 = 147 /* LANG4 */,
582 |
583 | /* LANG5: Defines the Zenkaku/Hankaku key for Japanese USB word-processing keyboards. */
584 | keyboardLANG5 = 148 /* LANG5 */,
585 |
586 | /* LANG6-9: Reserved for language-specific functions, such as Front End Processors and Input Method Editors. */
587 | keyboardLANG6 = 149 /* LANG6 */,
588 |
589 | keyboardLANG7 = 150 /* LANG7 */,
590 |
591 | keyboardLANG8 = 151 /* LANG8 */,
592 |
593 | keyboardLANG9 = 152 /* LANG9 */,
594 |
595 | keyboardAlternateErase = 153 /* AlternateErase */,
596 |
597 | keyboardSysReqOrAttention = 154 /* SysReq/Attention */,
598 |
599 | keyboardCancel = 155 /* Cancel */,
600 |
601 | keyboardClear = 156 /* Clear */,
602 |
603 | keyboardPrior = 157 /* Prior */,
604 |
605 | keyboardReturn = 158 /* Return */,
606 |
607 | keyboardSeparator = 159 /* Separator */,
608 |
609 | keyboardOut = 160 /* Out */,
610 |
611 | keyboardOper = 161 /* Oper */,
612 |
613 | keyboardClearOrAgain = 162 /* Clear/Again */,
614 |
615 | keyboardCrSelOrProps = 163 /* CrSel/Props */,
616 |
617 | keyboardExSel = 164 /* ExSel */,
618 |
619 | /* 0xA5-0xDF: Reserved */
620 |
621 | keyboardLeftControl = 224 /* Left Control */,
622 |
623 | keyboardLeftShift = 225 /* Left Shift */,
624 |
625 | keyboardLeftAlt = 226 /* Left Alt */,
626 |
627 | keyboardLeftGUI = 227 /* Left GUI */,
628 |
629 | keyboardRightControl = 228 /* Right Control */,
630 |
631 | keyboardRightShift = 229 /* Right Shift */,
632 |
633 | keyboardRightAlt = 230 /* Right Alt */,
634 |
635 | keyboardRightGUI = 231 /* Right GUI */,
636 |
637 | /* 0xE8-0xFFFF: Reserved */
638 | keyboard_Reserved = 65535,
639 | }
640 |
--------------------------------------------------------------------------------
/src/utils/addEventListener.ts:
--------------------------------------------------------------------------------
1 | // eslint-disable-next-line import/no-extraneous-dependencies
2 | import { EventEmitter, NativeModulesProxy } from 'expo-modules-core'
3 |
4 | import mapIosKeyCode from './mapIosKeyCode'
5 | import ReactNativeKeysModule from '../ReactNativeKeysModule'
6 | import { ModifiersType } from '../types'
7 |
8 | import type {
9 | CallbackFn, CommandCallback, CommandPayload, EventTypes, IOSKeyboardEvent, ReactNativeKeysEvent,
10 | } from '../types'
11 |
12 | // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
13 | const emitter = new EventEmitter(ReactNativeKeysModule ?? NativeModulesProxy.ReactNativeKeys)
14 |
15 | const transformEvent = (nativeEvent: IOSKeyboardEvent) => {
16 | const { modifierFlags, characters, keyCode } = nativeEvent.presses[0] || {}
17 |
18 | const getModifierState: ReactNativeKeysEvent['getModifierState'] = (
19 | key,
20 | ) => {
21 | switch (key) {
22 | case ModifiersType.Hyper:
23 | return modifierFlags.command
24 | case ModifiersType.Alt:
25 | return modifierFlags.alternate
26 | case ModifiersType.Meta:
27 | return modifierFlags.command
28 | case ModifiersType.Control:
29 | return modifierFlags.control
30 | case ModifiersType.Shift:
31 | return modifierFlags.shift
32 | case ModifiersType.CapsLock:
33 | return modifierFlags.alphaShift
34 | default:
35 | return false
36 | }
37 | }
38 |
39 | return {
40 | altKey: modifierFlags.alternate,
41 | ctrlKey: modifierFlags.control,
42 | metaKey: modifierFlags.command,
43 | shiftKey: modifierFlags.shift,
44 | getModifierState,
45 | key: characters,
46 | nativeEvent,
47 | keyCode: mapIosKeyCode(keyCode),
48 | }
49 | }
50 |
51 | function addEventListener(
52 | eventName: TEventName,
53 | callback: TEventName extends 'command' ? CommandCallback : CallbackFn,
54 | options?: {
55 | /** Web Only */
56 | readonly passive?: boolean;
57 | readonly once?: boolean;
58 | /** Web Only */
59 | readonly capture?: boolean;
60 | },
61 | ) {
62 | if (eventName === 'command') {
63 | const subscription = emitter.addListener('command', (event) => {
64 | if (options?.once) {
65 | subscription.remove()
66 | }
67 | const cb = callback as CommandCallback
68 | return cb(event as CommandPayload)
69 | })
70 |
71 | return subscription
72 | }
73 |
74 | const cb = callback as CallbackFn
75 |
76 | const subscription = emitter.addListener(eventName, (event: IOSKeyboardEvent) => {
77 | if (options?.once) {
78 | subscription.remove()
79 | }
80 | return cb(transformEvent(event))
81 | })
82 |
83 | return subscription
84 | }
85 |
86 | export const removeAllListeners = emitter.removeAllListeners.bind(emitter)
87 |
88 | export default addEventListener
89 |
--------------------------------------------------------------------------------
/src/utils/addEventListener.web.ts:
--------------------------------------------------------------------------------
1 | import mapWebKeyCode from './mapWebKeyCode'
2 | import {
3 | ModifiersType,
4 | } from '../types'
5 |
6 | import type {
7 | ReactNativeKeysEvent,
8 | EventTypes,
9 | CommandCallback,
10 | CallbackFn,
11 | } from '../types'
12 | import type { Subscription } from 'expo-modules-core'
13 | import type { Key } from 'ts-key-enum'
14 |
15 | export * from '../types'
16 |
17 | function addEventListener(
18 | eventType: TEventType,
19 | callback: TEventType extends 'command' ? CommandCallback : CallbackFn,
20 | opts?: {
21 | /** Web Only */
22 | readonly passive?: boolean;
23 | readonly once?: boolean;
24 | /** Web Only */
25 | readonly capture?: boolean;
26 | },
27 | ): Subscription {
28 | if (eventType === 'command') {
29 | return addEventListener('keydown', (event) => {
30 | const cb = callback as CommandCallback
31 | if (event.key) {
32 | cb({
33 | input: event.key,
34 | modifierFlags: {
35 | alphaShift: event.shiftKey,
36 | alternate: event.altKey,
37 | command: event.metaKey,
38 | control: event.ctrlKey,
39 | numericPad: false,
40 | shift: event.shiftKey,
41 | },
42 | })
43 | }
44 | }, opts)
45 | }
46 | const internalCallback = (nativeEvent: KeyboardEvent) => {
47 | const event: ReactNativeKeysEvent = {
48 | altKey: nativeEvent.altKey,
49 | nativeEvent,
50 | ctrlKey: nativeEvent.ctrlKey,
51 | key: nativeEvent.key,
52 | keyCode: mapWebKeyCode(nativeEvent.key as Key),
53 | metaKey: nativeEvent.metaKey,
54 | shiftKey: nativeEvent.shiftKey,
55 | getModifierState: (keyArg) => {
56 | switch (keyArg) {
57 | case ModifiersType.Alt:
58 | return nativeEvent.altKey
59 | case ModifiersType.Shift:
60 | return nativeEvent.shiftKey
61 | case ModifiersType.Control:
62 | return nativeEvent.ctrlKey
63 | case ModifiersType.Meta:
64 | return nativeEvent.metaKey
65 | default:
66 | return nativeEvent.getModifierState(keyArg)
67 | }
68 | },
69 | }
70 | const cb = callback as CallbackFn
71 | cb(event)
72 | }
73 |
74 | const options = {
75 | once: opts?.once,
76 | passive: opts?.passive,
77 | capture: opts?.capture,
78 | }
79 |
80 | document.body.addEventListener(eventType as 'keydown' | 'keyup', internalCallback, options)
81 |
82 | return {
83 | remove: () => {
84 | document.body.removeEventListener(eventType as 'keydown' | 'keyup', internalCallback, options)
85 | },
86 | }
87 | }
88 |
89 | export default addEventListener
90 |
--------------------------------------------------------------------------------
/src/utils/dealWithEvent.ts:
--------------------------------------------------------------------------------
1 | import type { OnPressCallback } from '../contexts/KeysContext'
2 | import type { Modifiers, ReactNativeKeysEvent, KeyCode } from '../types'
3 |
4 | function dealWithEvent(
5 | event: ReactNativeKeysEvent,
6 | modifiers: readonly Modifiers[],
7 | keyToMatch: KeyCode,
8 | action: OnPressCallback,
9 | ) {
10 | const keyCodeMatch = keyToMatch === event.keyCode
11 | const modifiersMatch = modifiers.length === 0 || modifiers.every((k) => event.getModifierState(k))
12 |
13 | if (keyCodeMatch && modifiersMatch) {
14 | return action(event)
15 | }
16 | return false
17 | }
18 |
19 | export default dealWithEvent
20 |
--------------------------------------------------------------------------------
/src/utils/mapIosKeyCode.ts:
--------------------------------------------------------------------------------
1 | import { KeyCode, UIKeyboardHIDUsage } from '../types'
2 |
3 | const keyMap: Record<
4 | KeyCode,
5 | UIKeyboardHIDUsage | readonly UIKeyboardHIDUsage[]
6 | > = {
7 | [KeyCode.Alt]: [
8 | UIKeyboardHIDUsage.keyboardLeftAlt,
9 | UIKeyboardHIDUsage.keyboardRightAlt,
10 | ],
11 | [KeyCode.ScrollLock]: UIKeyboardHIDUsage.keyboardScrollLock,
12 | [KeyCode.Control]: [
13 | UIKeyboardHIDUsage.keyboardLeftControl,
14 | UIKeyboardHIDUsage.keyboardRightControl,
15 | ],
16 | [KeyCode.AltGraph]: [],
17 | [KeyCode.NumLock]: UIKeyboardHIDUsage.keypadNumLock,
18 | [KeyCode.CapsLock]: UIKeyboardHIDUsage.keyboardCapsLock,
19 | [KeyCode.Shift]: [
20 | UIKeyboardHIDUsage.keyboardLeftShift,
21 | UIKeyboardHIDUsage.keyboardRightShift,
22 | ],
23 | Meta: [],
24 | PrintScreen: UIKeyboardHIDUsage.keyboardPrintScreen,
25 | [KeyCode.NumberPadPlus]: UIKeyboardHIDUsage.keypadPlus,
26 | [KeyCode.CapsLock]: UIKeyboardHIDUsage.keyboardCapsLock,
27 | [KeyCode.Escape]: UIKeyboardHIDUsage.keyboardEscape,
28 | // [ReactNativeKeysKeyCode.Space]: UIKeyboardHIDUsage.keyboardSpacebar,
29 | [KeyCode.Delete]: UIKeyboardHIDUsage.keyboardDeleteForward,
30 | [KeyCode.Backspace]:
31 | UIKeyboardHIDUsage.keyboardDeleteOrBackspace,
32 | [KeyCode.Enter]: UIKeyboardHIDUsage.keyboardReturnOrEnter,
33 | [KeyCode.Tab]: UIKeyboardHIDUsage.keyboardTab,
34 | [KeyCode.PageUp]: UIKeyboardHIDUsage.keyboardPageUp,
35 | [KeyCode.PageDown]: UIKeyboardHIDUsage.keyboardPageDown,
36 | [KeyCode.End]: UIKeyboardHIDUsage.keyboardEnd,
37 | [KeyCode.Home]: UIKeyboardHIDUsage.keyboardHome,
38 | [KeyCode.ArrowLeft]: UIKeyboardHIDUsage.keyboardLeftArrow,
39 | [KeyCode.ArrowUp]: UIKeyboardHIDUsage.keyboardUpArrow,
40 | [KeyCode.ArrowRight]: UIKeyboardHIDUsage.keyboardRightArrow,
41 | [KeyCode.ArrowDown]: UIKeyboardHIDUsage.keyboardDownArrow,
42 | [KeyCode.Insert]: UIKeyboardHIDUsage.keyboardInsert,
43 | [KeyCode.Help]: UIKeyboardHIDUsage.keyboardHelp,
44 | [KeyCode.Mute]: UIKeyboardHIDUsage.keyboardMute,
45 | [KeyCode.VolumeDown]: UIKeyboardHIDUsage.keyboardVolumeDown,
46 | [KeyCode.VolumeUp]: UIKeyboardHIDUsage.keyboardVolumeUp,
47 | // [ReactNativeKeysKeyCode.Comma]: UIKeyboardHIDUsage.keyboardComma,
48 | // [ReactNativeKeysKeyCode.Period]: UIKeyboardHIDUsage.keyboardPeriod,
49 | [KeyCode.Key0]: UIKeyboardHIDUsage.keyboard0,
50 | [KeyCode.Key1]: UIKeyboardHIDUsage.keyboard1,
51 | [KeyCode.Key2]: UIKeyboardHIDUsage.keyboard2,
52 | [KeyCode.Key3]: UIKeyboardHIDUsage.keyboard3,
53 | [KeyCode.Key4]: UIKeyboardHIDUsage.keyboard4,
54 | [KeyCode.Key5]: UIKeyboardHIDUsage.keyboard5,
55 | [KeyCode.Key6]: UIKeyboardHIDUsage.keyboard6,
56 | [KeyCode.Key7]: UIKeyboardHIDUsage.keyboard7,
57 | [KeyCode.Key8]: UIKeyboardHIDUsage.keyboard8,
58 | [KeyCode.Key9]: UIKeyboardHIDUsage.keyboard9,
59 | [KeyCode.KeyA]: UIKeyboardHIDUsage.keyboardA,
60 | [KeyCode.KeyB]: UIKeyboardHIDUsage.keyboardB,
61 | [KeyCode.KeyC]: UIKeyboardHIDUsage.keyboardC,
62 | [KeyCode.KeyD]: UIKeyboardHIDUsage.keyboardD,
63 | [KeyCode.KeyE]: UIKeyboardHIDUsage.keyboardE,
64 | [KeyCode.KeyF]: UIKeyboardHIDUsage.keyboardF,
65 | [KeyCode.KeyG]: UIKeyboardHIDUsage.keyboardG,
66 | [KeyCode.KeyH]: UIKeyboardHIDUsage.keyboardH,
67 | [KeyCode.KeyI]: UIKeyboardHIDUsage.keyboardI,
68 | [KeyCode.KeyJ]: UIKeyboardHIDUsage.keyboardJ,
69 | [KeyCode.KeyK]: UIKeyboardHIDUsage.keyboardK,
70 | [KeyCode.KeyL]: UIKeyboardHIDUsage.keyboardL,
71 | [KeyCode.KeyM]: UIKeyboardHIDUsage.keyboardM,
72 | [KeyCode.KeyN]: UIKeyboardHIDUsage.keyboardN,
73 | [KeyCode.KeyO]: UIKeyboardHIDUsage.keyboardO,
74 | [KeyCode.KeyP]: UIKeyboardHIDUsage.keyboardP,
75 | [KeyCode.KeyQ]: UIKeyboardHIDUsage.keyboardQ,
76 | [KeyCode.KeyR]: UIKeyboardHIDUsage.keyboardR,
77 | [KeyCode.KeyS]: UIKeyboardHIDUsage.keyboardS,
78 | [KeyCode.KeyT]: UIKeyboardHIDUsage.keyboardT,
79 | [KeyCode.KeyU]: UIKeyboardHIDUsage.keyboardU,
80 | [KeyCode.KeyV]: UIKeyboardHIDUsage.keyboardV,
81 | [KeyCode.KeyW]: UIKeyboardHIDUsage.keyboardW,
82 | [KeyCode.KeyX]: UIKeyboardHIDUsage.keyboardX,
83 | [KeyCode.KeyY]: UIKeyboardHIDUsage.keyboardY,
84 | [KeyCode.KeyZ]: UIKeyboardHIDUsage.keyboardZ,
85 | [KeyCode.Pause]: UIKeyboardHIDUsage.keyboardPause,
86 | [KeyCode.F1]: UIKeyboardHIDUsage.keyboardF1,
87 | [KeyCode.F2]: UIKeyboardHIDUsage.keyboardF2,
88 | [KeyCode.F3]: UIKeyboardHIDUsage.keyboardF3,
89 | [KeyCode.F4]: UIKeyboardHIDUsage.keyboardF4,
90 | [KeyCode.F5]: UIKeyboardHIDUsage.keyboardF5,
91 | [KeyCode.F6]: UIKeyboardHIDUsage.keyboardF6,
92 | [KeyCode.F7]: UIKeyboardHIDUsage.keyboardF7,
93 | [KeyCode.F8]: UIKeyboardHIDUsage.keyboardF8,
94 | [KeyCode.F9]: UIKeyboardHIDUsage.keyboardF9,
95 | [KeyCode.F10]: UIKeyboardHIDUsage.keyboardF10,
96 | [KeyCode.F11]: UIKeyboardHIDUsage.keyboardF11,
97 | [KeyCode.F12]: UIKeyboardHIDUsage.keyboardF12,
98 | [KeyCode.F13]: UIKeyboardHIDUsage.keyboardF13,
99 | [KeyCode.F14]: UIKeyboardHIDUsage.keyboardF14,
100 | [KeyCode.F15]: UIKeyboardHIDUsage.keyboardF15,
101 | [KeyCode.F16]: UIKeyboardHIDUsage.keyboardF16,
102 | [KeyCode.F17]: UIKeyboardHIDUsage.keyboardF17,
103 | [KeyCode.F18]: UIKeyboardHIDUsage.keyboardF18,
104 | [KeyCode.F19]: UIKeyboardHIDUsage.keyboardF19,
105 | [KeyCode.F20]: UIKeyboardHIDUsage.keyboardF20,
106 | [KeyCode.Find]: UIKeyboardHIDUsage.keyboardFind,
107 | [KeyCode.Redo]: UIKeyboardHIDUsage.keyboardAgain,
108 | [KeyCode.Stop]: UIKeyboardHIDUsage.keyboardStop,
109 | [KeyCode.Cut]: UIKeyboardHIDUsage.keyboardCut,
110 | [KeyCode.Paste]: UIKeyboardHIDUsage.keyboardPaste,
111 | [KeyCode.Undo]: UIKeyboardHIDUsage.keyboardUndo,
112 | [KeyCode.Copy]: UIKeyboardHIDUsage.keyboardCopy,
113 | [KeyCode.CapsLock]: UIKeyboardHIDUsage.keyboardCapsLock,
114 | }
115 |
116 | const mapIosKeyCode = (
117 | keyCode?: UIKeyboardHIDUsage,
118 | ): KeyCode | null => (
119 | (Object.keys(keyMap).find((k) => {
120 | const val = keyMap[k as KeyCode]
121 | return Array.isArray(val) && keyCode ? val.includes(keyCode) : val === keyCode
122 | }) as unknown as KeyCode) || null
123 | )
124 |
125 | export default mapIosKeyCode
126 |
--------------------------------------------------------------------------------
/src/utils/mapWebKeyCode.ts:
--------------------------------------------------------------------------------
1 | import { Key } from 'ts-key-enum'
2 |
3 | import { KeyCode } from '../types'
4 |
5 | export const keyMap: Record = {
6 | [KeyCode.Alt]: Key.Alt,
7 | [KeyCode.AltGraph]: Key.AltGraph,
8 | [KeyCode.ArrowDown]: Key.ArrowDown,
9 | [KeyCode.ArrowLeft]: Key.ArrowLeft,
10 | [KeyCode.ArrowRight]: Key.ArrowRight,
11 | [KeyCode.ArrowUp]: Key.ArrowUp,
12 | [KeyCode.Backspace]: Key.Backspace,
13 | [KeyCode.CapsLock]: Key.CapsLock,
14 | [KeyCode.Control]: Key.Control,
15 | [KeyCode.Delete]: Key.Delete,
16 | [KeyCode.End]: Key.End,
17 | [KeyCode.Enter]: Key.Enter,
18 | [KeyCode.Escape]: Key.Escape,
19 | [KeyCode.F1]: Key.F1,
20 | [KeyCode.F10]: Key.F10,
21 | [KeyCode.F11]: Key.F11,
22 | [KeyCode.F12]: Key.F12,
23 | [KeyCode.F13]: Key.F13,
24 | [KeyCode.F14]: Key.F14,
25 | [KeyCode.F15]: Key.F15,
26 | [KeyCode.F16]: Key.F16,
27 | [KeyCode.F17]: Key.F17,
28 | [KeyCode.F18]: Key.F18,
29 | [KeyCode.F19]: Key.F19,
30 | [KeyCode.F2]: Key.F2,
31 | [KeyCode.F20]: Key.F20,
32 | [KeyCode.F3]: Key.F3,
33 | [KeyCode.F4]: Key.F4,
34 | [KeyCode.F5]: Key.F5,
35 | [KeyCode.F6]: Key.F6,
36 | [KeyCode.F7]: Key.F7,
37 | [KeyCode.F8]: Key.F8,
38 | [KeyCode.F9]: Key.F9,
39 | [KeyCode.Undo]: Key.Undo,
40 | [KeyCode.Cut]: Key.Cut,
41 | [KeyCode.Paste]: Key.Paste,
42 | [KeyCode.Copy]: Key.Copy,
43 | [KeyCode.Find]: Key.Find,
44 | [KeyCode.Stop]: Key.MediaStop,
45 | [KeyCode.Redo]: [Key.Again, Key.Redo],
46 | [KeyCode.Help]: Key.Help,
47 | [KeyCode.Home]: Key.Home,
48 | [KeyCode.Insert]: Key.Insert,
49 | [KeyCode.Meta]: Key.Meta,
50 | [KeyCode.Mute]: Key.AudioVolumeMute,
51 | [KeyCode.NumberPadPlus]: Key.Add,
52 | [KeyCode.NumLock]: Key.NumLock,
53 | [KeyCode.PageDown]: Key.PageDown,
54 | [KeyCode.PageUp]: Key.PageUp,
55 | [KeyCode.Pause]: Key.Pause,
56 | [KeyCode.PrintScreen]: Key.PrintScreen,
57 | [KeyCode.ScrollLock]: Key.ScrollLock,
58 | [KeyCode.Shift]: Key.Shift,
59 | // [UnifiedKeyCode.Space]: ExtendedKeySpace.Space,
60 | [KeyCode.Tab]: Key.Tab,
61 | [KeyCode.VolumeDown]: Key.AudioVolumeDown,
62 | [KeyCode.VolumeUp]: Key.AudioVolumeUp,
63 | [KeyCode.Key0]: '0',
64 | [KeyCode.Key1]: '1',
65 | [KeyCode.Key2]: '2',
66 | [KeyCode.Key3]: '3',
67 | [KeyCode.Key4]: '4',
68 | [KeyCode.Key5]: '5',
69 | [KeyCode.Key6]: '6',
70 | [KeyCode.Key7]: '7',
71 | [KeyCode.Key8]: '8',
72 | [KeyCode.Key9]: '9',
73 | [KeyCode.KeyA]: 'a',
74 | [KeyCode.KeyB]: 'b',
75 | [KeyCode.KeyC]: 'c',
76 | [KeyCode.KeyD]: 'd',
77 | [KeyCode.KeyE]: 'e',
78 | [KeyCode.KeyF]: 'f',
79 | [KeyCode.KeyG]: 'g',
80 | [KeyCode.KeyH]: 'h',
81 | [KeyCode.KeyI]: 'i',
82 | [KeyCode.KeyJ]: 'j',
83 | [KeyCode.KeyK]: 'k',
84 | [KeyCode.KeyL]: 'l',
85 | [KeyCode.KeyM]: 'm',
86 | [KeyCode.KeyN]: 'n',
87 | [KeyCode.KeyO]: 'o',
88 | [KeyCode.KeyP]: 'p',
89 | [KeyCode.KeyQ]: 'q',
90 | [KeyCode.KeyR]: 'r',
91 | [KeyCode.KeyS]: 's',
92 | [KeyCode.KeyT]: 't',
93 | [KeyCode.KeyU]: 'u',
94 | [KeyCode.KeyV]: 'v',
95 | [KeyCode.KeyW]: 'w',
96 | [KeyCode.KeyX]: 'x',
97 | [KeyCode.KeyY]: 'y',
98 | [KeyCode.KeyZ]: 'z',
99 | }
100 |
101 | const mapWebKeyCode = (key: Key): KeyCode | null => (
102 | (Object.keys(keyMap).find((k) => {
103 | const val = keyMap[k as KeyCode] as Key | readonly Key[]
104 | return Array.isArray(val) ? val.includes(key) : val === key
105 | }) as unknown as KeyCode) || null
106 | )
107 |
108 | export default mapWebKeyCode
109 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "expo/tsconfig.base",
3 | "compilerOptions": {
4 | "outDir": "./build",
5 | "forceConsistentCasingInFileNames": true,
6 | "strict": true,
7 | "declaration": true,
8 | "noEmit": false
9 | },
10 | "include": [ "./src" ],
11 | "exclude": [
12 | "**/__mocks__/*",
13 | "**/__tests__/*",
14 | "**/__stories__/*"
15 | ]
16 | }
17 |
--------------------------------------------------------------------------------