react-native-webrtc-kaleidoscope 2.2.2 → 2.4.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 (100) hide show
  1. package/README.md +42 -3
  2. package/android/src/main/java/com/simiancraft/kaleidoscope/gpu/ShadersGenerated.kt +354 -0
  3. package/catalog/shaders/aurora-silk/aurora-silk.form.tsx +35 -0
  4. package/catalog/shaders/aurora-silk/aurora-silk.frag +106 -0
  5. package/catalog/shaders/aurora-silk/aurora-silk.ts +92 -0
  6. package/catalog/shaders/halftone-waves/halftone-waves.form.tsx +35 -0
  7. package/catalog/shaders/halftone-waves/halftone-waves.frag +84 -0
  8. package/catalog/shaders/halftone-waves/halftone-waves.ts +100 -0
  9. package/catalog/shaders/index.ts +16 -0
  10. package/catalog/shaders/kaleidoscope/kaleidoscope.form.tsx +35 -0
  11. package/catalog/shaders/kaleidoscope/kaleidoscope.frag +93 -0
  12. package/catalog/shaders/kaleidoscope/kaleidoscope.ts +81 -0
  13. package/catalog/shaders/neo-memphis/neo-memphis.form.tsx +35 -0
  14. package/catalog/shaders/neo-memphis/neo-memphis.frag +152 -0
  15. package/catalog/shaders/neo-memphis/neo-memphis.ts +84 -0
  16. package/dist/catalog/shaders/aurora-silk/aurora-silk.d.ts +26 -0
  17. package/dist/catalog/shaders/aurora-silk/aurora-silk.d.ts.map +1 -0
  18. package/dist/catalog/shaders/aurora-silk/aurora-silk.form.d.ts +3 -0
  19. package/dist/catalog/shaders/aurora-silk/aurora-silk.form.d.ts.map +1 -0
  20. package/dist/catalog/shaders/aurora-silk/aurora-silk.form.js +13 -0
  21. package/dist/catalog/shaders/aurora-silk/aurora-silk.form.js.map +1 -0
  22. package/dist/catalog/shaders/aurora-silk/aurora-silk.js +70 -0
  23. package/dist/catalog/shaders/aurora-silk/aurora-silk.js.map +1 -0
  24. package/dist/catalog/shaders/halftone-waves/halftone-waves.d.ts +26 -0
  25. package/dist/catalog/shaders/halftone-waves/halftone-waves.d.ts.map +1 -0
  26. package/dist/catalog/shaders/halftone-waves/halftone-waves.form.d.ts +3 -0
  27. package/dist/catalog/shaders/halftone-waves/halftone-waves.form.d.ts.map +1 -0
  28. package/dist/catalog/shaders/halftone-waves/halftone-waves.form.js +13 -0
  29. package/dist/catalog/shaders/halftone-waves/halftone-waves.form.js.map +1 -0
  30. package/dist/catalog/shaders/halftone-waves/halftone-waves.js +78 -0
  31. package/dist/catalog/shaders/halftone-waves/halftone-waves.js.map +1 -0
  32. package/dist/catalog/shaders/index.d.ts +16 -0
  33. package/dist/catalog/shaders/index.d.ts.map +1 -1
  34. package/dist/catalog/shaders/index.js +9 -1
  35. package/dist/catalog/shaders/index.js.map +1 -1
  36. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.d.ts +24 -0
  37. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.d.ts.map +1 -0
  38. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.form.d.ts +3 -0
  39. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.form.d.ts.map +1 -0
  40. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.form.js +14 -0
  41. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.form.js.map +1 -0
  42. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.js +61 -0
  43. package/dist/catalog/shaders/kaleidoscope/kaleidoscope.js.map +1 -0
  44. package/dist/catalog/shaders/neo-memphis/neo-memphis.d.ts +26 -0
  45. package/dist/catalog/shaders/neo-memphis/neo-memphis.d.ts.map +1 -0
  46. package/dist/catalog/shaders/neo-memphis/neo-memphis.form.d.ts +3 -0
  47. package/dist/catalog/shaders/neo-memphis/neo-memphis.form.d.ts.map +1 -0
  48. package/dist/catalog/shaders/neo-memphis/neo-memphis.form.js +13 -0
  49. package/dist/catalog/shaders/neo-memphis/neo-memphis.form.js.map +1 -0
  50. package/dist/catalog/shaders/neo-memphis/neo-memphis.js +62 -0
  51. package/dist/catalog/shaders/neo-memphis/neo-memphis.js.map +1 -0
  52. package/dist/src/components/preset-control-panel/preset-control-panel.d.ts +9 -1
  53. package/dist/src/components/preset-control-panel/preset-control-panel.d.ts.map +1 -1
  54. package/dist/src/components/preset-control-panel/preset-control-panel.js +7 -3
  55. package/dist/src/components/preset-control-panel/preset-control-panel.js.map +1 -1
  56. package/dist/src/kaleidoscope/controls.d.ts.map +1 -1
  57. package/dist/src/kaleidoscope/controls.js +6 -3
  58. package/dist/src/kaleidoscope/controls.js.map +1 -1
  59. package/dist/src/kaleidoscope/shader-to-spec.d.ts +15 -1
  60. package/dist/src/kaleidoscope/shader-to-spec.d.ts.map +1 -1
  61. package/dist/src/kaleidoscope/shader-to-spec.js +23 -4
  62. package/dist/src/kaleidoscope/shader-to-spec.js.map +1 -1
  63. package/dist/src/kaleidoscope/types.d.ts +3 -1
  64. package/dist/src/kaleidoscope/types.d.ts.map +1 -1
  65. package/dist/src/kaleidoscope/types.js.map +1 -1
  66. package/dist/src/persistence/async-storage-store.d.ts +3 -0
  67. package/dist/src/persistence/async-storage-store.d.ts.map +1 -0
  68. package/dist/src/persistence/async-storage-store.js +26 -0
  69. package/dist/src/persistence/async-storage-store.js.map +1 -0
  70. package/dist/src/persistence/index.d.ts +4 -0
  71. package/dist/src/persistence/index.d.ts.map +1 -0
  72. package/dist/src/persistence/index.js +22 -0
  73. package/dist/src/persistence/index.js.map +1 -0
  74. package/dist/src/persistence/provider.d.ts +38 -0
  75. package/dist/src/persistence/provider.d.ts.map +1 -0
  76. package/dist/src/persistence/provider.js +96 -0
  77. package/dist/src/persistence/provider.js.map +1 -0
  78. package/dist/src/persistence/state.d.ts +54 -0
  79. package/dist/src/persistence/state.d.ts.map +1 -0
  80. package/dist/src/persistence/state.js +126 -0
  81. package/dist/src/persistence/state.js.map +1 -0
  82. package/dist/web-driver/shaders.generated.d.ts +4 -0
  83. package/dist/web-driver/shaders.generated.d.ts.map +1 -1
  84. package/dist/web-driver/shaders.generated.js +351 -1
  85. package/dist/web-driver/shaders.generated.js.map +1 -1
  86. package/ios/KaleidoscopeModule/shaders/GENERATIVE.txt +4 -0
  87. package/ios/KaleidoscopeModule/shaders/SHADERS.txt +4 -0
  88. package/ios/KaleidoscopeModule/shaders/aurora-silk.metalsrc +51 -0
  89. package/ios/KaleidoscopeModule/shaders/halftone-waves.metalsrc +41 -0
  90. package/ios/KaleidoscopeModule/shaders/kaleidoscope.metalsrc +45 -0
  91. package/ios/KaleidoscopeModule/shaders/neo-memphis.metalsrc +181 -0
  92. package/package.json +43 -3
  93. package/src/components/preset-control-panel/preset-control-panel.tsx +15 -2
  94. package/src/kaleidoscope/controls.ts +6 -3
  95. package/src/kaleidoscope/shader-to-spec.ts +32 -5
  96. package/src/kaleidoscope/types.ts +3 -1
  97. package/src/persistence/async-storage-store.ts +33 -0
  98. package/src/persistence/index.ts +28 -0
  99. package/src/persistence/provider.tsx +165 -0
  100. package/src/persistence/state.ts +167 -0
