@digia-engage/core 2.2.1 → 2.3.1
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/DigiaEngageReactNative.podspec +1 -1
- package/LICENSE +77 -0
- package/README.md +1 -1
- package/lib/commonjs/Digia.js +1 -1
- package/lib/commonjs/DigiaAnchorView.js +42 -25
- package/lib/commonjs/DigiaAnchorView.js.map +1 -1
- package/lib/commonjs/DigiaHealthReporter.js +1 -1
- package/lib/commonjs/DigiaProvider.js +38 -6
- package/lib/commonjs/DigiaProvider.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/Digia.js +1 -1
- package/lib/module/DigiaAnchorView.js +42 -25
- package/lib/module/DigiaAnchorView.js.map +1 -1
- package/lib/module/DigiaHealthReporter.js +1 -1
- package/lib/module/DigiaProvider.js +38 -6
- package/lib/module/DigiaProvider.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/DigiaAnchorView.d.ts +17 -1
- package/lib/typescript/DigiaAnchorView.d.ts.map +1 -1
- package/lib/typescript/DigiaProvider.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/templateTypes.d.ts +2 -0
- package/lib/typescript/templateTypes.d.ts.map +1 -1
- package/package.json +2 -8
- package/src/Digia.ts +1 -1
- package/src/DigiaAnchorView.tsx +74 -41
- package/src/DigiaHealthReporter.ts +1 -1
- package/src/DigiaProvider.tsx +36 -6
- package/src/index.ts +1 -0
- package/src/templateTypes.ts +2 -0
- package/android/.project +0 -28
- package/android/bin/.gradle/8.13/fileHashes/fileHashes.lock +0 -0
- package/android/bin/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/bin/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/bin/.project +0 -34
- package/android/bin/build/generated/source/buildConfig/debug/com/digia/engage/rn/BuildConfig.class +0 -0
- package/android/bin/build/generated/source/codegen/java/com/digia/engage/rn/NativeDigiaEngageSpec.class +0 -0
- package/android/bin/build.gradle +0 -97
- package/android/bin/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/bin/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/bin/gradle.properties +0 -2
- package/android/bin/gradlew +0 -185
- package/android/bin/gradlew.bat +0 -89
- package/android/bin/local.properties +0 -1
- package/android/bin/settings.gradle +0 -25
- package/android/bin/src/main/AndroidManifest.xml +0 -2
- package/android/bin/src/main/java/com/digia/engage/rn/DigiaAnchorViewManager.kt +0 -90
- package/android/bin/src/main/java/com/digia/engage/rn/DigiaModule.kt +0 -309
- package/android/bin/src/main/java/com/digia/engage/rn/DigiaPackage.kt +0 -70
- package/android/bin/src/main/java/com/digia/engage/rn/DigiaSlotViewManager.kt +0 -183
- package/android/bin/src/main/java/com/digia/engage/rn/DigiaViewManager.kt +0 -64
- package/android/local.properties +0 -1
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
package com.digia.engage.rn
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import android.view.View
|
|
5
|
-
import android.view.ViewTreeObserver
|
|
6
|
-
import android.widget.FrameLayout
|
|
7
|
-
import androidx.lifecycle.LifecycleOwner
|
|
8
|
-
import androidx.lifecycle.ViewModelStoreOwner
|
|
9
|
-
import androidx.lifecycle.setViewTreeLifecycleOwner
|
|
10
|
-
import androidx.lifecycle.setViewTreeViewModelStoreOwner
|
|
11
|
-
import androidx.savedstate.SavedStateRegistryOwner
|
|
12
|
-
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
|
13
|
-
import com.digia.engage.DigiaSlotView
|
|
14
|
-
import com.facebook.react.bridge.Arguments
|
|
15
|
-
import com.facebook.react.bridge.WritableMap
|
|
16
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
17
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
18
|
-
import com.facebook.react.uimanager.UIManagerHelper
|
|
19
|
-
import com.facebook.react.uimanager.annotations.ReactProp
|
|
20
|
-
import com.facebook.react.uimanager.events.Event
|
|
21
|
-
import java.util.concurrent.atomic.AtomicInteger
|
|
22
|
-
|
|
23
|
-
// ── ContentSizeChangeEvent ────────────────────────────────────────────────────
|
|
24
|
-
|
|
25
|
-
private class ContentSizeChangeEvent(
|
|
26
|
-
surfaceId: Int,
|
|
27
|
-
viewTag: Int,
|
|
28
|
-
private val heightDp: Double,
|
|
29
|
-
private val widthDp: Double,
|
|
30
|
-
) : Event<ContentSizeChangeEvent>(surfaceId, viewTag) {
|
|
31
|
-
override fun getEventName(): String = "onContentSizeChange"
|
|
32
|
-
override fun getEventData(): WritableMap =
|
|
33
|
-
Arguments.createMap().apply {
|
|
34
|
-
putDouble("height", heightDp)
|
|
35
|
-
putDouble("width", widthDp)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ── DigiaSlotContainerView ────────────────────────────────────────────────────
|
|
40
|
-
|
|
41
|
-
// Plain FrameLayout wrapper: Fabric can measure it before window attachment.
|
|
42
|
-
// The inner DigiaSlotView (ComposeView) is created lazily in onAttachedToWindow.
|
|
43
|
-
internal class DigiaSlotContainerView(context: Context) : FrameLayout(context) {
|
|
44
|
-
|
|
45
|
-
var rnContext: ThemedReactContext? = null
|
|
46
|
-
|
|
47
|
-
private var _slotView: DigiaSlotView? = null
|
|
48
|
-
private val lastReportedHeightPx = AtomicInteger(-1)
|
|
49
|
-
|
|
50
|
-
var placementKey: String = ""
|
|
51
|
-
set(value) {
|
|
52
|
-
field = value
|
|
53
|
-
val slot = _slotView ?: return
|
|
54
|
-
slot.placementKey = value
|
|
55
|
-
lastReportedHeightPx.set(-1)
|
|
56
|
-
// Defer measure so the slot has a non-zero width. Do NOT call requestLayout() here —
|
|
57
|
-
// it sets PFLAG_FORCE_LAYOUT on the container and RN bypasses a full traversal,
|
|
58
|
-
// causing subsequent Compose requestLayout() calls to be swallowed.
|
|
59
|
-
post { measureAndDispatch() }
|
|
60
|
-
postDelayed({
|
|
61
|
-
lastReportedHeightPx.set(-1)
|
|
62
|
-
measureAndDispatch()
|
|
63
|
-
}, DELAYED_MEASURE_MS)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private val globalLayoutListener = ViewTreeObserver.OnGlobalLayoutListener {
|
|
67
|
-
measureAndDispatch()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// preDrawListener catches Compose content changes that globalLayoutListener misses in RN's
|
|
71
|
-
// layout model: Compose's invalidate() propagates to ViewRootImpl even when requestLayout()
|
|
72
|
-
// is blocked by PFLAG_FORCE_LAYOUT.
|
|
73
|
-
private val preDrawListener = ViewTreeObserver.OnPreDrawListener {
|
|
74
|
-
measureAndDispatch()
|
|
75
|
-
true
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
override fun onAttachedToWindow() {
|
|
79
|
-
super.onAttachedToWindow()
|
|
80
|
-
if (_slotView == null) createSlotView()
|
|
81
|
-
viewTreeObserver.addOnGlobalLayoutListener(globalLayoutListener)
|
|
82
|
-
viewTreeObserver.addOnPreDrawListener(preDrawListener)
|
|
83
|
-
post { measureAndDispatch() }
|
|
84
|
-
// Retry: catches campaigns that arrive slightly after mount.
|
|
85
|
-
postDelayed({
|
|
86
|
-
if (lastReportedHeightPx.get() <= 0) {
|
|
87
|
-
lastReportedHeightPx.set(-1)
|
|
88
|
-
measureAndDispatch()
|
|
89
|
-
}
|
|
90
|
-
}, DELAYED_MEASURE_MS)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
override fun onDetachedFromWindow() {
|
|
94
|
-
viewTreeObserver.removeOnGlobalLayoutListener(globalLayoutListener)
|
|
95
|
-
viewTreeObserver.removeOnPreDrawListener(preDrawListener)
|
|
96
|
-
super.onDetachedFromWindow()
|
|
97
|
-
lastReportedHeightPx.set(-1)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Defer measureAndDispatch to avoid re-measuring during Compose's composition phase,
|
|
101
|
-
// which crashes with "pending composition has not been applied".
|
|
102
|
-
override fun requestLayout() {
|
|
103
|
-
super.requestLayout()
|
|
104
|
-
post { measureAndDispatch() }
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private fun createSlotView() {
|
|
108
|
-
val themedCtx = context as? ThemedReactContext
|
|
109
|
-
val activityCtx: Context = themedCtx?.currentActivity ?: context
|
|
110
|
-
|
|
111
|
-
val slot = DigiaSlotView(activityCtx)
|
|
112
|
-
|
|
113
|
-
val activity = themedCtx?.currentActivity
|
|
114
|
-
if (activity is LifecycleOwner) slot.setViewTreeLifecycleOwner(activity)
|
|
115
|
-
if (activity is ViewModelStoreOwner) slot.setViewTreeViewModelStoreOwner(activity)
|
|
116
|
-
if (activity is SavedStateRegistryOwner) slot.setViewTreeSavedStateRegistryOwner(activity)
|
|
117
|
-
|
|
118
|
-
slot.placementKey = placementKey
|
|
119
|
-
slot.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
|
|
120
|
-
slot.addOnLayoutChangeListener { _: View, l: Int, _: Int, r: Int, _: Int,
|
|
121
|
-
_: Int, _: Int, _: Int, _: Int ->
|
|
122
|
-
if (r - l > 0) measureAndDispatch()
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
addView(slot)
|
|
126
|
-
_slotView = slot
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
fun measureAndDispatch() {
|
|
130
|
-
val slot = _slotView ?: return
|
|
131
|
-
val ctx = rnContext ?: return
|
|
132
|
-
val viewWidth = width
|
|
133
|
-
if (viewWidth <= 0) return
|
|
134
|
-
|
|
135
|
-
val widthSpec = MeasureSpec.makeMeasureSpec(viewWidth, MeasureSpec.EXACTLY)
|
|
136
|
-
val heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
|
|
137
|
-
slot.measure(widthSpec, heightSpec)
|
|
138
|
-
val intrinsicHeightPx = slot.measuredHeight
|
|
139
|
-
|
|
140
|
-
if (intrinsicHeightPx == lastReportedHeightPx.get()) return
|
|
141
|
-
lastReportedHeightPx.set(intrinsicHeightPx)
|
|
142
|
-
|
|
143
|
-
val density = resources.displayMetrics.density
|
|
144
|
-
val heightDp = intrinsicHeightPx / density
|
|
145
|
-
|
|
146
|
-
val dispatcher = UIManagerHelper.getEventDispatcherForReactTag(ctx, id) ?: return
|
|
147
|
-
val surfaceId = UIManagerHelper.getSurfaceId(this)
|
|
148
|
-
dispatcher.dispatchEvent(ContentSizeChangeEvent(surfaceId, id, heightDp.toDouble(), 0.0))
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
companion object {
|
|
152
|
-
private const val DELAYED_MEASURE_MS = 300L
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// ── DigiaSlotViewManager ──────────────────────────────────────────────────────
|
|
157
|
-
|
|
158
|
-
internal class DigiaSlotViewManager : SimpleViewManager<DigiaSlotContainerView>() {
|
|
159
|
-
|
|
160
|
-
override fun getName(): String = VIEW_NAME
|
|
161
|
-
|
|
162
|
-
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any> =
|
|
163
|
-
mapOf("onContentSizeChange" to mapOf("registrationName" to "onContentSizeChange"))
|
|
164
|
-
|
|
165
|
-
override fun createViewInstance(context: ThemedReactContext): DigiaSlotContainerView {
|
|
166
|
-
val container = DigiaSlotContainerView(context)
|
|
167
|
-
container.rnContext = context
|
|
168
|
-
container.layoutParams = FrameLayout.LayoutParams(
|
|
169
|
-
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
170
|
-
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
171
|
-
)
|
|
172
|
-
return container
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
@ReactProp(name = "placementKey")
|
|
176
|
-
fun setPlacementKey(view: DigiaSlotContainerView, placementKey: String?) {
|
|
177
|
-
view.placementKey = placementKey.orEmpty()
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
companion object {
|
|
181
|
-
const val VIEW_NAME = "DigiaSlotView"
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DigiaViewManager
|
|
3
|
-
*
|
|
4
|
-
* React Native ViewManager that exposes `DigiaHostView` (from the Digia Android SDK) as the native
|
|
5
|
-
* view behind the JS `<DigiaHostView>` component.
|
|
6
|
-
*
|
|
7
|
-
* The view hosts the `DigiaHost` composable which manages dialog and bottom-sheet overlays driven
|
|
8
|
-
* by Digia CEP plugins.
|
|
9
|
-
*/
|
|
10
|
-
package com.digia.engage.rn
|
|
11
|
-
|
|
12
|
-
import android.content.Context
|
|
13
|
-
import android.widget.FrameLayout
|
|
14
|
-
import androidx.lifecycle.LifecycleOwner
|
|
15
|
-
import androidx.lifecycle.ViewModelStoreOwner
|
|
16
|
-
import androidx.lifecycle.setViewTreeLifecycleOwner
|
|
17
|
-
import androidx.lifecycle.setViewTreeViewModelStoreOwner
|
|
18
|
-
import androidx.savedstate.SavedStateRegistryOwner
|
|
19
|
-
import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
|
20
|
-
import com.digia.engage.DigiaHostView
|
|
21
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
22
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
23
|
-
|
|
24
|
-
internal class DigiaViewManager : SimpleViewManager<DigiaHostView>() {
|
|
25
|
-
|
|
26
|
-
override fun getName(): String = VIEW_NAME
|
|
27
|
-
|
|
28
|
-
override fun createViewInstance(context: ThemedReactContext): DigiaHostView {
|
|
29
|
-
// Prefer the current Activity as the context provider so that the Compose
|
|
30
|
-
// runtime can access a proper LifecycleOwner / ViewModelStoreOwner.
|
|
31
|
-
val activityContext: Context = context.currentActivity ?: context
|
|
32
|
-
|
|
33
|
-
val view = DigiaHostView(activityContext)
|
|
34
|
-
|
|
35
|
-
// Explicitly wire the Android Architecture Component owners so that the
|
|
36
|
-
// Compose runtime (which uses ViewTree* APIs) works correctly regardless
|
|
37
|
-
// of React Native's internal view hierarchy wiring.
|
|
38
|
-
val activity = context.currentActivity
|
|
39
|
-
if (activity is LifecycleOwner) {
|
|
40
|
-
view.setViewTreeLifecycleOwner(activity)
|
|
41
|
-
}
|
|
42
|
-
if (activity is ViewModelStoreOwner) {
|
|
43
|
-
view.setViewTreeViewModelStoreOwner(activity)
|
|
44
|
-
}
|
|
45
|
-
if (activity is SavedStateRegistryOwner) {
|
|
46
|
-
view.setViewTreeSavedStateRegistryOwner(activity)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// React Native controls sizing via its layout system; fill whatever space
|
|
50
|
-
// the JS stylesheet allocates (typically StyleSheet.absoluteFill).
|
|
51
|
-
view.layoutParams =
|
|
52
|
-
FrameLayout.LayoutParams(
|
|
53
|
-
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
54
|
-
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
android.util.Log.d("DigiaHost", "[DigiaViewManager] RN-side NativeDigiaHostView instance created (id=${view.id})")
|
|
58
|
-
return view
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
companion object {
|
|
62
|
-
const val VIEW_NAME = "DigiaHostView"
|
|
63
|
-
}
|
|
64
|
-
}
|
package/android/local.properties
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
sdk.dir=/Users/ram/Library/Android/sdk
|