@shortkitsdk/react-native 0.2.11 → 0.2.14
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/build.gradle.kts +13 -1
- package/android/src/main/java/com/shortkit/reactnative/ReactCarouselOverlayHost.kt +157 -54
- package/android/src/main/java/com/shortkit/reactnative/ReactOverlayHost.kt +67 -56
- package/android/src/main/java/com/shortkit/reactnative/ReactVideoCarouselOverlayHost.kt +431 -0
- package/android/src/main/java/com/shortkit/reactnative/ShortKitBridge.kt +154 -26
- package/android/src/main/java/com/shortkit/reactnative/ShortKitFeedView.kt +160 -35
- package/android/src/main/java/com/shortkit/reactnative/ShortKitFeedViewManager.kt +5 -0
- package/android/src/main/java/com/shortkit/reactnative/ShortKitModule.kt +45 -10
- package/android/src/main/java/com/shortkit/reactnative/ShortKitPlayerNativeView.kt +9 -0
- package/ios/ReactCarouselOverlayHost.swift +37 -17
- package/ios/ReactOverlayHost.swift +33 -35
- package/ios/ReactVideoCarouselOverlayHost.swift +283 -0
- package/ios/ShortKitBridge.swift +78 -2
- package/ios/ShortKitFeedView.swift +24 -3
- package/ios/ShortKitModule.mm +6 -2
- package/ios/ShortKitSDK.xcframework/Info.plist +4 -4
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.abi.json +2597 -389
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +69 -5
- 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 +69 -5
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/ShortKitSDK +0 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/_CodeSignature/CodeResources +168 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +2597 -389
- package/ios/ShortKitSDK.xcframework/ios-arm64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +69 -5
- package/ios/ShortKitSDK.xcframework/ios-arm64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +69 -5
- package/ios/ShortKitSDK.xcframework/ios-arm64-simulator/ShortKitSDK.framework/ShortKitSDK +0 -0
- package/ios/ShortKitSDK.xcframework/ios-arm64-simulator/ShortKitSDK.framework/_CodeSignature/CodeResources +168 -0
- package/ios/ShortKitSDK.xcframework.bak2/Info.plist +43 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64/ShortKitSDK.framework/Headers/ShortKitSDK-Swift.h +418 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64/ShortKitSDK.framework/Info.plist +16 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.abi.json +31351 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +865 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.swiftinterface +865 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64/ShortKitSDK.framework/Modules/module.modulemap +4 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64/ShortKitSDK.framework/ShortKitSDK +0 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64-simulator/ShortKitSDK.framework/Headers/ShortKitSDK-Swift.h +418 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64-simulator/ShortKitSDK.framework/Info.plist +16 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +31351 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +865 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +865 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64-simulator/ShortKitSDK.framework/Modules/module.modulemap +4 -0
- package/ios/ShortKitSDK.xcframework.bak2/ios-arm64-simulator/ShortKitSDK.framework/ShortKitSDK +0 -0
- package/package.json +1 -1
- package/src/ShortKitCarouselOverlaySurface.tsx +57 -2
- package/src/ShortKitContext.ts +2 -1
- package/src/ShortKitFeed.tsx +19 -1
- package/src/ShortKitOverlaySurface.tsx +148 -41
- package/src/ShortKitPlayer.tsx +25 -3
- package/src/ShortKitProvider.tsx +4 -2
- package/src/ShortKitVideoCarouselOverlaySurface.tsx +156 -0
- package/src/index.ts +8 -1
- package/src/serialization.ts +8 -0
- package/src/specs/NativeShortKitModule.ts +31 -1
- package/src/types.ts +45 -1
package/ios/ShortKitBridge.swift
CHANGED
|
@@ -30,6 +30,9 @@ import ShortKitSDK
|
|
|
30
30
|
/// Preload handles keyed by UUID, consumed by feed views via preloadId prop.
|
|
31
31
|
public var preloadHandles: [String: FeedPreload] = [:]
|
|
32
32
|
|
|
33
|
+
/// Tracks the most recently created preload or registered feed ID for feedReady routing.
|
|
34
|
+
private var activeFeedId: String = ""
|
|
35
|
+
|
|
33
36
|
// MARK: - Feed Instance Registry
|
|
34
37
|
|
|
35
38
|
private struct WeakFeedRef {
|
|
@@ -41,6 +44,7 @@ import ShortKitSDK
|
|
|
41
44
|
|
|
42
45
|
public func registerFeed(id: String, viewController vc: ShortKitFeedViewController) {
|
|
43
46
|
feedRegistry[id] = WeakFeedRef(vc: vc)
|
|
47
|
+
activeFeedId = id
|
|
44
48
|
|
|
45
49
|
// Wire per-feed remaining content count callback
|
|
46
50
|
vc.onRemainingContentCountChange = { [weak self] count in
|
|
@@ -50,6 +54,11 @@ import ShortKitSDK
|
|
|
50
54
|
])
|
|
51
55
|
}
|
|
52
56
|
|
|
57
|
+
// Wire per-feed ready callback
|
|
58
|
+
vc.onFeedReady = { [weak self] in
|
|
59
|
+
self?.emitOnMain("onFeedReady", body: ["feedId": id])
|
|
60
|
+
}
|
|
61
|
+
|
|
53
62
|
// Replay buffered operations on the next run-loop tick so the VC's
|
|
54
63
|
// view hierarchy is fully set up after didMoveToWindow returns.
|
|
55
64
|
if let ops = pendingOps.removeValue(forKey: id) {
|
|
@@ -315,14 +324,35 @@ import ShortKitSDK
|
|
|
315
324
|
}
|
|
316
325
|
}
|
|
317
326
|
|
|
318
|
-
@objc public func preloadFeed(_ configJSON: String, completion: @escaping (String) -> Void) {
|
|
327
|
+
@objc public func preloadFeed(_ configJSON: String, itemsJSON: String?, completion: @escaping (String) -> Void) {
|
|
319
328
|
let config = Self.parseFeedConfig(configJSON)
|
|
320
|
-
|
|
329
|
+
let preload: FeedPreload?
|
|
330
|
+
|
|
331
|
+
NSLog("[ShortKit Bridge] preloadFeed called — feedSource: %@, hasItemsJSON: %@",
|
|
332
|
+
config.feedSource == .custom ? "custom" : "algorithmic",
|
|
333
|
+
itemsJSON != nil ? "yes (\(itemsJSON!.prefix(100))...)" : "no")
|
|
334
|
+
|
|
335
|
+
if config.feedSource == .custom {
|
|
336
|
+
guard let json = itemsJSON, let items = Self.parseFeedInputs(json) else {
|
|
337
|
+
NSLog("[ShortKit Bridge] ❌ preloadFeed: feedSource=custom but no valid items — returning empty")
|
|
338
|
+
completion("")
|
|
339
|
+
return
|
|
340
|
+
}
|
|
341
|
+
NSLog("[ShortKit Bridge] preloadFeed: creating custom preload with %d items", items.count)
|
|
342
|
+
preload = shortKit?.preloadFeed(items: items)
|
|
343
|
+
} else {
|
|
344
|
+
preload = shortKit?.preloadFeed(filter: config.filter)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
guard let preload else {
|
|
348
|
+
NSLog("[ShortKit Bridge] ❌ preloadFeed: shortKit?.preloadFeed returned nil")
|
|
321
349
|
completion("")
|
|
322
350
|
return
|
|
323
351
|
}
|
|
324
352
|
let uuid = UUID().uuidString
|
|
353
|
+
NSLog("[ShortKit Bridge] ✅ preloadFeed: created handle %@", uuid)
|
|
325
354
|
preloadHandles[uuid] = preload
|
|
355
|
+
activeFeedId = uuid
|
|
326
356
|
completion(uuid)
|
|
327
357
|
}
|
|
328
358
|
|
|
@@ -621,13 +651,19 @@ import ShortKitSDK
|
|
|
621
651
|
let feedSource: FeedSource = feedSourceStr == "custom" ? .custom : .algorithmic
|
|
622
652
|
|
|
623
653
|
let carouselOverlay = parseCarouselOverlay(obj["carouselOverlay"] as? String)
|
|
654
|
+
let videoCarouselOverlay = parseVideoCarouselOverlay(obj["videoCarouselOverlay"] as? String)
|
|
624
655
|
|
|
625
656
|
let filter = parseFeedFilter(obj["filter"] as? String)
|
|
626
657
|
|
|
658
|
+
let scrollAxisStr = obj["scrollAxis"] as? String ?? "vertical"
|
|
659
|
+
let scrollAxis: ScrollAxis = scrollAxisStr == "horizontal" ? .horizontal : .vertical
|
|
660
|
+
|
|
627
661
|
return FeedConfig(
|
|
628
662
|
feedHeight: feedHeight,
|
|
663
|
+
scrollAxis: scrollAxis,
|
|
629
664
|
videoOverlay: videoOverlay,
|
|
630
665
|
carouselOverlay: carouselOverlay,
|
|
666
|
+
videoCarouselOverlay: videoCarouselOverlay,
|
|
631
667
|
surveyOverlay: .none,
|
|
632
668
|
adOverlay: .none,
|
|
633
669
|
muteOnStart: muteOnStart,
|
|
@@ -706,6 +742,39 @@ import ShortKitSDK
|
|
|
706
742
|
return .none
|
|
707
743
|
}
|
|
708
744
|
|
|
745
|
+
/// Parse a double-stringified video carousel overlay JSON into a `VideoCarouselOverlayMode`.
|
|
746
|
+
///
|
|
747
|
+
/// Examples:
|
|
748
|
+
/// - `"\"none\""` -> `.none`
|
|
749
|
+
/// - `"{\"type\":\"custom\",\"name\":\"news\"}"` -> `.custom { ReactVideoCarouselOverlayHost() }`
|
|
750
|
+
private static func parseVideoCarouselOverlay(_ json: String?) -> VideoCarouselOverlayMode {
|
|
751
|
+
guard let json,
|
|
752
|
+
let data = json.data(using: .utf8),
|
|
753
|
+
let parsed = try? JSONSerialization.jsonObject(with: data) else {
|
|
754
|
+
return .none
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if let str = parsed as? String, str == "none" {
|
|
758
|
+
return .none
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if let obj = parsed as? [String: Any],
|
|
762
|
+
let type = obj["type"] as? String,
|
|
763
|
+
type == "custom" {
|
|
764
|
+
let name = obj["name"] as? String ?? "Default"
|
|
765
|
+
return .custom { @Sendable in
|
|
766
|
+
let host = ReactVideoCarouselOverlayHost()
|
|
767
|
+
host.surfacePresenter = ShortKitBridge.shared?.surfacePresenter
|
|
768
|
+
host.bridge = ShortKitBridge.shared
|
|
769
|
+
host.videoCarouselOverlayModuleName = "ShortKitVideoCarouselOverlay_\(name)"
|
|
770
|
+
host.prepareSurface()
|
|
771
|
+
return host
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
return .none
|
|
776
|
+
}
|
|
777
|
+
|
|
709
778
|
/// Parse a double-stringified feedHeight JSON.
|
|
710
779
|
/// e.g. `"{\"type\":\"fullscreen\"}"` or `"{\"type\":\"percentage\",\"value\":0.8}"`
|
|
711
780
|
private static func parseFeedHeight(_ json: String?) -> FeedHeight {
|
|
@@ -766,6 +835,13 @@ import ShortKitSDK
|
|
|
766
835
|
continue
|
|
767
836
|
}
|
|
768
837
|
result.append(.imageCarousel(carouselItem))
|
|
838
|
+
case "videoCarousel":
|
|
839
|
+
guard let itemData = obj["item"] as? [String: Any],
|
|
840
|
+
let itemJSON = try? JSONSerialization.data(withJSONObject: itemData),
|
|
841
|
+
let carouselItem = try? JSONDecoder().decode(VideoCarouselItem.self, from: itemJSON) else {
|
|
842
|
+
continue
|
|
843
|
+
}
|
|
844
|
+
result.append(.videoCarousel(carouselItem))
|
|
769
845
|
default:
|
|
770
846
|
continue
|
|
771
847
|
}
|
|
@@ -66,6 +66,7 @@ import ShortKitSDK
|
|
|
66
66
|
feedVC.view.frame = bounds
|
|
67
67
|
addSubview(feedVC.view)
|
|
68
68
|
feedVC.didMove(toParent: parentVC)
|
|
69
|
+
feedVC.activate()
|
|
69
70
|
if let feedId = self.feedId {
|
|
70
71
|
ShortKitBridge.shared?.registerFeed(id: feedId, viewController: feedVC)
|
|
71
72
|
}
|
|
@@ -80,12 +81,30 @@ import ShortKitSDK
|
|
|
80
81
|
var feedConfig = ShortKitBridge.parseFeedConfig(self.config ?? "{}")
|
|
81
82
|
|
|
82
83
|
// Consume preload handle if available
|
|
83
|
-
if let preloadId = self.preloadId
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
if let preloadId = self.preloadId {
|
|
85
|
+
NSLog("[ShortKit FeedView] preloadId prop: %@", preloadId)
|
|
86
|
+
if let preload = ShortKitBridge.shared?.consumePreload(id: preloadId) {
|
|
87
|
+
feedConfig.preload = preload
|
|
88
|
+
NSLog("[ShortKit FeedView] ✅ Preload handle consumed for feedId: %@", preloadId)
|
|
89
|
+
} else {
|
|
90
|
+
NSLog("[ShortKit FeedView] ❌ No preload handle found for feedId: %@", preloadId)
|
|
91
|
+
NSLog("[ShortKit FeedView] Available preload handles: %@", ShortKitBridge.shared?.preloadHandles.keys.joined(separator: ", ") ?? "none")
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
NSLog("[ShortKit FeedView] No preloadId prop set")
|
|
86
95
|
}
|
|
87
96
|
|
|
97
|
+
NSLog("[ShortKit FeedView] feedConfig.preload is %@", feedConfig.preload != nil ? "SET" : "NIL")
|
|
98
|
+
NSLog("[ShortKit FeedView] feedConfig.feedSource: %@", feedConfig.feedSource == .custom ? "custom" : "algorithmic")
|
|
99
|
+
|
|
100
|
+
NSLog("[ShortKit FeedView] Creating ShortKitFeedViewController with config.preload=%@, config.feedSource=%@",
|
|
101
|
+
feedConfig.preload != nil ? "SET" : "NIL",
|
|
102
|
+
feedConfig.feedSource == .custom ? "custom" : "algorithmic")
|
|
103
|
+
|
|
88
104
|
let feedVC = ShortKitFeedViewController(shortKit: sdk, config: feedConfig, startAtItemId: startAtItemId)
|
|
105
|
+
feedVC.setBridgeManaged()
|
|
106
|
+
|
|
107
|
+
NSLog("[ShortKit FeedView] VC created successfully (bridge-managed)")
|
|
89
108
|
|
|
90
109
|
feedVC.onDismiss = {
|
|
91
110
|
ShortKitBridge.shared?.emitDismiss()
|
|
@@ -113,6 +132,7 @@ import ShortKitSDK
|
|
|
113
132
|
}
|
|
114
133
|
guard let feedVC = feedViewController else { return }
|
|
115
134
|
|
|
135
|
+
feedVC.deactivate()
|
|
116
136
|
feedVC.willMove(toParent: nil)
|
|
117
137
|
feedVC.view.removeFromSuperview()
|
|
118
138
|
feedVC.removeFromParent()
|
|
@@ -126,6 +146,7 @@ import ShortKitSDK
|
|
|
126
146
|
}
|
|
127
147
|
guard let feedVC = feedViewController else { return }
|
|
128
148
|
|
|
149
|
+
feedVC.deactivate()
|
|
129
150
|
feedVC.willMove(toParent: nil)
|
|
130
151
|
feedVC.view.removeFromSuperview()
|
|
131
152
|
feedVC.removeFromParent()
|
package/ios/ShortKitModule.mm
CHANGED
|
@@ -71,6 +71,7 @@ RCT_EXPORT_MODULE(ShortKitModule)
|
|
|
71
71
|
@"onSurveyResponse",
|
|
72
72
|
@"onContentTapped",
|
|
73
73
|
@"onDismiss",
|
|
74
|
+
@"onFeedReady",
|
|
74
75
|
@"onRefreshRequested",
|
|
75
76
|
@"onDidFetchContentItems",
|
|
76
77
|
@"onOverlayActiveChanged",
|
|
@@ -81,6 +82,9 @@ RCT_EXPORT_MODULE(ShortKitModule)
|
|
|
81
82
|
@"onOverlayActiveCueChanged",
|
|
82
83
|
@"onOverlayFeedScrollPhaseChanged",
|
|
83
84
|
@"onOverlayTimeUpdate",
|
|
85
|
+
@"onOverlayFullState",
|
|
86
|
+
@"onCarouselActiveImageChanged",
|
|
87
|
+
@"onVideoCarouselActiveVideoChanged",
|
|
84
88
|
];
|
|
85
89
|
}
|
|
86
90
|
|
|
@@ -104,7 +108,6 @@ RCT_EXPORT_MODULE(ShortKitModule)
|
|
|
104
108
|
|
|
105
109
|
- (void)emitEvent:(NSString *)name body:(NSDictionary *)body {
|
|
106
110
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
107
|
-
// New Architecture: use the codegen EventEmitterCallback directly
|
|
108
111
|
if (_eventEmitterCallback) {
|
|
109
112
|
_eventEmitterCallback(std::string([name UTF8String]), body);
|
|
110
113
|
}
|
|
@@ -258,9 +261,10 @@ RCT_EXPORT_METHOD(applyFilter:(NSString *)feedId filterJSON:(NSString *)filterJS
|
|
|
258
261
|
}
|
|
259
262
|
|
|
260
263
|
RCT_EXPORT_METHOD(preloadFeed:(NSString *)configJSON
|
|
264
|
+
itemsJSON:(NSString *)itemsJSON
|
|
261
265
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
262
266
|
reject:(RCTPromiseRejectBlock)reject) {
|
|
263
|
-
[_shortKitBridge preloadFeed:configJSON completion:^(NSString *uuid) {
|
|
267
|
+
[_shortKitBridge preloadFeed:configJSON itemsJSON:itemsJSON completion:^(NSString *uuid) {
|
|
264
268
|
resolve(uuid);
|
|
265
269
|
}];
|
|
266
270
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>ShortKitSDK.framework/ShortKitSDK</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-arm64
|
|
11
|
+
<string>ios-arm64</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>ShortKitSDK.framework</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
@@ -17,14 +17,12 @@
|
|
|
17
17
|
</array>
|
|
18
18
|
<key>SupportedPlatform</key>
|
|
19
19
|
<string>ios</string>
|
|
20
|
-
<key>SupportedPlatformVariant</key>
|
|
21
|
-
<string>simulator</string>
|
|
22
20
|
</dict>
|
|
23
21
|
<dict>
|
|
24
22
|
<key>BinaryPath</key>
|
|
25
23
|
<string>ShortKitSDK.framework/ShortKitSDK</string>
|
|
26
24
|
<key>LibraryIdentifier</key>
|
|
27
|
-
<string>ios-arm64</string>
|
|
25
|
+
<string>ios-arm64-simulator</string>
|
|
28
26
|
<key>LibraryPath</key>
|
|
29
27
|
<string>ShortKitSDK.framework</string>
|
|
30
28
|
<key>SupportedArchitectures</key>
|
|
@@ -33,6 +31,8 @@
|
|
|
33
31
|
</array>
|
|
34
32
|
<key>SupportedPlatform</key>
|
|
35
33
|
<string>ios</string>
|
|
34
|
+
<key>SupportedPlatformVariant</key>
|
|
35
|
+
<string>simulator</string>
|
|
36
36
|
</dict>
|
|
37
37
|
</array>
|
|
38
38
|
<key>CFBundlePackageType</key>
|