@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,39 +0,0 @@
1
- 'use strict';
2
-
3
- export let RuntimeKind = /*#__PURE__*/function (RuntimeKind) {
4
- /**
5
- * The React Native runtime, which is the main runtime for React Native where
6
- * React exists and where components are rendered.
7
- */
8
- RuntimeKind[RuntimeKind["ReactNative"] = 1] = "ReactNative";
9
- /**
10
- * The UI runtime, which is a special runtime that executes on the UI thread,
11
- * mostly used for animations and gestures.
12
- */
13
- RuntimeKind[RuntimeKind["UI"] = 2] = "UI";
14
- /** Additional runtime created on-demand by the user. */
15
- RuntimeKind[RuntimeKind["Worker"] = 3] = "Worker";
16
- return RuntimeKind;
17
- }({});
18
-
19
- /**
20
- * Programmatic way to check the current runtime kind. It's useful when you need
21
- * specific implementations for different runtimes created by Worklets.
22
- *
23
- * For more optimized calls you can check the value of
24
- * `globalThis.__RUNTIME_KIND` directly.
25
- *
26
- * @returns The kind of the current runtime.
27
- */
28
- export function getRuntimeKind() {
29
- 'worklet';
30
-
31
- return globalThis.__RUNTIME_KIND;
32
- }
33
- if (globalThis.__RUNTIME_KIND === undefined) {
34
- // In Jest environments eager imports make this file to evaluate before
35
- // `initializers.ts` file, therefore we have to set the RuntimeKind here,
36
- // just to be safe.
37
- globalThis.__RUNTIME_KIND = RuntimeKind.ReactNative;
38
- }
39
- //# sourceMappingURL=runtimeKind.js.map
@@ -1,100 +0,0 @@
1
- 'use strict';
2
-
3
- import { setupCallGuard } from './callGuard';
4
- import { getMemorySafeCapturableConsole, setupConsole } from './initializers';
5
- import { SHOULD_BE_USE_WEB } from './PlatformChecker';
6
- import { setupRunLoop } from './runLoop/workletRuntime';
7
- import { RuntimeKind } from './runtimeKind';
8
- import { createSerializable, makeShareableCloneOnUIRecursive } from './serializable';
9
- import { isWorkletFunction } from './workletFunction';
10
- import { registerWorkletsError, WorkletsError } from './WorkletsError';
11
- import { WorkletsModule } from './WorkletsModule';
12
-
13
- /**
14
- * Lets you create a new JS runtime which can be used to run worklets possibly
15
- * on different threads than JS or UI thread.
16
- *
17
- * @param config - Runtime configuration object - {@link WorkletRuntimeConfig}.
18
- * @returns WorkletRuntime which is a
19
- * `jsi::HostObject<worklets::WorkletRuntime>` - {@link WorkletRuntime}
20
- * @see https://docs.swmansion.com/react-native-worklets/docs/threading/createWorkletRuntime/
21
- */
22
- // @ts-expect-error Public API overload.
23
-
24
- /**
25
- * @deprecated Please use the new config object signature instead:
26
- * `createWorkletRuntime({ name, initializer })`
27
- *
28
- * Lets you create a new JS runtime which can be used to run worklets possibly
29
- * on different threads than JS or UI thread.
30
- * @param name - A name used to identify the runtime which will appear in
31
- * devices list in Chrome DevTools.
32
- * @param initializer - An optional worklet that will be run synchronously on
33
- * the same thread immediately after the runtime is created.
34
- * @returns WorkletRuntime which is a
35
- * `jsi::HostObject<worklets::WorkletRuntime>` - {@link WorkletRuntime}
36
- * @see https://docs.swmansion.com/react-native-worklets/docs/threading/createWorkletRuntime/
37
- */
38
-
39
- export function createWorkletRuntime(nameOrConfig, initializer) {
40
- const runtimeBoundCapturableConsole = getMemorySafeCapturableConsole();
41
- let name;
42
- let initializerFn;
43
- let useDefaultQueue = true;
44
- let customQueue;
45
- let animationQueuePollingRate;
46
- let enableEventLoop = true;
47
- if (typeof nameOrConfig === 'string') {
48
- name = nameOrConfig;
49
- initializerFn = initializer;
50
- } else {
51
- // TODO: Make anonymous name globally unique.
52
- name = nameOrConfig?.name ?? 'anonymous';
53
- initializerFn = nameOrConfig?.initializer;
54
- useDefaultQueue = nameOrConfig?.useDefaultQueue ?? true;
55
- customQueue = nameOrConfig?.customQueue;
56
- animationQueuePollingRate = Math.round(nameOrConfig?.animationQueuePollingRate ?? 16);
57
- enableEventLoop = nameOrConfig?.enableEventLoop ?? true;
58
- }
59
- if (initializerFn && !isWorkletFunction(initializerFn)) {
60
- throw new WorkletsError('The initializer passed to `createWorkletRuntime` is not a worklet.');
61
- }
62
- return WorkletsModule.createWorkletRuntime(name, createSerializable(() => {
63
- 'worklet';
64
-
65
- setupCallGuard();
66
- registerWorkletsError();
67
- setupConsole(runtimeBoundCapturableConsole);
68
- if (enableEventLoop) {
69
- setupRunLoop(animationQueuePollingRate);
70
- }
71
- initializerFn?.();
72
- }), useDefaultQueue, customQueue, enableEventLoop);
73
- }
74
-
75
- // @ts-expect-error Check `runOnUI` overload.
76
-
77
- /** Schedule a worklet to execute on the background queue. */
78
- export function runOnRuntime(workletRuntime, worklet) {
79
- 'worklet';
80
-
81
- if (__DEV__ && !SHOULD_BE_USE_WEB && !isWorkletFunction(worklet)) {
82
- throw new WorkletsError('The function passed to `runOnRuntime` is not a worklet.');
83
- }
84
- if (globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative) {
85
- return (...args) => globalThis._scheduleOnRuntime(workletRuntime, makeShareableCloneOnUIRecursive(() => {
86
- 'worklet';
87
-
88
- worklet(...args);
89
- }));
90
- }
91
- return (...args) => WorkletsModule.scheduleOnRuntime(workletRuntime, createSerializable(() => {
92
- 'worklet';
93
-
94
- worklet(...args);
95
- globalThis.__flushMicrotasks();
96
- }));
97
- }
98
-
99
- /** Configuration object for creating a worklet runtime. */
100
- //# sourceMappingURL=runtimes.js.map