mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Check in OSS NativeModule specs
Summary: This diff checks in the output from `fbsource//xplat/js:FBReactNativeSpec-flow-type-android-files` into `react-native-github/ReactAndroid/src/main/java/com/facebook/fbreact/specs/`. To update the codegen output, please run: ``` js1 build oss-native-modules-specs -p android ``` To use the codegen, add the following as a buck dep to your target: ``` fbsource//xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/fbreact/specs:FBReactNativeSpecAndroid ``` Changelog: [Android][Added] Check in TurboModules codegen Reviewed By: fkgozali Differential Revision: D17990380 fbshipit-source-id: 94895e375311e9360c308dffadf1558a5ff04212
This commit is contained in:
committed by
Facebook Github Bot
parent
48f367da91
commit
d3ac9fa0c3
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
||||
* directory of this source tree.
|
||||
*
|
||||
* <p>Generated by an internal genrule from Flow types.
|
||||
*
|
||||
* @generated
|
||||
* @nolint
|
||||
*/
|
||||
|
||||
package com.facebook.fbreact.specs;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReactModuleWithSpec;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.common.build.ReactBuildConfig;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class NativeBlobModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
|
||||
public NativeBlobModuleSpec(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public abstract void sendOverSocket(ReadableMap blob, double socketID);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void addNetworkingHandler();
|
||||
|
||||
@ReactMethod
|
||||
public abstract void createFromParts(ReadableArray parts, String withId);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void addWebSocketHandler(double id);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void release(String blobId);
|
||||
|
||||
@ReactMethod
|
||||
public abstract void removeWebSocketHandler(double id);
|
||||
|
||||
protected abstract Map<String, Object> getTypedExportedConstants();
|
||||
|
||||
@Override
|
||||
public final @Nullable Map<String, Object> getConstants() {
|
||||
Map<String, Object> constants = getTypedExportedConstants();
|
||||
if (ReactBuildConfig.DEBUG || ReactBuildConfig.IS_INTERNAL_BUILD) {
|
||||
Set<String> obligatoryFlowConstants = new HashSet<>(Arrays.asList(
|
||||
"BLOB_URI_SCHEME"
|
||||
));
|
||||
Set<String> optionalFlowConstants = new HashSet<>(Arrays.asList(
|
||||
"BLOB_URI_HOST"
|
||||
));
|
||||
Set<String> undeclaredConstants = new HashSet<>(constants.keySet());
|
||||
undeclaredConstants.removeAll(obligatoryFlowConstants);
|
||||
undeclaredConstants.removeAll(optionalFlowConstants);
|
||||
if (!undeclaredConstants.isEmpty()) {
|
||||
throw new IllegalStateException(String.format("Native Module Flow doesn't declare constants: %s", undeclaredConstants));
|
||||
}
|
||||
undeclaredConstants = obligatoryFlowConstants;
|
||||
undeclaredConstants.removeAll(constants.keySet());
|
||||
if (!undeclaredConstants.isEmpty()) {
|
||||
throw new IllegalStateException(String.format("Native Module doesn't fill in constants: %s", undeclaredConstants));
|
||||
}
|
||||
}
|
||||
return constants;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user