@@ -1,9 +1,13 @@
1
1
  anamorphic-lensflare
2
+ aurora-silk
2
3
  clouds
3
4
  corporate-blobs
4
5
  fireflies
5
6
  godrays
7
+ halftone-waves
8
+ kaleidoscope
6
9
  light-beams-and-motes
7
10
  nebula
11
+ neo-memphis
8
12
  plasma
9
13
  simianlights
@@ -1,4 +1,5 @@
1
1
  anamorphic-lensflare.frag
2
+ aurora-silk.frag
2
3
  clouds.frag
3
4
  composite-blit.frag
4
5
  composite-blur.frag
@@ -9,8 +10,11 @@ composite-subject.frag
9
10
  corporate-blobs.frag
10
11
  fireflies.frag
11
12
  godrays.frag
13
+ halftone-waves.frag
14
+ kaleidoscope.frag
12
15
  light-beams-and-motes.frag
13
16
  nebula.frag
17
+ neo-memphis.frag
14
18
  passthrough.vert
15
19
  plasma.frag
16
20
  simianlights.frag
@@ -0,0 +1,51 @@
1
+ #include <metal_stdlib>
2
+ #include <simd/simd.h>
3
+
4
+ using namespace metal;
5
+
6
+ struct main0_out
7
+ {
8
+ float4 oColor [[color(0)]];
9
+ };
10
+
11
+ struct main0_in
12
+ {
13
+ float2 vUv [[user(locn0)]];
14
+ };
15
+
16
+ fragment main0_out main0(main0_in in [[stage_in]], constant float2& uResolution [[buffer(0)]], constant float& uAngle [[buffer(1)]], constant float& uTime [[buffer(2)]], constant float& uSpeed [[buffer(3)]], constant float3& uColorLow [[buffer(4)]], constant float3& uColorHigh [[buffer(5)]], constant float& uRibbons [[buffer(6)]], constant float& uCalm [[buffer(7)]], constant float& uSoftness [[buffer(8)]], constant float3& uRibbonColor [[buffer(9)]], constant float& uStyle [[buffer(10)]])
17
+ {
18
+ main0_out out = {};
19
+ float2 _80 = ((in.vUv * uResolution) - (uResolution * 0.5)) / float2(uResolution.y);
20
+ float _87 = cos(uAngle);
21
+ float _90 = sin(uAngle);
22
+ float2 _103 = float2x2(float2(_87, -_90), float2(_90, _87)) * _80;
23
+ float _109 = uTime * uSpeed;
24
+ float _112 = _103.y;
25
+ float _139 = fast::clamp(uRibbons, 0.0, 5.0);
26
+ float _149 = 1.0 - (uCalm * (1.0 - smoothstep(0.1500000059604644775390625, 0.62000000476837158203125, length(_80))));
27
+ float3 _364;
28
+ _364 = mix(uColorLow, uColorHigh, float3(fast::clamp(((_112 * 0.85000002384185791015625) + 0.5) + (0.039999999105930328369140625 * sin(_109 * 0.17000000178813934326171875)), 0.0, 1.0)));
29
+ float3 _298;
30
+ for (int _363 = 0; _363 < 5; _364 = _298, _363++)
31
+ {
32
+ float _165 = float(_363);
33
+ if (_165 >= _139)
34
+ {
35
+ break;
36
+ }
37
+ float _195 = _103.x;
38
+ float _204 = (_195 * 1.39999997615814208984375) + (_109 * (0.100000001490116119384765625 + (0.039999999105930328369140625 * _165)));
39
+ float _207 = _165 * 17.0;
40
+ float _319 = floor(_204);
41
+ float _321 = fract(_204);
42
+ float _247 = mix(0.0599999986588954925537109375, 0.1500000059604644775390625, fract(sin((_165 * 7.30000019073486328125) + 1.0) * 43758.546875));
43
+ float _255 = mix(0.008000000379979610443115234375, _247 * 1.60000002384185791015625, uSoftness);
44
+ float _267 = (1.0 - smoothstep(_247 - _255, _247 + _255, abs(_112 - ((((-0.4199999868869781494140625) + ((0.839999973773956298828125 * (_165 + 0.5)) / _139)) + (0.070000000298023223876953125 * sin((_109 * 0.189999997615814208984375) + (_165 * 1.7000000476837158203125)))) + (((mix(fract(sin(_319 + _207) * 43758.546875), fract(sin((_319 + 1.0) + _207) * 43758.546875), (_321 * _321) * (3.0 - (2.0 * _321))) - 0.5) * 0.5) + (0.100000001490116119384765625 * sin(((_195 * 2.2999999523162841796875) + (_109 * (0.2599999904632568359375 + (0.0599999986588954925537109375 * _165)))) + (_165 * 2.099999904632568359375)))))))) * _149;
45
+ float3 _277 = mix(uRibbonColor, uColorHigh, float3(_165 * 0.12000000476837158203125));
46
+ _298 = mix(mix(_364, _277, float3(_267 * 0.85000002384185791015625)), _364 + ((_277 * _267) * 0.4000000059604644775390625), float3(uStyle));
47
+ }
48
+ out.oColor = float4(_364, 1.0);
49
+ return out;
50
+ }
51
+
@@ -0,0 +1,41 @@
1
+ #include <metal_stdlib>
2
+ #include <simd/simd.h>
3
+
4
+ using namespace metal;
5
+
6
+ struct main0_out
7
+ {
8
+ float4 oColor [[color(0)]];
9
+ };
10
+
11
+ struct main0_in
12
+ {
13
+ float2 vUv [[user(locn0)]];
14
+ };
15
+
16
+ fragment main0_out main0(main0_in in [[stage_in]], constant float2& uResolution [[buffer(0)]], constant float& uPitch [[buffer(1)]], constant float& uTime [[buffer(2)]], constant float& uSpeed [[buffer(3)]], constant float& uAngle [[buffer(4)]], constant float& uCalm [[buffer(5)]], constant float& uDotSize [[buffer(6)]], constant float& uWaveAmp [[buffer(7)]], constant float& uShape [[buffer(8)]], constant float3& uPaper [[buffer(9)]], constant float3& uInk [[buffer(10)]])
17
+ {
18
+ main0_out out = {};
19
+ float2 _29 = ((in.vUv * uResolution) - (uResolution * 0.5)) / float2(uResolution.y);
20
+ float2 _38 = _29 * uPitch;
21
+ float2 _53 = (floor(_38) + float2(0.5)) / float2(uPitch);
22
+ float _59 = uTime * uSpeed;
23
+ float _70 = uAngle + 2.2000000476837158203125;
24
+ float _123 = uDotSize * mix(1.0 - uWaveAmp, 1.0 + uWaveAmp, mix((0.5 + (0.25 * sin((dot(_53, float2(cos(uAngle), sin(uAngle))) * 3.099999904632568359375) + _59))) + (0.25 * sin((dot(_53, float2(cos(_70), sin(_70))) * 4.69999980926513671875) - (_59 * 0.769999980926513671875))), 0.5, uCalm * (1.0 - smoothstep(0.1500000059604644775390625, 0.62000000476837158203125, length(_29)))));
25
+ float2 _126 = abs(fract(_38) - float2(0.5));
26
+ float _130 = _126.x;
27
+ float _132 = _126.y;
28
+ float _138 = length(_126);
29
+ float _198;
30
+ if (uShape < 1.0)
31
+ {
32
+ _198 = mix((_130 + _132) * 0.707099974155426025390625, _138, fast::clamp(uShape, 0.0, 1.0));
33
+ }
34
+ else
35
+ {
36
+ _198 = mix(_138, fast::max(_130, _132), fast::clamp(uShape - 1.0, 0.0, 1.0));
37
+ }
38
+ out.oColor = float4(mix(uPaper, uInk, float3(smoothstep(_123 + 0.0599999986588954925537109375, _123 - 0.0599999986588954925537109375, _198))), 1.0);
39
+ return out;
40
+ }
41
+
@@ -0,0 +1,45 @@
1
+ #pragma clang diagnostic ignored "-Wmissing-prototypes"
2
+
3
+ #include <metal_stdlib>
4
+ #include <simd/simd.h>
5
+
6
+ using namespace metal;
7
+
8
+ struct main0_out
9
+ {
10
+ float4 oColor [[color(0)]];
11
+ };
12
+
13
+ struct main0_in
14
+ {
15
+ float2 vUv [[user(locn0)]];
16
+ };
17
+
18
+ // Implementation of the GLSL mod() function, which is slightly different than Metal fmod()
19
+ template<typename Tx, typename Ty>
20
+ inline Tx mod(Tx x, Ty y)
21
+ {
22
+ return x - y * floor(x / y);
23
+ }
24
+
25
+ fragment main0_out main0(main0_in in [[stage_in]], constant float2& uResolution [[buffer(0)]], constant float& uTime [[buffer(1)]], constant float& uRotate [[buffer(2)]], constant float& uZoom [[buffer(3)]], constant float& uSegments [[buffer(4)]], constant float& uSpeed [[buffer(5)]], constant float3& uColorA [[buffer(6)]], constant float3& uColorB [[buffer(7)]], constant float3& uColorC [[buffer(8)]], constant float& uCalm [[buffer(9)]])
26
+ {
27
+ main0_out out = {};
28
+ float2 _29 = ((in.vUv * uResolution) - (uResolution * 0.5)) / float2(uResolution.y);
29
+ float _33 = length(_29);
30
+ float _39 = uTime * uRotate;
31
+ float _42 = cos(_39);
32
+ float _45 = sin(_39);
33
+ float2 _58 = float2x2(float2(_42, -_45), float2(_45, _42)) * _29;
34
+ float _78 = fast::max(3.0, floor(uSegments));
35
+ float _94 = 3.1415927410125732421875 / _78;
36
+ float _96 = abs(mod(atan2(_58.y, _58.x + 9.9999997473787516355514526367188e-06), 6.283185482025146484375 / _78) - _94);
37
+ float2 _104 = float2(cos(_96), sin(_96)) * ((_33 * uZoom) * (1.0 + (0.0599999986588954925537109375 * sin(uTime * 0.23000000417232513427734375))));
38
+ float _109 = uTime * uSpeed;
39
+ float _112 = _104.x;
40
+ float _121 = _104.y;
41
+ float _150 = (sin((_112 * 6.0) + _109) + sin(((_112 + _121) * 4.19999980926513671875) - (_109 * 0.699999988079071044921875))) + sin((length(_104 - float2(0.89999997615814208984375 + (0.25 * sin(_109 * 0.310000002384185791015625)), 0.0)) * 7.0) + (_109 * 1.10000002384185791015625));
42
+ out.oColor = float4(mix(mix(mix(uColorA, uColorB, float3(0.5 + (0.5 * sin(_150)))), uColorC, float3(smoothstep(0.25, 0.89999997615814208984375, 0.5 + (0.5 * sin(sin(((_121 * 5.0) - (_109 * 0.89999997615814208984375)) + sin((_112 * 3.099999904632568359375) + (_109 * 0.4000000059604644775390625))) + (_150 * 0.5)))) * 0.64999997615814208984375)) * (1.0 - (0.180000007152557373046875 * (smoothstep(0.0350000001490116119384765625, 0.0, abs(_96 - _94)) + smoothstep(0.0350000001490116119384765625, 0.0, _96)))), (uColorA + uColorB) * 0.5, float3((uCalm * (1.0 - smoothstep(0.1500000059604644775390625, 0.62000000476837158203125, _33))) * 0.60000002384185791015625)), 1.0);
43
+ return out;
44
+ }
45
+
@@ -0,0 +1,181 @@
1
+ #include <metal_stdlib>
2
+ #include <simd/simd.h>
3
+
4
+ using namespace metal;
5
+
6
+ struct main0_out
7
+ {
8
+ float4 oColor [[color(0)]];
9
+ };
10
+
11
+ struct main0_in
12
+ {
13
+ float2 vUv [[user(locn0)]];
14
+ };
15
+
16
+ fragment main0_out main0(main0_in in [[stage_in]], constant float3& uBgColor [[buffer(0)]], constant float& uDensity [[buffer(1)]], constant float& uOutline [[buffer(2)]], constant float3& uColorA [[buffer(3)]], constant float3& uColorB [[buffer(4)]], constant float3& uColorC [[buffer(5)]], constant float2& uResolution [[buffer(6)]], constant float& uTime [[buffer(7)]], constant float& uDrift [[buffer(8)]], constant float& uScale [[buffer(9)]], constant float& uCalm [[buffer(10)]])
17
+ {
18
+ main0_out out = {};
19
+ float _603;
20
+ float2 _448 = ((in.vUv * uResolution) - (uResolution * 0.5)) / float2(uResolution.y);
21
+ float _457 = uTime * uDrift;
22
+ float2 _464 = _448 * uScale;
23
+ float2 _477 = ((_464 * 2.2999999523162841796875) + float2(_457 * 0.04500000178813934326171875, _457 * (-0.02999999932944774627685546875))) + float2(51.700000762939453125);
24
+ float _1460;
25
+ float3 _1461;
26
+ do
27
+ {
28
+ float2 _817 = fract((floor(_477) + float2(7.0)) * float2(234.339996337890625, 435.345001220703125));
29
+ float2 _825 = _817 + float2(dot(_817, _817 + float2(34.229999542236328125)));
30
+ float _831 = fract(_825.x * _825.y);
31
+ _603 = uDensity;
32
+ if (_831 > _603)
33
+ {
34
+ _1461 = uBgColor;
35
+ _1460 = 0.0;
36
+ break;
37
+ }
38
+ float _612 = fract(_831 * 113.76999664306640625);
39
+ float _626 = (fract(_831 * 57.310001373291015625) * 6.283185482025146484375) + ((_457 * (_612 - 0.5)) * 0.800000011920928955078125);
40
+ float _628 = cos(_626);
41
+ float _630 = sin(_626);
42
+ float _634 = _831 * 6.283185482025146484375;
43
+ float2 _656 = float2x2(float2(_628, -_630), float2(_630, _628)) * ((fract(_477) - float2(0.5)) - (float2(sin((_457 * 0.60000002384185791015625) + _634), cos((_457 * 0.800000011920928955078125) + _634)) * 0.039999999105930328369140625));
44
+ float _658 = mix(0.14000000059604644775390625, 0.300000011920928955078125, _612);
45
+ float _661 = _658 * 0.60000002384185791015625;
46
+ float _1452;
47
+ if ((fract(_831 * 431.1300048828125) * 6.0) < 3.0)
48
+ {
49
+ _1452 = length(_656) - (_658 * 0.2700000107288360595703125);
50
+ }
51
+ else
52
+ {
53
+ float _678 = _658 * 0.1319999992847442626953125;
54
+ float2 _836 = abs(_656);
55
+ float2 _838 = _836 - float2(_661, _678);
56
+ float2 _855 = _836 - float2(_678, _661);
57
+ _1452 = fast::min(length(fast::max(_838, float2(0.0))) + fast::min(fast::max(_838.x, _838.y), 0.0), length(fast::max(_855, float2(0.0))) + fast::min(fast::max(_855.x, _855.y), 0.0));
58
+ }
59
+ float _796 = fract(_831 * 769.22998046875) * 3.0;
60
+ float3 _1459;
61
+ if (_796 < 1.0)
62
+ {
63
+ _1459 = uColorA;
64
+ }
65
+ else
66
+ {
67
+ _1459 = select(uColorC, uColorB, bool3(_796 < 2.0));
68
+ }
69
+ _1461 = _1459;
70
+ _1460 = (fract(_831 * 891.71002197265625) < uOutline) ? smoothstep(0.01200000010430812835693359375, -0.01200000010430812835693359375, abs(_1452 + (_658 * 0.0360000021755695343017578125)) - (_658 * 0.05400000512599945068359375)) : smoothstep(0.01200000010430812835693359375, -0.01200000010430812835693359375, _1452);
71
+ break;
72
+ } while(false);
73
+ float2 _509 = _464 + float2(_457 * (-0.0599999986588954925537109375), _457 * 0.039999999105930328369140625);
74
+ float _1481;
75
+ float3 _1482;
76
+ do
77
+ {
78
+ float2 _1234 = fract(floor(_509) * float2(234.339996337890625, 435.345001220703125));
79
+ float2 _1242 = _1234 + float2(dot(_1234, _1234 + float2(34.229999542236328125)));
80
+ float _1248 = fract(_1242.x * _1242.y);
81
+ if (_1248 > _603)
82
+ {
83
+ _1482 = uBgColor;
84
+ _1481 = 0.0;
85
+ break;
86
+ }
87
+ float _1029 = fract(_1248 * 113.76999664306640625);
88
+ float _1043 = (fract(_1248 * 57.310001373291015625) * 6.283185482025146484375) + ((_457 * (_1029 - 0.5)) * 0.800000011920928955078125);
89
+ float _1045 = cos(_1043);
90
+ float _1047 = sin(_1043);
91
+ float _1051 = _1248 * 6.283185482025146484375;
92
+ float2 _1073 = float2x2(float2(_1045, -_1047), float2(_1047, _1045)) * ((fract(_509) - float2(0.5)) - (float2(sin((_457 * 0.60000002384185791015625) + _1051), cos((_457 * 0.800000011920928955078125) + _1051)) * 0.039999999105930328369140625));
93
+ float _1075 = mix(0.14000000059604644775390625, 0.300000011920928955078125, _1029);
94
+ float _1080 = fract(_1248 * 431.1300048828125) * 6.0;
95
+ float _1475;
96
+ if (_1080 < 1.0)
97
+ {
98
+ _1475 = length(_1073) - _1075;
99
+ }
100
+ else
101
+ {
102
+ float _1476;
103
+ if (_1080 < 2.0)
104
+ {
105
+ _1476 = abs(length(_1073) - (_1075 * 0.800000011920928955078125)) - (_1075 * 0.180000007152557373046875);
106
+ }
107
+ else
108
+ {
109
+ float _1477;
110
+ if (_1080 < 3.0)
111
+ {
112
+ float _1289 = abs(_1073.x) - _1075;
113
+ float2 _1427 = _1073;
114
+ _1427.x = _1289;
115
+ float _1295 = _1073.y + (_1075 * 0.57735025882720947265625);
116
+ float2 _1430 = _1427;
117
+ _1430.y = _1295;
118
+ float _1301 = 1.73205077648162841796875 * _1295;
119
+ float2 _1472;
120
+ if ((_1289 + _1301) > 0.0)
121
+ {
122
+ _1472 = float2(_1289 - _1301, ((-1.73205077648162841796875) * _1289) - _1295) * 0.5;
123
+ }
124
+ else
125
+ {
126
+ _1472 = _1430;
127
+ }
128
+ float2 _1440 = _1472;
129
+ _1440.x = _1472.x - fast::clamp(_1472.x, (-2.0) * _1075, 0.0);
130
+ _1477 = (-length(_1440)) * sign(_1472.y);
131
+ }
132
+ else
133
+ {
134
+ float _1478;
135
+ if (_1080 < 4.0)
136
+ {
137
+ float _1142 = _1075 * 0.23999999463558197021484375;
138
+ float2 _1340 = abs(_1073);
139
+ float2 _1342 = _1340 - float2(_1075, _1142);
140
+ float2 _1359 = _1340 - float2(_1142, _1075);
141
+ _1478 = fast::min(length(fast::max(_1342, float2(0.0))) + fast::min(fast::max(_1342.x, _1342.y), 0.0), length(fast::max(_1359, float2(0.0))) + fast::min(fast::max(_1359.x, _1359.y), 0.0));
142
+ }
143
+ else
144
+ {
145
+ float _1479;
146
+ if (_1080 < 5.0)
147
+ {
148
+ float2 _1376 = abs(_1073) - float2(_1075 * 0.7799999713897705078125);
149
+ _1479 = length(fast::max(_1376, float2(0.0))) + fast::min(fast::max(_1376.x, _1376.y), 0.0);
150
+ }
151
+ else
152
+ {
153
+ float _1170 = _1073.x;
154
+ _1479 = fast::max(abs(_1073.y - ((0.4000000059604644775390625 * _1075) * sin((_1170 / _1075) * 6.5))) - (_1075 * 0.17000000178813934326171875), abs(_1170) - _1075);
155
+ }
156
+ _1478 = _1479;
157
+ }
158
+ _1477 = _1478;
159
+ }
160
+ _1476 = _1477;
161
+ }
162
+ _1475 = _1476;
163
+ }
164
+ float _1213 = fract(_1248 * 769.22998046875) * 3.0;
165
+ float3 _1480;
166
+ if (_1213 < 1.0)
167
+ {
168
+ _1480 = uColorA;
169
+ }
170
+ else
171
+ {
172
+ _1480 = select(uColorC, uColorB, bool3(_1213 < 2.0));
173
+ }
174
+ _1482 = _1480;
175
+ _1481 = (fract(_1248 * 891.71002197265625) < uOutline) ? smoothstep(0.01200000010430812835693359375, -0.01200000010430812835693359375, abs(_1475 + (_1075 * 0.0599999986588954925537109375)) - (_1075 * 0.0900000035762786865234375)) : smoothstep(0.01200000010430812835693359375, -0.01200000010430812835693359375, _1475);
176
+ break;
177
+ } while(false);
178
+ out.oColor = float4(mix(mix(uBgColor, mix(uBgColor, _1461, float3(0.550000011920928955078125)), float3(_1460)), _1482, float3(_1481 * (1.0 - (uCalm * (1.0 - smoothstep(0.1500000059604644775390625, 0.62000000476837158203125, length(_448))))))), 1.0);
179
+ return out;
180
+ }
181
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-webrtc-kaleidoscope",
3
- "version": "2.2.2",
3
+ "version": "2.4.0",
4
4
  "description": "Live video effects (blur, background replacement, generative backgrounds, flip/rotate) for react-native-webrtc, packaged as a managed-Expo-friendly Expo Module. Working on web, Android, and iOS. Active development.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -18,7 +18,7 @@
