react-native-effects 0.0.1 → 0.2.0

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/LICENSE +20 -0
  2. package/README.md +313 -0
  3. package/lib/module/components/Aurora.js +184 -0
  4. package/lib/module/components/Aurora.js.map +1 -0
  5. package/lib/module/components/CalicoSwirl.js +155 -0
  6. package/lib/module/components/CalicoSwirl.js.map +1 -0
  7. package/lib/module/components/Campfire.js +225 -0
  8. package/lib/module/components/Campfire.js.map +1 -0
  9. package/lib/module/components/CircularGradient.js +52 -0
  10. package/lib/module/components/CircularGradient.js.map +1 -0
  11. package/lib/module/components/Iridescence.js +57 -0
  12. package/lib/module/components/Iridescence.js.map +1 -0
  13. package/lib/module/components/LinearGradient.js +48 -0
  14. package/lib/module/components/LinearGradient.js.map +1 -0
  15. package/lib/module/components/LiquidChrome.js +75 -0
  16. package/lib/module/components/LiquidChrome.js.map +1 -0
  17. package/lib/module/components/ShaderView/index.js +252 -0
  18. package/lib/module/components/ShaderView/index.js.map +1 -0
  19. package/lib/module/components/ShaderView/types.js +4 -0
  20. package/lib/module/components/ShaderView/types.js.map +1 -0
  21. package/lib/module/components/ShaderViewWithPanGesture/index.js +196 -0
  22. package/lib/module/components/ShaderViewWithPanGesture/index.js.map +1 -0
  23. package/lib/module/components/Silk.js +83 -0
  24. package/lib/module/components/Silk.js.map +1 -0
  25. package/lib/module/consts.js +154 -0
  26. package/lib/module/consts.js.map +1 -0
  27. package/lib/module/hooks/useClock.js +15 -0
  28. package/lib/module/hooks/useClock.js.map +1 -0
  29. package/lib/module/hooks/useParamsSynchronizable.js +37 -0
  30. package/lib/module/hooks/useParamsSynchronizable.js.map +1 -0
  31. package/lib/module/hooks/useWGPUSetup.js +54 -0
  32. package/lib/module/hooks/useWGPUSetup.js.map +1 -0
  33. package/lib/module/index.js +15 -0
  34. package/lib/module/index.js.map +1 -0
  35. package/lib/module/package.json +1 -0
  36. package/lib/module/shaders/TRIANGLE_VERTEX_SHADER.js +20 -0
  37. package/lib/module/shaders/TRIANGLE_VERTEX_SHADER.js.map +1 -0
  38. package/lib/module/shaders/uniforms.js +21 -0
  39. package/lib/module/shaders/uniforms.js.map +1 -0
  40. package/lib/module/utils/backgroundRuntime.js +12 -0
  41. package/lib/module/utils/backgroundRuntime.js.map +1 -0
  42. package/lib/module/utils/colors.js +94 -0
  43. package/lib/module/utils/colors.js.map +1 -0
  44. package/lib/module/utils/initWebGPU.js +40 -0
  45. package/lib/module/utils/initWebGPU.js.map +1 -0
  46. package/lib/typescript/package.json +1 -0
  47. package/lib/typescript/src/components/Aurora.d.ts +17 -0
  48. package/lib/typescript/src/components/Aurora.d.ts.map +1 -0
  49. package/lib/typescript/src/components/CalicoSwirl.d.ts +13 -0
  50. package/lib/typescript/src/components/CalicoSwirl.d.ts.map +1 -0
  51. package/lib/typescript/src/components/Campfire.d.ts +17 -0
  52. package/lib/typescript/src/components/Campfire.d.ts.map +1 -0
  53. package/lib/typescript/src/components/CircularGradient.d.ts +19 -0
  54. package/lib/typescript/src/components/CircularGradient.d.ts.map +1 -0
  55. package/lib/typescript/src/components/Iridescence.d.ts +11 -0
  56. package/lib/typescript/src/components/Iridescence.d.ts.map +1 -0
  57. package/lib/typescript/src/components/LinearGradient.d.ts +15 -0
  58. package/lib/typescript/src/components/LinearGradient.d.ts.map +1 -0
  59. package/lib/typescript/src/components/LiquidChrome.d.ts +17 -0
  60. package/lib/typescript/src/components/LiquidChrome.d.ts.map +1 -0
  61. package/lib/typescript/src/components/ShaderView/index.d.ts +3 -0
  62. package/lib/typescript/src/components/ShaderView/index.d.ts.map +1 -0
  63. package/lib/typescript/src/components/ShaderView/types.d.ts +35 -0
  64. package/lib/typescript/src/components/ShaderView/types.d.ts.map +1 -0
  65. package/lib/typescript/src/components/ShaderViewWithPanGesture/index.d.ts +35 -0
  66. package/lib/typescript/src/components/ShaderViewWithPanGesture/index.d.ts.map +1 -0
  67. package/lib/typescript/src/components/Silk.d.ts +17 -0
  68. package/lib/typescript/src/components/Silk.d.ts.map +1 -0
  69. package/lib/typescript/src/consts.d.ts +2 -0
  70. package/lib/typescript/src/consts.d.ts.map +1 -0
  71. package/lib/typescript/src/hooks/useClock.d.ts +3 -0
  72. package/lib/typescript/src/hooks/useClock.d.ts.map +1 -0
  73. package/lib/typescript/src/hooks/useParamsSynchronizable.d.ts +22 -0
  74. package/lib/typescript/src/hooks/useParamsSynchronizable.d.ts.map +1 -0
  75. package/lib/typescript/src/hooks/useWGPUSetup.d.ts +15 -0
  76. package/lib/typescript/src/hooks/useWGPUSetup.d.ts.map +1 -0
  77. package/lib/typescript/src/index.d.ts +16 -0
  78. package/lib/typescript/src/index.d.ts.map +1 -0
  79. package/lib/typescript/src/shaders/TRIANGLE_VERTEX_SHADER.d.ts +2 -0
  80. package/lib/typescript/src/shaders/TRIANGLE_VERTEX_SHADER.d.ts.map +1 -0
  81. package/lib/typescript/src/shaders/uniforms.d.ts +6 -0
  82. package/lib/typescript/src/shaders/uniforms.d.ts.map +1 -0
  83. package/lib/typescript/src/utils/backgroundRuntime.d.ts +3 -0
  84. package/lib/typescript/src/utils/backgroundRuntime.d.ts.map +1 -0
  85. package/lib/typescript/src/utils/colors.d.ts +22 -0
  86. package/lib/typescript/src/utils/colors.d.ts.map +1 -0
  87. package/lib/typescript/src/utils/initWebGPU.d.ts +23 -0
  88. package/lib/typescript/src/utils/initWebGPU.d.ts.map +1 -0
  89. package/package.json +175 -7
  90. package/src/components/Aurora.tsx +203 -0
  91. package/src/components/CalicoSwirl.tsx +167 -0
  92. package/src/components/Campfire.tsx +244 -0
  93. package/src/components/CircularGradient.tsx +76 -0
  94. package/src/components/Iridescence.tsx +67 -0
  95. package/src/components/LinearGradient.tsx +62 -0
  96. package/src/components/LiquidChrome.tsx +94 -0
  97. package/src/components/ShaderView/index.tsx +262 -0
  98. package/src/components/ShaderView/types.ts +36 -0
  99. package/src/components/ShaderViewWithPanGesture/index.tsx +225 -0
  100. package/src/components/Silk.tsx +102 -0
  101. package/src/consts.ts +152 -0
  102. package/src/hooks/useClock.ts +20 -0
  103. package/src/hooks/useParamsSynchronizable.ts +52 -0
  104. package/src/hooks/useWGPUSetup.tsx +73 -0
  105. package/src/index.tsx +32 -0
  106. package/src/shaders/TRIANGLE_VERTEX_SHADER.ts +17 -0
  107. package/src/shaders/uniforms.ts +18 -0
  108. package/src/utils/backgroundRuntime.ts +10 -0
  109. package/src/utils/colors.ts +117 -0
  110. package/src/utils/initWebGPU.ts +47 -0
