@shortkitsdk/react-native 0.2.25 → 0.2.26

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 (30) hide show
  1. package/android/libs/shortkit-release.aar +0 -0
  2. package/ios/ShortKitBridge.swift +42 -4
  3. package/ios/ShortKitFeedView.swift +50 -4
  4. package/ios/ShortKitFeedViewManager.mm +2 -0
  5. package/ios/ShortKitModule.mm +13 -3
  6. package/ios/ShortKitSDK.xcframework/Info.plist +5 -5
  7. package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Info.plist +2 -2
  8. package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.abi.json +1946 -218
  9. package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +51 -6
  10. package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  11. package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.swiftinterface +51 -6
  12. package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/ShortKitSDK +0 -0
  13. package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/_CodeSignature/CodeResources +9 -9
  14. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Info.plist +2 -2
  15. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +1946 -218
  16. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +51 -6
  17. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  18. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +51 -6
  19. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1946 -218
  20. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +51 -6
  21. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  22. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +51 -6
  23. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/ShortKitSDK +0 -0
  24. package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/_CodeSignature/CodeResources +17 -17
  25. package/package.json +1 -1
  26. package/src/ShortKitFeed.tsx +42 -3
  27. package/src/ShortKitProvider.tsx +2 -1
  28. package/src/specs/NativeShortKitModule.ts +17 -1
  29. package/src/specs/ShortKitFeedViewNativeComponent.ts +3 -0
  30. package/src/types.ts +58 -2
Binary file
@@ -70,6 +70,37 @@ import ShortKitSDK
70
70
  self?.emitOnMain("onFeedReady", body: ["feedId": id])
71
71
  }
72
72
 
73
+ // Wire per-feed refresh state callback (scoped by feedId)
74
+ vc.onRefreshStateChanged = { [weak self] state in
75
+ NSLog("[ShortKit Bridge] onRefreshStateChangedPerFeed feedId=%@ status=%@", id, "\(state)")
76
+ var body: [String: Any] = ["feedId": id]
77
+ switch state {
78
+ case .idle:
79
+ body["status"] = "idle"
80
+ body["progress"] = 0.0
81
+ case .pulling(let progress):
82
+ body["status"] = "pulling"
83
+ body["progress"] = progress
84
+ case .triggered:
85
+ body["status"] = "triggered"
86
+ body["progress"] = 0.0
87
+ case .refreshing:
88
+ body["status"] = "refreshing"
89
+ body["progress"] = 0.0
90
+ }
91
+ self?.emitOnMain("onRefreshStateChangedPerFeed", body: body)
92
+ }
93
+
94
+ // Wire per-feed video-carousel cell tap event
95
+ vc.onVideoCarouselCellTap = { [weak self] payload in
96
+ self?.emitOnMain("onVideoCarouselCellTap", body: [
97
+ "feedId": id,
98
+ "id": payload.id,
99
+ "index": payload.index,
100
+ "pageIndex": payload.pageIndex,
101
+ ])
102
+ }
103
+
73
104
  // Replay buffered operations on the next run-loop tick so the VC's
74
105
  // view hierarchy is fully set up after didMoveToWindow returns.