18
18
  ],
19
19
  "author": "the-simian <info@simiancraft.com>",
20
20
  "license": "MIT",
21
- "homepage": "https://github.com/simiancraft/react-native-webrtc-kaleidoscope#readme",
21
+ "homepage": "https://simiancraft.github.io/react-native-webrtc-kaleidoscope/",
22
22
  "repository": {
23
23
  "type": "git",
24
24
  "url": "git+https://github.com/simiancraft/react-native-webrtc-kaleidoscope.git"
@@ -62,6 +62,13 @@
62
62
  "import": "./dist/src/nativewind.js",
63
63
  "default": "./dist/src/nativewind.js"
64
64
  },
65
+ "./persistence": {
66
+ "types": "./dist/src/persistence/index.d.ts",
67
+ "react-native": "./src/persistence/index.ts",
68
+ "browser": "./dist/src/persistence/index.js",
69
+ "import": "./dist/src/persistence/index.js",
70
+ "default": "./dist/src/persistence/index.js"
71
+ },
65
72
  "./livekit": {
66
73
  "types": "./dist/src/livekit.d.ts",
67
74
  "browser": "./dist/src/livekit.js",
@@ -425,6 +432,34 @@
425
432
  "import": "./dist/catalog/shaders/plasma/plasma.form.js",
426
433
  "default": "./dist/catalog/shaders/plasma/plasma.form.js"
427
434
  },
