react-native-webrtc-kaleidoscope 2.7.13 → 2.8.1
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.
- package/README.md +1 -1
- package/android/build.gradle +28 -16
- package/android/src/main/java/com/simiancraft/kaleidoscope/effects/CompositeFactory.kt +9 -7
- package/android/src/main/java/com/simiancraft/kaleidoscope/effects/TransformFactory.kt +9 -7
- package/android/src/main/webrtc/prefixed/com/simiancraft/kaleidoscope/webrtc/WebRtc.kt +13 -0
- package/android/src/main/webrtc/unprefixed/com/simiancraft/kaleidoscope/webrtc/WebRtc.kt +13 -0
- package/catalog/images/README.md +1 -1
- package/ios/Kaleidoscope.podspec +16 -9
- package/ios/KaleidoscopeModule/Registration.swift +8 -3
- package/ios/KaleidoscopeModule/WebRTCTypes.swift +15 -0
- package/ios/KaleidoscopeModule/effects/CompositeProcessor.swift +5 -1
- package/ios/KaleidoscopeModule/effects/FrameBridge.swift +5 -1
- package/ios/KaleidoscopeModule/effects/TransformProcessor.swift +5 -1
- package/llms.txt +5 -5
- package/package.json +1 -1
- package/plugin/build/lib/preset-book.js +1 -1
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ Want the selection, live tweaks, and mask edge to survive a reload? Wrap your ap
|
|
|
175
175
|
|
|
176
176
|
### Using LiveKit
|
|
177
177
|
|
|
178
|
-
If your project uses `@livekit/react-native` it pulls in `@livekit/react-native-webrtc`, a fork that preserves the same `videoEffects` native classes and `_setVideoEffects` JS API. Kaleidoscope works against either fork; the Android Gradle script picks whichever one autolinking surfaced. Pick **one** fork, never both, or the native classes collide.
|
|
178
|
+
If your project uses `@livekit/react-native` it pulls in `@livekit/react-native-webrtc`, a fork that preserves the same `videoEffects` native classes and `_setVideoEffects` JS API. Kaleidoscope works against either fork; the Android Gradle script picks whichever one autolinking surfaced. That includes `@livekit/react-native-webrtc` 144.2.0 and later (required by `@livekit/react-native` 3), which link LiveKit's prefixed WebRTC build (`livekit.org.webrtc` on Android, `LiveKitWebRTC` on iOS); kaleidoscope detects it at build time. Pick **one** fork, never both, or the native classes collide.
|
|
179
179
|
|
|
180
180
|
```sh
|
|
181
181
|
bun add @livekit/react-native @livekit/react-native-webrtc react-native-webrtc-kaleidoscope
|
package/android/build.gradle
CHANGED
|
@@ -14,6 +14,25 @@ if (expoModulesCorePlugin.exists()) {
|
|
|
14
14
|
applyKotlinExpoModulesCorePlugin()
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// Two forks ship the same classes under `com.oney.WebRTCModule.videoEffects.*`:
|
|
18
|
+
// - react-native-webrtc/react-native-webrtc (upstream)
|
|
19
|
+
// - livekit/react-native-webrtc (LiveKit fork, required by @livekit/react-native)
|
|
20
|
+
// Pick whichever the consumer's autolinking surfaced; throw if neither is present.
|
|
21
|
+
def rnWebrtcCandidates = [':react-native-webrtc', ':livekit_react-native-webrtc']
|
|
22
|
+
def rnWebrtcProject = rnWebrtcCandidates.find { rootProject.findProject(it) != null }
|
|
23
|
+
if (rnWebrtcProject == null) {
|
|
24
|
+
throw new GradleException(
|
|
25
|
+
'react-native-webrtc-kaleidoscope: install either react-native-webrtc ' +
|
|
26
|
+
'or @livekit/react-native-webrtc as a peer dependency.'
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// @livekit/react-native-webrtc 144.2.0 and later link LiveKit's prefixed WebRTC
|
|
31
|
+
// build (io.github.webrtc-sdk:android-prefixed), which renames org.webrtc to
|
|
32
|
+
// livekit.org.webrtc. Read the fork's build script, which is known before it is
|
|
33
|
+
// evaluated, and compile the matching aliases in src/main/webrtc/.
|
|
34
|
+
def rnWebrtcPrefixed = rootProject.project(rnWebrtcProject).buildFile.text.contains('android-prefixed')
|
|
35
|
+
|
|
17
36
|
android {
|
|
18
37
|
namespace 'com.simiancraft.kaleidoscope'
|
|
19
38
|
compileSdkVersion safeExtGet('compileSdkVersion', 34)
|
|
@@ -36,6 +55,12 @@ android {
|
|
|
36
55
|
testOptions {
|
|
37
56
|
unitTests.returnDefaultValues = true
|
|
38
57
|
}
|
|
58
|
+
|
|
59
|
+
sourceSets {
|
|
60
|
+
main {
|
|
61
|
+
java.srcDirs += rnWebrtcPrefixed ? 'src/main/webrtc/prefixed' : 'src/main/webrtc/unprefixed'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
39
64
|
}
|
|
40
65
|
|
|
41
66
|
dependencies {
|
|
@@ -43,26 +68,13 @@ dependencies {
|
|
|
43
68
|
|
|
44
69
|
// react-native-webrtc is a peer dependency: link against its types
|
|
45
70
|
// (ProcessorProvider, VideoFrameProcessor, VideoFrameProcessorFactoryInterface,
|
|
46
|
-
// and the
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
// Two forks ship the same classes under `com.oney.WebRTCModule.videoEffects.*`:
|
|
50
|
-
// - react-native-webrtc/react-native-webrtc (upstream)
|
|
51
|
-
// - livekit/react-native-webrtc (LiveKit fork, required by @livekit/react-native)
|
|
52
|
-
// Pick whichever the consumer's autolinking surfaced; throw if neither is present.
|
|
53
|
-
def rnWebrtcCandidates = [':react-native-webrtc', ':livekit_react-native-webrtc']
|
|
54
|
-
def rnWebrtcProject = rnWebrtcCandidates.find { rootProject.findProject(it) != null }
|
|
55
|
-
if (rnWebrtcProject == null) {
|
|
56
|
-
throw new GradleException(
|
|
57
|
-
'react-native-webrtc-kaleidoscope: install either react-native-webrtc ' +
|
|
58
|
-
'or @livekit/react-native-webrtc as a peer dependency.'
|
|
59
|
-
)
|
|
60
|
-
}
|
|
71
|
+
// and the WebRTC surface it bundles) at compile time only; the consumer app
|
|
72
|
+
// provides the runtime via autolinking. See rnWebrtcProject above.
|
|
61
73
|
compileOnly project(rnWebrtcProject)
|
|
62
74
|
|
|
63
75
|
// Person/background mask: MediaPipe Tasks ImageSegmenter (Mask.kt), the same
|
|
64
76
|
// model family the web and iOS sides run.
|
|
65
|
-
implementation 'com.google.mediapipe:tasks-vision:0.10.
|
|
77
|
+
implementation 'com.google.mediapipe:tasks-vision:0.10.32'
|
|
66
78
|
|
|
67
79
|
// Unit tests (JVM, testDebugUnitTest). The real org.json shadows the stubbed
|
|
68
80
|
// android.jar copy so CompositeLayers' JSONArray/JSONObject parsing runs for real.
|
|
@@ -55,10 +55,12 @@ import com.simiancraft.kaleidoscope.gpu.Ingest
|
|
|
55
55
|
import com.simiancraft.kaleidoscope.gpu.Shaders
|
|
56
56
|
import com.simiancraft.kaleidoscope.segmentation.Mask
|
|
57
57
|
import com.simiancraft.kaleidoscope.segmentation.MaskTuning
|
|
58
|
-
import
|
|
59
|
-
import
|
|
60
|
-
import
|
|
61
|
-
import
|
|
58
|
+
import com.simiancraft.kaleidoscope.webrtc.SurfaceTextureHelper
|
|
59
|
+
import com.simiancraft.kaleidoscope.webrtc.TextureBuffer
|
|
60
|
+
import com.simiancraft.kaleidoscope.webrtc.TextureBufferImpl
|
|
61
|
+
import com.simiancraft.kaleidoscope.webrtc.TextureBufferType
|
|
62
|
+
import com.simiancraft.kaleidoscope.webrtc.VideoFrame
|
|
63
|
+
import com.simiancraft.kaleidoscope.webrtc.YuvConverter
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
* @param context held for Mask (segmentation) and to read bundled image assets.
|
|
@@ -148,8 +150,8 @@ private class CompositeProcessor(
|
|
|
148
150
|
return null
|
|
149
151
|
}
|
|
150
152
|
val inputBuffer = frame.buffer
|
|
151
|
-
if (inputBuffer !is
|
|
152
|
-
if (inputBuffer.type !=
|
|
153
|
+
if (inputBuffer !is TextureBuffer) return null
|
|
154
|
+
if (inputBuffer.type != TextureBufferType.OES) {
|
|
153
155
|
Log.w(TAG, "TextureBuffer type is ${inputBuffer.type}; expected OES. Forwarding.")
|
|
154
156
|
return null
|
|
155
157
|
}
|
|
@@ -276,7 +278,7 @@ private class CompositeProcessor(
|
|
|
276
278
|
TextureBufferImpl(
|
|
277
279
|
ready.width,
|
|
278
280
|
ready.height,
|
|
279
|
-
|
|
281
|
+
TextureBufferType.RGB,
|
|
280
282
|
readyTextureId,
|
|
281
283
|
Matrix(),
|
|
282
284
|
textureHelper.handler,
|
|
@@ -47,10 +47,12 @@ import com.simiancraft.kaleidoscope.gpu.GlProgram
|
|
|
47
47
|
import com.simiancraft.kaleidoscope.gpu.Ingest
|
|
48
48
|
import com.simiancraft.kaleidoscope.gpu.Orientation
|
|
49
49
|
import com.simiancraft.kaleidoscope.gpu.Shaders
|
|
50
|
-
import
|
|
51
|
-
import
|
|
52
|
-
import
|
|
53
|
-
import
|
|
50
|
+
import com.simiancraft.kaleidoscope.webrtc.SurfaceTextureHelper
|
|
51
|
+
import com.simiancraft.kaleidoscope.webrtc.TextureBuffer
|
|
52
|
+
import com.simiancraft.kaleidoscope.webrtc.TextureBufferImpl
|
|
53
|
+
import com.simiancraft.kaleidoscope.webrtc.TextureBufferType
|
|
54
|
+
import com.simiancraft.kaleidoscope.webrtc.VideoFrame
|
|
55
|
+
import com.simiancraft.kaleidoscope.webrtc.YuvConverter
|
|
54
56
|
|
|
55
57
|
/**
|
|
56
58
|
* @param op Which screen-space reorientation this factory's processor applies.
|
|
@@ -122,7 +124,7 @@ private class TransformProcessor(
|
|
|
122
124
|
return null
|
|
123
125
|
}
|
|
124
126
|
val inputBuffer = frame.buffer
|
|
125
|
-
if (inputBuffer !is
|
|
127
|
+
if (inputBuffer !is TextureBuffer) {
|
|
126
128
|
// Chained after a CPU effect emitting I420; silently forward.
|
|
127
129
|
return null
|
|
128
130
|
}
|
|
@@ -135,7 +137,7 @@ private class TransformProcessor(
|
|
|
135
137
|
// already normalized orientation (display-upright, rotation 0), so it is
|
|
136
138
|
// copied into the FBO via a plain 2D-sampler passthrough with NO texture
|
|
137
139
|
// matrix; re-applying Ingest here would double-apply the rotation.
|
|
138
|
-
val isOes = inputBuffer.type ==
|
|
140
|
+
val isOes = inputBuffer.type == TextureBufferType.OES
|
|
139
141
|
val bufW = inputBuffer.width
|
|
140
142
|
val bufH = inputBuffer.height
|
|
141
143
|
if (bufW <= 0 || bufH <= 0) {
|
|
@@ -259,7 +261,7 @@ private class TransformProcessor(
|
|
|
259
261
|
TextureBufferImpl(
|
|
260
262
|
ready.width,
|
|
261
263
|
ready.height,
|
|
262
|
-
|
|
264
|
+
TextureBufferType.RGB,
|
|
263
265
|
readyTextureId,
|
|
264
266
|
Matrix(),
|
|
265
267
|
textureHelper.handler,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The WebRTC classes the effects use, resolved against whichever WebRTC build
|
|
2
|
+
// the consumer's react-native-webrtc links. android/build.gradle compiles
|
|
3
|
+
// exactly one of webrtc/prefixed and webrtc/unprefixed.
|
|
4
|
+
//
|
|
5
|
+
// @livekit/react-native-webrtc 144.2.0 and later link LiveKit's prefixed WebRTC build, which renames org.webrtc to livekit.org.webrtc.
|
|
6
|
+
package com.simiancraft.kaleidoscope.webrtc
|
|
7
|
+
|
|
8
|
+
typealias SurfaceTextureHelper = livekit.org.webrtc.SurfaceTextureHelper
|
|
9
|
+
typealias TextureBuffer = livekit.org.webrtc.VideoFrame.TextureBuffer
|
|
10
|
+
typealias TextureBufferImpl = livekit.org.webrtc.TextureBufferImpl
|
|
11
|
+
typealias TextureBufferType = livekit.org.webrtc.VideoFrame.TextureBuffer.Type
|
|
12
|
+
typealias VideoFrame = livekit.org.webrtc.VideoFrame
|
|
13
|
+
typealias YuvConverter = livekit.org.webrtc.YuvConverter
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The WebRTC classes the effects use, resolved against whichever WebRTC build
|
|
2
|
+
// the consumer's react-native-webrtc links. android/build.gradle compiles
|
|
3
|
+
// exactly one of webrtc/prefixed and webrtc/unprefixed.
|
|
4
|
+
//
|
|
5
|
+
// Upstream react-native-webrtc and @livekit/react-native-webrtc before 144.2.0 ship WebRTC under org.webrtc.
|
|
6
|
+
package com.simiancraft.kaleidoscope.webrtc
|
|
7
|
+
|
|
8
|
+
typealias SurfaceTextureHelper = org.webrtc.SurfaceTextureHelper
|
|
9
|
+
typealias TextureBuffer = org.webrtc.VideoFrame.TextureBuffer
|
|
10
|
+
typealias TextureBufferImpl = org.webrtc.TextureBufferImpl
|
|
11
|
+
typealias TextureBufferType = org.webrtc.VideoFrame.TextureBuffer.Type
|
|
12
|
+
typealias VideoFrame = org.webrtc.VideoFrame
|
|
13
|
+
typealias YuvConverter = org.webrtc.YuvConverter
|
package/catalog/images/README.md
CHANGED
|
@@ -132,7 +132,7 @@ kept crisp (~750 KB), not a photographic background.
|
|
|
132
132
|
An image with transparent regions: a cutout that lets a lower layer (the night sky,
|
|
133
133
|
a shader) show through, or a logo. Keep the alpha; never flatten it.
|
|
134
134
|
|
|
135
|
-
- **Photographic cutout** (the `fairy-caves`, `spaceship`, `wizard-tower`
|
|
135
|
+
- **Photographic cutout** (the `fairy-caves`, `spaceship`, `wizard-tower` images):
|
|
136
136
|
lossy WebP at ~q88 with alpha preserved. Keep the source aspect (these are often
|
|
137
137
|
3:2 or 16:9); the compositor cover-fits, so the exact aspect is not load-bearing.
|
|
138
138
|
|
package/ios/Kaleidoscope.podspec
CHANGED
|
@@ -71,9 +71,10 @@ Pod::Spec.new do |s|
|
|
|
71
71
|
s.dependency 'MediaPipeTasksVision', '0.10.14'
|
|
72
72
|
|
|
73
73
|
# Fork-resolving dependency on react-native-webrtc. The Kaleidoscope target
|
|
74
|
-
# needs FRAMEWORK_SEARCH_PATHS pointing at
|
|
75
|
-
#
|
|
76
|
-
#
|
|
74
|
+
# needs FRAMEWORK_SEARCH_PATHS pointing at the fork's WebRTC framework
|
|
75
|
+
# (WebRTC.framework, or LiveKitWebRTC.framework from @livekit/react-native-webrtc
|
|
76
|
+
# 144.2.0 on) so the Swift WebRTC import in Registration.swift, FrameBridge.swift,
|
|
77
|
+
# and the Processor files resolves at compile time. We do not declare the framework
|
|
77
78
|
# directly (it is not OS-shipped, so `s.weak_framework` is wrong; and it is
|
|
78
79
|
# vended by two different forks at two different paths). Instead we depend
|
|
79
80
|
# on whichever rn-webrtc fork the consumer installed, and CocoaPods
|
|
@@ -95,12 +96,18 @@ Pod::Spec.new do |s|
|
|
|
95
96
|
# via a podspec dependency edge. The two declarations of the same pod merge
|
|
96
97
|
# in CocoaPods' dependency graph.
|
|
97
98
|
#
|
|
98
|
-
# `__dir__`
|
|
99
|
-
#
|
|
100
|
-
#
|
|
101
|
-
#
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
# Probe two places for the LiveKit fork. `__dir__` is normally
|
|
100
|
+
# `<consumer>/node_modules/react-native-webrtc-kaleidoscope/ios/`, so
|
|
101
|
+
# `../../@livekit/react-native-webrtc` is its sibling in node_modules. When the
|
|
102
|
+
# library is symlinked (a `file:` dependency, pnpm), `__dir__` is the link's
|
|
103
|
+
# real path and that sibling does not exist, so also check the app's own
|
|
104
|
+
# node_modules beside the Podfile's directory, which is where the config
|
|
105
|
+
# plugin's resolveWebrtcPod looks.
|
|
106
|
+
livekit_fork_paths = [File.expand_path('../../@livekit/react-native-webrtc', __dir__)]
|
|
107
|
+
if defined?(Pod::Config)
|
|
108
|
+
livekit_fork_paths << File.expand_path('../node_modules/@livekit/react-native-webrtc', Pod::Config.instance.installation_root.to_s)
|
|
109
|
+
end
|
|
110
|
+
if livekit_fork_paths.any? { |path| File.directory?(path) }
|
|
104
111
|
s.dependency 'livekit-react-native-webrtc'
|
|
105
112
|
else
|
|
106
113
|
s.dependency 'react-native-webrtc'
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// - one "composite" compositor (CompositeProcessor): EVERY art effect (images,
|
|
16
16
|
// blur, generative shaders, masked subjects) is now a LAYER inside a
|
|
17
17
|
// composite, delivered out-of-band via setCompositeLayers (CompositeLayers) and
|
|
18
|
-
// composited per frame. The per-effect art processors (
|
|
18
|
+
// composited per frame. The per-effect art processors (one per bundled image,
|
|
19
19
|
// the bare generative names, blur) and their data-driven registration are
|
|
20
20
|
// gone; adding a preset is pure JS (a new Composite in the book), no Swift
|
|
21
21
|
// change and no native registration. Mirrors android/.../Registration.kt
|
|
@@ -29,11 +29,16 @@
|
|
|
29
29
|
// - react-native-webrtc/react-native-webrtc -> module `react_native_webrtc`
|
|
30
30
|
// - livekit/react-native-webrtc (@livekit/react-native) -> `livekit_react_native_webrtc`
|
|
31
31
|
// We import whichever is present; the symbols are identical either way. WebRTC
|
|
32
|
-
// types (RTCVideoFrame etc.) come from WebRTC.framework
|
|
32
|
+
// types (RTCVideoFrame etc.) come from WebRTC.framework, or from LiveKitWebRTC
|
|
33
|
+
// through the aliases in WebRTCTypes.swift.
|
|
33
34
|
|
|
34
35
|
import Foundation
|
|
35
36
|
import os.log
|
|
36
|
-
|
|
37
|
+
#if canImport(LiveKitWebRTC)
|
|
38
|
+
import LiveKitWebRTC
|
|
39
|
+
#else
|
|
40
|
+
import WebRTC
|
|
41
|
+
#endif
|
|
37
42
|
#if canImport(livekit_react_native_webrtc)
|
|
38
43
|
import livekit_react_native_webrtc
|
|
39
44
|
#elseif canImport(react_native_webrtc)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The WebRTC types the effects use, resolved against whichever WebRTC framework
|
|
2
|
+
// the consumer's react-native-webrtc links.
|
|
3
|
+
//
|
|
4
|
+
// @livekit/react-native-webrtc 144.2.0 and later link LiveKitWebRTC, LiveKit's
|
|
5
|
+
// prefixed build: the module is renamed and every Objective-C class gains an LK
|
|
6
|
+
// prefix (LKRTCVideoFrame). These aliases restore the unprefixed names, so the
|
|
7
|
+
// effect code reads the same against either framework. Upstream
|
|
8
|
+
// react-native-webrtc and earlier LiveKit releases link WebRTC, unprefixed.
|
|
9
|
+
#if canImport(LiveKitWebRTC)
|
|
10
|
+
import LiveKitWebRTC
|
|
11
|
+
|
|
12
|
+
public typealias RTCCVPixelBuffer = LKRTCCVPixelBuffer
|
|
13
|
+
public typealias RTCVideoCapturer = LKRTCVideoCapturer
|
|
14
|
+
public typealias RTCVideoFrame = LKRTCVideoFrame
|
|
15
|
+
#endif
|
|
@@ -48,7 +48,11 @@ import MetalKit
|
|
|
48
48
|
import os.log
|
|
49
49
|
import QuartzCore
|
|
50
50
|
import simd
|
|
51
|
-
|
|
51
|
+
#if canImport(LiveKitWebRTC)
|
|
52
|
+
import LiveKitWebRTC
|
|
53
|
+
#else
|
|
54
|
+
import WebRTC
|
|
55
|
+
#endif
|
|
52
56
|
#if canImport(livekit_react_native_webrtc)
|
|
53
57
|
import livekit_react_native_webrtc
|
|
54
58
|
#elseif canImport(react_native_webrtc)
|
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
import CoreVideo
|
|
16
16
|
import Foundation
|
|
17
|
-
|
|
17
|
+
#if canImport(LiveKitWebRTC)
|
|
18
|
+
import LiveKitWebRTC
|
|
19
|
+
#else
|
|
20
|
+
import WebRTC
|
|
21
|
+
#endif
|
|
18
22
|
|
|
19
23
|
enum FrameBridge {
|
|
20
24
|
/// Extract the input CVPixelBuffer from a camera RTCVideoFrame, or nil if
|
|
@@ -32,7 +32,11 @@ import Foundation
|
|
|
32
32
|
import Metal
|
|
33
33
|
import os.log
|
|
34
34
|
import simd
|
|
35
|
-
|
|
35
|
+
#if canImport(LiveKitWebRTC)
|
|
36
|
+
import LiveKitWebRTC
|
|
37
|
+
#else
|
|
38
|
+
import WebRTC
|
|
39
|
+
#endif
|
|
36
40
|
|
|
37
41
|
// Import whichever react-native-webrtc fork is present; both expose the same
|
|
38
42
|
// VideoFrameProcessorDelegate / ProcessorProvider symbols. See Registration.swift.
|
package/llms.txt
CHANGED
|
@@ -82,7 +82,7 @@ The plugin statically analyzes ONE file to decide which image assets ship in you
|
|
|
82
82
|
|
|
83
83
|
1. **Exact filename, exact location:** `kaleidoscope.preset-book.ts` at the **project root** (the directory containing `package.json` and your app config). A book named or placed differently still typechecks and still works on web, but at prebuild NO assets are copied and every image background silently renders nothing on native. This is the most common integration mistake; the failure is silent.
|
|
84
84
|
2. **The book is parsed as text, never executed.** Keep every `image` layer's `source` statically analyzable: a single named import from `react-native-webrtc-kaleidoscope/images/<category>/<leaf>`, a `require('./local.webp')` literal, or a `const X = Asset.fromModule(require('./local.webp')).uri` binding (the binding may span lines; a formatter wrapping it at a narrow print width is fine). Do not compute sources, build layers in helper functions, or re-export the book through a barrel; the parser will not follow them, and each skipped `image` layer warns at prebuild naming the layer id.
|
|
85
|
-
3. **An `image` layer's `id` doubles as its native
|
|
85
|
+
3. **An `image` layer's `id` doubles as its native image id**: keep it equal to the image file's basename (`office-dark`, `my-bg`). Your own background images must be `.webp` (native resolves `assets/images/<id>.webp`).
|
|
86
86
|
4. **Re-run `bunx expo prebuild` after editing the book** (adding/deleting presets changes the native asset set). JS-only uniform tweaks hot-reload without it.
|
|
87
87
|
|
|
88
88
|
## Starting fileset (six files that run)
|
|
@@ -93,7 +93,7 @@ These are trimmed copies of the demo's working files (`demo/kaleidoscope.preset-
|
|
|
93
93
|
|
|
94
94
|
```ts
|
|
95
95
|
import type { KaleidoscopePresetBook } from 'react-native-webrtc-kaleidoscope';
|
|
96
|
-
// Packaged multi-layer
|
|
96
|
+
// Packaged multi-layer composites. Each carries its own taxonomy and thumbnail;
|
|
97
97
|
// delete the import + the entry to opt out of one.
|
|
98
98
|
import { clouds } from 'react-native-webrtc-kaleidoscope/composites/clouds';
|
|
99
99
|
import { corporateBlobs } from 'react-native-webrtc-kaleidoscope/composites/corporate-blobs';
|
|
@@ -150,7 +150,7 @@ export const presets = {
|
|
|
150
150
|
],
|
|
151
151
|
},
|
|
152
152
|
|
|
153
|
-
// --- Worlds: packaged
|
|
153
|
+
// --- Worlds: packaged composites, spread in as-is. One line each; delete freely. ---
|
|
154
154
|
'wizard-tower': wizardTower,
|
|
155
155
|
'wizard-tower-night': wizardTowerNight,
|
|
156
156
|
'observation-deck': observationDeck,
|
|
@@ -530,7 +530,7 @@ Each preset supplies its editor as a `controls` component on the book entry: pac
|
|
|
530
530
|
|
|
531
531
|
## Bundled assets you can reference
|
|
532
532
|
|
|
533
|
-
- **Packaged composites** (multi-layer
|
|
533
|
+
- **Packaged composites** (multi-layer stacks), each behind `react-native-webrtc-kaleidoscope/composites/<name>`: `wizard-tower`, `wizard-tower-night`, `observation-deck`, `fairy-cave`, `fairy-grotto`, `fairy-hollow`, `underwater`, `nebula`, `simianlights`, `corporate-blobs`, `clouds`. Import the export and spread it into your book.
|
|
534
534
|
- **Background images**, each behind `react-native-webrtc-kaleidoscope/images/<category>/<leaf>`: `office/office-dark`, `office/office-light`, `home/home-dark`, `home/home-light`, `nature/landscape-dark`, `nature/landscape-light`, `sci-fi/sci-fi-light`, `underwater/oceanscape-dark`, `simiancraft/simiancraft-light`, `simiancraft/simiancraft-dark`, `simiancraft/simiancraft-light-transparency`, `simiancraft/simiancraft-dark-transparency`, `corporate/corporate-logo`, `fairy-caves/grotto`, `fairy-caves/hollow`, `fairy-caves/treehouse`, `fairy-caves/treehouse-2`, `fairy-caves/treehouse-3`, `spaceship/observation-deck`, `wizard-tower/wizard-tower-1`, `wizard-tower/wizard-tower-2`, `wizard-tower/wizard-tower-night`, plus `debug/debug-resolutions` (a viewport calibration grid for verifying cover-fit). On web an image `source` can also be any image URL or data URI; native resolves bundled image ids only.
|
|
535
535
|
|
|
536
536
|
## Web vs native differences
|
|
@@ -543,7 +543,7 @@ Each preset supplies its editor as a `controls` component on the book entry: pac
|
|
|
543
543
|
|
|
544
544
|
## LiveKit
|
|
545
545
|
|
|
546
|
-
`@livekit/react-native` pulls in `@livekit/react-native-webrtc`, a fork that preserves the same `videoEffects` native classes; kaleidoscope works against either fork (pick one, never both). On native, bind to the local track's underlying `MediaStreamTrack`:
|
|
546
|
+
`@livekit/react-native` pulls in `@livekit/react-native-webrtc`, a fork that preserves the same `videoEffects` native classes; kaleidoscope works against either fork (pick one, never both), including LiveKit's prefixed WebRTC build in `@livekit/react-native-webrtc` 144.2.0 and later, detected at build time. On native, bind to the local track's underlying `MediaStreamTrack`:
|
|
547
547
|
|
|
548
548
|
```ts
|
|
549
549
|
const { kaleidoscope } = bindKaleidoscope(localCameraTrack.mediaStreamTrack, { presets });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-webrtc-kaleidoscope",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
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",
|
|
@@ -93,7 +93,7 @@ function parseImageRefs(source) {
|
|
|
93
93
|
const sourceM = body.match(/source\s*:\s*(require\(\s*['"][^'"]+['"]\s*\)|[A-Za-z0-9_$]+)/);
|
|
94
94
|
const expr = sourceM?.[1];
|
|
95
95
|
// The warn-never-throw contract: a layer the parse cannot follow is skipped
|
|
96
|
-
// LOUDLY, naming the layer, so the missing
|
|
96
|
+
// LOUDLY, naming the layer, so the missing image surfaces at prebuild
|
|
97
97
|
// instead of on-device.
|
|
98
98
|
if (!expr) {
|
|
99
99
|
console.warn(
|