react-native-nitro-modules 0.32.1 → 0.33.0
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/src/main/java/com/margelo/nitro/views/HybridView.kt +1 -8
- package/android/src/main/java/com/margelo/nitro/views/RecyclableView.kt +15 -0
- package/android/src/main/res/values/ids.xml +4 -0
- package/cpp/jsi/JSICache.cpp +1 -0
- package/cpp/utils/NitroDefines.hpp +1 -1
- package/cpp/utils/PropNameIDCache.cpp +5 -1
- package/ios/views/HybridView.swift +2 -1
- package/ios/views/RecyclableView.swift +20 -0
- package/package.json +1 -1
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
package com.margelo.nitro.views
|
|
2
2
|
|
|
3
3
|
import android.view.View
|
|
4
|
-
import androidx.annotation.Keep
|
|
5
|
-
import com.facebook.jni.HybridData
|
|
6
|
-
import com.facebook.proguard.annotations.DoNotStrip
|
|
7
4
|
import com.margelo.nitro.core.HybridObject
|
|
8
5
|
|
|
9
6
|
/**
|
|
10
7
|
* A base class for all Kotlin-based Hybrid Views.
|
|
11
8
|
*/
|
|
12
|
-
@Keep
|
|
13
|
-
@DoNotStrip
|
|
14
9
|
abstract class HybridView : HybridObject() {
|
|
15
10
|
/**
|
|
16
|
-
* Get the `
|
|
11
|
+
* Get the `View` this HybridView is holding.
|
|
17
12
|
*
|
|
18
13
|
* This value should not change during the lifetime of this `HybridView`.
|
|
19
14
|
*/
|
|
20
|
-
@get:DoNotStrip
|
|
21
|
-
@get:Keep
|
|
22
15
|
abstract val view: View
|
|
23
16
|
|
|
24
17
|
/**
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
package com.margelo.nitro.views
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A `HybridView` that can also be recycled.
|
|
5
|
+
*/
|
|
6
|
+
interface RecyclableView {
|
|
7
|
+
/**
|
|
8
|
+
* Called when the view is going to be recycled to
|
|
9
|
+
* be re-used later on with different props.
|
|
10
|
+
*
|
|
11
|
+
* This is a good place to reset any internal state
|
|
12
|
+
* to it's default value.
|
|
13
|
+
*/
|
|
14
|
+
fun prepareForRecycle()
|
|
15
|
+
}
|
package/cpp/jsi/JSICache.cpp
CHANGED
|
@@ -20,7 +20,11 @@ const jsi::PropNameID& PropNameIDCache::get(jsi::Runtime& runtime, const std::st
|
|
|
20
20
|
if (cachedName != cache.end()) {
|
|
21
21
|
// cache warm!
|
|
22
22
|
const BorrowingReference<jsi::PropNameID>& value = cachedName->second;
|
|
23
|
-
|
|
23
|
+
if (value != nullptr) {
|
|
24
|
+
// Reference is still alive - return it.
|
|
25
|
+
return *value;
|
|
26
|
+
}
|
|
27
|
+
// Reference is dead (e.g. runtime was recreated), re-create it.
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
// not cached - create the jsi::PropNameID...
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
/// A base protocol for all Swift-based Hybrid Views.
|
|
14
14
|
public protocol HybridView: HybridObject {
|
|
15
|
+
associatedtype ViewType: UIView
|
|
15
16
|
/**
|
|
16
17
|
* Get the ``UIView`` this HybridView is holding.
|
|
17
18
|
*
|
|
18
19
|
* This value should not change during the lifetime of this ``HybridView``.
|
|
19
20
|
*/
|
|
20
|
-
var view:
|
|
21
|
+
var view: ViewType { get }
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Called right before updating props.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RecyclableView.swift
|
|
3
|
+
// NitroModules
|
|
4
|
+
//
|
|
5
|
+
// Created by Marc Rousavy on 13.01.25.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
/// A `HybridView` that can also be recycled.
|
|
11
|
+
public protocol RecyclableView {
|
|
12
|
+
/**
|
|
13
|
+
* Called when the view is going to be recycled to
|
|
14
|
+
* be re-used later on with different props.
|
|
15
|
+
*
|
|
16
|
+
* This is a good place to reset any internal state
|
|
17
|
+
* to it's default value.
|
|
18
|
+
*/
|
|
19
|
+
func prepareForRecycle()
|
|
20
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-modules",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|