@amazon-devices/react-native-worklets 1.0.1 → 1.0.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.
Files changed (95) hide show
  1. package/kepler-compatibility.json +2 -1
  2. package/lib/module/index.js +0 -25
  3. package/package.json +1 -1
  4. package/src/index.ts +0 -52
  5. package/bundleMode/index.js +0 -59
  6. package/lib/module/PlatformChecker/PlatformChecker.js +0 -8
  7. package/lib/module/PlatformChecker/index.js +0 -18
  8. package/lib/module/WorkletsError.js +0 -29
  9. package/lib/module/WorkletsModule/JSWorklets.js +0 -111
  10. package/lib/module/WorkletsModule/NativeWorklets.js +0 -126
  11. package/lib/module/WorkletsModule/index.js +0 -4
  12. package/lib/module/WorkletsModule/workletsModuleInstance.js +0 -7
  13. package/lib/module/WorkletsModule/workletsModuleInstance.web.js +0 -5
  14. package/lib/module/WorkletsModule/workletsModuleProxy.js +0 -4
  15. package/lib/module/bundleUnpacker.js +0 -47
  16. package/lib/module/callGuard.js +0 -30
  17. package/lib/module/deprecated.js +0 -20
  18. package/lib/module/errors.js +0 -69
  19. package/lib/module/featureFlags/index.js +0 -48
  20. package/lib/module/initializers.js +0 -221
  21. package/lib/module/isSynchronizable.js +0 -6
  22. package/lib/module/logger.js +0 -15
  23. package/lib/module/privateGlobals.d.js +0 -7
  24. package/lib/module/publicGlobals.js +0 -6
  25. package/lib/module/runLoop/common/setImmediatePolyfill.js +0 -15
  26. package/lib/module/runLoop/common/setIntervalPolyfill.js +0 -26
  27. package/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js +0 -10
  28. package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js +0 -52
  29. package/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js +0 -32
  30. package/lib/module/runLoop/workletRuntime/index.js +0 -19
  31. package/lib/module/runLoop/workletRuntime/queueMicrotask.js +0 -11
  32. package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js +0 -48
  33. package/lib/module/runLoop/workletRuntime/setTimeout.js +0 -28
  34. package/lib/module/runLoop/workletRuntime/taskQueue.js +0 -37
  35. package/lib/module/runtimeKind.js +0 -39
  36. package/lib/module/runtimes.js +0 -100
  37. package/lib/module/serializable.js +0 -568
  38. package/lib/module/serializableMappingCache.js +0 -37
  39. package/lib/module/specs/NativeWorkletsModule.js +0 -5
  40. package/lib/module/specs/NativeWorkletsModule.kepler.js +0 -7
  41. package/lib/module/specs/index.js +0 -10
  42. package/lib/module/synchronizable.js +0 -9
  43. package/lib/module/synchronizableUnpacker.js +0 -42
  44. package/lib/module/threads.js +0 -347
  45. package/lib/module/utils/checkCppVersion.js +0 -30
  46. package/lib/module/utils/jsVersion.js +0 -9
  47. package/lib/module/valueUnpacker.js +0 -60
  48. package/lib/module/workletFunction.js +0 -37
  49. package/lib/module/workletRuntimeEntry.js +0 -32
  50. package/lib/module/workletTypes.js +0 -12
  51. package/scripts/validate-react-native-version.js +0 -43
  52. package/src/PlatformChecker/PlatformChecker.ts +0 -7
  53. package/src/PlatformChecker/index.ts +0 -30
  54. package/src/WorkletsError.ts +0 -36
  55. package/src/WorkletsModule/JSWorklets.ts +0 -200
  56. package/src/WorkletsModule/NativeWorklets.ts +0 -256
  57. package/src/WorkletsModule/index.ts +0 -7
  58. package/src/WorkletsModule/workletsModuleInstance.ts +0 -9
  59. package/src/WorkletsModule/workletsModuleInstance.web.ts +0 -5
  60. package/src/WorkletsModule/workletsModuleProxy.ts +0 -126
  61. package/src/bundleUnpacker.ts +0 -75
  62. package/src/callGuard.ts +0 -33
  63. package/src/deprecated.ts +0 -32
  64. package/src/errors.ts +0 -80
  65. package/src/featureFlags/index.ts +0 -72
  66. package/src/initializers.ts +0 -262
  67. package/src/isSynchronizable.ts +0 -13
  68. package/src/logger.ts +0 -16
  69. package/src/publicGlobals.ts +0 -39
  70. package/src/runLoop/common/setImmediatePolyfill.ts +0 -20
  71. package/src/runLoop/common/setIntervalPolyfill.ts +0 -38
  72. package/src/runLoop/uiRuntime/mockedRequestAnimationFrame.ts +0 -11
  73. package/src/runLoop/uiRuntime/requestAnimationFrame.ts +0 -66
  74. package/src/runLoop/uiRuntime/setTimeoutPolyfill.ts +0 -40
  75. package/src/runLoop/workletRuntime/index.ts +0 -18
  76. package/src/runLoop/workletRuntime/queueMicrotask.ts +0 -13
  77. package/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts +0 -61
  78. package/src/runLoop/workletRuntime/setTimeout.ts +0 -37
  79. package/src/runLoop/workletRuntime/taskQueue.ts +0 -44
  80. package/src/runtimeKind.ts +0 -37
  81. package/src/runtimes.ts +0 -193
  82. package/src/serializable.ts +0 -801
  83. package/src/serializableMappingCache.ts +0 -42
  84. package/src/specs/NativeWorkletsModule.kepler.ts +0 -11
  85. package/src/specs/NativeWorkletsModule.ts +0 -9
  86. package/src/specs/index.ts +0 -13
  87. package/src/synchronizable.ts +0 -32
  88. package/src/synchronizableUnpacker.ts +0 -67
  89. package/src/threads.ts +0 -452
  90. package/src/utils/checkCppVersion.ts +0 -34
  91. package/src/utils/jsVersion.ts +0 -7
  92. package/src/valueUnpacker.ts +0 -90
  93. package/src/workletFunction.ts +0 -42
  94. package/src/workletRuntimeEntry.ts +0 -35
  95. package/src/workletTypes.ts +0 -81
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "versions": {
3
3
  "1.0.0": "/com.amazon.kepler.worklets_1@IWorklets_0",
4
- "1.0.1": "/com.amazon.kepler.worklets_1@IWorklets_0"
4
+ "1.0.1": "/com.amazon.kepler.worklets_1@IWorklets_0",
5
+ "1.0.2": "/com.amazon.kepler.worklets_1@IWorklets_0"
5
6
  }
