react-native-worklets 0.9.1 → 0.9.2

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.
@@ -2,11 +2,7 @@
2
2
 
3
3
  #include <jsi/jsi.h>
4
4
 
5
- #ifndef NDEBUG
6
- // Nothing
7
- #else
8
5
  #include <memory>
9
- #endif // NDEBUG
10
6
  #include <string>
11
7
 
12
8
  namespace worklets {
@@ -63,36 +59,47 @@ class UnpackerLoader {
63
59
  "[Worklets] UnpackerLoader tried to install unpackers but the code for unpackers was not loaded.");
64
60
  }
65
61
 
62
+ const auto useSourceMaps =
66
63
  #ifndef NDEBUG
67
- auto evalWithSourceMap = rt.global().getPropertyAsFunction(rt, "evalWithSourceMap");
68
- evalWithSourceMap.call(rt, valueUnpacker_.code, valueUnpacker_.location, valueUnpacker_.sourceMap);
69
- evalWithSourceMap.call(
70
- rt, synchronizableUnpacker_.code, synchronizableUnpacker_.location, synchronizableUnpacker_.sourceMap);
71
- evalWithSourceMap.call(
72
- rt,
73
- customSerializableUnpacker_.code,
74
- customSerializableUnpacker_.location,
75
- customSerializableUnpacker_.sourceMap);
76
- evalWithSourceMap.call(
77
- rt, shareableHostUnpacker_.code, shareableHostUnpacker_.location, shareableHostUnpacker_.sourceMap);
78
- evalWithSourceMap.call(
79
- rt, shareableGuestUnpacker_.code, shareableGuestUnpacker_.location, shareableGuestUnpacker_.sourceMap);
80
- evalWithSourceMap.call(
81
- rt, remoteFunctionUnpacker_.code, remoteFunctionUnpacker_.location, remoteFunctionUnpacker_.sourceMap);
64
+ !valueUnpacker_.sourceMap.empty();
82
65
  #else
83
- rt.evaluateJavaScript(std::make_shared<facebook::jsi::StringBuffer>(valueUnpacker_.code), valueUnpacker_.location);
84
- rt.evaluateJavaScript(
85
- std::make_shared<facebook::jsi::StringBuffer>(synchronizableUnpacker_.code), synchronizableUnpacker_.location);
86
- rt.evaluateJavaScript(
87
- std::make_shared<facebook::jsi::StringBuffer>(customSerializableUnpacker_.code),
88
- customSerializableUnpacker_.location);
89
- rt.evaluateJavaScript(
90
- std::make_shared<facebook::jsi::StringBuffer>(shareableHostUnpacker_.code), shareableHostUnpacker_.location);
91
- rt.evaluateJavaScript(
92
- std::make_shared<facebook::jsi::StringBuffer>(shareableGuestUnpacker_.code), shareableGuestUnpacker_.location);
93
- rt.evaluateJavaScript(
94
- std::make_shared<facebook::jsi::StringBuffer>(remoteFunctionUnpacker_.code), remoteFunctionUnpacker_.location);
66
+ false;
95
67
  #endif // NDEBUG
