@shortkitsdk/react-native 0.2.34 → 0.2.35
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/android/libs/shortkit-release.aar +0 -0
- package/android/src/main/java/com/shortkit/reactnative/ReactCarouselOverlayHost.kt +6 -1
- package/android/src/main/java/com/shortkit/reactnative/ReactOverlayHost.kt +8 -1
- package/android/src/main/java/com/shortkit/reactnative/ReactVideoCarouselOverlayHost.kt +7 -0
- package/android/src/main/java/com/shortkit/reactnative/ShortKitPackage.kt +0 -2
- package/ios/ShortKitSDK.xcframework/Info.plist +5 -5
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Info.plist +2 -2
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.abi.json +357 -35
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +2 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.swiftinterface +2 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/ShortKitSDK +0 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/_CodeSignature/CodeResources +9 -9
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Info.plist +2 -2
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +357 -35
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +357 -35
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +2 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/ShortKitSDK +0 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/_CodeSignature/CodeResources +17 -17
- package/ios/ShortKitWidgetNativeView.swift +30 -3
- package/ios/ShortKitWidgetNativeViewManager.mm +1 -0
- package/package.json +1 -1
- package/src/ShortKitPlayer.tsx +20 -1
- package/src/ShortKitWidget.tsx +63 -15
- package/src/specs/ShortKitWidgetViewNativeComponent.ts +15 -3
- package/src/types.ts +5 -0
- package/android/src/main/java/com/shortkit/reactnative/ShortKitPlayerNativeView.kt +0 -149
- package/android/src/main/java/com/shortkit/reactnative/ShortKitPlayerViewManager.kt +0 -35
- package/android/src/main/java/com/shortkit/reactnative/ShortKitWidgetNativeView.kt +0 -149
- package/android/src/main/java/com/shortkit/reactnative/ShortKitWidgetViewManager.kt +0 -30
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
package com.shortkit.reactnative
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.widget.FrameLayout
|
|
5
|
-
import com.shortkit.sdk.config.PlayerClickAction
|
|
6
|
-
import com.shortkit.sdk.config.VideoOverlayMode
|
|
7
|
-
import com.shortkit.sdk.config.WidgetConfig
|
|
8
|
-
import com.shortkit.sdk.widget.ShortKitWidgetView
|
|
9
|
-
import com.shortkit.sdk.config.FeedConfig
|
|
10
|
-
import com.shortkit.sdk.model.FeedFilter
|
|
11
|
-
import com.shortkit.sdk.model.WidgetInput
|
|
12
|
-
import org.json.JSONArray
|
|
13
|
-
import org.json.JSONObject
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Fabric native view wrapping [ShortKitWidgetView] for use as a
|
|
17
|
-
* horizontal video carousel in React Native.
|
|
18
|
-
*
|
|
19
|
-
* Props:
|
|
20
|
-
* - `config`: JSON string with WidgetConfig values
|
|
21
|
-
* - `items`: JSON string with WidgetInput array (compact playback-ID form)
|
|
22
|
-
*/
|
|
23
|
-
class ShortKitWidgetNativeView(context: Context) : FrameLayout(context) {
|
|
24
|
-
|
|
25
|
-
private var widgetView: ShortKitWidgetView? = null
|
|
26
|
-
private var configJson: String? = null
|
|
27
|
-
private var itemsJson: String? = null
|
|
28
|
-
private var parsedConfig: WidgetConfig = WidgetConfig()
|
|
29
|
-
private var parsedItems: List<WidgetInput> = emptyList()
|
|
30
|
-
|
|
31
|
-
var config: String?
|
|
32
|
-
get() = configJson
|
|
33
|
-
set(value) {
|
|
34
|
-
if (value == configJson) return
|
|
35
|
-
configJson = value
|
|
36
|
-
parsedConfig = parseWidgetConfig(value)
|
|
37
|
-
// If widget is already built, rebuild to pick up new config.
|
|
38
|
-
if (widgetView != null) {
|
|
39
|
-
removeWidget()
|
|
40
|
-
embedWidgetIfNeeded()
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var items: String?
|
|
45
|
-
get() = itemsJson
|
|
46
|
-
set(value) {
|
|
47
|
-
if (value == itemsJson) return
|
|
48
|
-
itemsJson = value
|
|
49
|
-
parsedItems = parseWidgetInputs(value) ?: emptyList()
|
|
50
|
-
// Post-mount update on an existing widget.
|
|
51
|
-
widgetView?.configure(parsedItems)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
override fun onAttachedToWindow() {
|
|
55
|
-
super.onAttachedToWindow()
|
|
56
|
-
embedWidgetIfNeeded()
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
override fun onDetachedFromWindow() {
|
|
60
|
-
super.onDetachedFromWindow()
|
|
61
|
-
removeWidget()
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private fun embedWidgetIfNeeded() {
|
|
65
|
-
if (widgetView != null) return
|
|
66
|
-
val sdk = ShortKitBridge.shared?.sdk ?: return
|
|
67
|
-
|
|
68
|
-
// Pass items at initialize time so the widget never races the server
|
|
69
|
-
// fetch — analogous to the feed's `feedItems` prop wiring.
|
|
70
|
-
val view = ShortKitWidgetView(context).apply {
|
|
71
|
-
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
72
|
-
}
|
|
73
|
-
view.initialize(sdk, parsedConfig, parsedItems)
|
|
74
|
-
addView(view)
|
|
75
|
-
widgetView = view
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private fun removeWidget() {
|
|
79
|
-
widgetView?.let { removeView(it) }
|
|
80
|
-
widgetView = null
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private fun parseWidgetConfig(json: String?): WidgetConfig {
|
|
84
|
-
if (json.isNullOrEmpty()) return WidgetConfig()
|
|
85
|
-
return try {
|
|
86
|
-
val obj = JSONObject(json)
|
|
87
|
-
WidgetConfig(
|
|
88
|
-
cardCount = obj.optInt("cardCount", 3),
|
|
89
|
-
cardSpacing = obj.optDouble("cardSpacing", 8.0).toFloat(),
|
|
90
|
-
cornerRadius = obj.optDouble("cornerRadius", 12.0).toFloat(),
|
|
91
|
-
autoplay = obj.optBoolean("autoplay", true),
|
|
92
|
-
muteOnStart = obj.optBoolean("muteOnStart", true),
|
|
93
|
-
loop = obj.optBoolean("loop", true),
|
|
94
|
-
rotationInterval = obj.optLong("rotationInterval", 10_000L),
|
|
95
|
-
clickAction = when (obj.optString("clickAction", "feed")) {
|
|
96
|
-
"feed" -> PlayerClickAction.FEED
|
|
97
|
-
"mute" -> PlayerClickAction.MUTE
|
|
98
|
-
"none" -> PlayerClickAction.NONE
|
|
99
|
-
else -> PlayerClickAction.FEED
|
|
100
|
-
},
|
|
101
|
-
cardOverlay = parseOverlay(obj),
|
|
102
|
-
filter = obj.optString("filter", "").let { filterStr ->
|
|
103
|
-
if (filterStr.isNotEmpty()) ShortKitBridge.parseFeedFilterToModel(filterStr) else null
|
|
104
|
-
},
|
|
105
|
-
feedConfig = obj.optString("feedConfig", "").let { fcStr ->
|
|
106
|
-
if (fcStr.isNotEmpty()) ShortKitBridge.parseFeedConfig(fcStr, context) else FeedConfig()
|
|
107
|
-
},
|
|
108
|
-
)
|
|
109
|
-
} catch (_: Exception) {
|
|
110
|
-
WidgetConfig()
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private fun parseOverlay(obj: JSONObject): VideoOverlayMode {
|
|
115
|
-
val overlay = obj.opt("overlay") ?: return VideoOverlayMode.None
|
|
116
|
-
if (overlay is JSONObject && overlay.optString("type") == "custom") {
|
|
117
|
-
return VideoOverlayMode.Custom {
|
|
118
|
-
ReactOverlayHost(context)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return VideoOverlayMode.None
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Parse a JSON array of `WidgetInput` values (compact playback-ID form).
|
|
126
|
-
* Mirrors the JS `WidgetInput` type:
|
|
127
|
-
* `{ type: 'video'; playbackId: string; fallbackUrl?: string }`.
|
|
128
|
-
*/
|
|
129
|
-
private fun parseWidgetInputs(json: String?): List<WidgetInput>? {
|
|
130
|
-
if (json.isNullOrEmpty()) return null
|
|
131
|
-
return try {
|
|
132
|
-
val arr = JSONArray(json)
|
|
133
|
-
val out = mutableListOf<WidgetInput>()
|
|
134
|
-
for (i in 0 until arr.length()) {
|
|
135
|
-
val obj = arr.getJSONObject(i)
|
|
136
|
-
if (obj.optString("type") != "video") continue
|
|
137
|
-
val playbackId = obj.optString("playbackId", "")
|
|
138
|
-
if (playbackId.isEmpty()) continue
|
|
139
|
-
val fallbackUrl = if (obj.has("fallbackUrl") && !obj.isNull("fallbackUrl")) {
|
|
140
|
-
obj.getString("fallbackUrl")
|
|
141
|
-
} else null
|
|
142
|
-
out.add(WidgetInput.Video(playbackId = playbackId, fallbackUrl = fallbackUrl))
|
|
143
|
-
}
|
|
144
|
-
out
|
|
145
|
-
} catch (_: Exception) {
|
|
146
|
-
null
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
package com.shortkit.reactnative
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.module.annotations.ReactModule
|
|
4
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
5
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
-
import com.facebook.react.uimanager.annotations.ReactProp
|
|
7
|
-
|
|
8
|
-
@ReactModule(name = ShortKitWidgetViewManager.REACT_CLASS)
|
|
9
|
-
class ShortKitWidgetViewManager : SimpleViewManager<ShortKitWidgetNativeView>() {
|
|
10
|
-
|
|
11
|
-
override fun getName(): String = REACT_CLASS
|
|
12
|
-
|
|
13
|
-
override fun createViewInstance(context: ThemedReactContext): ShortKitWidgetNativeView {
|
|
14
|
-
return ShortKitWidgetNativeView(context)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
@ReactProp(name = "config")
|
|
18
|
-
fun setConfig(view: ShortKitWidgetNativeView, config: String?) {
|
|
19
|
-
view.config = config
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@ReactProp(name = "items")
|
|
23
|
-
fun setItems(view: ShortKitWidgetNativeView, items: String?) {
|
|
24
|
-
view.items = items
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
companion object {
|
|
28
|
-
const val REACT_CLASS = "ShortKitWidgetView"
|
|
29
|
-
}
|
|
30
|
-
}
|