@react-native-gpui/worklets 0.13.0-alpha.0 → 0.13.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/desktop/cpp/GPUIWorkletsModule.cpp +17 -0
- package/desktop/cpp/GPUIWorkletsModule.h +4 -0
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@react-native-gpui/worklets` are listed here. Each version's section becomes the notes of its GitHub release.
|
|
4
4
|
|
|
5
|
+
## 0.13.0-alpha.1 - 2026-11-12
|
|
6
|
+
|
|
7
|
+
- Added a hook that runs after each frame's animation callbacks, which Reanimated uses to apply its pending updates.
|
|
8
|
+
|
|
5
9
|
## 0.13.0-alpha.0 - 2026-11-01
|
|
6
10
|
|
|
7
11
|
- First release, for `react-native-worklets` 0.13.x.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @react-native-gpui/worklets
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Adapter for [`react-native-worklets`](https://github.com/software-mansion/react-native-reanimated/tree/main/packages/react-native-worklets) (MIT): runs worklets on desktop, driven by the renderer's frame clock.
|
|
4
4
|
|
|
5
5
|
Part of [react-native-gpui](https://github.com/streetwriters/react-native-gpui), React Native for macOS, Windows and Linux.
|
|
6
6
|
|
|
@@ -176,6 +176,11 @@ void Module::requestAnimationFrame(std::function<void(double)> callback) {
|
|
|
176
176
|
rngpui::requestFrames("worklets", true);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
void Module::setAfterFrame(std::function<void()> afterFrame) {
|
|
180
|
+
std::lock_guard<std::mutex> lock(callbacksMutex_);
|
|
181
|
+
afterFrame_ = std::move(afterFrame);
|
|
182
|
+
}
|
|
183
|
+
|
|
179
184
|
void Module::onFrame(double timestampMs) {
|
|
180
185
|
const auto count = ++workletFrames;
|
|
181
186
|
if (animationTracingEnabled()) {
|
|
@@ -283,6 +288,18 @@ void Module::onFrame(double timestampMs) {
|
|
|
283
288
|
reportError(error);
|
|
284
289
|
}
|
|
285
290
|
}
|
|
291
|
+
std::function<void()> afterFrame;
|
|
292
|
+
{
|
|
293
|
+
std::lock_guard<std::mutex> lock(callbacksMutex_);
|
|
294
|
+
afterFrame = afterFrame_;
|
|
295
|
+
}
|
|
296
|
+
if (afterFrame) {
|
|
297
|
+
try {
|
|
298
|
+
afterFrame();
|
|
299
|
+
} catch (const facebook::jsi::JSError& error) {
|
|
300
|
+
reportError(error);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
286
303
|
{
|
|
287
304
|
std::lock_guard<std::mutex> lock(callbacksMutex_);
|
|
288
305
|
if (frameCallbacks_.empty()) {
|
|
@@ -25,6 +25,9 @@ class Module final : public facebook::react::NativeWorkletsModuleSpec<Module> {
|
|
|
25
25
|
|
|
26
26
|
void onFrame(double timestampMs);
|
|
27
27
|
void requestAnimationFrame(std::function<void(double)> callback);
|
|
28
|
+
/// Runs after every frame's animation callbacks, as the display link's
|
|
29
|
+
/// handler does on iOS.
|
|
30
|
+
void setAfterFrame(std::function<void()> afterFrame);
|
|
28
31
|
std::shared_ptr<worklets::WorkletRuntime> uiRuntime() const;
|
|
29
32
|
std::shared_ptr<worklets::UIScheduler> uiScheduler() const;
|
|
30
33
|
|
|
@@ -45,6 +48,7 @@ class Module final : public facebook::react::NativeWorkletsModuleSpec<Module> {
|
|
|
45
48
|
std::shared_ptr<worklets::WorkletsModuleProxy> proxy_;
|
|
46
49
|
std::mutex callbacksMutex_;
|
|
47
50
|
std::vector<std::function<void(double)>> frameCallbacks_;
|
|
51
|
+
std::function<void()> afterFrame_;
|
|
48
52
|
};
|
|
49
53
|
|
|
50
54
|
void onFrame(double timestampMs);
|
package/package.json
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-gpui/worklets",
|
|
3
|
-
"version": "0.13.0-alpha.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.13.0-alpha.1",
|
|
4
|
+
"description": "Adapter for react-native-worklets (MIT): runs worklets on desktop, driven by the renderer's frame clock",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/streetwriters/react-native-gpui.git",
|
|
8
|
+
"url": "git+https://github.com/streetwriters/react-native-gpui-modules.git",
|
|
9
9
|
"directory": "modules/worklets"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://github.com/streetwriters/react-native-gpui-modules/tree/main/modules/worklets#readme",
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/streetwriters/react-native-gpui/issues"
|
|
13
|
+
"url": "https://github.com/streetwriters/react-native-gpui-modules/issues"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"desktop",
|
|
17
17
|
"react-native.config.js",
|
|
18
18
|
"src",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
19
21
|
"CHANGELOG.md",
|
|
20
22
|
"!**/*.test.js",
|
|
21
23
|
"!**/*.test.mjs",
|