From ac77fcae229a8a78358e6602143fece345cdcd8b Mon Sep 17 00:00:00 2001 From: Vitor Neves Date: Tue, 11 Nov 2025 14:58:34 +0100 Subject: [PATCH 1/2] Initial commit Generated by create-expo-module 1.0.10. --- .eslintrc.js | 5 + .gitignore | 57 + .npmignore | 14 + android/build.gradle | 43 + android/src/main/AndroidManifest.xml | 2 + .../modules/helpscout/ExpoHelpscoutModule.kt | 50 + .../modules/helpscout/ExpoHelpscoutView.kt | 30 + example/.gitignore | 41 + example/App.tsx | 73 + example/app.json | 32 + example/assets/adaptive-icon.png | Bin 0 -> 17547 bytes example/assets/favicon.png | Bin 0 -> 1466 bytes example/assets/icon.png | Bin 0 -> 22380 bytes example/assets/splash-icon.png | Bin 0 -> 17547 bytes example/babel.config.js | 6 + example/index.ts | 8 + example/metro.config.js | 34 + example/package-lock.json | 9123 +++++++++ example/package.json | 26 + example/tsconfig.json | 10 + example/webpack.config.js | 20 + expo-module.config.json | 9 + ios/ExpoHelpscout.podspec | 29 + ios/ExpoHelpscoutModule.swift | 48 + ios/ExpoHelpscoutView.swift | 38 + package-lock.json | 16805 ++++++++++++++++ package.json | 43 + src/ExpoHelpscout.types.ts | 19 + src/ExpoHelpscoutModule.ts | 12 + src/ExpoHelpscoutModule.web.ts | 15 + src/ExpoHelpscoutView.tsx | 11 + src/ExpoHelpscoutView.web.tsx | 15 + src/index.ts | 5 + tsconfig.json | 9 + 34 files changed, 26632 insertions(+) create mode 100644 .eslintrc.js create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 android/build.gradle create mode 100644 android/src/main/AndroidManifest.xml create mode 100644 android/src/main/java/expo/modules/helpscout/ExpoHelpscoutModule.kt create mode 100644 android/src/main/java/expo/modules/helpscout/ExpoHelpscoutView.kt create mode 100644 example/.gitignore create mode 100644 example/App.tsx create mode 100644 example/app.json create mode 100644 example/assets/adaptive-icon.png create mode 100644 example/assets/favicon.png create mode 100644 example/assets/icon.png create mode 100644 example/assets/splash-icon.png create mode 100644 example/babel.config.js create mode 100644 example/index.ts create mode 100644 example/metro.config.js create mode 100644 example/package-lock.json create mode 100644 example/package.json create mode 100644 example/tsconfig.json create mode 100644 example/webpack.config.js create mode 100644 expo-module.config.json create mode 100644 ios/ExpoHelpscout.podspec create mode 100644 ios/ExpoHelpscoutModule.swift create mode 100644 ios/ExpoHelpscoutView.swift create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/ExpoHelpscout.types.ts create mode 100644 src/ExpoHelpscoutModule.ts create mode 100644 src/ExpoHelpscoutModule.web.ts create mode 100644 src/ExpoHelpscoutView.tsx create mode 100644 src/ExpoHelpscoutView.web.tsx create mode 100644 src/index.ts create mode 100644 tsconfig.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..45cf2c1 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,5 @@ +module.exports = { + root: true, + extends: ['universe/native', 'universe/web'], + ignorePatterns: ['build'], +}; diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e64b91c --- /dev/null +++ b/.gitignore @@ -0,0 +1,57 @@ +# OSX +# +.DS_Store + +# VSCode +.vscode/ +jsconfig.json + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IJ +# +.classpath +.cxx +.gradle +.idea +.project +.settings +local.properties +android.iml +android/app/libs +android/keystores/debug.keystore + +# Cocoapods +# +example/ios/Pods + +# Ruby +example/vendor/ + +# node.js +# +node_modules/ +npm-debug.log +yarn-debug.log +yarn-error.log + +# Expo +.expo/* diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..937d158 --- /dev/null +++ b/.npmignore @@ -0,0 +1,14 @@ +# Exclude all top-level hidden directories by convention +/.*/ + +# Exclude tarballs generated by `npm pack` +/*.tgz + +__mocks__ +__tests__ + +/babel.config.js +/android/src/androidTest/ +/android/src/test/ +/android/build/ +/example/ diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..8657721 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,43 @@ +apply plugin: 'com.android.library' + +group = 'expo.modules.helpscout' +version = '0.1.0' + +def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle") +apply from: expoModulesCorePlugin +applyKotlinExpoModulesCorePlugin() +useCoreDependencies() +useExpoPublishing() + +// If you want to use the managed Android SDK versions from expo-modules-core, set this to true. +// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code. +// Most of the time, you may like to manage the Android SDK versions yourself. +def useManagedAndroidSdkVersions = false +if (useManagedAndroidSdkVersions) { + useDefaultAndroidSdkVersions() +} else { + buildscript { + // Simple helper that allows the root project to override versions declared by this library. + ext.safeExtGet = { prop, fallback -> + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback + } + } + project.android { + compileSdkVersion safeExtGet("compileSdkVersion", 36) + defaultConfig { + minSdkVersion safeExtGet("minSdkVersion", 24) + targetSdkVersion safeExtGet("targetSdkVersion", 36) + } + } +} + +android { + namespace "expo.modules.helpscout" + defaultConfig { + versionCode 1 + versionName "0.1.0" + } + lintOptions { + abortOnError false + } +} diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..bdae66c --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/android/src/main/java/expo/modules/helpscout/ExpoHelpscoutModule.kt b/android/src/main/java/expo/modules/helpscout/ExpoHelpscoutModule.kt new file mode 100644 index 0000000..54f5f09 --- /dev/null +++ b/android/src/main/java/expo/modules/helpscout/ExpoHelpscoutModule.kt @@ -0,0 +1,50 @@ +package expo.modules.helpscout + +import expo.modules.kotlin.modules.Module +import expo.modules.kotlin.modules.ModuleDefinition +import java.net.URL + +class ExpoHelpscoutModule : Module() { + // Each module class must implement the definition function. The definition consists of components + // that describes the module's functionality and behavior. + // See https://docs.expo.dev/modules/module-api for more details about available components. + override fun definition() = ModuleDefinition { + // Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument. + // Can be inferred from module's class name, but it's recommended to set it explicitly for clarity. + // The module will be accessible from `requireNativeModule('ExpoHelpscout')` in JavaScript. + Name("ExpoHelpscout") + + // Defines constant property on the module. + Constant("PI") { + Math.PI + } + + // Defines event names that the module can send to JavaScript. + Events("onChange") + + // Defines a JavaScript synchronous function that runs the native code on the JavaScript thread. + Function("hello") { + "Hello world! 👋" + } + + // Defines a JavaScript function that always returns a Promise and whose native code + // is by default dispatched on the different thread than the JavaScript runtime runs on. + AsyncFunction("setValueAsync") { value: String -> + // Send an event to JavaScript. + sendEvent("onChange", mapOf( + "value" to value + )) + } + + // Enables the module to be used as a native view. Definition components that are accepted as part of + // the view definition: Prop, Events. + View(ExpoHelpscoutView::class) { + // Defines a setter for the `url` prop. + Prop("url") { view: ExpoHelpscoutView, url: URL -> + view.webView.loadUrl(url.toString()) + } + // Defines an event that the view can send to JavaScript. + Events("onLoad") + } + } +} diff --git a/android/src/main/java/expo/modules/helpscout/ExpoHelpscoutView.kt b/android/src/main/java/expo/modules/helpscout/ExpoHelpscoutView.kt new file mode 100644 index 0000000..157cfab --- /dev/null +++ b/android/src/main/java/expo/modules/helpscout/ExpoHelpscoutView.kt @@ -0,0 +1,30 @@ +package expo.modules.helpscout + +import android.content.Context +import android.webkit.WebView +import android.webkit.WebViewClient +import expo.modules.kotlin.AppContext +import expo.modules.kotlin.viewevent.EventDispatcher +import expo.modules.kotlin.views.ExpoView + +class ExpoHelpscoutView(context: Context, appContext: AppContext) : ExpoView(context, appContext) { + // Creates and initializes an event dispatcher for the `onLoad` event. + // The name of the event is inferred from the value and needs to match the event name defined in the module. + private val onLoad by EventDispatcher() + + // Defines a WebView that will be used as the root subview. + internal val webView = WebView(context).apply { + layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) + webViewClient = object : WebViewClient() { + override fun onPageFinished(view: WebView, url: String) { + // Sends an event to JavaScript. Triggers a callback defined on the view component in JavaScript. + onLoad(mapOf("url" to url)) + } + } + } + + init { + // Adds the WebView to the view hierarchy. + addView(webView) + } +} diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..d914c32 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,41 @@ +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +node_modules/ + +# Expo +.expo/ +dist/ +web-build/ +expo-env.d.ts + +# Native +.kotlin/ +*.orig.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision + +# Metro +.metro-health-check* + +# debug +npm-debug.* +yarn-debug.* +yarn-error.* + +# macOS +.DS_Store +*.pem + +# local env files +.env*.local + +# typescript +*.tsbuildinfo + +# generated native folders +/ios +/android diff --git a/example/App.tsx b/example/App.tsx new file mode 100644 index 0000000..f6f5822 --- /dev/null +++ b/example/App.tsx @@ -0,0 +1,73 @@ +import { useEvent } from 'expo'; +import ExpoHelpscout, { ExpoHelpscoutView } from 'expo-helpscout'; +import { Button, SafeAreaView, ScrollView, Text, View } from 'react-native'; + +export default function App() { + const onChangePayload = useEvent(ExpoHelpscout, 'onChange'); + + return ( + + + Module API Example + + {ExpoHelpscout.PI} + + + {ExpoHelpscout.hello()} + + +