@@ -0,0 +1,15 @@
1
+ import type { ViewProps } from 'react-native';
2
+ import type { ColorInput } from '../utils/colors';
3
+ type Props = ViewProps & {
4
+ /** The color of the start of the gradient. */
5
+ startColor: ColorInput;
6
+ /** The color of the end of the gradient. */
7
+ endColor: ColorInput;
8
+ /** The angle of the gradient in degrees (0-360). */
9
+ angle: number;
10
+ /** Rotation speed in degrees/second. 0 = static. Default: 0 */
11
+ speed?: number;
12
+ };
13
+ export default function LinearGradient({ startColor, endColor, angle, speed, ...viewProps }: Props): import("react").JSX.Element;
14
+ export {};
15
+ //# sourceMappingURL=LinearGradient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinearGradient.d.ts","sourceRoot":"","sources":["../../../../src/components/LinearGradient.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,KAAK,KAAK,GAAG,SAAS,GAAG;IACvB,8CAA8C;IAC9C,UAAU,EAAE,UAAU,CAAC;IACvB,4CAA4C;IAC5C,QAAQ,EAAE,UAAU,CAAC;IACrB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,UAAU,EACV,QAAQ,EACR,KAAK,EACL,KAAS,EACT,GAAG,SAAS,EACb,EAAE,KAAK,+BAcP"}
@@ -0,0 +1,17 @@
1
+ import type { ViewProps } from 'react-native';
2
+ import type { ColorInput } from '../utils/colors';
3
+ type Props = ViewProps & {
4
+ /** The base color for the liquid chrome effect. */
5
+ color?: ColorInput;
6
+ /** Animation speed multiplier. Default: 0.2 */
7
+ speed?: number;
8
+ /** Amplitude of the distortion. Default: 0.3 */
9
+ amplitude?: number;
10
+ /** Horizontal frequency. Default: 3 */
11
+ frequencyX?: number;
12
+ /** Vertical frequency. Default: 3 */
13
+ frequencyY?: number;
14
+ };
15
+ export default function LiquidChrome({ color, speed, amplitude, frequencyX, frequencyY, ...viewProps }: Props): import("react").JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=LiquidChrome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiquidChrome.d.ts","sourceRoot":"","sources":["../../../../src/components/LiquidChrome.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,KAAK,KAAK,GAAG,SAAS,GAAG;IACvB,mDAAmD;IACnD,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,KAAiB,EACjB,KAAW,EACX,SAAe,EACf,UAAc,EACd,UAAc,EACd,GAAG,SAAS,EACb,EAAE,KAAK,+BAiBP"}
@@ -0,0 +1,3 @@
1
+ import type { ShaderViewProps } from './types';
2
+ export default function ShaderView({ fragmentShader, colors, speed, params, isStatic, transparent, paramsSynchronizable, style, ...viewProps }: ShaderViewProps): import("react").JSX.Element;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ShaderView/index.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAS/C,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,cAAc,EACd,MAAW,EACX,KAAW,EACX,MAAW,EACX,QAAgB,EAChB,WAAmB,EACnB,oBAAoB,EACpB,KAAK,EACL,GAAG,SAAS,EACb,EAAE,eAAe,+BAiOjB"}
@@ -0,0 +1,35 @@
1
+ import type { ViewProps } from 'react-native';
2
+ import type { Synchronizable } from 'react-native-worklets';
3
+ import type { ColorInput } from '../../utils/colors';
4
+ /**
5
+ * A 4-float synchronizable whose values are written into the dedicated `u.live`
6
+ * uniform slot every frame. It has its own slot, so it never collides with the
7
+ * 8 static `params` (`u.params0`/`u.params1`).
8
+ *
9
+ * This is the bridge for live, per-frame input (touch position, scroll
10
+ * progress, velocity) coming from the JS thread into the off-thread render
11
+ * loop. Create one with `useParamsSynchronizable` and update it from
12
+ * gesture/scroll handlers. See `ShaderViewWithPanGesture`.
13
+ */
14
+ export type ParamsSynchronizable = Synchronizable<Float64Array>;
15
+ export type ShaderViewProps = ViewProps & {
16
+ /** WGSL fragment shader source (must declare the Uniforms struct) */
17
+ fragmentShader: string;
18
+ /** Array of colors mapped to u.color0, u.color1 (max 2). Default: [] */
19
+ colors?: ColorInput[];
20
+ /** Time multiplier — controls animation speed. Default: 1.0 */
21
+ speed?: number;
22
+ /** Up to 8 shader-specific floats mapped to u.params0.xyzw and u.params1.xyzw */
23
+ params?: number[];
24
+ /** Render once then stop the RAF loop. Default: false */
25
+ isStatic?: boolean;
26
+ /** Use transparent background (clear to alpha 0). Default: false */
27
+ transparent?: boolean;
28
+ /**
29
+ * Optional live input. Its 4 floats are written into the dedicated `u.live`
30
+ * slot every frame — independent of the static `params`. Use for
31
+ * touch/scroll/audio. Create it with `useParamsSynchronizable`.
32
+ */
33
+ paramsSynchronizable?: ParamsSynchronizable;
34
+ };
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/ShaderView/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;GASG;AACH,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACxC,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;IACtB,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oEAAoE;IACpE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { ShaderViewProps } from '../ShaderView/types';
2
+ /**
3
+ * A {@link ShaderView} that feeds touch input into the shader's `u.live`:
4
+ *
5
+ * - `live.x` → pointer X, normalized 0..1 (left → right)
6
+ * - `live.y` → pointer Y, normalized 0..1 (bottom → top, matching UV space)
7
+ * - `live.z` → 1.0 while touching, 0.0 when released
8
+ * - `live.w` → 0.0 (reserved)
9
+ *
10
+ * Dragging moves the pointer **relatively** — it pushes from where the pointer
11
+ * already is rather than jumping under the finger — and a fling lets it glide to
12
+ * a stop. The position is **remembered**: it stays wherever it ended and is
13
+ * never reset; only the "touched" flag (`live.z`) toggles on release. A
14
+ * shader can read `live.xy` as a stable resting position and use `live.z`
15
+ * purely for touch-driven emphasis, so the effect never snaps back.
16
+ *
17
+ * The resting value before the first touch is `[0, 0, 0, 0]` by default; pass
18
+ * `initialParamsSynchronizable` to seed it — e.g. `[0.5, 0.5, 0, 0]` to start a
19
+ * pointer at screen center.
20
+ *
21
+ * The drag runs as a **worklet on the UI thread** and writes the synchronizable
22
+ * directly, so pointer updates never hop to the JS thread — matching the rest of
23
+ * the library, which renders off the JS thread. The render runtime reads the
24
+ * same synchronizable each frame.
25
+ */
26
+ export type ShaderViewWithPanGestureProps = Omit<ShaderViewProps, 'paramsSynchronizable'> & {
27
+ /**
28
+ * Initial value for the gesture channel (`u.live`) before the first touch.
29
+ * Defaults to `[0, 0, 0, 0]`. Use e.g. `[0.5, 0.5, 0, 0]` to rest a pointer at
30
+ * screen center.
31
+ */
32
+ initialParamsSynchronizable?: readonly [number, number, number, number];
33
+ };
34
+ export default function ShaderViewWithPanGesture({ style, initialParamsSynchronizable, ...props }: ShaderViewWithPanGestureProps): import("react").JSX.Element;
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ShaderViewWithPanGesture/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAC9C,eAAe,EACf,sBAAsB,CACvB,GAAG;IACF;;;;OAIG;IACH,2BAA2B,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACzE,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,KAAK,EACL,2BAA0C,EAC1C,GAAG,KAAK,EACT,EAAE,6BAA6B,+BAuK/B"}
@@ -0,0 +1,17 @@
1
+ import type { ViewProps } from 'react-native';
2
+ import type { ColorInput } from '../utils/colors';
3
+ type Props = ViewProps & {
4
+ /** The base color for the silk effect. */
5
+ color?: ColorInput;
6
+ /** Animation speed multiplier. Default: 1.0 */
7
+ speed?: number;
8
+ /** Scale of the pattern. Default: 1.0 */
9
+ scale?: number;
10
+ /** Rotation angle in radians. Default: 0.0 */
11
+ rotation?: number;
12
+ /** Intensity of the noise grain. Default: 1.5 */
13
+ noiseIntensity?: number;
14
+ };
15
+ export default function Silk({ color, speed, scale, rotation, noiseIntensity, ...viewProps }: Props): import("react").JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=Silk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Silk.d.ts","sourceRoot":"","sources":["../../../../src/components/Silk.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,KAAK,KAAK,GAAG,SAAS,GAAG;IACvB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAC3B,KAAiB,EACjB,KAAW,EACX,KAAW,EACX,QAAc,EACd,cAAoB,EACpB,GAAG,SAAS,EACb,EAAE,KAAK,+BAiBP"}
@@ -0,0 +1,2 @@
1
+ export declare const NAMED_COLORS: Record<string, number>;
2
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuJ/C,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type SharedValue } from 'react-native-reanimated';
2
+ export declare function useClock(): SharedValue<number>;
3
+ //# sourceMappingURL=useClock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useClock.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useClock.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC,wBAAgB,QAAQ,IAAI,WAAW,CAAC,MAAM,CAAC,CAW9C"}
@@ -0,0 +1,22 @@
1
+ import type { ParamsSynchronizable } from '../components/ShaderView/types';
2
+ /**
3
+ * Creates a {@link ParamsSynchronizable} — a 4-float channel written into the
4
+ * dedicated `u.live` slot of a {@link ShaderView} every frame. It has its own
5
+ * uniform slot, so it leaves all 8 static `params` untouched.
6
+ *
7
+ * The returned `setParamsSynchronizable` runs on the JS thread (call it from gesture or scroll
8
+ * handlers); the values are read by the off-thread render loop. By convention
9
+ * the four floats carry `(x, y, active, extra)` for pointer input, or
10
+ * `(progress, ...)` for scroll-driven effects — but the meaning is up to the
11
+ * shader consuming `u.live`.
12
+ *
13
+ * Pass `initial` to seed the channel's starting value (read once on first
14
+ * render), so the shader has a sane resting state before the first update —
15
+ * e.g. `[0.5, 0.5, 0, 0]` to start a pointer at screen center. Defaults to all
16
+ * zeros.
17
+ */
18
+ export declare function useParamsSynchronizable(initial?: readonly [number, number, number, number]): {
19
+ paramsSynchronizable: ParamsSynchronizable;
20
+ setParamsSynchronizable: (x: number, y: number, active: number, extra: number) => void;
21
+ };
22
+ //# sourceMappingURL=useParamsSynchronizable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useParamsSynchronizable.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useParamsSynchronizable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,GAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAgB,GAChE;IACD,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,uBAAuB,EAAE,CACvB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,KACV,IAAI,CAAC;CACX,CAqBA"}
@@ -0,0 +1,15 @@
1
+ import { type CanvasRef, type RNCanvasContext } from 'react-native-webgpu';
2
+ import type { WorkletRuntime } from 'react-native-worklets';
3
+ type GPUResources = {
4
+ device: GPUDevice;
5
+ context: RNCanvasContext;
6
+ presentationFormat: GPUTextureFormat;
7
+ };
8
+ type WGPUSetupResult = {
9
+ canvasRef: React.RefObject<CanvasRef>;
10
+ runtime: WorkletRuntime;
11
+ resources: GPUResources | null;
12
+ };
13
+ export declare function useWGPUSetup(): WGPUSetupResult;
14
+ export {};
15
+ //# sourceMappingURL=useWGPUSetup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWGPUSetup.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useWGPUSetup.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,eAAe,CAAC;IACzB,kBAAkB,EAAE,gBAAgB,CAAC;CACtC,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,YAAY,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,wBAAgB,YAAY,IAAI,eAAe,CAiD9C"}
@@ -0,0 +1,16 @@
1
+ import CircularGradient from './components/CircularGradient';
2
+ import LinearGradient from './components/LinearGradient';
3
+ import ShaderView from './components/ShaderView';
4
+ import ShaderViewWithPanGesture from './components/ShaderViewWithPanGesture';
5
+ import Iridescence from './components/Iridescence';
6
+ import LiquidChrome from './components/LiquidChrome';
7
+ import Silk from './components/Silk';
8
+ import Campfire from './components/Campfire';
9
+ import CalicoSwirl from './components/CalicoSwirl';
10
+ import Aurora from './components/Aurora';
11
+ import { useParamsSynchronizable } from './hooks/useParamsSynchronizable';
12
+ export type { ShaderViewProps, ParamsSynchronizable, } from './components/ShaderView/types';
13
+ export type { ShaderViewWithPanGestureProps } from './components/ShaderViewWithPanGesture';
14
+ export type { ColorInput } from './utils/colors';
15
+ export { CircularGradient, LinearGradient, ShaderView, ShaderViewWithPanGesture, Iridescence, LiquidChrome, Silk, Campfire, CalicoSwirl, Aurora, useParamsSynchronizable, };
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,UAAU,MAAM,yBAAyB,CAAC;AACjD,OAAO,wBAAwB,MAAM,uCAAuC,CAAC;AAC7E,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,YAAY,MAAM,2BAA2B,CAAC;AACrD,OAAO,IAAI,MAAM,mBAAmB,CAAC;AACrC,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,WAAW,MAAM,0BAA0B,CAAC;AACnD,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,YAAY,EACV,eAAe,EACf,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAC3F,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,wBAAwB,EACxB,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,MAAM,EACN,uBAAuB,GACxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const TRIANGLE_VERTEX_SHADER = "\n struct VSOut { \n @builtin(position) pos: vec4<f32>,\n @location(0) ndc: vec2<f32>,\n };\n \n @vertex \n fn main(@builtin(vertex_index) vid: u32) -> VSOut {\n var p = array<vec2<f32>,3>(\n vec2<f32>(-1.0,-3.0), vec2<f32>(-1.0,1.0), vec2<f32>(3.0,1.0)\n );\n var o: VSOut;\n o.pos = vec4<f32>(p[vid], 0, 1.0);\n o.ndc = p[vid];\n return o;\n }\n";
2
+ //# sourceMappingURL=TRIANGLE_VERTEX_SHADER.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TRIANGLE_VERTEX_SHADER.d.ts","sourceRoot":"","sources":["../../../../src/shaders/TRIANGLE_VERTEX_SHADER.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,mYAgBlC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /** 112 bytes = 7 × vec4<f32> */
2
+ export declare const UNIFORM_BUFFER_SIZE = 112;
3
+ /** Number of float32 values in the uniform buffer */
4
+ export declare const UNIFORM_FLOAT_COUNT: number;
5
+ export declare const UNIFORMS_WGSL = "\nstruct Uniforms {\n resolution: vec4<f32>, // (width, height, aspect, pixelRatio)\n time: vec4<f32>, // (seconds, dt, 0, 0)\n color0: vec4<f32>, // colors[0] RGBA\n color1: vec4<f32>, // colors[1] RGBA\n params0: vec4<f32>, // params[0..3]\n params1: vec4<f32>, // params[4..7]\n live: vec4<f32>, // paramsSynchronizable (touch/scroll/audio); (0,0,0,0) when unused\n};\n@group(0) @binding(0) var<uniform> u: Uniforms;\n";
6
+ //# sourceMappingURL=uniforms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniforms.d.ts","sourceRoot":"","sources":["../../../../src/shaders/uniforms.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,QAA0B,CAAC;AAE3D,eAAO,MAAM,aAAa,kdAWzB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const BackgroundRuntime: import("react-native-worklets").WorkletRuntime;
2
+ export declare function runOnBackground(callback: (...args: any[]) => void): void;
3
+ //# sourceMappingURL=backgroundRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backgroundRuntime.d.ts","sourceRoot":"","sources":["../../../../src/utils/backgroundRuntime.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,gDAE5B,CAAC;AAEH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,QAGjE"}
@@ -0,0 +1,22 @@
1
+ export type ColorInput = number | string;
2
+ /**
3
+ * RGBA color values normalized to 0-1 range
4
+ */
5
+ export type RGBA = {
6
+ r: number;
7
+ g: number;
8
+ b: number;
9
+ a: number;
10
+ };
11
+ /**
12
+ * Converts various color formats to RGBA object
13
+ * @param color - Can be:
14
+ * - Hex number (0xff0000)
15
+ * - Hex string ("#ff0000" or "ff0000")
16
+ * - RGB string ("rgb(255, 0, 0)")
17
+ * - RGBA string ("rgba(255, 0, 0, 0.5)")
18
+ * - Named color ("red", "blue", "purple", etc.)
19
+ * @returns RGBA object with normalized values (0-1), alpha defaults to 1.0 for non-rgba formats
20
+ */
21
+ export declare function colorToVec4(color: ColorInput): RGBA;
22
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../../src/utils/colors.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CA4FnD"}
@@ -0,0 +1,23 @@
1
+ import { type WorkletRuntime } from 'react-native-worklets';
2
+ /**
3
+ * Installs WebGPU globals on the given worklet runtime.
4
+ *
5
+ * Worklet runtimes run on a separate JS context that lacks browser-like globals.
6
+ * This function captures WebGPU constants and `navigator.gpu` from the RN thread
7
+ * and injects them into the worklet's `globalThis` so that WebGPU code can run
8
+ * as if it were in a browser environment.
9
+ *
10
+ * @param runtime - The worklet runtime to initialize
11
+ */
12
+ export declare function initWebGPU(runtime: WorkletRuntime): void;
13
+ declare global {
14
+ var self: typeof globalThis;
15
+ var _WORKLET: boolean | undefined;
16
+ var performance: {
17
+ now(): number;
18
+ };
19
+ interface Navigator {
20
+ gpu: GPU;
21
+ }
22
+ }
23
+ //# sourceMappingURL=initWebGPU.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initWebGPU.d.ts","sourceRoot":"","sources":["../../../../src/utils/initWebGPU.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE/E;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,cAAc,QAwBjD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,IAAI,EAAE,OAAO,UAAU,CAAC;IAC5B,IAAI,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,IAAI,WAAW,EAAE;QAAE,GAAG,IAAI,MAAM,CAAA;KAAE,CAAC;IAEnC,UAAU,SAAS;QACjB,GAAG,EAAE,GAAG,CAAC;KACV;CACF"}
package/package.json CHANGED
@@ -1,12 +1,180 @@
1
1
  {
2
2
  "name": "react-native-effects",
3
- "version": "0.0.1",
4
- "main": "index.js",
3
+ "version": "0.2.0",
4
+ "description": "WebGPU-powered visual effects running on a background thread in React Native",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "*.podspec",
22
+ "react-native.config.js",
23
+ "!ios/build",
24
+ "!android/build",
25
+ "!android/gradle",
26
+ "!android/gradlew",
27
+ "!android/gradlew.bat",
28
+ "!android/local.properties",
29
+ "!**/__tests__",
30
+ "!**/__fixtures__",
31
+ "!**/__mocks__",
32
+ "!**/.*"
33
+ ],
5
34
  "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
