@shortkitsdk/react-native 0.2.25 → 0.2.27
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/ios/ShortKitBridge.swift +42 -4
- package/ios/ShortKitFeedView.swift +56 -4
- package/ios/ShortKitFeedViewManager.mm +2 -0
- package/ios/ShortKitModule.mm +13 -3
- 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 +1953 -218
- package/ios/ShortKitSDK.xcframework/ios-arm64/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +51 -6
- 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 +51 -6
- 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 +1953 -218
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +51 -6
- 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 +51 -6
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1953 -218
- package/ios/ShortKitSDK.xcframework/ios-arm64_x86_64-simulator/ShortKitSDK.framework/Modules/ShortKitSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +51 -6
- 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 +51 -6
- 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/package.json +1 -1
- package/src/ShortKitFeed.tsx +42 -3
- package/src/ShortKitProvider.tsx +2 -1
- package/src/specs/NativeShortKitModule.ts +17 -1
- package/src/specs/ShortKitFeedViewNativeComponent.ts +3 -0
- package/src/types.ts +58 -2
|
Binary file
|
package/ios/ShortKitBridge.swift
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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,18 @@ import ShortKitSDK
|
|
|
155
190
|
feedVC.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
156
191
|
addSubview(feedVC.view)
|
|
157
192
|
feedVC.didMove(toParent: parentVC)
|
|
193
|
+
|
|
194
|
+
// With FVC.viewDidAppear no longer self-claiming for bridge-managed
|
|
195
|
+
// surfaces, the bridge is the sole authority on claim timing. Mirror
|
|
196
|
+
// the reattach path: explicitly activate iff the RN `active` prop
|
|
197
|
+
// is true. If the prop is false (e.g. user is on a different tab
|
|
198
|
+
// while this FVC was created to handle a delayed API response), the
|
|
199
|
+
// FVC stays idle — no claim, no pool mutation, no hijack. A later
|
|
200
|
+
// prop change to active=true triggers `feedVC.activate()` via the
|
|
201
|
+
// prop's didSet.
|
|
202
|
+
if active {
|
|
203
|
+
feedVC.activate()
|
|
204
|
+
}
|
|
158
205
|
}
|
|
159
206
|
|
|
160
207
|
/// Detach the feedVC from the parent VC hierarchy without destroying it.
|
|
@@ -162,15 +209,20 @@ import ShortKitSDK
|
|
|
162
209
|
/// (e.g. pushing a new screen on top). The feedVC and its state are preserved
|
|
163
210
|
/// so they can be re-attached when the view returns to the window.
|
|
164
211
|
private func suspendFeedViewController() {
|
|
212
|
+
NSLog("[ShortKit FeedView] suspendFeedViewController ENTRY feedId=%@", feedId ?? "nil")
|
|
165
213
|
if let feedId = self.feedId {
|
|
166
214
|
ShortKitBridge.shared?.unregisterFeed(id: feedId)
|
|
167
215
|
}
|
|
168
|
-
guard let feedVC = feedViewController else {
|
|
216
|
+
guard let feedVC = feedViewController else {
|
|
217
|
+
NSLog("[ShortKit FeedView] suspendFeedViewController NOOP — no feedVC")
|
|
218
|
+
return
|
|
219
|
+
}
|
|
169
220
|
|
|
170
221
|
feedVC.deactivate()
|
|
171
222
|
feedVC.willMove(toParent: nil)
|
|
172
223
|
feedVC.view.removeFromSuperview()
|
|
173
224
|
feedVC.removeFromParent()
|
|
225
|
+
NSLog("[ShortKit FeedView] suspendFeedViewController EXIT — VC retained for re-attach")
|
|
174
226
|
// Keep feedViewController reference — re-attached in embedFeedViewControllerIfNeeded
|
|
175
227
|
}
|
|
176
228
|
|
|
@@ -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
|
package/ios/ShortKitModule.mm
CHANGED
|
@@ -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
|
|
261
|
+
RCT_EXPORT_METHOD(setFeedItems:(NSString *)feedId
|
|
262
|
+
items:(NSString *)json
|
|
263
|
+
startAtId:(NSString *)startAtId) {
|
|
260
264
|
if (_shortKitBridge) {
|
|
261
|
-
[_shortKitBridge setFeedItems:feedId 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:
|
|
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];
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
<key>CFBundlePackageType</key>
|
|
12
12
|
<string>FMWK</string>
|
|
13
13
|
<key>CFBundleVersion</key>
|
|
14
|
-
<string>0.2.
|
|
14
|
+
<string>0.2.27</string>
|
|
15
15
|
<key>CFBundleShortVersionString</key>
|
|
16
|
-
<string>0.2.
|
|
16
|
+
<string>0.2.27</string>
|
|
17
17
|
<key>MinimumOSVersion</key>
|
|
18
18
|
<string>16.0</string>
|
|
19
19
|
</dict>
|