435
+ "./shaders/kaleidoscope/form": {
436
+ "types": "./dist/catalog/shaders/kaleidoscope/kaleidoscope.form.d.ts",
437
+ "react-native": "./catalog/shaders/kaleidoscope/kaleidoscope.form.tsx",
438
+ "browser": "./dist/catalog/shaders/kaleidoscope/kaleidoscope.form.js",
439
+ "import": "./dist/catalog/shaders/kaleidoscope/kaleidoscope.form.js",
440
+ "default": "./dist/catalog/shaders/kaleidoscope/kaleidoscope.form.js"
441
+ },
442
+ "./shaders/neo-memphis/form": {
443
+ "types": "./dist/catalog/shaders/neo-memphis/neo-memphis.form.d.ts",
444
+ "react-native": "./catalog/shaders/neo-memphis/neo-memphis.form.tsx",
445
+ "browser": "./dist/catalog/shaders/neo-memphis/neo-memphis.form.js",
446
+ "import": "./dist/catalog/shaders/neo-memphis/neo-memphis.form.js",
447
+ "default": "./dist/catalog/shaders/neo-memphis/neo-memphis.form.js"
448
+ },
449
+ "./shaders/halftone-waves/form": {
450
+ "types": "./dist/catalog/shaders/halftone-waves/halftone-waves.form.d.ts",
451
+ "react-native": "./catalog/shaders/halftone-waves/halftone-waves.form.tsx",
452
+ "browser": "./dist/catalog/shaders/halftone-waves/halftone-waves.form.js",
453
+ "import": "./dist/catalog/shaders/halftone-waves/halftone-waves.form.js",
454
+ "default": "./dist/catalog/shaders/halftone-waves/halftone-waves.form.js"
455
+ },
456
+ "./shaders/aurora-silk/form": {
457
+ "types": "./dist/catalog/shaders/aurora-silk/aurora-silk.form.d.ts",
458
+ "react-native": "./catalog/shaders/aurora-silk/aurora-silk.form.tsx",
459
+ "browser": "./dist/catalog/shaders/aurora-silk/aurora-silk.form.js",
460
+ "import": "./dist/catalog/shaders/aurora-silk/aurora-silk.form.js",
461
+ "default": "./dist/catalog/shaders/aurora-silk/aurora-silk.form.js"
462
+ },
428
463
  "./shaders/blur/form": {
429
464
  "types": "./dist/catalog/shaders/blur/blur.form.d.ts",
430
465
  "react-native": "./catalog/shaders/blur/blur.form.tsx",
@@ -553,12 +588,16 @@
553
588
  "@livekit/react-native-webrtc": ">=144.0.0",
554
589
  "livekit-client": ">=2.0.0",
555
590
  "nativewind": ">=4.0.0",
556
- "@react-native-community/slider": ">=4.5.0"
591
+ "@react-native-community/slider": ">=4.5.0",
592
+ "@react-native-async-storage/async-storage": ">=1.23.0"
557
593
  },
