Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/worklets.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Worklets

`nitroFetchOnWorklet()` lets you run parsing/mapping off the JS thread using `react-native-worklets-core` (Android). On iOS or when worklets are unavailable, it falls back to running the mapper on the JS thread.
`nitroFetchOnWorklet()` lets you run parsing/mapping off the JS thread using `react-native-worklets` .

## Usage

Expand All @@ -12,7 +12,7 @@ const map = (payload: { bodyString?: string }) => {
return JSON.parse(payload.bodyString ?? '{}');
};

const data = await nitroFetchOnWorklet('https://httpbin.org/get', undefined, map, { preferBytes: false });
const data = nitroFetchOnWorklet('https://httpbin.org/get', undefined, map, { preferBytes: false });
```

Options
Expand All @@ -22,6 +22,6 @@ Options

Notes

- Ensure `react-native-worklets-core` is installed in your app to get off-thread execution on Android.
- On iOS, the mapper runs on JS but the API surface remains the same.
- Ensure `react-native-worklets` is installed in your app to get off-thread.


2 changes: 1 addition & 1 deletion example/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const root = path.resolve(__dirname, '..', 'package');
module.exports = getConfig(
{
presets: ['module:@react-native/babel-preset'],
plugins: ["react-native-worklets-core/plugin"],
plugins: ["react-native-worklets/plugin"],
},
{ root, pkg }
);
133 changes: 97 additions & 36 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PODS:
- hermes-engine (0.81.0):
- hermes-engine/Pre-built (= 0.81.0)
- hermes-engine/Pre-built (0.81.0)
- NitroFetch (0.1.3):
- NitroFetch (0.1.6):
- boost
- DoubleConversion
- fast_float
Expand Down Expand Up @@ -1865,34 +1865,6 @@ PODS:
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- react-native-worklets-core (1.6.2):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-jsi
- React-NativeModulesApple
- React-RCTFabric
- React-renderercss
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- React-NativeModulesApple (0.81.0):
- boost
- DoubleConversion
Expand Down Expand Up @@ -2397,6 +2369,95 @@ PODS:
- React-perflogger (= 0.81.0)
- React-utils (= 0.81.0)
- SocketRocket
- RNWorklets (0.7.2):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-hermes
- React-ImageManager
- React-jsi
- React-NativeModulesApple
- React-RCTFabric
- React-renderercss
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNWorklets/worklets (= 0.7.2)
- SocketRocket
- Yoga
- RNWorklets/worklets (0.7.2):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-hermes
- React-ImageManager
- React-jsi
- React-NativeModulesApple
- React-RCTFabric
- React-renderercss
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNWorklets/worklets/apple (= 0.7.2)
- SocketRocket
- Yoga
- RNWorklets/worklets/apple (0.7.2):
- boost
- DoubleConversion
- fast_float
- fmt
- glog
- hermes-engine
- RCT-Folly
- RCT-Folly/Fabric
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-hermes
- React-ImageManager
- React-jsi
- React-NativeModulesApple
- React-RCTFabric
- React-renderercss
- React-rendererdebug
- React-utils
- ReactCodegen
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- SocketRocket
- Yoga
- SocketRocket (0.7.1)
- Yoga (0.0.0)

Expand All @@ -2409,7 +2470,7 @@ DEPENDENCIES:
- glog (from `../../node_modules/react-native/third-party-podspecs/glog.podspec`)
- hermes-engine (from `../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
- NitroFetch (from `../../node_modules/react-native-nitro-fetch`)
- NitroModules (from `../../node_modules/react-native-nitro-modules`)
- NitroModules (from `../node_modules/react-native-nitro-modules`)
- RCT-Folly (from `../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTDeprecation (from `../../node_modules/react-native/ReactApple/Libraries/RCTFoundation/RCTDeprecation`)
- RCTRequired (from `../../node_modules/react-native/Libraries/Required`)
Expand Down Expand Up @@ -2445,7 +2506,6 @@ DEPENDENCIES:
- React-Mapbuffer (from `../../node_modules/react-native/ReactCommon`)
- React-microtasksnativemodule (from `../../node_modules/react-native/ReactCommon/react/nativemodule/microtasks`)
- react-native-safe-area-context (from `../../node_modules/react-native-safe-area-context`)
- react-native-worklets-core (from `../../node_modules/react-native-worklets-core`)
- React-NativeModulesApple (from `../../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
- React-oscompat (from `../../node_modules/react-native/ReactCommon/oscompat`)
- React-perflogger (from `../../node_modules/react-native/ReactCommon/reactperflogger`)
Expand Down Expand Up @@ -2476,6 +2536,7 @@ DEPENDENCIES:
- ReactAppDependencyProvider (from `build/generated/ios`)
- ReactCodegen (from `build/generated/ios`)
- ReactCommon/turbomodule/core (from `../../node_modules/react-native/ReactCommon`)
- RNWorklets (from `../../node_modules/react-native-worklets`)
- SocketRocket (~> 0.7.1)
- Yoga (from `../../node_modules/react-native/ReactCommon/yoga`)

Expand All @@ -2502,7 +2563,7 @@ EXTERNAL SOURCES:
NitroFetch:
:path: "../../node_modules/react-native-nitro-fetch"
NitroModules:
:path: "../../node_modules/react-native-nitro-modules"
:path: "../node_modules/react-native-nitro-modules"
RCT-Folly:
:podspec: "../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec"
RCTDeprecation:
Expand Down Expand Up @@ -2571,8 +2632,6 @@ EXTERNAL SOURCES:
:path: "../../node_modules/react-native/ReactCommon/react/nativemodule/microtasks"
react-native-safe-area-context:
:path: "../../node_modules/react-native-safe-area-context"
react-native-worklets-core:
:path: "../../node_modules/react-native-worklets-core"
React-NativeModulesApple:
:path: "../../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios"
React-oscompat:
Expand Down Expand Up @@ -2633,6 +2692,8 @@ EXTERNAL SOURCES:
:path: build/generated/ios
ReactCommon:
:path: "../../node_modules/react-native/ReactCommon"
RNWorklets:
:path: "../../node_modules/react-native-worklets"
Yoga:
:path: "../../node_modules/react-native/ReactCommon/yoga"

Expand All @@ -2644,7 +2705,7 @@ SPEC CHECKSUMS:
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
hermes-engine: e7491a2038f2618c8cd444ed411a6deb350a3742
NitroFetch: d99e3c3dad9f70317525c4fad230dff507857720
NitroFetch: 660adfb47f84b28db664f97b50e5dc28506ab6c1
NitroModules: 7d693306799405ca141ef5c24efc0936f20a09c0
RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669
RCTDeprecation: 0735ab4f6b3ec93a7f98187b5da74d7916e2cf4c
Expand Down Expand Up @@ -2680,7 +2741,6 @@ SPEC CHECKSUMS:
React-Mapbuffer: e402e7a0535b2213c50727553621480fe8cd8ade
React-microtasksnativemodule: a63ce5595016996a9bac1f10c70a7a7fe6506649
react-native-safe-area-context: c6e2edd1c1da07bdce287fa9d9e60c5f7b514616
react-native-worklets-core: 28a6e2121dcf62543b703e81bc4860e9a0150cee
React-NativeModulesApple: b3766e1f87b08064ebc459b9e1538da2447ca874
React-oscompat: 34f3d3c06cadcbc470bc4509c717fb9b919eaa8b
React-perflogger: a1edb025fd5d44f61bf09307e248f7608d7b2dcf
Expand Down Expand Up @@ -2711,6 +2771,7 @@ SPEC CHECKSUMS:
ReactAppDependencyProvider: c91900fa724baee992f01c05eeb4c9e01a807f78
ReactCodegen: c3a2e945d68bcf8839624acaf1b276acbb41e9ba
ReactCommon: 116d6ee71679243698620d8cd9a9042541e44aa6
RNWorklets: 96b3ffd8c15260237ce97f1e3a8330f20ee4d562
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
Yoga: 00013dd9cde63a2d98e8002fcc4f5ddb66c10782

Expand Down
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"@react-native/new-app-screen": "0.81.0",
"react": "19.1.0",
"react-native": "0.81.0",
"react-native-nitro-modules": "^0.29.2",
"react-native-nitro-modules": "^0.33.2",
"react-native-safe-area-context": "^5.5.2",
"react-native-worklets-core": "^1.6.2"
},
"react-native-worklets": "^0.7.2"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
Expand Down
3 changes: 3 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
removeAllFromAutoprefetch,
} from 'react-native-nitro-fetch';

