Skip to content

Commit 942849d

Browse files
feat: new architecture improvements
1 parent 0a413f2 commit 942849d

File tree

6 files changed

+144
-43
lines changed

6 files changed

+144
-43
lines changed

example/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = getConfig(
88
{
99
presets: ['module:@react-native/babel-preset'],
1010
plugins: [
11-
// ['react-native-worklets-core/plugin'],
11+
['react-native-worklets-core/plugin'],
1212
'react-native-reanimated/plugin',
1313
],
1414
},

example/ios/Podfile.lock

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,10 @@ PODS:
10021002
- ReactCommon/turbomodule/bridging
10031003
- ReactCommon/turbomodule/core
10041004
- Yoga
1005+
- react-native-worklets-core (1.3.3):
1006+
- React
1007+
- React-callinvoker
1008+
- React-Core
10051009
- React-nativeconfig (0.74.4)
10061010
- React-NativeModulesApple (0.74.4):
10071011
- glog
@@ -1231,8 +1235,6 @@ PODS:
12311235
- React-logger (= 0.74.4)
12321236
- React-perflogger (= 0.74.4)
12331237
- React-utils (= 0.74.4)
1234-
- RNFS (2.20.0):
1235-
- React-Core
12361238
- RNReanimated (3.14.0):
12371239
- DoubleConversion
12381240
- glog
@@ -1255,6 +1257,40 @@ PODS:
12551257
- ReactCommon/turbomodule/core
12561258
- Yoga
12571259
- SocketRocket (0.7.0)
1260+
- vision-camera-resize-plugin (3.1.0):
1261+
- DoubleConversion
1262+
- glog
1263+
- hermes-engine
1264+
- RCT-Folly (= 2024.01.01.00)
1265+
- RCTRequired
1266+
- RCTTypeSafety
1267+
- React-Codegen
1268+
- React-Core
1269+
- React-debug
1270+
- React-Fabric
1271+
- React-featureflags
1272+
- React-graphics
1273+
- React-ImageManager
1274+
- React-NativeModulesApple
1275+
- React-RCTFabric
1276+
- React-rendererdebug
1277+
- React-utils
1278+
- ReactCommon/turbomodule/bridging
1279+
- ReactCommon/turbomodule/core
1280+
- VisionCamera
1281+
- Yoga
1282+
- VisionCamera (4.5.2):
1283+
- VisionCamera/Core (= 4.5.2)
1284+
- VisionCamera/FrameProcessors (= 4.5.2)
1285+
- VisionCamera/React (= 4.5.2)
1286+
- VisionCamera/Core (4.5.2)
1287+
- VisionCamera/FrameProcessors (4.5.2):
1288+
- React
1289+
- React-callinvoker
1290+
- react-native-worklets-core
1291+
- VisionCamera/React (4.5.2):
1292+
- React-Core
1293+
- VisionCamera/FrameProcessors
12581294
- Yoga (0.0.0)
12591295

12601296
DEPENDENCIES:
@@ -1293,6 +1329,7 @@ DEPENDENCIES:
12931329
- react-native-fast-opencv (from `../..`)
12941330
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
12951331
- "react-native-skia (from `../node_modules/@shopify/react-native-skia`)"
1332+
- react-native-worklets-core (from `../node_modules/react-native-worklets-core`)
12961333
- React-nativeconfig (from `../node_modules/react-native/ReactCommon`)
12971334
- React-NativeModulesApple (from `../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
12981335
- React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
@@ -1316,8 +1353,9 @@ DEPENDENCIES:
13161353
- React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`)
13171354
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
13181355
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
1319-
- RNFS (from `../node_modules/react-native-fs`)
13201356
- RNReanimated (from `../node_modules/react-native-reanimated`)
1357+
- vision-camera-resize-plugin (from `../node_modules/vision-camera-resize-plugin`)
1358+
- VisionCamera (from `../node_modules/react-native-vision-camera`)
13211359
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
13221360

13231361
SPEC REPOS:
@@ -1393,6 +1431,8 @@ EXTERNAL SOURCES:
13931431
:path: "../node_modules/react-native-image-picker"
13941432
react-native-skia:
13951433
:path: "../node_modules/@shopify/react-native-skia"
1434+
react-native-worklets-core:
1435+
:path: "../node_modules/react-native-worklets-core"
13961436
React-nativeconfig:
13971437
:path: "../node_modules/react-native/ReactCommon"
13981438
React-NativeModulesApple:
@@ -1439,10 +1479,12 @@ EXTERNAL SOURCES:
14391479
:path: "../node_modules/react-native/ReactCommon/react/utils"
14401480
ReactCommon:
14411481
:path: "../node_modules/react-native/ReactCommon"
1442-
RNFS:
1443-
:path: "../node_modules/react-native-fs"
14441482
RNReanimated:
14451483
:path: "../node_modules/react-native-reanimated"
1484+
vision-camera-resize-plugin:
1485+
:path: "../node_modules/vision-camera-resize-plugin"
1486+
VisionCamera:
1487+
:path: "../node_modules/react-native-vision-camera"
14461488
Yoga:
14471489
:path: "../node_modules/react-native/ReactCommon/yoga"
14481490

@@ -1478,17 +1520,18 @@ SPEC CHECKSUMS:
14781520
React-jsitracing: 4e9c99e73a6269b27b0d4cbab277dd90df3e5ac0
14791521
React-logger: fbfb50e2a2b1b46ee087f0a52739fadecc5e81a4
14801522
React-Mapbuffer: d39610dff659d8cf1fea485abae08bbf6f9c8279
1481-
react-native-fast-opencv: 259f4e3bc7741b9cd9a84275ef04e050e08ca99e
1482-
react-native-image-picker: f5e7af75efb813aa7239e94310167d2b69b606d6
1483-
react-native-skia: 1fe8f96e9b54dda040958f66e02361f27ebb4694
1523+
react-native-fast-opencv: ab1ec9e61ccab56c9120d847eefddd636eea859a
1524+
react-native-image-picker: c3afe5472ef870d98a4b28415fc0b928161ee5f7
1525+
react-native-skia: 4857f8a85d0e4fc152c7b8aff4fbcc7573be1cf9
1526+
react-native-worklets-core: f51430dd07bf5343d4918d28a4bb00fe8f98b982
14841527
React-nativeconfig: 2be4363c2c4ac2b42419577774e83e4e4fd2af9f
14851528
React-NativeModulesApple: 453ada38f826a508e48872c7a7877c431af48bba
14861529
React-perflogger: 9745f800ab4d12ec4325bde7bd090eafb87c5570
14871530
React-RCTActionSheet: 4225e883c5feaffc072c86128cc42cb070097010
14881531
React-RCTAnimation: 6b318e7e475ea574abf6a65e58e4989dd19d9ec4
1489-
React-RCTAppDelegate: e0dc75d2ee20299cb66c57e60042e2d5c6699a64
1532+
React-RCTAppDelegate: 00d29b205df54386bc4e9c8929c500ed00ee1d57
14901533
React-RCTBlob: cf152386cc829be9323b2845fd9ec25122a986c3
1491-
React-RCTFabric: 36988acdc30838cfe9404a3a2d3b9e699d0b2270
1534+
React-RCTFabric: 071b326a331bd1ccb59e5886c0cd38e414ec9c9f
14921535
React-RCTImage: d3d5e0f0740fbd53705f7e9acc067bafe395026c
14931536
React-RCTLinking: 3ed7d222d3534287b408855b9d378d6576b7661b
14941537
React-RCTNetwork: 33a6bb615c1f7678538298aed9f27ecd69d512f3
@@ -1504,11 +1547,12 @@ SPEC CHECKSUMS:
15041547
React-runtimescheduler: 3f312d33f475467a59864e0c5ab8708461387d1c
15051548
React-utils: e8b0eac797c81c574b24f6515fec4015599b643c
15061549
ReactCommon: eebffb37a90138c6db6eb8b2d952e7e5c6bc083c
1507-
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
1508-
RNReanimated: 547f464b5464b66e9f841e4b95531c1bf5ed2344
1550+
RNReanimated: f4ff116e33e0afc3d127f70efe928847c7c66355
15091551
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
1552+
vision-camera-resize-plugin: 4306d5df9bce0e603bbe6ab04337f21a606f4ad1
1553+
VisionCamera: 057aff621f7801b7d99a00d157fa39244bbd4fd2
15101554
Yoga: 6259f968a4fdf516d76a4432dead624d71aa0fb1
15111555

15121556
PODFILE CHECKSUM: ded8a41f26047703e900afe99b8a72ca375b02ca
15131557

1514-
COCOAPODS: 1.14.3
1558+
COCOAPODS: 1.15.2

example/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"@shopify/react-native-skia": "^1.3.10",
1414
"react": "18.2.0",
1515
"react-native": "0.74.4",
16-
"react-native-fs": "^2.20.0",
1716
"react-native-image-picker": "^7.1.2",
1817
"react-native-reanimated": "^3.14.0",
1918
"react-native-vision-camera": "^4.5.1",

example/src/ImageExample.tsx

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,40 @@ export function ImageExample() {
3030

3131
OpenCV.invoke('cvtColor', src, dst, ColorConversionCodes.COLOR_BGR2HSV);
3232

33-
// const lowerBound = OpenCV.createObject(ObjectType.Scalar, 30, 60, 60);
34-
// const upperBound = OpenCV.createObject(ObjectType.Scalar, 50, 255, 255);
33+
const lowerBound = OpenCV.createObject(ObjectType.Scalar, 30, 60, 60);
34+
const upperBound = OpenCV.createObject(ObjectType.Scalar, 50, 255, 255);
3535

36-
// OpenCV.invoke('inRange', dst, lowerBound, upperBound, dst);
36+
OpenCV.invoke('inRange', dst, lowerBound, upperBound, dst);
3737

38-
// const channels = OpenCV.createObject(ObjectType.MatVector);
39-
// OpenCV.invoke('split', dst, channels);
40-
// const grayChannel = OpenCV.copyObjectFromVector(channels, 0);
38+
const channels = OpenCV.createObject(ObjectType.MatVector);
39+
OpenCV.invoke('split', dst, channels);
40+
const grayChannel = OpenCV.copyObjectFromVector(channels, 0);
4141

42-
// const contours = OpenCV.createObject(ObjectType.MatVector);
42+
const contours = OpenCV.createObject(ObjectType.MatVector);
4343

44-
// OpenCV.invoke(
45-
// 'findContours',
46-
// grayChannel,
47-
// contours,
48-
// RetrievalModes.RETR_TREE,
49-
// ContourApproximationModes.CHAIN_APPROX_SIMPLE
50-
// );
44+
OpenCV.invoke(
45+
'findContours',
46+
grayChannel,
47+
contours,
48+
RetrievalModes.RETR_TREE,
49+
ContourApproximationModes.CHAIN_APPROX_SIMPLE
50+
);
5151

52-
// const contoursMats = OpenCV.toJSValue(contours);
52+
const contoursMats = OpenCV.toJSValue(contours);
5353

54-
// const rectangles: Rect[] = [];
54+
const rectangles: Rect[] = [];
5555

56-
// for (let i = 0; i < contoursMats.array.length; i++) {
57-
// const contour = OpenCV.copyObjectFromVector(contours, i);
58-
// const { value: area } = OpenCV.invoke('contourArea', contour, false);
56+
for (let i = 0; i < contoursMats.array.length; i++) {
57+
const contour = OpenCV.copyObjectFromVector(contours, i);
58+
const { value: area } = OpenCV.invoke('contourArea', contour, false);
5959

60-
// if (area > 3000) {
61-
// const rect = OpenCV.invoke('boundingRect', contour);
62-
// rectangles.push(rect);
63-
// }
64-
// }
60+
if (area > 3000) {
61+
const rect = OpenCV.invoke('boundingRect', contour);
62+
rectangles.push(rect);
63+
}
64+
}
6565

66-
// console.log(rectangles);
66+
console.log(rectangles);
6767

6868

6969
const result = OpenCV.toJSValue(dst);

ios/FastOpencv.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#import <React/RCTBridge+Private.h>
44
#import <jsi/jsi.h>
55

6+
@interface RCTBridge (RCTTurboModule)
7+
- (std::shared_ptr<facebook::react::CallInvoker>)jsCallInvoker;
8+
@end
69

710
using namespace facebook;
811

@@ -22,13 +25,15 @@ - (void)setBridge:(RCTBridge *)bridge {
2225

2326
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
2427
{
28+
RCTBridge* bridge = [RCTBridge currentBridge];
2529
RCTCxxBridge *cxxBridge = (RCTCxxBridge *)_bridge;
2630

2731
if (!cxxBridge.runtime) {
2832
return @(false);
2933
}
3034

31-
auto callInvoker = cxxBridge.jsCallInvoker;
35+
auto callInvoker = [bridge jsCallInvoker];
36+
3237
facebook::jsi::Runtime *jsRuntime =
3338
(facebook::jsi::Runtime *)cxxBridge.runtime;
3439

yarn.lock

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10932,9 +10932,11 @@ __metadata:
1093210932
react: 18.2.0
1093310933
react-native: 0.74.4
1093410934
react-native-builder-bob: ^0.29.0
10935-
react-native-fs: ^2.20.0
1093610935
react-native-image-picker: ^7.1.2
1093710936
react-native-reanimated: ^3.14.0
10937+
react-native-vision-camera: ^4.5.1
10938+
react-native-worklets-core: ^1.3.3
10939+
vision-camera-resize-plugin: ^3.1.0
1093810940
languageName: unknown
1093910941
linkType: soft
1094010942

@@ -10969,7 +10971,7 @@ __metadata:
1096910971
languageName: unknown
1097010972
linkType: soft
1097110973

10972-
"react-native-fs@npm:2.20.0, react-native-fs@npm:^2.20.0":
10974+
"react-native-fs@npm:2.20.0":
1097310975
version: 2.20.0
1097410976
resolution: "react-native-fs@npm:2.20.0"
1097510977
dependencies:
@@ -11015,6 +11017,38 @@ __metadata:
1101511017
languageName: node
1101611018
linkType: hard
1101711019

11020+
"react-native-vision-camera@npm:^4.5.1":
11021+
version: 4.5.2
11022+
resolution: "react-native-vision-camera@npm:4.5.2"
11023+
peerDependencies:
11024+
"@shopify/react-native-skia": "*"
11025+
react: "*"
11026+
react-native: "*"
11027+
react-native-reanimated: "*"
11028+
react-native-worklets-core: "*"
11029+
peerDependenciesMeta:
11030+
"@shopify/react-native-skia":
11031+
optional: true
11032+
react-native-reanimated:
11033+
optional: true
11034+
react-native-worklets-core:
11035+
optional: true
11036+
checksum: 19ee9f5a4105c47b6abfd8e4cf7558634e60f7d68ce6d9cc4a2c5b2b359d921c1121978637a2a4d571a75204a39141159438aac84f679c5ab33469052da8b671
11037+
languageName: node
11038+
linkType: hard
11039+
11040+
"react-native-worklets-core@npm:^1.3.3":
11041+
version: 1.3.3
11042+
resolution: "react-native-worklets-core@npm:1.3.3"
11043+
dependencies:
11044+
string-hash-64: ^1.0.3
11045+
peerDependencies:
11046+
react: "*"
11047+
react-native: "*"
11048+
checksum: bf2f0eb5852ac1e4f58e20fd5912bed46c0f2bd5a671dadb596b7edf2aa5816874c694f472adaaefdb9ef19e5355c05ceb2877946bfaa0cd081c9cc0c95aa404
11049+
languageName: node
11050+
linkType: hard
11051+
1101811052
"react-native@npm:0.74.4":
1101911053
version: 0.74.4
1102011054
resolution: "react-native@npm:0.74.4"
@@ -12159,6 +12193,13 @@ __metadata:
1215912193
languageName: node
1216012194
linkType: hard
1216112195

12196+
"string-hash-64@npm:^1.0.3":
12197+
version: 1.0.3
12198+
resolution: "string-hash-64@npm:1.0.3"
12199+
checksum: 79de8431b4fa3e85a2429cd52a34f7948221ff167b7a094e05d6bcfd0173474b232e0c9845c96f74b0d7b6b0c8bbe2c3532a4cacb21635293ef0cf3cc8e77f06
12200+
languageName: node
12201+
linkType: hard
12202+
1216212203
"string-length@npm:^4.0.1":
1216312204
version: 4.0.2
1216412205
resolution: "string-length@npm:4.0.2"
@@ -13140,6 +13181,18 @@ __metadata:
1314013181
languageName: node
1314113182
linkType: hard
1314213183

13184+
"vision-camera-resize-plugin@npm:^3.1.0":
13185+
version: 3.1.0
13186+
resolution: "vision-camera-resize-plugin@npm:3.1.0"
13187+
peerDependencies:
13188+
react: "*"
13189+
react-native: "*"
13190+
react-native-vision-camera: ">=4.0.1"
13191+
react-native-worklets-core: ">=1.2.0"
13192+
checksum: 34187b1f18987f22a4260fff2a3267eb0f4ecbd121b949cbb7bc41ef7b3b26d9a50632ba6ddfc7d00eedcef248d11ad58f676541a71d835a41635a0579790a9b
13193+
languageName: node
13194+
linkType: hard
13195+
1314313196
"vlq@npm:^1.0.0":
1314413197
version: 1.0.1
1314513198
resolution: "vlq@npm:1.0.1"

0 commit comments

Comments
 (0)