Skip to content

Commit b13e41d

Browse files
p-sunfacebook-github-bot
authored andcommitted
Migrate ScreenshotManager from NativeModule to TurboModule
Summary: Changelog: [JS] Migrate ScreenshotManager from NativeModule to TurboModule. Fix SnapshotExample in rn-tester. `const ScreenshotManager = NativeModules.ScreenshotManager;` makes all of RNTesterAppRoute render blank in Bridgeless, because we throw a jsi::JSError when JS calls `NativeModule.get` while in Bridgeless. Reviewed By: RSNara Differential Revision: D33640935 fbshipit-source-id: 124a3b43e1440a7ca0071c95c4388350d2e4affa
1 parent 9d2df5b commit b13e41d

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@
1010

1111
import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport';
1212
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';
13+
import type {UnsafeObject} from 'react-native/Libraries/Types/CodegenTypes';
14+
15+
export type ScreenshotManagerOptions = UnsafeObject;
1316

1417
export interface Spec extends TurboModule {
1518
+getConstants: () => {||};
16-
takeSnapshot(id: string): Promise<string>;
19+
takeScreenshot(
20+
id: string,
21+
options: ScreenshotManagerOptions,
22+
): Promise<string>;
1723
}
1824

1925
const NativeModule = TurboModuleRegistry.get<Spec>('ScreenshotManager');
20-
21-
export function takeSnapshot(id: string): Promise<string> {
26+
export function takeScreenshot(
27+
id: string,
28+
options: ScreenshotManagerOptions,
29+
): Promise<string> {
2230
if (NativeModule != null) {
23-
return NativeModule.takeSnapshot(id);
31+
return NativeModule.takeScreenshot(id, options);
2432
}
2533
return Promise.reject();
2634
}

packages/rn-tester/Podfile.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ SPEC CHECKSUMS:
881881
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
882882
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
883883
FBLazyVector: b81a2b70c72d8b0aefb652cea22c11e9ffd02949
884-
FBReactNativeSpec: 3f88f49873cc4123da7877f1b183e7776bbc4fa9
884+
FBReactNativeSpec: 35cca37e6328d64b4e38c4adb1a28db74b60aeac
885885
Flipper: 30e8eeeed6abdc98edaf32af0cda2f198be4b733
886886
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
887887
Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c
@@ -892,7 +892,7 @@ SPEC CHECKSUMS:
892892
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
893893
FlipperKit: d8d346844eca5d9120c17d441a2f38596e8ed2b9
894894
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
895-
glog: c10b67b343303f51715e5c5eedb18a41402f350a
895+
glog: 476ee3e89abb49e07f822b48323c51c57124b572
896896
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
897897
OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b
898898
RCT-Folly: 803a9cfd78114b2ec0f140cfa6fa2a6bafb2d685
@@ -923,10 +923,10 @@ SPEC CHECKSUMS:
923923
React-RCTTest: 12bbd7fc2e72bd9920dc7286c5b8ef96639582b6
924924
React-RCTText: e9146b2c0550a83d1335bfe2553760070a2d75c7
925925
React-RCTVibration: 50be9c390f2da76045ef0dfdefa18b9cf9f35cfa
926-
React-rncore: c76a90ccef0be9fc0f6dab7c16d9194ec6b54e13
926+
React-rncore: d292b6c2196dcd555622a538e1b206aa2e0ad8a2
927927
React-runtimeexecutor: 4b0c6eb341c7d3ceb5e2385cb0fdb9bf701024f3
928928
ReactCommon: 7a2714d1128f965392b6f99a8b390e3aa38c9569
929-
ScreenshotManager: bae0da23de347c4527710cca486f6b156902512b
929+
ScreenshotManager: e8da2e62b3c08a87cece436776ce91555ecec77c
930930
Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75
931931
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
932932

packages/rn-tester/js/examples/ActionSheetIOS/ActionSheetIOSExample.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ const {
1717
Text,
1818
View,
1919
Alert,
20-
NativeModules,
2120
findNodeHandle,
2221
} = require('react-native');
23-
const ScreenshotManager = NativeModules.ScreenshotManager;
22+
const ScreenshotManager = require('../../../NativeModuleExample/NativeScreenshotManager');
2423

2524
const BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel'];
2625
const DESTRUCTIVE_INDEX = 3;

packages/rn-tester/js/examples/Snapshot/SnapshotExample.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,8 @@
1111
'use strict';
1212

1313
const React = require('react');
14-
const {
15-
Alert,
16-
Image,
17-
NativeModules,
18-
StyleSheet,
19-
Text,
20-
View,
21-
} = require('react-native');
22-
const ScreenshotManager = NativeModules.ScreenshotManager;
14+
const {Alert, Image, StyleSheet, Text, View} = require('react-native');
15+
const ScreenshotManager = require('../../../NativeModuleExample/NativeScreenshotManager');
2316

2417
class ScreenshotExample extends React.Component<{...}, $FlowFixMeState> {
2518
state = {

0 commit comments

Comments
 (0)