import { getRuntimeKind } from 'react-native-worklets';

type Row = {
url: string;
builtinMs: number;
Expand Down Expand Up @@ -202,6 +204,7 @@ export default function App() {
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${encodeURIComponent(ids.join(','))}&vs_currencies=usd`;
const mapper = (payload: { bodyString?: string }) => {
'worklet';
console.log('getRuntimeKind', getRuntimeKind()); // Ensures worklet is running
const txt = payload.bodyString ?? '';
const json = JSON.parse(txt) as Record<string, { usd: number }>;
const entries = Object.entries(json);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"react": "19.1.0",
"react-native": "0.81.0",
"react-native-builder-bob": "^0.40.13",
"react-native-nitro-modules": "^0.29.2",
"react-native-nitro-modules": "^0.33.2",
"release-it": "^17.10.0",
"turbo": "^1.10.7",
"typescript": "^5.8.3"
Expand Down
2 changes: 1 addition & 1 deletion package/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ repositories {

def kotlin_version = getExtOrDefault("kotlinVersion")
// ---------- Cronet (Java API only) ----------
def cronetVersion = (getExtOrDefault("cronetVersion") ?: "119.6045.31")
def cronetVersion = (getExtOrDefault("cronetVersion") ?: "141.7340.3")


dependencies {
Expand Down
2 changes: 1 addition & 1 deletion package/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
{
exclude: /\/node_modules\//,
presets: ['module:react-native-builder-bob/babel-preset'],
plugins: ['react-native-worklets-core/plugin'],
plugins: ['react-native-worklets/plugin'],
},
],
};
Loading
Loading