35
+ "example": "yarn workspace react-native-effects-example",
36
+ "clean": "del-cli lib",
37
+ "prepare": "bob build",
38
+ "typecheck": "tsc",
39
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
40
+ "test": "jest",
41
+ "prettier": "prettier --check \"**/*.{js,ts,tsx,json,md}\"",
42
+ "prettier:write": "prettier --write \"**/*.{js,ts,tsx,json,md}\"",
43
+ "release": "release-it --only-version"
44
+ },
45
+ "keywords": [
46
+ "react-native",
47
+ "ios",
48
+ "android",
49
+ "webgpu",
50
+ "glb",
51
+ "gltf",
52
+ "worklets"
53
+ ],
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/blazejkustra/react-native-effects.git"
57
+ },
58
+ "author": "Blazej Kustra <kustrablazej@gmail.com> (https://github.com/blazejkustra)",
59
+ "license": "MIT",
60
+ "bugs": {
61
+ "url": "https://github.com/blazejkustra/react-native-effects/issues"
62
+ },
63
+ "homepage": "https://github.com/blazejkustra/react-native-effects#readme",
64
+ "publishConfig": {
65
+ "registry": "https://registry.npmjs.org/"
66
+ },
67
+ "devDependencies": {
68
+ "@commitlint/config-conventional": "^21.0.2",
69
+ "@eslint/compat": "^2.1.0",
70
+ "@eslint/eslintrc": "^3.3.5",
71
+ "@eslint/js": "^9.39.4",
72
+ "@react-native/babel-preset": "0.85.3",
73
+ "@react-native/eslint-config": "0.85.3",
74
+ "@react-native/jest-preset": "0.85.3",
75
+ "@release-it/conventional-changelog": "^11.0.1",
76
+ "@types/jest": "^29.5.14",
77
+ "@types/react": "^19.2.17",
78
+ "@webgpu/types": "0.1.70",
79
+ "commitlint": "^21.0.2",
80
+ "del-cli": "^7.0.0",
81
+ "eslint": "^9.39.4",
82
+ "eslint-config-prettier": "^10.1.8",
83
+ "eslint-plugin-prettier": "^5.5.6",
84
+ "jest": "^29.7.0",
85
+ "lefthook": "^2.1.9",
86
+ "prettier": "^3.8.3",
87
+ "react": "19.2.3",
88
+ "react-native": "0.85.3",
89
+ "react-native-builder-bob": "^0.41.0",
90
+ "react-native-gesture-handler": "2.31.1",
91
+ "react-native-reanimated": "4.3.1",
92
+ "react-native-webgpu": "0.5.14",
93
+ "react-native-worklets": "0.8.3",
94
+ "release-it": "^20.2.0",
95
+ "turbo": "^2.9.16",
96
+ "typescript": "^6.0.3"
97
+ },
98
+ "peerDependencies": {
99
+ "react": "*",
100
+ "react-native": "*",
101
+ "react-native-gesture-handler": ">=2.0.0",
102
+ "react-native-webgpu": ">=0.5.0",
103
+ "react-native-worklets": ">=0.8.0"
104
+ },
105
+ "resolutions": {
106
+ "metro": "patch:metro@npm%3A0.84.4#./.yarn/patches/metro-npm-0.84.4.patch",
107
+ "metro-runtime": "patch:metro-runtime@npm%3A0.84.4#./.yarn/patches/metro-runtime-npm-0.84.4.patch"
108
+ },
109
+ "workspaces": [
110
+ "example"
111
+ ],
112
+ "packageManager": "yarn@4.11.0",
113
+ "react-native-builder-bob": {
114
+ "source": "src",
115
+ "output": "lib",
116
+ "targets": [
117
+ [
118
+ "module",
119
+ {
120
+ "esm": true
121
+ }
122
+ ],
123
+ [
124
+ "typescript",
125
+ {
126
+ "project": "tsconfig.build.json"
127
+ }
128
+ ]
129
+ ]
130
+ },
131
+ "prettier": {
132
+ "quoteProps": "consistent",
133
+ "singleQuote": true,
134
+ "tabWidth": 2,
135
+ "trailingComma": "es5",
136
+ "useTabs": false
137
+ },
138
+ "jest": {
139
+ "preset": "@react-native/jest-preset",
140
+ "modulePathIgnorePatterns": [
141
+ "<rootDir>/example/node_modules",
142
+ "<rootDir>/lib/"
143
+ ]
144
+ },
145
+ "commitlint": {
146
+ "extends": [
147
+ "@commitlint/config-conventional"
148
+ ]
149
+ },
150
+ "release-it": {
151
+ "git": {
152
+ "commitMessage": "chore: release ${version}",
153
+ "tagName": "v${version}"
154
+ },
155
+ "npm": {
156
+ "publish": true
157
+ },
158
+ "github": {
159
+ "release": true
160
+ },
161
+ "plugins": {
162
+ "@release-it/conventional-changelog": {
163
+ "preset": {
164
+ "name": "angular"
165
+ }
166
+ }
167
+ }
7
168
  },
8
- "keywords": [],
9
- "author": "",
10
- "license": "ISC",
11
- "description": ""
169
+ "create-react-native-library": {
170
+ "type": "library",
171
+ "languages": "js",
172
+ "tools": [
173
+ "eslint",
174
+ "jest",
175
+ "lefthook",
176
+ "release-it"
177
+ ],
178
+ "version": "0.57.2"
179
+ }
12
180
  }