)eventDispatcher
26 | {
27 | return [self moduleForName:@"EventDispatcher" lazilyLoadIfNecessary:YES];
28 | }
29 |
30 | @end
31 |
--------------------------------------------------------------------------------
/packages/core/react-android/react/src/main/java/com/facebook/proguard/annotations/KeepGettersAndSetters.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | package com.facebook.proguard.annotations;
9 |
10 | import static java.lang.annotation.RetentionPolicy.CLASS;
11 |
12 | import java.lang.annotation.ElementType;
13 | import java.lang.annotation.Retention;
14 | import java.lang.annotation.Target;
15 |
16 | /**
17 | * Add this annotation to a class, to keep all "void set*(***)" and get* methods.
18 | *
19 | * This is useful for classes that are controlled by animator-like classes that control various
20 | * properties with reflection.
21 | *
22 | *
NOTE: This is not needed for Views because their getters and setters are
23 | * automatically kept by the default Android SDK ProGuard config.
24 | */
25 | @Target({ElementType.TYPE})
26 | @Retention(CLASS)
27 | public @interface KeepGettersAndSetters {}
28 |
--------------------------------------------------------------------------------
/packages/core/react-android/react/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | package com.facebook.react.bridge;
9 |
10 | import android.app.Activity;
11 | import android.content.Context;
12 |
13 | /**
14 | * A context wrapper that always wraps Android Application {@link Context} and {
15 | * CatalystInstance} by extending {@link ReactContext}
16 | */
17 | public class ReactApplicationContext extends ReactContext {
18 | // We want to wrap ApplicationContext, since there is no easy way to verify that application
19 | // context is passed as a param, we use {@link Context#getApplicationContext} to ensure that
20 | // the context we're wrapping is in fact an application context.
21 | public ReactApplicationContext(Context context) {
22 | super(context.getApplicationContext());
23 | }
24 |
25 | }
26 |
27 | // Nothing reactish here, which is good news.
28 |
--------------------------------------------------------------------------------
/packages/core/react-android/react/src/main/java/com/facebook/react/jstasks/NoRetryPolicy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | package com.facebook.react.jstasks;
9 |
10 | public class NoRetryPolicy implements HeadlessJsTaskRetryPolicy {
11 |
12 | public static final NoRetryPolicy INSTANCE = new NoRetryPolicy();
13 |
14 | private NoRetryPolicy() {}
15 |
16 | @Override
17 | public boolean canRetry() {
18 | return false;
19 | }
20 |
21 | @Override
22 | public int getDelay() {
23 | throw new IllegalStateException("Should not retrieve delay as canRetry is: " + canRetry());
24 | }
25 |
26 | @Override
27 | public HeadlessJsTaskRetryPolicy update() {
28 | throw new IllegalStateException("Should not update as canRetry is: " + canRetry());
29 | }
30 |
31 | @Override
32 | public HeadlessJsTaskRetryPolicy copy() {
33 | // Class is immutable so no need to copy
34 | return this;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/packages/core/react-android/react/src/main/java/com/facebook/react/bridge/WritableMap.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | package com.facebook.react.bridge;
9 |
10 | import androidx.annotation.NonNull;
11 | import androidx.annotation.Nullable;
12 |
13 | /** Interface for a mutable map. Used to pass arguments from Java to JS. */
14 | public interface WritableMap extends ReadableMap {
15 |
16 | void putNull(@NonNull String key);
17 |
18 | void putBoolean(@NonNull String key, boolean value);
19 |
20 | void putDouble(@NonNull String key, double value);
21 |
22 | void putInt(@NonNull String key, int value);
23 |
24 | void putString(@NonNull String key, @Nullable String value);
25 |
26 | void putArray(@NonNull String key, @Nullable ReadableArray value);
27 |
28 | void putMap(@NonNull String key, @Nullable ReadableMap value);
29 |
30 | void merge(@NonNull ReadableMap source);
31 |
32 | WritableMap copy();
33 | }
34 |
--------------------------------------------------------------------------------
/apps/demo-react-native/.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 |
24 | # Android/IntelliJ
25 | #
26 | build/
27 | .idea
28 | .gradle
29 | local.properties
30 | *.iml
31 | *.hprof
32 |
33 | # node.js
34 | #
35 | node_modules/
36 | npm-debug.log
37 | yarn-error.log
38 |
39 | # BUCK
40 | buck-out/
41 | \.buckd/
42 | *.keystore
43 | !debug.keystore
44 |
45 | # fastlane
46 | #
47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48 | # screenshots whenever they are needed.
49 | # For more information about the recommended setup visit:
50 | # https://docs.fastlane.tools/best-practices/source-control/
51 |
52 | */fastlane/report.xml
53 | */fastlane/Preview.html
54 | */fastlane/screenshots
55 |
56 | # Bundle artifact
57 | *.jsbundle
58 |
59 | # CocoaPods
60 | /ios/Pods/
61 |
--------------------------------------------------------------------------------
/packages/core/react-android/react/src/main/java/com/facebook/react/module/annotations/ReactModuleList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | package com.facebook.react.module.annotations;
9 |
10 | import static java.lang.annotation.ElementType.TYPE;
11 | import static java.lang.annotation.RetentionPolicy.SOURCE;
12 |
13 | import com.facebook.react.bridge.NativeModule;
14 | import java.lang.annotation.Retention;
15 | import java.lang.annotation.Target;
16 |
17 | /**
18 | * Annotates a function that returns a list of ModuleSpecs from which we get a list of NativeModules
19 | * to create ReactModuleInfos from.
20 | */
21 | @Retention(SOURCE)
22 | @Target(TYPE)
23 | public @interface ReactModuleList {
24 |
25 | /**
26 | * The Native modules in this list should be annotated with {@link ReactModule}.
27 | *
28 | * @return List of Native modules in the package.
29 | */
30 | Class extends NativeModule>[] nativeModules();
31 | }
32 |
--------------------------------------------------------------------------------
/nx.json:
--------------------------------------------------------------------------------
1 | {
2 | "namedInputs": {
3 | "default": ["{projectRoot}/**/*", "sharedGlobals"],
4 | "sharedGlobals": ["{workspaceRoot}/workspace.json", "{workspaceRoot}/tsconfig.base.json", "{workspaceRoot}/tslint.json", "{workspaceRoot}/nx.json"],
5 | "production": ["default", "!{projectRoot}/.eslintrc.json", "!{projectRoot}/src/test-setup.[jt]s"]
6 | },
7 | "workspaceLayout": {
8 | "appsDir": "apps",
9 | "libsDir": "packages"
10 | },
11 | "tasksRunnerOptions": {
12 | "default": {
13 | "options": {
14 | "runtimeCacheInputs": ["node -v"]
15 | }
16 | }
17 | },
18 | "$schema": "./node_modules/nx/schemas/nx-schema.json",
19 | "useDaemonProcess": false,
20 | "parallel": 1,
21 | "targetDefaults": {
22 | "build": {
23 | "cache": true
24 | },
25 | "build.all": {
26 | "cache": true
27 | },
28 | "build.hooks": {
29 | "cache": true
30 | },
31 | "lint": {
32 | "cache": true
33 | },
34 | "test": {
35 | "cache": true
36 | },
37 | "e2e": {
38 | "cache": true
39 | }
40 | },
41 | "defaultBase": "master"
42 | }
43 |
--------------------------------------------------------------------------------
/packages/core/react-android/react/src/main/java/com/facebook/react/views/scroll/ScrollEventType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | package com.facebook.react.views.scroll;
9 |
10 | /** Scroll event types that JS module RCTEventEmitter can understand */
11 | public enum ScrollEventType {
12 | BEGIN_DRAG,
13 | END_DRAG,
14 | SCROLL,
15 | MOMENTUM_BEGIN,
16 | MOMENTUM_END;
17 |
18 | public static String getJSEventName(ScrollEventType type) {
19 | switch (type) {
20 | case BEGIN_DRAG:
21 | return "topScrollBeginDrag";
22 | case END_DRAG:
23 | return "topScrollEndDrag";
24 | case SCROLL:
25 | return "topScroll";
26 | case MOMENTUM_BEGIN:
27 | return "topMomentumScrollBegin";
28 | case MOMENTUM_END:
29 | return "topMomentumScrollEnd";
30 | default:
31 | throw new IllegalArgumentException("Unsupported ScrollEventType: " + type);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/apps/demo-react-native/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "idiom": "iphone",
5 | "scale": "2x",
6 | "size": "20x20"
7 | },
8 | {
9 | "idiom": "iphone",
10 | "scale": "3x",
11 | "size": "20x20"
12 | },
13 | {
14 | "idiom": "iphone",
15 | "scale": "2x",
16 | "size": "29x29"
17 | },
18 | {
19 | "idiom": "iphone",
20 | "scale": "3x",
21 | "size": "29x29"
22 | },
23 | {
24 | "idiom": "iphone",
25 | "scale": "2x",
26 | "size": "40x40"
27 | },
28 | {
29 | "idiom": "iphone",
30 | "scale": "3x",
31 | "size": "40x40"
32 | },
33 | {
34 | "idiom": "iphone",
35 | "scale": "2x",
36 | "size": "60x60"
37 | },
38 | {
39 | "idiom": "iphone",
40 | "scale": "3x",
41 | "size": "60x60"
42 | },
43 | {
44 | "idiom": "ios-marketing",
45 | "scale": "1x",
46 | "size": "1024x1024"
47 | }
48 | ],
49 | "info": {
50 | "author": "xcode",
51 | "version": 1
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/packages/core/platforms/ios/lib_core/Libraries/LinkingIOS/RCTLinkingPlugins.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | *
7 | * @generated by an internal plugin build system
8 | */
9 |
10 | #ifdef RN_DISABLE_OSS_PLUGIN_HEADER
11 |
12 | // FB Internal: FBRCTLinkingPlugins.h is autogenerated by the build system.
13 | #import
14 |
15 | #else
16 |
17 | // OSS-compatibility layer
18 |
19 | #import
20 |
21 | #pragma GCC diagnostic push
22 | #pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | // RCTTurboModuleManagerDelegate should call this to resolve module classes.
29 | Class RCTLinkingClassProvider(const char *name);
30 |
31 | // Lookup functions
32 | Class RCTLinkingManagerCls(void) __attribute__((used));
33 |
34 | #ifdef __cplusplus
35 | }
36 | #endif
37 |
38 | #pragma GCC diagnostic pop
39 |
40 | #endif // RN_DISABLE_OSS_PLUGIN_HEADER
41 |
--------------------------------------------------------------------------------
/packages/react-native-module-test/.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 |
24 | # Android/IntelliJ
25 | #
26 | build/
27 | .idea
28 | .gradle
29 | local.properties
30 | *.iml
31 | *.hprof
32 |
33 | # node.js
34 | #
35 | node_modules/
36 | npm-debug.log
37 | yarn-error.log
38 |
39 | # BUCK
40 | buck-out/
41 | \.buckd/
42 | *.keystore
43 | !debug.keystore
44 |
45 | # fastlane
46 | #
47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48 | # screenshots whenever they are needed.
49 | # For more information about the recommended setup visit:
50 | # https://docs.fastlane.tools/best-practices/source-control/
51 |
52 | */fastlane/report.xml
53 | */fastlane/Preview.html
54 | */fastlane/screenshots
55 |
56 | # Bundle artifact
57 | *.jsbundle
58 |
59 | # CocoaPods
60 | /ios/Pods/
61 |
--------------------------------------------------------------------------------
/tsconfig.base.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "rootDir": ".",
4 | "sourceMap": true,
5 | "declaration": true,
6 | "moduleResolution": "node",
7 | "emitDecoratorMetadata": true,
8 | "experimentalDecorators": true,
9 | "noEmitHelpers": false,
10 | "target": "ES2020",
11 | "module": "ESNext",
12 | "jsx": "react-native",
13 | "lib": [
14 | "ESNext",
15 | "dom"
16 | ],
17 | "skipLibCheck": true,
18 | "skipDefaultLibCheck": true,
19 | "baseUrl": ".",
20 | "plugins": [
21 | {
22 | "transform": "@nativescript/webpack/dist/transformers/NativeClass",
23 | "type": "raw"
24 | }
25 | ],
26 | "paths": {
27 | "@demo/shared": [
28 | "tools/demo/index.ts"
29 | ],
30 | "@open-native/core": [
31 | "packages/core/index.d.ts"
32 | ],
33 | "react-native-module-test": [
34 | "packages/react-native-module-test/index.d.ts"
35 | ],
36 | "@open-native/*": [
37 | "packages/*"
38 | ]
39 | }
40 | },
41 | "exclude": [
42 | "node_modules",
43 | "tmp"
44 | ]
45 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Ammar Ahmed
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/core/hooks/ios/extractors/module-aliased-name.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Gets the aliased name for a bridge module if there is one.
3 | * @param classImplementation The source code for the bridge module's
4 | * class implementation.
5 | * @returns The aliased name for the bridge module as a string, or undefined if
6 | * no alias was registered (in which case, the Obj-C class name should be used
7 | * for the bridge module as-is).
8 | */
9 | export function extractModuleAliasedName(
10 | classImplementation: string
11 | ): string | undefined {
12 | const exportModuleMatches = [
13 | ...classImplementation.matchAll(/RCT_EXPORT_MODULE\((.*)\)/gm),
14 | ];
15 | const exportModuleNoLoadMatches = [
16 | ...classImplementation.matchAll(/RCT_EXPORT_MODULE_NO_LOAD\((.*)\)/gm),
17 | ];
18 | const exportPreRegisteredModuleNoLoadMatches = [
19 | ...classImplementation.matchAll(
20 | /RCT_EXPORT_PRE_REGISTERED_MODULE\((.*)\)/gm
21 | ),
22 | ];
23 |
24 | return (
25 | exportModuleMatches[0]?.[1] ||
26 | exportModuleNoLoadMatches[0]?.[1] ||
27 | exportPreRegisteredModuleNoLoadMatches[0]?.[1]
28 | );
29 | }
30 |
--------------------------------------------------------------------------------
/packages/core/react-android/react/src/main/java/com/facebook/react/bridge/NativeModuleCallExceptionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | package com.facebook.react.bridge;
9 |
10 | /**
11 | * Interface for a class that knows how to handle an Exception thrown by a native module invoked
12 | * from JS. Since these Exceptions are triggered by JS calls (and can be fixed in JS), a common way
13 | * to handle one is to show a error dialog and allow the developer to change and reload JS.
14 | *
15 | * We should also note that we have a unique stance on what 'caused' means: even if there's a bug
16 | * in the framework/native code, it was triggered by JS and theoretically since we were able to set
17 | * up the bridge, JS could change its logic, reload, and not trigger that crash.
18 | */
19 | public interface NativeModuleCallExceptionHandler {
20 |
21 | /** Do something to display or log the exception. */
22 | void handleException(Exception e);
23 | }
24 |
--------------------------------------------------------------------------------
/packages/core/react-android/react/src/main/java/com/facebook/react/bridge/ReadableArray.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) Meta Platforms, Inc. and affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | package com.facebook.react.bridge;
9 |
10 | import androidx.annotation.NonNull;
11 | import java.util.ArrayList;
12 |
13 | /**
14 | * Interface for an array that allows typed access to its members. Used to pass parameters from JS
15 | * to Java.
16 | */
17 | public interface ReadableArray {
18 |
19 | int size();
20 |
21 | boolean isNull(int index);
22 |
23 | boolean getBoolean(int index);
24 |
25 | double getDouble(int index);
26 |
27 | int getInt(int index);
28 |
29 | @NonNull
30 | String getString(int index);
31 |
32 | @NonNull
33 | ReadableArray getArray(int index);
34 |
35 | @NonNull
36 | ReadableMap getMap(int index);
37 |
38 | @NonNull
39 | Dynamic getDynamic(int index);
40 |
41 | @NonNull
42 | ReadableType getType(int index);
43 |
44 | @NonNull
45 | ArrayList