6
7
  }
@@ -1,26 +1 @@
1
- 'use strict';
2
1
 
3
- import './publicGlobals';
4
- import { init } from './initializers';
5
- import { bundleModeInit } from './workletRuntimeEntry';
6
- init();
7
- export { isShareableRef, makeShareable, makeShareableCloneOnUIRecursive, makeShareableCloneRecursive, shareableMappingCache } from './deprecated';
8
- export { getStaticFeatureFlag, setDynamicFeatureFlag } from './featureFlags';
9
- export { isSynchronizable } from './isSynchronizable';
10
- export { getRuntimeKind, RuntimeKind } from './runtimeKind';
11
- export { createWorkletRuntime, runOnRuntime } from './runtimes';
12
- export { createSerializable, isSerializableRef } from './serializable';
13
- export { serializableMappingCache } from './serializableMappingCache';
14
- export { createSynchronizable } from './synchronizable';
15
- export { callMicrotasks, executeOnUIRuntimeSync, runOnJS, runOnUI, runOnUIAsync, runOnUISync, scheduleOnRN, scheduleOnUI,
16
- // eslint-disable-next-line camelcase
17
- unstable_eventLoopTask } from './threads';
18
- export { isWorkletFunction } from './workletFunction';
19
- export { WorkletsModule } from './WorkletsModule';
20
- // @ts-expect-error We must trick the bundler to include
21
- // the `workletRuntimeEntry` file the way it cannot optimize it out.
22
- if (globalThis._ALWAYS_FALSE) {
23
- // Bundle mode.
24
- bundleModeInit();
25
- }
26
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1 +1 @@
1
- {"//": "amzn_mod - update package name and build with yarn", "name": "@amazon-devices/react-native-worklets", "version": "1.0.1+0.6.0", "description": "The React Native multithreading library", "keywords": ["react-native", "react", "native", "worklets"], "scripts": {"build": "yarn workspace @amazon-devices/babel-plugin-worklets build && bob build && yarn build:unpackers", "build:unpackers": "node ./scripts/export-unpackers.js", "circular-dependency-check": "yarn madge --extensions js,jsx --circular lib", "find-unused-code:js": "knip", "format": "yarn format:js && yarn format:plugin && yarn format:common && yarn format:android && yarn format:apple", "format:android": "yarn format:android:java && yarn format:android:cpp && yarn format:android:cmake", "format:android:cpp": "find android/src -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i", "format:android:cmake": "find ./android -type d \\( -name build -o -name .cxx \\) -prune -o -type f -name 'CMakeLists.txt' -print | xargs ../../scripts/format-cmake.sh", "format:android:java": "node ../../scripts/format-java.js", "format:apple": "find apple -iname \"*.h\" -o -iname \"*.m\" -o -iname \"*.mm\" -o -iname \"*.cpp\" | xargs clang-format -i", "format:common": "find Common -iname \"*.h\" -o -iname \"*.cpp\" | xargs clang-format -i", "format:js": "prettier --write --list-different src", "format:plugin": "yarn workspace babel-plugin-worklets format", "lint": "yarn lint:js && yarn lint:common && yarn lint:plugin && yarn lint:android && yarn lint:apple", "lint:android": "../../scripts/validate-android.sh && ./android/gradlew -p android spotlessCheck -q && ../../scripts/cpplint.sh android/src && yarn format:android:cpp --dry-run -Werror && yarn lint:cmake", "lint:apple": "../../scripts/validate-apple.sh && yarn format:apple --dry-run -Werror", "lint:common": "../../scripts/validate-common.sh && ../../scripts/cpplint.sh Common && yarn format:common --dry-run -Werror", "lint:cmake": "find ./android -type d \\( -name build -o -name .cxx \\) -prune -o -type f -name 'CMakeLists.txt' -print | xargs ../../scripts/lint-cmake.sh", "lint:clang-tidy": "find Common -iname \"*.h\" -o -iname \"*.cpp\" | xargs ../../scripts/clang-tidy-lint.sh", "lint:js": "eslint src && yarn prettier --check src", "lint:plugin": "yarn workspace babel-plugin-worklets lint", "test": "jest", "type:check": "yarn type:check:src && yarn type:check:plugin && yarn type:check:app && yarn type:check:tests", "type:check:src": "yarn tsc --noEmit", "type:check:app": "yarn workspace common-app type:check", "type:check:plugin": "yarn workspace babel-plugin-worklets type:check", "type:check:tests": "../../scripts/test-ts.sh __typetests__", "use-strict-check": "node ../../scripts/validate-use-strict.js"}, "repository": {"type": "git", "url": "git+https://github.com/software-mansion/react-native-reanimated.git", "directory": "packages/react-native-worklets"}, "license": "See license in LICENSE", "readmeFilename": "README.md", "bugs": {"url": "https://github.com/software-mansion/react-native-reanimated/issues"}, "homepage": "https://docs.swmansion.com/react-native-worklets", "peerDependencies": {"@babel/core": "^7.0.0-0", "react": "*", "react-native": "*"}, "dependencies": {"@babel/plugin-transform-arrow-functions": "^7.0.0-0", "@babel/plugin-transform-class-properties": "^7.0.0-0", "@babel/plugin-transform-classes": "^7.0.0-0", "@babel/plugin-transform-nullish-coalescing-operator": "^7.0.0-0", "@babel/plugin-transform-optional-chaining": "^7.0.0-0", "@babel/plugin-transform-shorthand-properties": "^7.0.0-0", "@babel/plugin-transform-template-literals": "^7.0.0-0", "@babel/plugin-transform-unicode-regex": "^7.0.0-0", "@babel/preset-typescript": "^7.16.7", "convert-source-map": "^2.0.0", "semver": "7.7.2"}, "devDependencies": {"@babel/cli": "^7.20.0", "@babel/core": "^7.25.2", "@react-native-community/cli": "20.0.0", "@react-native/eslint-config": "0.81.0", "@types/jest": "^29.5.5", "@types/react": "^19.1.0", "clang-format-node": "^1.3.1", "eslint": "^9.29.0", "jest": "^29.0.0", "knip": "^5.61.3", "madge": "^5.0.1", "prettier": "^3.3.3", "react": "19.1.0", "react-native": "0.81.5", "react-native-builder-bob": "0.40.13", "@react-native/babel-preset": "0.81.0", "typescript": "5.8.3"}, "main": "./lib/module/index", "module": "./lib/module/index", "react-native": "./src/index", "source": "./src/index", "types": "lib/typescript/index.d.ts", "files": ["src", "lib", "android", "apple", "Common", "compatibility.json", "bundleMode/index.js", "bundleMode/index.d.ts", "scripts/worklets_utils.rb", "scripts/validate-react-native-version.js", "SystemModules", "SystemBundles", "plugin/index.js", "*.podspec", "react-native.config.js", "kepler-compatibility.json", "oss-attribution", "!apple/build", "!android/build", "!android/gradle", "!android/gradlew", "!android/gradlew.bat", "!android/local.properties", "!**/__tests__", "!**/__fixtures__", "!**/__mocks__", "!**/.*", "kepler-transformed-package-info.json"], "react-native-builder-bob": {"source": "src", "output": "lib", "targets": [["module", {"esm": false, "jsxRuntime": "automatic"}], "typescript"]}, "interfaceOnly": {"keep": ["plugin"]}, "codegenConfig": {"name": "rnworklets", "type": "modules", "jsSrcsDir": "src/specs", "android": {"javaPackageName": "com.swmansion.worklets"}, "ios": {"modulesConformingToProtocol": {"RCTBundleConsumer": ["WorkletsModule"]}}}}
1
+ {"name": "@amazon-devices/react-native-worklets", "version": "1.0.2+0.6.0", "description": "The React Native multithreading library", "keywords": ["react-native", "react", "native", "worklets"], "homepage": "https://docs.swmansion.com/react-native-worklets", "bugs": {"url": "https://github.com/software-mansion/react-native-reanimated/issues"}, "license": "See license in LICENSE", "files": ["src", "lib", "android", "apple", "Common", "compatibility.json", "bundleMode/index.js", "bundleMode/index.d.ts", "scripts/worklets_utils.rb", "scripts/validate-react-native-version.js", "SystemModules", "SystemBundles", "plugin/index.js", "*.podspec", "react-native.config.js", "kepler-compatibility.json", "oss-attribution", "!apple/build", "!android/build", "!android/gradle", "!android/gradlew", "!android/gradlew.bat", "!android/local.properties", "!**/__tests__", "!**/__fixtures__", "!**/__mocks__", "!**/.*", "kepler-transformed-package-info.json"], "main": "./lib/module/index", "dependencies": {"@babel/plugin-transform-arrow-functions": "^7.0.0-0", "@babel/plugin-transform-nullish-coalescing-operator": "^7.0.0-0", "@babel/plugin-transform-optional-chaining": "^7.0.0-0", "@babel/plugin-transform-shorthand-properties": "^7.0.0-0", "@babel/plugin-transform-template-literals": "^7.0.0-0", "@babel/preset-typescript": "^7.16.7", "convert-source-map": "^2.0.0"}, "peerDependencies": {"@babel/core": "^7.0.0-0", "react": "*", "react-native": "*"}, "types": "lib/typescript/index.d.ts", "react-native": "./src/index", "interfaceOnly": {"keep": ["plugin"]}}
package/src/index.ts CHANGED
@@ -1,53 +1 @@
1
- 'use strict';
2
1
 
