@amazon-devices/react-native-worklets 1.0.0 → 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 (110) hide show
  1. package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +5 -3
  2. package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +5 -6
  3. package/Common/cpp/worklets/RunLoop/EventLoop.cpp +6 -6
  4. package/Common/cpp/worklets/SharedItems/Serializable.h +9 -8
  5. package/Common/cpp/worklets/Tools/JSISerializer.h +4 -4
  6. package/Common/cpp/worklets/Tools/JSScheduler.h +5 -3
  7. package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +3 -2
  8. package/Common/cpp/worklets/Tools/UIScheduler.h +4 -4
  9. package/Common/cpp/worklets/Tools/VersionUtils.h +1 -4
  10. package/Common/cpp/worklets/Tools/WorkletsSystraceSection.h +0 -25
  11. package/SystemModules/amzn__react-native-worklets-1.private.modules.txt +57 -33
  12. package/kepler-compatibility.json +3 -1
  13. package/lib/module/index.js +0 -25
  14. package/oss-attribution/attribution.txt +2262 -0
  15. package/oss-attribution/licenseInfos.json +585 -0
  16. package/package.json +1 -153
  17. package/src/index.ts +0 -52
  18. package/SystemBundles/cc12deac6e91c435b76698c8445aed85612f2f88e733218d14f88a35d06fb0f4.bundle +0 -10512
  19. package/SystemBundles/cc12deac6e91c435b76698c8445aed85612f2f88e733218d14f88a35d06fb0f4.map +0 -3771
  20. package/bundleMode/index.js +0 -59
  21. package/lib/module/PlatformChecker/PlatformChecker.js +0 -8
  22. package/lib/module/PlatformChecker/index.js +0 -18
  23. package/lib/module/WorkletsError.js +0 -29
  24. package/lib/module/WorkletsModule/JSWorklets.js +0 -111
  25. package/lib/module/WorkletsModule/NativeWorklets.js +0 -126
  26. package/lib/module/WorkletsModule/index.js +0 -4
  27. package/lib/module/WorkletsModule/workletsModuleInstance.js +0 -7
  28. package/lib/module/WorkletsModule/workletsModuleInstance.web.js +0 -5
  29. package/lib/module/WorkletsModule/workletsModuleProxy.js +0 -4
  30. package/lib/module/bundleUnpacker.js +0 -47
  31. package/lib/module/callGuard.js +0 -30
  32. package/lib/module/deprecated.js +0 -20
  33. package/lib/module/errors.js +0 -69
  34. package/lib/module/featureFlags/index.js +0 -48
  35. package/lib/module/initializers.js +0 -221
  36. package/lib/module/isSynchronizable.js +0 -6
  37. package/lib/module/logger.js +0 -15
  38. package/lib/module/privateGlobals.d.js +0 -7
  39. package/lib/module/publicGlobals.js +0 -6
  40. package/lib/module/runLoop/common/setImmediatePolyfill.js +0 -15
  41. package/lib/module/runLoop/common/setIntervalPolyfill.js +0 -26
  42. package/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js +0 -10
  43. package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js +0 -52
  44. package/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js +0 -32
  45. package/lib/module/runLoop/workletRuntime/index.js +0 -19
  46. package/lib/module/runLoop/workletRuntime/queueMicrotask.js +0 -11
  47. package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js +0 -48
  48. package/lib/module/runLoop/workletRuntime/setTimeout.js +0 -28
  49. package/lib/module/runLoop/workletRuntime/taskQueue.js +0 -37
  50. package/lib/module/runtimeKind.js +0 -39
  51. package/lib/module/runtimes.js +0 -100
  52. package/lib/module/serializable.js +0 -568
  53. package/lib/module/serializableMappingCache.js +0 -37
  54. package/lib/module/specs/NativeWorkletsModule.js +0 -5
  55. package/lib/module/specs/NativeWorkletsModule.kepler.js +0 -7
  56. package/lib/module/specs/index.js +0 -10
  57. package/lib/module/synchronizable.js +0 -9
  58. package/lib/module/synchronizableUnpacker.js +0 -42
  59. package/lib/module/threads.js +0 -347
  60. package/lib/module/utils/checkCppVersion.js +0 -30
  61. package/lib/module/utils/jsVersion.js +0 -9
  62. package/lib/module/valueUnpacker.js +0 -60
  63. package/lib/module/workletFunction.js +0 -37
  64. package/lib/module/workletRuntimeEntry.js +0 -32
  65. package/lib/module/workletTypes.js +0 -12
  66. package/scripts/validate-react-native-version.js +0 -43
  67. package/src/PlatformChecker/PlatformChecker.ts +0 -7
  68. package/src/PlatformChecker/index.ts +0 -30
  69. package/src/WorkletsError.ts +0 -36
  70. package/src/WorkletsModule/JSWorklets.ts +0 -200
  71. package/src/WorkletsModule/NativeWorklets.ts +0 -256
  72. package/src/WorkletsModule/index.ts +0 -7
  73. package/src/WorkletsModule/workletsModuleInstance.ts +0 -9
  74. package/src/WorkletsModule/workletsModuleInstance.web.ts +0 -5
  75. package/src/WorkletsModule/workletsModuleProxy.ts +0 -126
  76. package/src/bundleUnpacker.ts +0 -75
  77. package/src/callGuard.ts +0 -33
  78. package/src/deprecated.ts +0 -32
  79. package/src/errors.ts +0 -80
  80. package/src/featureFlags/index.ts +0 -72
  81. package/src/initializers.ts +0 -262
  82. package/src/isSynchronizable.ts +0 -13
  83. package/src/logger.ts +0 -16
  84. package/src/publicGlobals.ts +0 -39
  85. package/src/runLoop/common/setImmediatePolyfill.ts +0 -20
  86. package/src/runLoop/common/setIntervalPolyfill.ts +0 -38
  87. package/src/runLoop/uiRuntime/mockedRequestAnimationFrame.ts +0 -11
  88. package/src/runLoop/uiRuntime/requestAnimationFrame.ts +0 -66
  89. package/src/runLoop/uiRuntime/setTimeoutPolyfill.ts +0 -40
  90. package/src/runLoop/workletRuntime/index.ts +0 -18
  91. package/src/runLoop/workletRuntime/queueMicrotask.ts +0 -13
  92. package/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts +0 -61
  93. package/src/runLoop/workletRuntime/setTimeout.ts +0 -37
  94. package/src/runLoop/workletRuntime/taskQueue.ts +0 -44
  95. package/src/runtimeKind.ts +0 -37
  96. package/src/runtimes.ts +0 -193
  97. package/src/serializable.ts +0 -801
  98. package/src/serializableMappingCache.ts +0 -42
  99. package/src/specs/NativeWorkletsModule.kepler.ts +0 -11
  100. package/src/specs/NativeWorkletsModule.ts +0 -9
  101. package/src/specs/index.ts +0 -13
  102. package/src/synchronizable.ts +0 -32
  103. package/src/synchronizableUnpacker.ts +0 -67
  104. package/src/threads.ts +0 -452
  105. package/src/utils/checkCppVersion.ts +0 -34
  106. package/src/utils/jsVersion.ts +0 -7
  107. package/src/valueUnpacker.ts +0 -90
  108. package/src/workletFunction.ts +0 -42
  109. package/src/workletRuntimeEntry.ts +0 -35
  110. package/src/workletTypes.ts +0 -81