75
106
  if let ops = pendingOps.removeValue(forKey: id) {
@@ -272,20 +303,27 @@ import ShortKitSDK
272
303
 
273
304
  // MARK: - Custom Feed
274
305
 
275
- @objc public func setFeedItems(_ feedId: String, items json: String) {
306
+ @objc public func setFeedItems(_ feedId: String, items json: String, startAtId: String?) {
276
307
  guard let items = Self.parseFeedInputs(json) else { return }
277
308
  DispatchQueue.main.async { [weak self] in
278
309
  guard let self else { return }
279
310
  if let vc = self.feedViewController(for: feedId) {
280
- vc.setFeedItems(items)
311
+ vc.setFeedItems(items, startAtId: startAtId)
281
312
  } else {
282
313
  self.pendingOps[feedId, default: []].append { vc in
283
- vc.setFeedItems(items)
314
+ vc.setFeedItems(items, startAtId: startAtId)
284
315
  }
285
316
  }
286
317
  }
287
318
  }
288
319
 
320
+ @objc public func scrollFeedToItem(_ feedId: String, id: String, animated: Bool) {
321
+ DispatchQueue.main.async { [weak self] in
322
+ guard let self else { return }
323
+ self.feedViewController(for: feedId)?.scrollToItem(id: id, animated: animated)
324
+ }
325
+ }
326
+
289
327
  @objc public func appendFeedItems(_ feedId: String, items json: String) {
290
328
  guard let items = Self.parseFeedInputs(json) else { return }
291
329
  DispatchQueue.main.async { [weak self] in
@@ -910,7 +948,7 @@ import ShortKitSDK
910
948
  }
911
949
 
912
950
  /// Parse a JSON string of FeedInput[] from the JS bridge.
913
- private static func parseFeedInputs(_ json: String) -> [FeedInput]? {
951
+ static func parseFeedInputs(_ json: String) -> [FeedInput]? {
914
952
  guard let data = json.data(using: .utf8),
915
953
  let arr = try? JSONSerialization.jsonObject(with: data) as? [[String: Any]] else {
916
954
  return nil
@@ -29,6 +29,31 @@ import ShortKitSDK
29
29
  didSet { /* used at embed time only */ }
30
30
  }
31
31
 
32
+ /// JSON-serialized FeedInput[] for initial custom-feed items at mount time.
33
+ /// Parsed and wrapped in FeedPreload(immediateItems:) at embed time so the
34
+ /// SDK takes the sync render path — no async preload wait, no ref-attach
35
+ /// race, first cell dequeued on the first run-loop tick.
36
+ /// When preloadId is also set, preloadId takes precedence.
37
+ @objc public var feedItemsJSON: String? {
38
+ didSet { /* used at embed time only */ }
39
+ }
40
+
41
+ /// When the consumer explicitly manages this prop, it becomes the
42
+ /// authoritative suspension signal — overriding willMove(toWindow:).
43
+ private var isActiveManagedByProp = false
44
+
45
+ @objc public var active: Bool = true {
46
+ didSet {
47
+ guard active != oldValue, let feedVC = feedViewController else { return }
48
+ if !active { isActiveManagedByProp = true }
49
+ if active {
50
+ feedVC.activate()
51
+ } else {
52
+ feedVC.deactivate()
53
+ }
54
+ }
55
+ }
56
+
32
57
  @objc var feedId: String?
33
58
 
34
59
  // MARK: - Child VC
@@ -48,7 +73,7 @@ import ShortKitSDK
48
73
  public override func willMove(toWindow newWindow: UIWindow?) {
49
74
  super.willMove(toWindow: newWindow)
50
75
 
51
- if newWindow == nil {
76
+ if newWindow == nil && !isActiveManagedByProp {
52
77
  suspendFeedViewController()
53
78
  }
54
79
  }
@@ -71,14 +96,18 @@ import ShortKitSDK
71
96
 
72
97
  // Re-attach an existing suspended VC (e.g. after native stack pop)
73
98
  if let feedVC = feedViewController {
99
+ NSLog("[ShortKit FeedView] re-attaching suspended VC feedId=%@", feedId ?? "nil")
74
100
  parentVC.addChild(feedVC)
75
101
  feedVC.view.frame = bounds
76
102
  addSubview(feedVC.view)
77
103
  feedVC.didMove(toParent: parentVC)
78
- feedVC.activate()
104
+ if !isActiveManagedByProp {
105
+ feedVC.activate()
106
+ }
79
107
  if let feedId = self.feedId {
80
108
  ShortKitBridge.shared?.registerFeed(id: feedId, viewController: feedVC)
81
109
  }
110
+ NSLog("[ShortKit FeedView] re-attach complete — activate() called")
82
111
  return
83
112
  }
84
113
 
@@ -99,8 +128,14 @@ import ShortKitSDK
99
128
  NSLog("[ShortKit FeedView] ❌ No preload handle found for feedId: %@", preloadId)
100
129
  NSLog("[ShortKit FeedView] Available preload handles: %@", ShortKitBridge.shared?.preloadHandles.keys.joined(separator: ", ") ?? "none")
101
130
  }
131
+ } else if let json = self.feedItemsJSON,
132
+ let items = ShortKitBridge.parseFeedInputs(json) {
133
+ // feedItems prop: wrap in an immediate preload (no async prefetch
134
+ // work — items are available synchronously at viewDidLoad).
135
+ feedConfig.preload = FeedPreload(immediateItems: items)
136
+ NSLog("[ShortKit FeedView] feedItems prop: created immediate preload with %d items", items.count)
102
137
  } else {
103
- NSLog("[ShortKit FeedView] No preloadId prop set")
138
+ NSLog("[ShortKit FeedView] No preloadId or feedItems prop set")
104
139
  }
105
140
 
106
141
  NSLog("[ShortKit FeedView] feedConfig.preload is %@", feedConfig.preload != nil ? "SET" : "NIL")
@@ -155,6 +190,12 @@ import ShortKitSDK
155
190
  feedVC.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
156
191
  addSubview(feedVC.view)
157
192
  feedVC.didMove(toParent: parentVC)
193
+
194
+ // Fabric sets props BEFORE didMoveToWindow, so active=false may have
195
+ // fired its didSet while feedViewController was still nil. Apply now.
196
+ if isActiveManagedByProp && !active, let feedVC = feedViewController {
197
+ feedVC.deactivate()
198
+ }
158
199
  }
159
200
 
160
201
  /// Detach the feedVC from the parent VC hierarchy without destroying it.
@@ -162,15 +203,20 @@ import ShortKitSDK
162
203
  /// (e.g. pushing a new screen on top). The feedVC and its state are preserved
163
204
  /// so they can be re-attached when the view returns to the window.
164
205
  private func suspendFeedViewController() {
206
+ NSLog("[ShortKit FeedView] suspendFeedViewController ENTRY feedId=%@", feedId ?? "nil")
165
207
  if let feedId = self.feedId {
166
208
  ShortKitBridge.shared?.unregisterFeed(id: feedId)
167
209
  }
168
- guard let feedVC = feedViewController else { return }
210
+ guard let feedVC = feedViewController else {
211
+ NSLog("[ShortKit FeedView] suspendFeedViewController NOOP — no feedVC")
212
+ return
213
+ }
169
214
 
170
215
  feedVC.deactivate()
171
216
  feedVC.willMove(toParent: nil)
172
217
  feedVC.view.removeFromSuperview()
173
218
  feedVC.removeFromParent()
219
+ NSLog("[ShortKit FeedView] suspendFeedViewController EXIT — VC retained for re-attach")
174
220
  // Keep feedViewController reference — re-attached in embedFeedViewControllerIfNeeded
175
221
  }
176
222
 
@@ -27,5 +27,7 @@ RCT_EXPORT_VIEW_PROPERTY(startAtItemId, NSString)
27
27
  RCT_EXPORT_VIEW_PROPERTY(preloadId, NSString)
28
28
  RCT_EXPORT_VIEW_PROPERTY(feedId, NSString)
29
29
  RCT_EXPORT_VIEW_PROPERTY(seedThumbnailUrl, NSString)
30
+ RCT_EXPORT_VIEW_PROPERTY(feedItemsJSON, NSString)
31
+ RCT_EXPORT_VIEW_PROPERTY(active, BOOL)
30
32
 
31
33
  @end
@@ -71,7 +71,9 @@ RCT_EXPORT_MODULE(ShortKitModule)
71
71
  @"onContentTapped",
72
72
  @"onDismiss",
73
73
  @"onFeedReady",
74
+ @"onVideoCarouselCellTap",
74
75
  @"onRefreshStateChanged",
76
+ @"onRefreshStateChangedPerFeed",
75
77
  @"onDidFetchContentItems",
76
78
  @"onOverlayActiveChanged",
77
79
  @"onOverlayPlayerStateChanged",
@@ -256,17 +258,25 @@ RCT_EXPORT_METHOD(setMaxBitrate:(double)bitrate) {
256
258
 
257
259
  // MARK: - Custom Feed
258
260
 
259
- RCT_EXPORT_METHOD(setFeedItems:(NSString *)feedId items:(NSString *)items) {
261
+ RCT_EXPORT_METHOD(setFeedItems:(NSString *)feedId
262
+ items:(NSString *)json
263
+ startAtId:(NSString *)startAtId) {
260
264
  if (_shortKitBridge) {
261
- [_shortKitBridge setFeedItems:feedId items:items];
265
+ [_shortKitBridge setFeedItems:feedId items:json startAtId:startAtId];
262
266
  } else {
263
267
  if (!_pendingBridgeOps) _pendingBridgeOps = [NSMutableArray new];
264
268
  [_pendingBridgeOps addObject:^{
265
- [self->_shortKitBridge setFeedItems:feedId items:items];
269
+ [self->_shortKitBridge setFeedItems:feedId items:json startAtId:startAtId];
266
270
  }];
267
271
  }
268
272
  }
269
273
 
274
+ RCT_EXPORT_METHOD(scrollFeedToItem:(NSString *)feedId
275
+ id:(NSString *)itemId
276
+ animated:(BOOL)animated) {
277
+ [_shortKitBridge scrollFeedToItem:feedId id:itemId animated:animated];
278
+ }
279
+
270
280
  RCT_EXPORT_METHOD(appendFeedItems:(NSString *)feedId items:(NSString *)items) {
271
281
  if (_shortKitBridge) {
272
282
  [_shortKitBridge appendFeedItems:feedId items:items];
@@ -8,32 +8,32 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>ShortKitSDK.framework/ShortKitSDK</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64</string>
11
+ <string>ios-arm64_x86_64-simulator</string>
12
12
  <key>LibraryPath</key>
13
13
  <string>ShortKitSDK.framework</string>
14
14
  <key>SupportedArchitectures</key>
15
15
  <array>
16
16
  <string>arm64</string>
17
+ <string>x86_64</string>
17
18
  </array>
18
19
  <key>SupportedPlatform</key>
19
20
  <string>ios</string>
21
+ <key>SupportedPlatformVariant</key>
22
+ <string>simulator</string>
20
23
  </dict>
21
24
  <dict>
22
25
  <key>BinaryPath</key>
23
26
  <string>ShortKitSDK.framework/ShortKitSDK</string>
24
27
  <key>LibraryIdentifier</key>
25
- <string>ios-arm64_x86_64-simulator</string>
28
+ <string>ios-arm64</string>
26
29
  <key>LibraryPath</key>
27
30
  <string>ShortKitSDK.framework</string>
28
31
  <key>SupportedArchitectures</key>
29
32
  <array>
30
33
  <string>arm64</string>
31
- <string>x86_64</string>
32
34
  </array>
33
35
  <key>SupportedPlatform</key>
34
36
  <string>ios</string>
35
- <key>SupportedPlatformVariant</key>
36
- <string>simulator</string>
37
37
  </dict>
38
38
  </array>
39
39
  <key>CFBundlePackageType</key>
@@ -11,9 +11,9 @@
11
11
  <key>CFBundlePackageType</key>
12
12
  <string>FMWK</string>
13
13
  <key>CFBundleVersion</key>
14
- <string>0.2.25</string>
14
+ <string>0.2.26</string>
15
15
  <key>CFBundleShortVersionString</key>
16
- <string>0.2.25</string>
16
+ <string>0.2.26</string>
17
17
  <key>MinimumOSVersion</key>
18
18
  <string>16.0</string>
19
19
  </dict>