3
- import './publicGlobals';
4
-
5
- import { init } from './initializers';
6
- import { bundleModeInit } from './workletRuntimeEntry';
7
-
8
- init();
9
-
10
- export type { MakeShareableClone, ShareableRef } from './deprecated';
11
- export {
12
- isShareableRef,
13
- makeShareable,
14
- makeShareableCloneOnUIRecursive,
15
- makeShareableCloneRecursive,
16
- shareableMappingCache,
17
- } from './deprecated';
18
- export { getStaticFeatureFlag, setDynamicFeatureFlag } from './featureFlags';
19
- export { isSynchronizable } from './isSynchronizable';
20
- export { getRuntimeKind, RuntimeKind } from './runtimeKind';
21
- export { createWorkletRuntime, runOnRuntime } from './runtimes';
22
- export { createSerializable, isSerializableRef } from './serializable';
23
- export { serializableMappingCache } from './serializableMappingCache';
24
- export type { Synchronizable } from './synchronizable';
25
- export { createSynchronizable } from './synchronizable';
26
- export {
27
- callMicrotasks,
28
- executeOnUIRuntimeSync,
29
- runOnJS,
30
- runOnUI,
31
- runOnUIAsync,
32
- runOnUISync,
33
- scheduleOnRN,
34
- scheduleOnUI,
35
- // eslint-disable-next-line camelcase
36
- unstable_eventLoopTask,
37
- } from './threads';
38
- export { isWorkletFunction } from './workletFunction';
39
- export type { IWorkletsModule, WorkletsModuleProxy } from './WorkletsModule';
40
- export { WorkletsModule } from './WorkletsModule';
41
- export type {
42
- SerializableRef,
43
- WorkletFunction,
44
- WorkletRuntime,
45
- WorkletStackDetails,
46
- } from './workletTypes';
47
-
48
- // @ts-expect-error We must trick the bundler to include
49
- // the `workletRuntimeEntry` file the way it cannot optimize it out.
50
- if (globalThis._ALWAYS_FALSE) {
51
- // Bundle mode.
52
- bundleModeInit();
53
- }
@@ -1,59 +0,0 @@
1
- const { getDefaultConfig } = require('@react-native/metro-config');
2
- const path = require('path');
3
-
4
- const workletsPackageParentDir = path.resolve(__dirname, '../..');
5
-
6
- const defaults = getDefaultConfig(__dirname);
7
-
8
- module.exports = {
9
- bundleModeMetroConfig: {
10
- serializer: {
11
- getModulesRunBeforeMainModule(/** @type {string} dirname */ dirname) {
12
- return [
13
- require.resolve('react-native-worklets/src/workletRuntimeEntry.ts'),
14
- require.resolve(
15
- 'react-native-worklets/lib/module/workletRuntimeEntry.js'
16
- ),
17
- ...defaults.serializer.getModulesRunBeforeMainModule(dirname),
18
- ];
19
- },
20
- createModuleIdFactory() {
21
- let nextId = 0;
22
- const idFileMap = new Map();
23
- return (/** @type {string} */ moduleName) => {
24
- if (idFileMap.has(moduleName)) {
25
- return idFileMap.get(moduleName);
26
- }
27
- if (
28
- moduleName.includes('react-native-worklets/__generatedWorklets/')
29
- ) {
30
- const base = path.basename(moduleName, '.js');
31
- const id = Number(base);
32
- idFileMap.set(moduleName, id);
33
- return id;
34
- }
35
- idFileMap.set(moduleName, nextId++);
36
- return idFileMap.get(moduleName);
37
- };
38
- },
39
- },
40
- resolver: {
41
- resolveRequest: (
42
- /** @type {any} */ context,
43
- /** @type {string} */ moduleName,
44
- /** @type {any} */ platform
45
- ) => {
46
- if (
47
- moduleName.startsWith('react-native-worklets/__generatedWorklets/')
48
- ) {
49
- const fullModuleName = path.join(
50
- workletsPackageParentDir,
51
- moduleName
52
- );
53
- return { type: 'sourceFile', filePath: fullModuleName };
54
- }
55
- return context.resolveRequest(context, moduleName, platform);
56
- },
57
- },
58
- },
59
- };
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- import { Platform } from 'react-native';
4
- export const IS_JEST = !!process.env.JEST_WORKER_ID;
5
- export const IS_WEB = Platform.OS === 'web';
6
- export const IS_WINDOWS = Platform.OS === 'windows';
7
- export const SHOULD_BE_USE_WEB = IS_JEST || IS_WEB || IS_WINDOWS;
8
- //# sourceMappingURL=PlatformChecker.js.map
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- import { RuntimeKind } from '../runtimeKind';
4
- import { IS_JEST as RN_IS_JEST, IS_WEB as RN_IS_WEB, IS_WINDOWS as RN_IS_WINDOWS, SHOULD_BE_USE_WEB as RN_SHOULD_BE_USE_WEB } from './PlatformChecker';
5
- let IS_JEST = false;
6
- let IS_WEB = false;
7
- let IS_WINDOWS = false;
8
- let SHOULD_BE_USE_WEB = false;
9
- if (globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
10
- IS_JEST = RN_IS_JEST;
11
- IS_WEB = RN_IS_WEB;
12
- IS_WINDOWS = RN_IS_WINDOWS;
13
- SHOULD_BE_USE_WEB = RN_SHOULD_BE_USE_WEB;
14
- }
15
- export { IS_JEST, /** @knipIgnore */
16
- IS_WEB, /** @knipIgnore */
17
- IS_WINDOWS, SHOULD_BE_USE_WEB };
18
- //# sourceMappingURL=index.js.map
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- import { RuntimeKind } from './runtimeKind';
4
- function WorkletsErrorConstructor(message) {
5
- 'worklet';
6
-
7
- const prefix = '[Worklets]';
8
-
9
- // eslint-disable-next-line reanimated/use-worklets-error
10
- const errorInstance = new Error(message ? `${prefix} ${message}` : prefix);
11
- errorInstance.name = `WorkletsError`;
12
- return errorInstance;
13
- }
14
-
15
- /**
16
- * Registers WorkletsError in the global scope. Register only for Worklet
17
- * runtimes.
18
- */
19
- export function registerWorkletsError() {
20
- 'worklet';
21
-
22
- if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
23
- globalThis.WorkletsError = WorkletsErrorConstructor;
24
- }
25
- }
26
- export const WorkletsError = WorkletsErrorConstructor;
27
-
28
- // signed type
29
- //# sourceMappingURL=WorkletsError.js.map
@@ -1,111 +0,0 @@
1
- 'use strict';
2
-
3
- import { IS_JEST } from '../PlatformChecker';
4
- import { mockedRequestAnimationFrame } from '../runLoop/uiRuntime/mockedRequestAnimationFrame';
5
- import { WorkletsError } from '../WorkletsError';
6
- export function createJSWorkletsModule() {
7
- return new JSWorklets();
8
- }
9
-
10
- // In Node.js environments (like when static rendering with Expo Router)
11
- // requestAnimationFrame is unavailable, so we use our mock.
12
- // It also has to be mocked for Jest purposes (see `initializeUIRuntime`).
13
- const requestAnimationFrameImpl = IS_JEST || !globalThis.requestAnimationFrame ? mockedRequestAnimationFrame : globalThis.requestAnimationFrame;
14
- class JSWorklets {
15
- createSerializable() {
16
- throw new WorkletsError('createSerializable should never be called in JSWorklets.');
17
- }
18
- createSerializableString() {
19
- throw new WorkletsError('createSerializableString should never be called in JSWorklets.');
20
- }
21
- createSerializableNumber() {
22
- throw new WorkletsError('createSerializableNumber should never be called in JSWorklets.');
23
- }
24
- createSerializableBoolean() {
25
- throw new WorkletsError('createSerializableBoolean should never be called in JSWorklets.');
26
- }
27
- createSerializableBigInt() {
28
- throw new WorkletsError('createSerializableBigInt should never be called in JSWorklets.');
29
- }
30
- createSerializableUndefined() {
31
- throw new WorkletsError('createSerializableUndefined should never be called in JSWorklets.');
32
- }
33
- createSerializableNull() {
34
- throw new WorkletsError('createSerializableNull should never be called in JSWorklets.');
35
- }
36
- createSerializableTurboModuleLike() {
37
- throw new WorkletsError('createSerializableTurboModuleLike should never be called in JSWorklets.');
38
- }
39
- createSerializableObject() {
40
- throw new WorkletsError('createSerializableObject should never be called in JSWorklets.');
41
- }
42
- createSerializableMap() {
43
- throw new WorkletsError('createSerializableMap should never be called in JSWorklets.');
44
- }
45
- createSerializableSet() {
46
- throw new WorkletsError('createSerializableSet should never be called in JSWorklets.');
47
- }
48
- createSerializableImport() {
49
- throw new WorkletsError('createSerializableImport should never be called in JSWorklets.');
50
- }
51
- createSerializableHostObject() {
52
- throw new WorkletsError('createSerializableHostObject should never be called in JSWorklets.');
53
- }
54
- createSerializableArray() {
55
- throw new WorkletsError('createSerializableArray should never be called in JSWorklets.');
56
- }
57
- createSerializableInitializer() {
58
- throw new WorkletsError('createSerializableInitializer should never be called in JSWorklets.');
59
- }
60
- createSerializableFunction() {
61
- throw new WorkletsError('createSerializableFunction should never be called in JSWorklets.');
62
- }
63
- createSerializableWorklet() {
64
- throw new WorkletsError('createSerializableWorklet should never be called in JSWorklets.');
65
- }
66
- scheduleOnUI(worklet) {
67
- // TODO: `requestAnimationFrame` should be used exclusively in Reanimated
68
-
69
- // @ts-ignore web implementation has still not been updated after the rewrite,
70
- // this will be addressed once the web implementation updates are ready
71
- requestAnimationFrameImpl(worklet);
72
- }
73
- executeOnUIRuntimeSync() {
74
- throw new WorkletsError('`executeOnUIRuntimeSync` is not available in JSWorklets.');
75
- }
76
- createWorkletRuntime() {
77
- throw new WorkletsError('createWorkletRuntime is not available in JSWorklets.');
78
- }
79
- scheduleOnRuntime() {
80
- throw new WorkletsError('scheduleOnRuntime is not available in JSWorklets.');
81
- }
82
- createSynchronizable() {
83
- throw new WorkletsError('createSynchronizable should never be called in JSWorklets.');
84
- }
85
- synchronizableGetDirty() {
86
- throw new WorkletsError('synchronizableGetDirty should never be called in JSWorklets.');
87
- }
88
- synchronizableGetBlocking() {
89
- throw new WorkletsError('synchronizableGetBlocking should never be called in JSWorklets.');
90
- }
91
- synchronizableSetBlocking() {
92
- throw new WorkletsError('synchronizableSetBlocking should never be called in JSWorklets.');
93
- }
94
- synchronizableLock() {
95
- throw new WorkletsError('synchronizableLock should never be called in JSWorklets.');
96
- }
97
- synchronizableUnlock() {
98
- throw new WorkletsError('synchronizableUnlock should never be called in JSWorklets.');
99
- }
100
- reportFatalErrorOnJS() {
101
- throw new WorkletsError('reportFatalErrorOnJS should never be called in JSWorklets.');
102
- }
103
- getStaticFeatureFlag() {
104
- // mock implementation
105
- return false;
106
- }
107
- setDynamicFeatureFlag() {
108
- // noop
109
- }
110
- }
111
- //# sourceMappingURL=JSWorklets.js.map
@@ -1,126 +0,0 @@
1
- 'use strict';
2
-
3
- import { RuntimeKind } from '../runtimeKind';
4
- import { WorkletsTurboModule } from '../specs';
5
- import { checkCppVersion } from '../utils/checkCppVersion';
6
- import { jsVersion } from '../utils/jsVersion';
7
- import { WorkletsError } from '../WorkletsError';
8
- export function createNativeWorkletsModule() {
9
- return new NativeWorklets();
10
- }
11
- class NativeWorklets {
12
- #workletsModuleProxy;
13
- #serializableUndefined;
14
- #serializableNull;
15
- #serializableTrue;
16
- #serializableFalse;
17
- constructor() {
18
- globalThis._WORKLETS_VERSION_JS = jsVersion;
19
- if (global.__workletsModuleProxy === undefined && globalThis.__RUNTIME_KIND === RuntimeKind.ReactNative) {
20
- WorkletsTurboModule?.installTurboModule();
21
- }
22
- if (global.__workletsModuleProxy === undefined) {
23
- throw new WorkletsError(`Native part of Worklets doesn't seem to be initialized.
24
- See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#native-part-of-worklets-doesnt-seem-to-be-initialized for more details.`);
25
- }
26
- if (__DEV__) {
27
- checkCppVersion();
28
- }
29
- this.#workletsModuleProxy = global.__workletsModuleProxy;
30
- this.#serializableNull = this.#workletsModuleProxy.createSerializableNull();
31
- this.#serializableUndefined = this.#workletsModuleProxy.createSerializableUndefined();
32
- this.#serializableTrue = this.#workletsModuleProxy.createSerializableBoolean(true);
33
- this.#serializableFalse = this.#workletsModuleProxy.createSerializableBoolean(false);
34
- }
35
- createSerializable(value, shouldPersistRemote, nativeStateSource) {
36
- return this.#workletsModuleProxy.createSerializable(value, shouldPersistRemote, nativeStateSource);
37
- }
38
- createSerializableImport(from, to) {
39
- return this.#workletsModuleProxy.createSerializableImport(from, to);
40
- }
41
- createSerializableString(str) {
42
- return this.#workletsModuleProxy.createSerializableString(str);
43
- }
44
- createSerializableNumber(num) {
45
- return this.#workletsModuleProxy.createSerializableNumber(num);
46
- }
47
- createSerializableBoolean(bool) {
48
- return bool ? this.#serializableTrue : this.#serializableFalse;
49
- }
50
- createSerializableBigInt(bigInt) {
51
- return this.#workletsModuleProxy.createSerializableBigInt(bigInt);
52
- }
53
- createSerializableUndefined() {
54
- return this.#serializableUndefined;
55
- }
56
- createSerializableNull() {
57
- return this.#serializableNull;
58
- }
59
- createSerializableTurboModuleLike(props, proto) {
60
- return this.#workletsModuleProxy.createSerializableTurboModuleLike(props, proto);
61
- }
62
- createSerializableObject(obj, shouldRetainRemote, nativeStateSource) {
63
- return this.#workletsModuleProxy.createSerializableObject(obj, shouldRetainRemote, nativeStateSource);
64
- }
65
- createSerializableHostObject(obj) {
66
- return this.#workletsModuleProxy.createSerializableHostObject(obj);
67
- }
68
- createSerializableArray(array, shouldRetainRemote) {
69
- return this.#workletsModuleProxy.createSerializableArray(array, shouldRetainRemote);
70
- }
71
- createSerializableMap(keys, values) {
72
- return this.#workletsModuleProxy.createSerializableMap(keys, values);
73
- }
74
- createSerializableSet(values) {
75
- return this.#workletsModuleProxy.createSerializableSet(values);
76
- }
77
- createSerializableInitializer(obj) {
78
- return this.#workletsModuleProxy.createSerializableInitializer(obj);
79
- }
80
- createSerializableFunction(func) {
81
- return this.#workletsModuleProxy.createSerializableFunction(func);
82
- }
83
- createSerializableWorklet(worklet, shouldPersistRemote) {
84
- return this.#workletsModuleProxy.createSerializableWorklet(worklet, shouldPersistRemote);
85
- }
86
- scheduleOnUI(serializable) {
87
- return this.#workletsModuleProxy.scheduleOnUI(serializable);
88
- }
89
- executeOnUIRuntimeSync(serializable) {
90
- return this.#workletsModuleProxy.executeOnUIRuntimeSync(serializable);
91
- }
92
- createWorkletRuntime(name, initializer, useDefaultQueue, customQueue, enableEventLoop) {
93
- return this.#workletsModuleProxy.createWorkletRuntime(name, initializer, useDefaultQueue, customQueue, enableEventLoop);
94
- }
95
- scheduleOnRuntime(workletRuntime, serializableWorklet) {
96
- return this.#workletsModuleProxy.scheduleOnRuntime(workletRuntime, serializableWorklet);
97
- }
98
- createSynchronizable(value) {
99
- return this.#workletsModuleProxy.createSynchronizable(value);
100
- }
101
- synchronizableGetDirty(synchronizableRef) {
102
- return this.#workletsModuleProxy.synchronizableGetDirty(synchronizableRef);
103
- }
104
- synchronizableGetBlocking(synchronizableRef) {
105
- return this.#workletsModuleProxy.synchronizableGetBlocking(synchronizableRef);
106
- }
107
- synchronizableSetBlocking(synchronizableRef, value) {
108
- return this.#workletsModuleProxy.synchronizableSetBlocking(synchronizableRef, value);
109
- }
110
- synchronizableLock(synchronizableRef) {
111
- return this.#workletsModuleProxy.synchronizableLock(synchronizableRef);
112
- }
113
- synchronizableUnlock(synchronizableRef) {
114
- return this.#workletsModuleProxy.synchronizableUnlock(synchronizableRef);
115
- }
116
- reportFatalErrorOnJS(message, stack, name, jsEngine) {
117
- return this.#workletsModuleProxy.reportFatalErrorOnJS(message, stack, name, jsEngine);
118
- }
119
- getStaticFeatureFlag(name) {
120
- return this.#workletsModuleProxy.getStaticFeatureFlag(name);
121
- }
122
- setDynamicFeatureFlag(name, value) {
123
- this.#workletsModuleProxy.setDynamicFeatureFlag(name, value);
124
- }
125
- }
126
- //# sourceMappingURL=NativeWorklets.js.map
@@ -1,4 +0,0 @@
1
- 'use strict';
2
-
3
- export { WorkletsModule } from './workletsModuleInstance';
4
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- import { SHOULD_BE_USE_WEB } from '../PlatformChecker';
4
- import { createJSWorkletsModule } from './JSWorklets';
5
- import { createNativeWorkletsModule } from './NativeWorklets';
6
- export const WorkletsModule = SHOULD_BE_USE_WEB ? createJSWorkletsModule() : createNativeWorkletsModule();
7
- //# sourceMappingURL=workletsModuleInstance.js.map
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- import { createJSWorkletsModule } from './JSWorklets';
4
- export const WorkletsModule = createJSWorkletsModule();
5
- //# sourceMappingURL=workletsModuleInstance.web.js.map
@@ -1,4 +0,0 @@
1
- 'use strict';
2
-
3
- export {};
4
- //# sourceMappingURL=workletsModuleProxy.js.map
@@ -1,47 +0,0 @@
1
- 'use strict';
2
-
3
- import { logger } from './logger';
4
- import { WorkletsError } from './WorkletsError';
5
- const handleCache = new WeakMap();
6
- export function bundleValueUnpacker(objectToUnpack, category, remoteFunctionName) {
7
- const workletHash = objectToUnpack.__workletHash;
8
- if (workletHash !== undefined) {
9
- return getWorklet(workletHash, objectToUnpack.__closure);
10
- } else if (objectToUnpack.__init !== undefined) {
11
- let value = handleCache.get(objectToUnpack);
12
- if (value === undefined) {
13
- value = objectToUnpack.__init();
14
- handleCache.set(objectToUnpack, value);
15
- }
16
- return value;
17
- } else if (category === 'RemoteFunction') {
18
- const remoteFunctionHolder = () => {
19
- const label = remoteFunctionName ? `function \`${remoteFunctionName}\`` : 'anonymous function';
20
- throw new WorkletsError(`Tried to synchronously call a non-worklet ${label} on the UI thread.
21
- See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#tried-to-synchronously-call-a-non-worklet-function-on-the-ui-thread for more details.`);
22
- };
23
- remoteFunctionHolder.__remoteFunction = objectToUnpack;
24
- return remoteFunctionHolder;
25
- } else {
26
- throw new WorkletsError(`Data type in category "${category}" not recognized by value unpacker: "${globalThis._toString(objectToUnpack)}".`);
27
- }
28
- }
29
- function getWorklet(workletHash, closureVariables) {
30
- let worklet;
31
- if (__DEV__) {
32
- try {
33
- worklet = getWorkletFromMetroRequire(workletHash, closureVariables);
34
- } catch (_e) {
35
- logger.error('Unable to resolve worklet with hash ' + workletHash + '. Try reloading the app.');
36
- }
37
- } else {
38
- worklet = getWorkletFromMetroRequire(workletHash, closureVariables);
39
- }
40
- return worklet;
41
- }
42
- const metroRequire = globalThis.__r;
43
- function getWorkletFromMetroRequire(workletHash, closureVariables) {
44
- const factory = metroRequire(workletHash).default;
45
- return factory(closureVariables);
46
- }
47
- //# sourceMappingURL=bundleUnpacker.js.map
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- /** Used only with debug builds. */
4
- export function callGuardDEV(fn, ...args) {
5
- 'worklet';
6
-
7
- try {
8
- return fn(...args);
9
- } catch (error) {
10
- if (globalThis.__workletsModuleProxy) {
11
- const {
12
- message,
13
- stack,
14
- name,
15
- jsEngine
16
- } = error;
17
- globalThis.__workletsModuleProxy.reportFatalErrorOnJS(message, stack ?? '', name ?? 'WorkletsError', jsEngine ?? 'Worklets');
18
- } else {
19
- throw error;
20
- }
21
- }
22
- }
23
- export function setupCallGuard() {
24
- 'worklet';
25
-
26
- if (!globalThis.__callGuardDEV) {
27
- globalThis.__callGuardDEV = callGuardDEV;
28
- }
29
- }
30
- //# sourceMappingURL=callGuard.js.map
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- import { createSerializable, isSerializableRef, makeShareable, makeShareableCloneOnUIRecursive } from './serializable';
4
- import { serializableMappingCache } from './serializableMappingCache';
5
-
6
- /** @deprecated Use {@link SerializableRef} instead. */
7
-
8
- export { makeShareable, makeShareableCloneOnUIRecursive };
9
-
10
- /** @deprecated It will be removed in the next major version. */
11
-
12
- /** @deprecated Use {@link createSerializable} instead. */
13
- export const makeShareableCloneRecursive = createSerializable;
14
-
15
- /** @deprecated Use {@link isSerializableRef} instead. */
16
- export const isShareableRef = isSerializableRef;
17
-
18
- /** @deprecated Use {@link serializableMappingCache} instead. */
19
- export const shareableMappingCache = serializableMappingCache;
20
- //# sourceMappingURL=deprecated.js.map