@@ -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
@@ -1,69 +0,0 @@
1
- 'use strict';
2
-
3
- import { WorkletsError } from './WorkletsError';
4
- const _workletStackDetails = new Map();
5
- export function registerWorkletStackDetails(hash, stackDetails) {
6
- _workletStackDetails.set(hash, stackDetails);
7
- }
8
- function getBundleOffset(error) {
9
- const frame = error.stack?.split('\n')?.[0];
10
- if (frame) {
11
- const parsedFrame = /@([^@]+):(\d+):(\d+)/.exec(frame);
12
- if (parsedFrame) {
13
- const [, file, line, col] = parsedFrame;
14
- return [file, Number(line), Number(col)];
15
- }
16
- }
17
- return ['unknown', 0, 0];
18
- }
19
- function processStack(stack) {
20
- if (stack === '' || stack === undefined) {
21
- return undefined;
22
- }
23
- const workletStackEntries = stack.match(/worklet_(\d+):(\d+):(\d+)/g);
24
- let result = stack;
25
- workletStackEntries?.forEach(match => {
26
- const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);
27
- const errorDetails = _workletStackDetails.get(hash);
28
- if (!errorDetails) {
29
- return;
30
- }
31
- const [error, lineOffset, colOffset] = errorDetails;
32
- const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);
33
- const line = origLine + bundleLine + lineOffset;
34
- const col = origCol + bundleCol + colOffset;
35
- result = result.replace(match, `${bundleFile}:${line}:${col}`);
36
- });
37
- return result;
38
- }
39
- /**
40
- * Remote error is an error coming from a Worklet Runtime that we bubble up to
41
- * the RN Runtime.
42
- */
43
- export function reportFatalRemoteError({
44
- message,
45
- stack,
46
- name,
47
- jsEngine
48
- }, force) {
49
- const error = new WorkletsError();
50
- error.message = message;
51
- error.stack = processStack(stack);
52
- error.name = name;
53
- error.jsEngine = jsEngine;
54
- if (force) {
55
- throw error;
56
- } else {
57
- // @ts-expect-error React Native's `ErrorUtils` are hidden from the global scope.
58
- globalThis.ErrorUtils.reportFatalError(error);
59
- }
60
- }
61
-
62
- /**
63
- * Registers `reportFatalRemoteError` function in global scope to allow to
64
- * invoke it from C++.
65
- */
66
- export function registerReportFatalRemoteError() {
67
- globalThis.__reportFatalRemoteError = reportFatalRemoteError;
68
- }
69
- //# sourceMappingURL=errors.js.map
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- import { logger } from '../logger';
4
- import { WorkletsModule } from '../WorkletsModule';
5
- export const DynamicFlags = {
6
- EXAMPLE_DYNAMIC_FLAG: true,
7
- init() {
8
- Object.keys(DynamicFlags).forEach(key => {
9
- if (key !== 'init' && key !== 'setFlag') {
10
- WorkletsModule.setDynamicFeatureFlag(key, DynamicFlags[key]);
11
- }
12
- });
13
- },
14
- setFlag(name, value) {
15
- if (name in DynamicFlags) {
16
- DynamicFlags[name] = value;
17
- WorkletsModule.setDynamicFeatureFlag(name, value);
18
- } else {
19
- logger.warn(`The feature flag: '${name}' no longer exists, you can safely remove invocation of \`setDynamicFeatureFlag('${name}')\` from your code.`);
20
- }
21
- }
22
- };
23
- DynamicFlags.init();
24
- // Public API function to update a feature flag
25
- export function setDynamicFeatureFlag(name, value) {
26
- DynamicFlags.setFlag(name, value);
27
- }
28
-
29
- /**
30
- * This constant is needed for typechecking and preserving static typechecks in
31
- * generated .d.ts files. Without it, the static flags resolve to an object
32
- * without specific keys.
33
- */
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- const DefaultStaticFeatureFlags = {
36
- RUNTIME_TEST_FLAG: false,
37
- IOS_DYNAMIC_FRAMERATE_ENABLED: false
38
- };
39
- const staticFeatureFlags = {};
40
- export function getStaticFeatureFlag(name) {
41
- if (name in staticFeatureFlags) {
42
- return staticFeatureFlags[name];
43
- }
44
- const featureFlagValue = WorkletsModule.getStaticFeatureFlag(name);
45
- staticFeatureFlags[name] = featureFlagValue;
46
- return featureFlagValue;
47
- }
48
- //# sourceMappingURL=index.js.map