68
+
69
+ if (useSourceMaps) {
70
+ const auto evalWithSourceMap = rt.global().getPropertyAsFunction(rt, "evalWithSourceMap");
71
+ evalWithSourceMap.call(rt, valueUnpacker_.code, valueUnpacker_.location, valueUnpacker_.sourceMap);
72
+ evalWithSourceMap.call(
73
+ rt, synchronizableUnpacker_.code, synchronizableUnpacker_.location, synchronizableUnpacker_.sourceMap);
74
+ evalWithSourceMap.call(
75
+ rt,
76
+ customSerializableUnpacker_.code,
77
+ customSerializableUnpacker_.location,
78
+ customSerializableUnpacker_.sourceMap);
79
+ evalWithSourceMap.call(
80
+ rt, shareableHostUnpacker_.code, shareableHostUnpacker_.location, shareableHostUnpacker_.sourceMap);
81
+ evalWithSourceMap.call(
82
+ rt, shareableGuestUnpacker_.code, shareableGuestUnpacker_.location, shareableGuestUnpacker_.sourceMap);
83
+ evalWithSourceMap.call(
84
+ rt, remoteFunctionUnpacker_.code, remoteFunctionUnpacker_.location, remoteFunctionUnpacker_.sourceMap);
85
+ } else {
86
+ rt.evaluateJavaScript(
87
+ std::make_shared<facebook::jsi::StringBuffer>(valueUnpacker_.code), valueUnpacker_.location);
88
+ rt.evaluateJavaScript(
89
+ std::make_shared<facebook::jsi::StringBuffer>(synchronizableUnpacker_.code),
90
+ synchronizableUnpacker_.location);
91
+ rt.evaluateJavaScript(
92
+ std::make_shared<facebook::jsi::StringBuffer>(customSerializableUnpacker_.code),
93
+ customSerializableUnpacker_.location);
94
+ rt.evaluateJavaScript(
95
+ std::make_shared<facebook::jsi::StringBuffer>(shareableHostUnpacker_.code), shareableHostUnpacker_.location);
96
+ rt.evaluateJavaScript(
97
+ std::make_shared<facebook::jsi::StringBuffer>(shareableGuestUnpacker_.code),
98
+ shareableGuestUnpacker_.location);
99
+ rt.evaluateJavaScript(
100
+ std::make_shared<facebook::jsi::StringBuffer>(remoteFunctionUnpacker_.code),
101
+ remoteFunctionUnpacker_.location);
102
+ }
96
103
  }
97
104
 
98
105
  private:
