@mobileai/react-native 0.9.18 → 0.9.19
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/LICENSE +28 -20
- package/MobileAIFloatingOverlay.podspec +25 -0
- package/android/build.gradle +61 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/mobileai/overlay/FloatingOverlayView.kt +151 -0
- package/android/src/main/java/com/mobileai/overlay/MobileAIOverlayPackage.kt +23 -0
- package/android/src/newarch/com/mobileai/overlay/FloatingOverlayViewManager.kt +45 -0
- package/android/src/oldarch/com/mobileai/overlay/FloatingOverlayViewManager.kt +29 -0
- package/ios/MobileAIFloatingOverlayComponentView.mm +73 -0
- package/lib/module/components/AIAgent.js +902 -136
- package/lib/module/components/AIConsentDialog.js +439 -0
- package/lib/module/components/AgentChatBar.js +828 -134
- package/lib/module/components/AgentOverlay.js +2 -1
- package/lib/module/components/DiscoveryTooltip.js +21 -9
- package/lib/module/components/FloatingOverlayWrapper.js +108 -0
- package/lib/module/components/Icons.js +123 -0
- package/lib/module/config/endpoints.js +12 -2
- package/lib/module/core/AgentRuntime.js +373 -27
- package/lib/module/core/FiberAdapter.js +56 -0
- package/lib/module/core/FiberTreeWalker.js +186 -80
- package/lib/module/core/IdleDetector.js +19 -0
- package/lib/module/core/NativeAlertInterceptor.js +191 -0
- package/lib/module/core/systemPrompt.js +203 -45
- package/lib/module/index.js +3 -0
- package/lib/module/providers/GeminiProvider.js +72 -56
- package/lib/module/providers/ProviderFactory.js +6 -2
- package/lib/module/services/AudioInputService.js +3 -12
- package/lib/module/services/AudioOutputService.js +1 -13
- package/lib/module/services/ConversationService.js +166 -0
- package/lib/module/services/MobileAIKnowledgeRetriever.js +41 -0
- package/lib/module/services/VoiceService.js +29 -8
- package/lib/module/services/telemetry/MobileAI.js +44 -0
- package/lib/module/services/telemetry/TelemetryService.js +13 -1
- package/lib/module/services/telemetry/TouchAutoCapture.js +44 -18
- package/lib/module/specs/FloatingOverlayNativeComponent.ts +19 -0
- package/lib/module/support/CSATSurvey.js +95 -12
- package/lib/module/support/EscalationSocket.js +70 -1
- package/lib/module/support/ReportedIssueEventSource.js +148 -0
- package/lib/module/support/escalateTool.js +4 -2
- package/lib/module/support/index.js +1 -0
- package/lib/module/support/reportIssueTool.js +127 -0
- package/lib/module/support/supportPrompt.js +77 -9
- package/lib/module/tools/guideTool.js +2 -1
- package/lib/module/tools/longPressTool.js +4 -3
- package/lib/module/tools/pickerTool.js +6 -4
- package/lib/module/tools/tapTool.js +12 -3
- package/lib/module/tools/typeTool.js +19 -10
- package/lib/module/utils/logger.js +175 -6
- package/lib/typescript/react-native.config.d.ts +11 -0
- package/lib/typescript/src/components/AIAgent.d.ts +28 -2
- package/lib/typescript/src/components/AIConsentDialog.d.ts +153 -0
- package/lib/typescript/src/components/AgentChatBar.d.ts +15 -2
- package/lib/typescript/src/components/DiscoveryTooltip.d.ts +3 -1
- package/lib/typescript/src/components/FloatingOverlayWrapper.d.ts +51 -0
- package/lib/typescript/src/components/Icons.d.ts +8 -0
- package/lib/typescript/src/config/endpoints.d.ts +5 -3
- package/lib/typescript/src/core/AgentRuntime.d.ts +4 -0
- package/lib/typescript/src/core/FiberAdapter.d.ts +25 -0
- package/lib/typescript/src/core/FiberTreeWalker.d.ts +2 -0
- package/lib/typescript/src/core/IdleDetector.d.ts +11 -0
- package/lib/typescript/src/core/NativeAlertInterceptor.d.ts +55 -0
- package/lib/typescript/src/core/types.d.ts +106 -1
- package/lib/typescript/src/index.d.ts +9 -4
- package/lib/typescript/src/providers/GeminiProvider.d.ts +6 -5
- package/lib/typescript/src/services/ConversationService.d.ts +55 -0
- package/lib/typescript/src/services/MobileAIKnowledgeRetriever.d.ts +9 -0
- package/lib/typescript/src/services/telemetry/MobileAI.d.ts +7 -0
- package/lib/typescript/src/services/telemetry/TelemetryService.d.ts +1 -1
- package/lib/typescript/src/services/telemetry/TouchAutoCapture.d.ts +9 -6
- package/lib/typescript/src/services/telemetry/types.d.ts +3 -1
- package/lib/typescript/src/specs/FloatingOverlayNativeComponent.d.ts +17 -0
- package/lib/typescript/src/support/EscalationSocket.d.ts +17 -0
- package/lib/typescript/src/support/ReportedIssueEventSource.d.ts +24 -0
- package/lib/typescript/src/support/escalateTool.d.ts +5 -0
- package/lib/typescript/src/support/index.d.ts +2 -1
- package/lib/typescript/src/support/reportIssueTool.d.ts +20 -0
- package/lib/typescript/src/support/types.d.ts +56 -1
- package/lib/typescript/src/utils/logger.d.ts +15 -0
- package/package.json +19 -5
- package/react-native.config.js +12 -0
package/LICENSE
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Mohamed Salah
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
MobileAI Agent SDK License Agreement
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohamed Salah. All rights reserved.
|
|
4
|
+
|
|
5
|
+
END USER LICENSE AGREEMENT
|
|
6
|
+
|
|
7
|
+
IMPORTANT - READ CAREFULLY: This End User License Agreement ("EULA") is a legal agreement between you (either an individual or a single entity) and Mohamed Salah ("Licensor") for the MobileAI Agent SDK software product, which includes computer software and may include associated media, printed materials, and "online" or electronic documentation ("SOFTWARE PRODUCT"). By installing, copying, or otherwise using the SOFTWARE PRODUCT, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, do not install or use the SOFTWARE PRODUCT.
|
|
8
|
+
|
|
9
|
+
1. GRANT OF LICENSE.
|
|
10
|
+
Licensor grants you a non-exclusive, non-transferable, limited license to use the SOFTWARE PRODUCT solely for the purpose of integrating it into your application(s) that interconnect with the MobileAI online services, in accordance with the provided documentation and subject to your continued payment of applicable subscription or usage fees for the MobileAI services.
|
|
11
|
+
|
|
12
|
+
2. RESTRICTIONS.
|
|
13
|
+
- You may NOT modify, translate, reverse engineer, decompile, disassemble, or create derivative works based on the SOFTWARE PRODUCT.
|
|
14
|
+
- You may NOT rent, lease, lend, sell, redistribute, or sublicense the SOFTWARE PRODUCT.
|
|
15
|
+
- You may NOT use the SOFTWARE PRODUCT to develop a competitive service or product.
|
|
16
|
+
- You may NOT remove any proprietary notices or labels on the SOFTWARE PRODUCT.
|
|
17
|
+
|
|
18
|
+
3. COPYRIGHT.
|
|
19
|
+
All title, including but not limited to copyrights, in and to the SOFTWARE PRODUCT and any copies thereof are owned by Licensor or its suppliers. All title and intellectual property rights in and to the content which may be accessed through use of the SOFTWARE PRODUCT is the property of the respective content owner and may be protected by applicable copyright or other intellectual property laws and treaties.
|
|
20
|
+
|
|
21
|
+
4. TERMINATION.
|
|
22
|
+
Without prejudice to any other rights, Licensor may terminate this EULA if you fail to comply with the terms and conditions of this EULA. In such event, you must destroy all copies of the SOFTWARE PRODUCT in your possession.
|
|
23
|
+
|
|
24
|
+
5. NO WARRANTIES.
|
|
25
|
+
The SOFTWARE PRODUCT is provided "as is" without warranty of any kind. Licensor disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose.
|
|
26
|
+
|
|
27
|
+
6. LIMITATION OF LIABILITY.
|
|
28
|
+
In no event shall Licensor be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this SOFTWARE PRODUCT.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "MobileAIFloatingOverlay"
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.homepage = package['homepage'] || "https://github.com/mobileai"
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.authors = package['author']
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "13.0" }
|
|
14
|
+
s.source = { :git => "https://github.com/mobileai/react-native-ai-agent.git", :tag => "#{s.version}" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/MobileAIFloatingOverlayComponentView.{h,m,mm,cpp}"
|
|
17
|
+
|
|
18
|
+
s.pod_target_xcconfig = {
|
|
19
|
+
"DEFINES_MODULE" => "NO",
|
|
20
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
21
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
install_modules_dependencies(s)
|
|
25
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
dependencies {
|
|
8
|
+
classpath "com.android.tools.build:gradle:8.1.0"
|
|
9
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
apply plugin: "com.android.library"
|
|
14
|
+
apply plugin: "kotlin-android"
|
|
15
|
+
|
|
16
|
+
android {
|
|
17
|
+
compileSdkVersion 35
|
|
18
|
+
namespace "com.mobileai.overlay"
|
|
19
|
+
|
|
20
|
+
defaultConfig {
|
|
21
|
+
minSdkVersion 24
|
|
22
|
+
targetSdkVersion 35
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
buildTypes {
|
|
26
|
+
release {
|
|
27
|
+
minifyEnabled false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
compileOptions {
|
|
32
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
33
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
kotlinOptions {
|
|
37
|
+
jvmTarget = "17"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
sourceSets {
|
|
41
|
+
main {
|
|
42
|
+
// Backward compatibility: conditionally load the correct ViewManager implementation.
|
|
43
|
+
// newArchEnabled=true → Fabric (New Architecture, RN 0.74+)
|
|
44
|
+
// newArchEnabled=false → Paper (Old Architecture, <RN 0.74)
|
|
45
|
+
if (project.findProperty("newArchEnabled") == "true") {
|
|
46
|
+
java.srcDirs += ["src/newarch"]
|
|
47
|
+
} else {
|
|
48
|
+
java.srcDirs += ["src/oldarch"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
repositories {
|
|
55
|
+
mavenCentral()
|
|
56
|
+
google()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
dependencies {
|
|
60
|
+
implementation "com.facebook.react:react-android"
|
|
61
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
package com.mobileai.overlay
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.app.Dialog
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.graphics.Color
|
|
7
|
+
import android.graphics.drawable.ColorDrawable
|
|
8
|
+
import android.view.View
|
|
9
|
+
import android.view.ViewGroup
|
|
10
|
+
import android.view.WindowManager
|
|
11
|
+
import android.widget.FrameLayout
|
|
12
|
+
import com.facebook.react.bridge.ReactContext
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* FloatingOverlayView — A ViewGroup that renders its children in an elevated
|
|
16
|
+
* Dialog window using WindowManager.LayoutParams.TYPE_APPLICATION_PANEL.
|
|
17
|
+
*
|
|
18
|
+
* Architecture:
|
|
19
|
+
* TYPE_APPLICATION_PANEL (z=1000) sits above normal app windows (TYPE_APPLICATION, z=2)
|
|
20
|
+
* AND above React Native's <Modal> Dialog windows (also TYPE_APPLICATION), because
|
|
21
|
+
* TYPE_APPLICATION_PANEL explicitly describes a panel that floats above its parent
|
|
22
|
+
* application window. No SYSTEM_ALERT_WINDOW permission required — the panel is
|
|
23
|
+
* scoped to the consuming app's own window hierarchy.
|
|
24
|
+
*
|
|
25
|
+
* Used by both Old Arch (FloatingOverlayViewManager) and New Arch Fabric implementations.
|
|
26
|
+
*/
|
|
27
|
+
class FloatingOverlayView(context: Context) : ViewGroup(context) {
|
|
28
|
+
|
|
29
|
+
private var overlayDialog: Dialog? = null
|
|
30
|
+
|
|
31
|
+
// All RN children are placed in this container inside the Dialog
|
|
32
|
+
private val contentContainer = FrameLayout(context)
|
|
33
|
+
|
|
34
|
+
// ─── Lifecycle ──────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
override fun onAttachedToWindow() {
|
|
37
|
+
super.onAttachedToWindow()
|
|
38
|
+
showOverlay()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override fun onDetachedFromWindow() {
|
|
42
|
+
dismissOverlay()
|
|
43
|
+
super.onDetachedFromWindow()
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ─── Overlay management ──────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
private fun showOverlay() {
|
|
49
|
+
val activity = getActivity() ?: return
|
|
50
|
+
|
|
51
|
+
overlayDialog = Dialog(activity, android.R.style.Theme_Translucent_NoTitleBar).also { dialog ->
|
|
52
|
+
dialog.window?.let { window ->
|
|
53
|
+
// TYPE_APPLICATION_PANEL: sub-window panel above its application window.
|
|
54
|
+
// Requires the parent window's token — no SYSTEM_ALERT_WINDOW needed.
|
|
55
|
+
window.setType(WindowManager.LayoutParams.TYPE_APPLICATION_PANEL)
|
|
56
|
+
|
|
57
|
+
// Anchor to the Activity's root decor view token.
|
|
58
|
+
// This makes our panel a child of the main window,
|
|
59
|
+
// floating above it and above any Dialogs (which are peers of the main window).
|
|
60
|
+
val attrs = window.attributes
|
|
61
|
+
attrs.token = activity.window.decorView.windowToken
|
|
62
|
+
window.attributes = attrs
|
|
63
|
+
|
|
64
|
+
window.setLayout(
|
|
65
|
+
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
66
|
+
ViewGroup.LayoutParams.MATCH_PARENT
|
|
67
|
+
)
|
|
68
|
+
window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
|
69
|
+
|
|
70
|
+
// FLAG_NOT_FOCUSABLE: don't steal keyboard focus from the underlying app.
|
|
71
|
+
// Keyboard inputs (TextInput in the chat bar) still work because
|
|
72
|
+
// the chat bar's own TextInput will request focus explicitly when tapped.
|
|
73
|
+
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
|
74
|
+
|
|
75
|
+
// FLAG_NOT_TOUCH_MODAL: allow touches outside our visible UI to reach the
|
|
76
|
+
// underlying app / dialog windows. Without this, any touch on the transparent
|
|
77
|
+
// areas of our overlay would be consumed and swallowed.
|
|
78
|
+
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL)
|
|
79
|
+
|
|
80
|
+
window.addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
dialog.setContentView(contentContainer)
|
|
84
|
+
dialog.setCanceledOnTouchOutside(false)
|
|
85
|
+
dialog.show()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private fun dismissOverlay() {
|
|
90
|
+
try {
|
|
91
|
+
if (overlayDialog?.isShowing == true) {
|
|
92
|
+
overlayDialog?.dismiss()
|
|
93
|
+
}
|
|
94
|
+
} catch (e: Exception) {
|
|
95
|
+
// Activity may already be finishing — safe to ignore crash
|
|
96
|
+
} finally {
|
|
97
|
+
overlayDialog = null
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ─── Child view forwarding ───────────────────────────────────
|
|
102
|
+
// React Native's layout engine sees THIS ViewGroup, but actual rendering
|
|
103
|
+
// happens in the Dialog's contentContainer.
|
|
104
|
+
// We forward all child management calls to maintain RN's expectations.
|
|
105
|
+
|
|
106
|
+
override fun addView(child: View) {
|
|
107
|
+
contentContainer.addView(child)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
override fun addView(child: View, index: Int) {
|
|
111
|
+
contentContainer.addView(child, index)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
override fun addView(child: View, params: ViewGroup.LayoutParams) {
|
|
115
|
+
contentContainer.addView(child, params)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams) {
|
|
119
|
+
contentContainer.addView(child, index, params)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
override fun removeView(view: View) {
|
|
123
|
+
contentContainer.removeView(view)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
override fun removeViewAt(index: Int) {
|
|
127
|
+
contentContainer.removeViewAt(index)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
override fun getChildCount(): Int = contentContainer.childCount
|
|
131
|
+
|
|
132
|
+
override fun getChildAt(index: Int): View? = contentContainer.getChildAt(index)
|
|
133
|
+
|
|
134
|
+
// ─── Layout ──────────────────────────────────────────────────
|
|
135
|
+
|
|
136
|
+
// The Dialog manages sizing (MATCH_PARENT) — this View itself is invisible
|
|
137
|
+
// in the main window and only serves as an anchor.
|
|
138
|
+
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) { /* no-op */ }
|
|
139
|
+
|
|
140
|
+
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
141
|
+
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ─── Helpers ─────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
private fun getActivity(): Activity? {
|
|
147
|
+
// ReactContext knows the current Activity
|
|
148
|
+
return (context as? ReactContext)?.currentActivity
|
|
149
|
+
?: (context as? Activity)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package com.mobileai.overlay
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* MobileAIOverlayPackage — registers the FloatingOverlayViewManager with React Native.
|
|
10
|
+
*
|
|
11
|
+
* Auto-linked by React Native's auto-linking system via react-native.config.js.
|
|
12
|
+
* Consumers do NOT need to manually add this package to their MainApplication.
|
|
13
|
+
*/
|
|
14
|
+
class MobileAIOverlayPackage : ReactPackage {
|
|
15
|
+
|
|
16
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
17
|
+
return emptyList()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
21
|
+
return listOf(FloatingOverlayViewManager(reactContext))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package com.mobileai.overlay
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
7
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* New Architecture (Fabric) ViewManager for MobileAIFloatingOverlay.
|
|
11
|
+
*
|
|
12
|
+
* Used when newArchEnabled=true in the consuming app's gradle.properties.
|
|
13
|
+
* Loaded via the newarch/ sourceSet in build.gradle.
|
|
14
|
+
*
|
|
15
|
+
* Codegen generates FloatingOverlayNativeComponentSpec from src/specs/FloatingOverlayNativeComponent.ts.
|
|
16
|
+
* This class implements the generated spec interface for Fabric rendering.
|
|
17
|
+
*/
|
|
18
|
+
class FloatingOverlayViewManager(
|
|
19
|
+
private val reactApplicationContext: ReactApplicationContext
|
|
20
|
+
) : SimpleViewManager<FloatingOverlayView>() {
|
|
21
|
+
|
|
22
|
+
// Fabric: delegate is generated by Codegen. Null until Codegen runs.
|
|
23
|
+
// The interop layer uses this delegate to bridge JS<->Native in New Arch.
|
|
24
|
+
private val delegate: ViewManagerDelegate<FloatingOverlayView>? = try {
|
|
25
|
+
// Codegen generates this class during the build. It may not exist yet in dev setups.
|
|
26
|
+
Class.forName("com.mobileai.overlay.FloatingOverlayNativeComponentSpecDelegate")
|
|
27
|
+
.getConstructor(SimpleViewManager::class.java)
|
|
28
|
+
.newInstance(this) as? ViewManagerDelegate<FloatingOverlayView>
|
|
29
|
+
} catch (e: Exception) {
|
|
30
|
+
// Codegen hasn't run yet or interop is disabled — proceed without delegate
|
|
31
|
+
null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun getDelegate(): ViewManagerDelegate<FloatingOverlayView>? = delegate
|
|
35
|
+
|
|
36
|
+
override fun getName(): String = NAME
|
|
37
|
+
|
|
38
|
+
override fun createViewInstance(context: ThemedReactContext): FloatingOverlayView {
|
|
39
|
+
return FloatingOverlayView(context)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
companion object {
|
|
43
|
+
const val NAME = "MobileAIFloatingOverlay"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.mobileai.overlay
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
5
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Old Architecture (Paper) ViewManager for MobileAIFloatingOverlay.
|
|
9
|
+
*
|
|
10
|
+
* Used when newArchEnabled=false in the consuming app's gradle.properties.
|
|
11
|
+
* Loaded via the oldarch/ sourceSet in build.gradle.
|
|
12
|
+
*
|
|
13
|
+
* Consumers don't interact with this class — it's registered automatically via
|
|
14
|
+
* MobileAIOverlayPackage and the React Native auto-linking system.
|
|
15
|
+
*/
|
|
16
|
+
class FloatingOverlayViewManager(
|
|
17
|
+
private val reactApplicationContext: ReactApplicationContext
|
|
18
|
+
) : SimpleViewManager<FloatingOverlayView>() {
|
|
19
|
+
|
|
20
|
+
override fun getName(): String = NAME
|
|
21
|
+
|
|
22
|
+
override fun createViewInstance(context: ThemedReactContext): FloatingOverlayView {
|
|
23
|
+
return FloatingOverlayView(context)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
companion object {
|
|
27
|
+
const val NAME = "MobileAIFloatingOverlay"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#import <React/RCTViewComponentView.h>
|
|
2
|
+
#import <UIKit/UIKit.h>
|
|
3
|
+
|
|
4
|
+
#import <react/renderer/components/RNMobileAIOverlaySpec/ComponentDescriptors.h>
|
|
5
|
+
#import <react/renderer/components/RNMobileAIOverlaySpec/EventEmitters.h>
|
|
6
|
+
#import <react/renderer/components/RNMobileAIOverlaySpec/Props.h>
|
|
7
|
+
#import <react/renderer/components/RNMobileAIOverlaySpec/RCTComponentViewHelpers.h>
|
|
8
|
+
|
|
9
|
+
#import "RCTFabricComponentsPlugins.h"
|
|
10
|
+
|
|
11
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
+
@interface MobileAIFloatingOverlayComponentView : RCTViewComponentView
|
|
13
|
+
@end
|
|
14
|
+
NS_ASSUME_NONNULL_END
|
|
15
|
+
|
|
16
|
+
using namespace facebook::react;
|
|
17
|
+
|
|
18
|
+
@interface MobileAIFloatingOverlayComponentView () <RCTMobileAIFloatingOverlayViewProtocol>
|
|
19
|
+
@end
|
|
20
|
+
|
|
21
|
+
@implementation MobileAIFloatingOverlayComponentView {
|
|
22
|
+
UIView * _view;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
26
|
+
{
|
|
27
|
+
return concreteComponentDescriptorProvider<MobileAIFloatingOverlayComponentDescriptor>();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
31
|
+
{
|
|
32
|
+
if (self = [super initWithFrame:frame]) {
|
|
33
|
+
static const auto defaultProps = std::make_shared<const MobileAIFloatingOverlayProps>();
|
|
34
|
+
_props = defaultProps;
|
|
35
|
+
|
|
36
|
+
_view = [[UIView alloc] init];
|
|
37
|
+
|
|
38
|
+
self.contentView = _view;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return self;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
45
|
+
{
|
|
46
|
+
const auto &oldViewProps = *std::static_pointer_cast<MobileAIFloatingOverlayProps const>(_props);
|
|
47
|
+
const auto &newViewProps = *std::static_pointer_cast<MobileAIFloatingOverlayProps const>(props);
|
|
48
|
+
|
|
49
|
+
[super updateProps:props oldProps:oldProps];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@end
|
|
53
|
+
|
|
54
|
+
Class<RCTComponentViewProtocol> MobileAIFloatingOverlayCls(void)
|
|
55
|
+
{
|
|
56
|
+
return MobileAIFloatingOverlayComponentView.class;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ─── Linker Fix: Force inclusion of the library ────────────────
|
|
60
|
+
|
|
61
|
+
#import <React/RCTViewManager.h>
|
|
62
|
+
|
|
63
|
+
@interface MobileAIFloatingOverlayManager : RCTViewManager
|
|
64
|
+
@end
|
|
65
|
+
|
|
66
|
+
@implementation MobileAIFloatingOverlayManager
|
|
67
|
+
RCT_EXPORT_MODULE(MobileAIFloatingOverlay)
|
|
68
|
+
|
|
69
|
+
- (UIView *)view
|
|
70
|
+
{
|
|
71
|
+
return [[UIView alloc] init];
|
|
72
|
+
}
|
|
73
|
+
@end
|