558
594
  "peerDependenciesMeta": {
559
595
  "@react-native-community/slider": {
560
596
  "optional": true
561
597
  },
598
+ "@react-native-async-storage/async-storage": {
599
+ "optional": true
600
+ },
562
601
  "nativewind": {
563
602
  "optional": true
564
603
  },
@@ -578,6 +617,7 @@
578
617
  "devDependencies": {
579
618
  "@biomejs/biome": "^2.4.13",
580
619
  "@expo/config-plugins": "~56.0.8",
620
+ "@react-native-async-storage/async-storage": "1.23.1",
581
621
  "@react-native-community/slider": "5.2.0",
582
622
  "@semantic-release/changelog": "^6.0.3",
583
623
  "@semantic-release/git": "^10.0.1",
@@ -17,6 +17,14 @@ export type PresetControlPanelProps<P extends KaleidoscopePresetBook> = {
17
17
  readonly value: (keyof P & string) | null;
18
18
  /** Routed to the host, which applies it via `kaleidoscope(value, [patch])`. */
19
19
  readonly onPatch: KaleidoscopeControls['onPatch'];
20
+ /**
21
+ * Per-layer uniform overrides (e.g. a persisted selection's stored patches)
22
+ * merged over the preset's baked uniforms when the forms seed. Seed-time
23
+ * only: the forms re-seed on a preset switch, not when this prop changes
24
+ * mid-mount, so hosts restoring persisted patches should mount the panel
25
+ * after hydration.
26
+ */
27
+ readonly patches?: KaleidoscopeControls['uniforms'];
20
28
  readonly disabled?: boolean;
21
29
  };
22
30
 
@@ -24,6 +32,7 @@ export function PresetControlPanel<P extends KaleidoscopePresetBook>({
24
32
  presets,
25
33
  value,
26
34
  onPatch,
35
+ patches,
27
36
  disabled = false,
28
37
  }: PresetControlPanelProps<P>): ReactElement | null {
29
38
  if (value === null) return null;
@@ -32,11 +41,15 @@ export function PresetControlPanel<P extends KaleidoscopePresetBook>({
32
41
  if (!Controls) return null;
33
42
 
34
43
  // Per-layer baked uniforms keyed by id, for the controls component to seed each
35
- // layer's ControlForm. Only tunable layers carry uniforms.
44
+ // layer's ControlForm. Only tunable layers carry uniforms; stored overrides
45
+ // merge over the baked values so restored tweaks appear in the forms.
36
46
  const uniforms: Record<string, Record<string, number | readonly number[]>> = {};
37
47
  for (const layer of preset.layers) {
38
48
  if ('uniforms' in layer) {
39
- uniforms[layer.id] = { ...layer.uniforms } as Record<string, number | readonly number[]>;
49
+ uniforms[layer.id] = {
50
+ ...layer.uniforms,
51
+ ...patches?.[layer.id],
52
+ } as Record<string, number | readonly number[]>;
40
53
  }
41
54
  }
42
55
 
@@ -102,10 +102,13 @@ export const createControls = <P extends KaleidoscopePresetBook>(
102
102
  // Switch the preset (or clear): rebuild. Drop every live override first so
103
103
  // a reused layer id (e.g. 'blur', shared by the low/medium/high blur
104
104
  // presets) takes the new preset's baked uniforms instead of carrying a
105
- // stale slider override across. A transform rebuild does NOT pass through
106
- // here, so slider tweaks survive flips/rotations of the active preset.
105
+ // stale slider override across. Patches given WITH the switch (e.g. a
106
+ // persisted selection's overrides) merge into the rebuilt stack itself,
107
+ // so they land on every platform, native included. A transform rebuild
108
+ // does NOT pass through here, so slider tweaks survive flips/rotations
109
+ // of the active preset.
107
110
  activeId = cmd;
108
- art = cmd == null ? null : compositeToEffectSpec(presets[cmd] as KaleidoscopePreset);
111
+ art = cmd == null ? null : compositeToEffectSpec(presets[cmd] as KaleidoscopePreset, patches);
109
112
  resetLayerUniforms();
110
113
  apply();
111
114
  },
@@ -7,10 +7,37 @@
7
7
  // projection: the layers already carry their own ids, sources, uniforms, and
8
8
  // blend. Transforms are not book entries; the transform verb handles them.
9
9
 
10
- import type { KaleidoscopePreset } from '../kaleidoscope.preset-book.types';
10
+ import type { KaleidoscopeLayer, KaleidoscopePreset } from '../kaleidoscope.preset-book.types';
11
11
  import type { EffectSpec } from './effect.types';
12
12
 
13
- export const compositeToEffectSpec = (composite: KaleidoscopePreset): EffectSpec => ({
14
- name: 'composite',
15
- layers: composite.layers,
16
- });
13
+ /** The patch wire shape (layer id + partial uniforms), as the verb receives it. */
14
+ type LayerPatchInput = {
15
+ readonly id: string;
16
+ readonly uniforms: Readonly<Record<string, number | readonly number[]>>;
17
+ };
18
+
19
+ /**
20
+ * Project a composite into the spec, optionally merging per-layer uniform
21
+ * patches over the baked values (a switch-with-patches, e.g. restoring a
22
+ * persisted selection). Merging here, at the seam, is what carries the patches
23
+ * to EVERY platform: web rebuilds from these layers, and native re-sends them
24
+ * over setCompositeLayers. A patch addressing a non-tunable or unknown layer id
25
+ * is ignored.
26
+ */
27
+ export const compositeToEffectSpec = (
28
+ composite: KaleidoscopePreset,
29
+ patches?: ReadonlyArray<LayerPatchInput>,
30
+ ): EffectSpec => {
31
+ if (!patches || patches.length === 0) {
32
+ return { name: 'composite', layers: composite.layers };
33
+ }
34
+ const byId = new Map(patches.map((patch) => [patch.id, patch.uniforms]));
35
+ return {
36
+ name: 'composite',
37
+ layers: composite.layers.map((layer) => {
38
+ const override = byId.get(layer.id);
39
+ if (!override || !('uniforms' in layer)) return layer;
40
+ return { ...layer, uniforms: { ...layer.uniforms, ...override } } as KaleidoscopeLayer;
41
+ }),
42
+ };
43
+ };
@@ -78,7 +78,9 @@ export type KaleidoscopeBindOptions<P extends KaleidoscopePresetBook> = {
78
78
  * The art verb: select a composite by id (rebuilding the pipeline), or clear it
79
79
  * with `null`. When `cmd` is the currently-active preset id and `patches` is
80
80
  * given, the patches merge through the live no-rebuild uniform channel (keyed by
81
- * layer id) instead of rebuilding, so a slider drag stays smooth.
81
+ * layer id) instead of rebuilding, so a slider drag stays smooth. On a preset
82
+ * SWITCH, patches merge into the rebuilt layer stack itself, so a restored
83
+ * selection lands tuned on every platform, native included.
82
84
  */
83
85
  type KaleidoscopeCommand<P extends KaleidoscopePresetBook> = <K extends keyof P>(
84
86
  cmd: K | null,
@@ -0,0 +1,33 @@
1
+ // The default backing store: AsyncStorage under the canonical key. Works on
2
+ // every platform (the web build is localStorage-backed).
3
+ //
4
+ // `@react-native-async-storage/async-storage` is an OPTIONAL peer dependency of
5
+ // the package: only the `/persistence` subpath touches it, and Metro resolves
6
+ // it at bundle time for any app that imports this subpath (even with a custom
7
+ // `store`; bundlers do not tree-shake the default away).
8
+
9
+ import AsyncStorage from '@react-native-async-storage/async-storage';
10
+ import {
11
+ KALEIDOSCOPE_STATE_KEY,
12
+ type KaleidoscopeStateStore,
13
+ parseStoredKaleidoscopeState,
14
+ type StoredKaleidoscopeState,
15
+ serializeKaleidoscopeState,
16
+ } from './state';
17
+
18
+ export const kaleidoscopeAsyncStorageStore: KaleidoscopeStateStore = {
19
+ load(): Promise<StoredKaleidoscopeState | null> {
20
+ return AsyncStorage.getItem(KALEIDOSCOPE_STATE_KEY).then(
21
+ parseStoredKaleidoscopeState,
22
+ () => null,
23
+ );
24
+ },
25
+ save(state: StoredKaleidoscopeState): Promise<void> {
26
+ return AsyncStorage.setItem(KALEIDOSCOPE_STATE_KEY, serializeKaleidoscopeState(state)).then(
27
+ () => undefined,
28
+ (error) => {
29
+ console.warn('kaleidoscope: preset persistence save failed', error);
30
+ },
31
+ );
32
+ },
33
+ };
@@ -0,0 +1,28 @@
1
+ // Subpath entry: react-native-webrtc-kaleidoscope/persistence
2
+ //
3
+ // The persisted-selection convenience: a provider + hook that keep the last
4
+ // applied preset, its control-panel patches, and the mask across launches.
5
+ // Storage-agnostic via `KaleidoscopeStateStore`; defaults to AsyncStorage
6
+ // (`@react-native-async-storage/async-storage`, an optional peer dependency
7
+ // required only by apps that use the default store).
8
+
9
+ export { kaleidoscopeAsyncStorageStore } from './async-storage-store';
10
+ export {
11
+ KaleidoscopeStateProvider,
12
+ type KaleidoscopeStateProviderProps,
13
+ type KaleidoscopeStateValue,
14
+ useKaleidoscopeState,
15
+ } from './provider';
16
+ export {
17
+ DEFAULT_MASK,
18
+ KALEIDOSCOPE_STATE_KEY,
19
+ type KaleidoscopeStateStore,
20
+ parseStoredKaleidoscopeState,
21
+ pruneStoredState,
22
+ type StoredKaleidoscopeState,
23
+ type StoredLayerUniforms,
24
+ type StoredPatch,
25
+ type StoredPatches,
26
+ type StoredPatchMap,
27
+ serializeKaleidoscopeState,
28
+ } from './state';