@@ -136,7 +136,11 @@ val workletsPrefabHeadersDir: File = project.file("${layout.buildDirectory.get()
136
136
 
137
137
  fun reactNativeArchitectures(): List<String> {
138
138
  val value = project.findProperty("reactNativeArchitectures") as String?
139
- return value?.split(",") ?: listOf("armeabi-v7a", "x86", "x86_64", "arm64-v8a")
139
+ return value?.split(",")
140
+ ?.map { it.trim() }
141
+ ?.filter { it.isNotEmpty() }
142
+ ?.ifEmpty { null }
143
+ ?: listOf("armeabi-v7a", "x86", "x86_64", "arm64-v8a")
140
144
  }
141
145
 
142
146
  if (project == rootProject) {
@@ -1,6 +1,10 @@
1
1
  fun reactNativeArchitectures(): List<String> {
2
2
  val value = project.findProperty("reactNativeArchitectures") as String?
3
- return value?.split(",") ?: listOf("armeabi-v7a", "x86", "x86_64", "arm64-v8a")
3
+ return value?.split(",")
4
+ ?.map { it.trim() }
5
+ ?.filter { it.isNotEmpty() }
6
+ ?.ifEmpty { null }
7
+ ?: listOf("armeabi-v7a", "x86", "x86_64", "arm64-v8a")
4
8
  }
5
9
 
6
10
  tasks.configureEach {
@@ -15,13 +15,18 @@ const workletsLibEntryPath = path.join(
15
15
  function bundleModeResolveRequest(
16
16
  /** @type {any} */ context,
17
17
  /** @type {string} */ moduleName,
18
- /** @type {any} */ platform
18
+ /** @type {any} */ platform,
19
+ /** @type {any} */ userConfigResolveRequest
19
20
  ) {
20
21
  if (moduleName.startsWith(workletsDirPath)) {
21
22
  const fullModuleName = path.join(workletsPackageParentDir, moduleName);
22
23
  return { type: 'sourceFile', filePath: fullModuleName };
23
24
  }
24
- return context.resolveRequest(context, moduleName, platform);
25
+ return (userConfigResolveRequest || context.resolveRequest)(
26
+ context,
27
+ moduleName,
28
+ platform
29
+ );
25
30
  }
26
31
 
27
32
  /** Use in React Native Community projects. */
@@ -49,7 +54,18 @@ const bundleModeMetroConfig = {
49
54
  function getBundleModeMetroConfig(/** @type {any} */ config) {
50
55
  config.serializer.createModuleIdFactory = bundleModeCreateModuleIdFactory;
51
56
 
52
- config.resolver.resolveRequest = bundleModeResolveRequest;
57
+ const currentResolveRequest = config?.resolver?.resolveRequest;
58
+ config.resolver.resolveRequest = (
59
+ /** @type {any} */ context,
60
+ /** @type {string} */ moduleName,
61
+ /** @type {any} */ platform
62
+ ) =>
63
+ bundleModeResolveRequest(
64
+ context,
65
+ moduleName,
66
+ platform,
67
+ currentResolveRequest
68
+ );
53
69
 
54
70
  const currentGetTransformOptions = config?.transformer?.getTransformOptions;
55
71
  config.transformer.getTransformOptions = async () => {
@@ -5,5 +5,5 @@
5
5
  * version used to build the native part of the library in runtime. Remember to
6
6
  * keep this in sync with the version declared in `package.json`
7
7
  */
8
- export const jsVersion = '0.9.1';
8
+ export const jsVersion = '0.9.2';
9
9
  //# sourceMappingURL=jsVersion.js.map
@@ -3,5 +3,5 @@
3
3
  * version used to build the native part of the library in runtime. Remember to
4
4
  * keep this in sync with the version declared in `package.json`
5
5
  */
6
- export declare const jsVersion = "0.9.1";
6
+ export declare const jsVersion = "0.9.2";
7
7
  //# sourceMappingURL=jsVersion.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-worklets",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "The React Native multithreading library",
5
5
  "keywords": [
6
6
  "react-native",
@@ -71,6 +71,7 @@
71
71
  "@babel/plugin-transform-template-literals": "^7.27.1",
72
72
  "@babel/plugin-transform-unicode-regex": "^7.27.1",
73
73
  "@babel/preset-typescript": "^7.28.5",
74
+ "@babel/types": "^7.27.1",
74
75
  "convert-source-map": "^2.0.0",
75
76
  "semver": "^7.7.4"
76
77
  },
package/plugin/index.js CHANGED
@@ -380,10 +380,10 @@ var require_utils = __commonJS({
380
380
  exports2.isRelease = isRelease;
381
381
  exports2.replaceWithFactoryCall = replaceWithFactoryCall;
382
382
  var types_12 = require("@babel/types");
383
- function isRelease() {
384
- var _a, _b;
383
+ function isRelease(state) {
384
+ var _a, _b, _c;
385
385
  const pattern = /(prod|release|stag[ei])/i;
386
- return !!(((_a = process.env.BABEL_ENV) === null || _a === void 0 ? void 0 : _a.match(pattern)) || ((_b = process.env.NODE_ENV) === null || _b === void 0 ? void 0 : _b.match(pattern)));
386
+ return !!(((_a = state.file.opts.envName) === null || _a === void 0 ? void 0 : _a.match(pattern)) || ((_b = process.env.BABEL_ENV) === null || _b === void 0 ? void 0 : _b.match(pattern)) || ((_c = process.env.NODE_ENV) === null || _c === void 0 ? void 0 : _c.match(pattern)));
387
387
  }
388
388
  function replaceWithFactoryCall(toReplace, name, factoryCall) {
389
389
  if (!name || !needsDeclaration(toReplace)) {
@@ -839,7 +839,7 @@ var require_workletStringCode = __commonJS({
839
839
  const workletFunction = (0, types_12.functionExpression)((0, types_12.identifier)(workletName), expression.params, expression.body, expression.generator, expression.async);
840
840
  const code = (0, generator_1.default)(workletFunction).code;
841
841
  (0, assert_1.strict)(inputMap, "[Reanimated] `inputMap` is undefined.");
842
- const includeSourceMap = !((0, utils_1.isRelease)() || state.opts.disableSourceMaps);
842
+ const includeSourceMap = !((0, utils_1.isRelease)(state) || state.opts.disableSourceMaps);
843
843
  if (includeSourceMap) {
844
844
  inputMap.sourcesContent = [];
845
845
  for (const sourceFile of inputMap.sources) {
@@ -999,7 +999,7 @@ var require_workletFactory = __commonJS({
999
999
  const initDataObjectExpression = (0, types_12.objectExpression)([
1000
1000
  (0, types_12.objectProperty)((0, types_12.identifier)("code"), (0, types_12.stringLiteral)(funString))
1001
1001
  ]);
1002
- const shouldInjectLocation = !(0, utils_1.isRelease)();
1002
+ const shouldInjectLocation = !(0, utils_1.isRelease)(state);
1003
1003
  if (shouldInjectLocation) {
1004
1004
  let location = state.file.opts.filename;
1005
1005
  if (state.opts.relativeSourceLocation) {
@@ -1031,14 +1031,14 @@ var require_workletFactory = __commonJS({
1031
1031
  (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__closure"), false), (0, types_12.objectExpression)(closureVariables.map((variable) => !state.opts.bundleMode && variable.name.endsWith(types_2.workletClassFactorySuffix) ? (0, types_12.objectProperty)((0, types_12.identifier)(variable.name), (0, types_12.memberExpression)((0, types_12.identifier)(variable.name.slice(0, variable.name.length - types_2.workletClassFactorySuffix.length)), (0, types_12.identifier)(variable.name))) : (0, types_12.objectProperty)((0, types_12.cloneNode)(variable, true), (0, types_12.cloneNode)(variable, true), false, true))))),
1032
1032
  (0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__workletHash"), false), (0, types_12.numericLiteral)(workletHash)))
1033
1033
  ];
1034
- const shouldInjectVersion = !(0, utils_1.isRelease)();
1034
+ const shouldInjectVersion = !(0, utils_1.isRelease)(state);
1035
1035
  if (shouldInjectVersion) {
1036
1036
  statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__pluginVersion")), (0, types_12.stringLiteral)(shouldMockVersion() ? MOCK_VERSION : REAL_VERSION))));
1037
1037
  }
1038
1038
  if (shouldIncludeInitData) {
1039
1039
  statements.push((0, types_12.expressionStatement)((0, types_12.assignmentExpression)("=", (0, types_12.memberExpression)((0, types_12.identifier)(reactName), (0, types_12.identifier)("__initData"), false), (0, types_12.cloneNode)(initDataId, true))));
1040
1040
  }
1041
- if (!(0, utils_1.isRelease)() && !state.opts.bundleMode) {
1041
+ if (!(0, utils_1.isRelease)(state) && !state.opts.bundleMode) {
1042
1042
  statements.unshift((0, types_12.variableDeclaration)("const", [
1043
1043
  (0, types_12.variableDeclarator)((0, types_12.identifier)("_e"), (0, types_12.arrayExpression)([
1044
1044
  (0, types_12.newExpression)((0, types_12.memberExpression)((0, types_12.identifier)("global"), (0, types_12.identifier)("Error")), []),
@@ -1823,7 +1823,7 @@ var require_inlineStylesWarning = __commonJS({
1823
1823
  }
1824
1824
  }
1825
1825
  function processInlineStylesWarning(path, state) {
1826
- if ((0, utils_1.isRelease)()) {
1826
+ if ((0, utils_1.isRelease)(state)) {
1827
1827
  return;
1828
1828
  }
1829
1829
  if (state.opts.disableInlineStylesWarning) {
@@ -5,4 +5,4 @@
5
5
  * version used to build the native part of the library in runtime. Remember to
6
6
  * keep this in sync with the version declared in `package.json`
7
7
  */
8
- export const jsVersion = '0.9.1';
8
+ export const jsVersion = '0.9.2';