expo-live-activity 0.1.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/.eslintrc.js +5 -0
- package/README.md +35 -0
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/liveactivity/ExpoLiveActivityModule.kt +50 -0
- package/android/src/main/java/expo/modules/liveactivity/ExpoLiveActivityView.kt +30 -0
- package/build/ExpoLiveActivity.types.d.ts +18 -0
- package/build/ExpoLiveActivity.types.d.ts.map +1 -0
- package/build/ExpoLiveActivity.types.js +2 -0
- package/build/ExpoLiveActivity.types.js.map +1 -0
- package/build/ExpoLiveActivityModule.d.ts +10 -0
- package/build/ExpoLiveActivityModule.d.ts.map +1 -0
- package/build/ExpoLiveActivityModule.js +4 -0
- package/build/ExpoLiveActivityModule.js.map +1 -0
- package/build/ExpoLiveActivityModule.web.d.ts +10 -0
- package/build/ExpoLiveActivityModule.web.d.ts.map +1 -0
- package/build/ExpoLiveActivityModule.web.js +12 -0
- package/build/ExpoLiveActivityModule.web.js.map +1 -0
- package/build/ExpoLiveActivityView.d.ts +4 -0
- package/build/ExpoLiveActivityView.d.ts.map +1 -0
- package/build/ExpoLiveActivityView.js +7 -0
- package/build/ExpoLiveActivityView.js.map +1 -0
- package/build/ExpoLiveActivityView.web.d.ts +4 -0
- package/build/ExpoLiveActivityView.web.d.ts.map +1 -0
- package/build/ExpoLiveActivityView.web.js +7 -0
- package/build/ExpoLiveActivityView.web.js.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +6 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +17 -0
- package/ios/ExpoLiveActivity.podspec +29 -0
- package/ios/ExpoLiveActivityModule.swift +48 -0
- package/ios/ExpoLiveActivityView.swift +38 -0
- package/package.json +43 -0
- package/src/ExpoLiveActivity.types.ts +19 -0
- package/src/ExpoLiveActivityModule.ts +12 -0
- package/src/ExpoLiveActivityModule.web.ts +15 -0
- package/src/ExpoLiveActivityView.tsx +11 -0
- package/src/ExpoLiveActivityView.web.tsx +15 -0
- package/src/index.ts +5 -0
- package/tsconfig.json +9 -0
package/.eslintrc.js
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# expo-live-activity
|
|
2
|
+
|
|
3
|
+
My new module
|
|
4
|
+
|
|
5
|
+
# API documentation
|
|
6
|
+
|
|
7
|
+
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/live-activity/)
|
|
8
|
+
- [Documentation for the main branch](https://docs.expo.dev/versions/unversioned/sdk/live-activity/)
|
|
9
|
+
|
|
10
|
+
# Installation in managed Expo projects
|
|
11
|
+
|
|
12
|
+
For [managed](https://docs.expo.dev/archive/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](#api-documentation). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
|
|
13
|
+
|
|
14
|
+
# Installation in bare React Native projects
|
|
15
|
+
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
|
+
|
|
18
|
+
### Add the package to your npm dependencies
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm install expo-live-activity
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Configure for Android
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Configure for iOS
|
|
30
|
+
|
|
31
|
+
Run `npx pod-install` after installing the npm package.
|
|
32
|
+
|
|
33
|
+
# Contributing
|
|
34
|
+
|
|
35
|
+
Contributions are very welcome! Please refer to guidelines described in the [contributing guide]( https://github.com/expo/expo#contributing).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
group = 'expo.modules.liveactivity'
|
|
4
|
+
version = '0.1.0'
|
|
5
|
+
|
|
6
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
|
+
apply from: expoModulesCorePlugin
|
|
8
|
+
applyKotlinExpoModulesCorePlugin()
|
|
9
|
+
useCoreDependencies()
|
|
10
|
+
useExpoPublishing()
|
|
11
|
+
|
|
12
|
+
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
13
|
+
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
14
|
+
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
15
|
+
def useManagedAndroidSdkVersions = false
|
|
16
|
+
if (useManagedAndroidSdkVersions) {
|
|
17
|
+
useDefaultAndroidSdkVersions()
|
|
18
|
+
} else {
|
|
19
|
+
buildscript {
|
|
20
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
21
|
+
ext.safeExtGet = { prop, fallback ->
|
|
22
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
project.android {
|
|
26
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
|
27
|
+
defaultConfig {
|
|
28
|
+
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
29
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android {
|
|
35
|
+
namespace "expo.modules.liveactivity"
|
|
36
|
+
defaultConfig {
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "0.1.0"
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
abortOnError false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package expo.modules.liveactivity
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
import java.net.URL
|
|
6
|
+
|
|
7
|
+
class ExpoLiveActivityModule : Module() {
|
|
8
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
9
|
+
// that describes the module's functionality and behavior.
|
|
10
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
11
|
+
override fun definition() = ModuleDefinition {
|
|
12
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
13
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
14
|
+
// The module will be accessible from `requireNativeModule('ExpoLiveActivity')` in JavaScript.
|
|
15
|
+
Name("ExpoLiveActivity")
|
|
16
|
+
|
|
17
|
+
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
|
|
18
|
+
Constants(
|
|
19
|
+
"PI" to Math.PI
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
// Defines event names that the module can send to JavaScript.
|
|
23
|
+
Events("onChange")
|
|
24
|
+
|
|
25
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
26
|
+
Function("hello") {
|
|
27
|
+
"Hello world! 👋"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
31
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
32
|
+
AsyncFunction("setValueAsync") { value: String ->
|
|
33
|
+
// Send an event to JavaScript.
|
|
34
|
+
sendEvent("onChange", mapOf(
|
|
35
|
+
"value" to value
|
|
36
|
+
))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of
|
|
40
|
+
// the view definition: Prop, Events.
|
|
41
|
+
View(ExpoLiveActivityView::class) {
|
|
42
|
+
// Defines a setter for the `url` prop.
|
|
43
|
+
Prop("url") { view: ExpoLiveActivityView, url: URL ->
|
|
44
|
+
view.webView.loadUrl(url.toString())
|
|
45
|
+
}
|
|
46
|
+
// Defines an event that the view can send to JavaScript.
|
|
47
|
+
Events("onLoad")
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package expo.modules.liveactivity
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.webkit.WebView
|
|
5
|
+
import android.webkit.WebViewClient
|
|
6
|
+
import expo.modules.kotlin.AppContext
|
|
7
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
8
|
+
import expo.modules.kotlin.views.ExpoView
|
|
9
|
+
|
|
10
|
+
class ExpoLiveActivityView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
11
|
+
// Creates and initializes an event dispatcher for the `onLoad` event.
|
|
12
|
+
// The name of the event is inferred from the value and needs to match the event name defined in the module.
|
|
13
|
+
private val onLoad by EventDispatcher()
|
|
14
|
+
|
|
15
|
+
// Defines a WebView that will be used as the root subview.
|
|
16
|
+
internal val webView = WebView(context).apply {
|
|
17
|
+
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
18
|
+
webViewClient = object : WebViewClient() {
|
|
19
|
+
override fun onPageFinished(view: WebView, url: String) {
|
|
20
|
+
// Sends an event to JavaScript. Triggers a callback defined on the view component in JavaScript.
|
|
21
|
+
onLoad(mapOf("url" to url))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
init {
|
|
27
|
+
// Adds the WebView to the view hierarchy.
|
|
28
|
+
addView(webView)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
export type OnLoadEventPayload = {
|
|
3
|
+
url: string;
|
|
4
|
+
};
|
|
5
|
+
export type ExpoLiveActivityModuleEvents = {
|
|
6
|
+
onChange: (params: ChangeEventPayload) => void;
|
|
7
|
+
};
|
|
8
|
+
export type ChangeEventPayload = {
|
|
9
|
+
value: string;
|
|
10
|
+
};
|
|
11
|
+
export type ExpoLiveActivityViewProps = {
|
|
12
|
+
url: string;
|
|
13
|
+
onLoad: (event: {
|
|
14
|
+
nativeEvent: OnLoadEventPayload;
|
|
15
|
+
}) => void;
|
|
16
|
+
style?: StyleProp<ViewStyle>;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=ExpoLiveActivity.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivity.types.d.ts","sourceRoot":"","sources":["../src/ExpoLiveActivity.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,kBAAkB,CAAA;KAAE,KAAK,IAAI,CAAC;IAC7D,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivity.types.js","sourceRoot":"","sources":["../src/ExpoLiveActivity.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\n\nexport type OnLoadEventPayload = {\n url: string;\n};\n\nexport type ExpoLiveActivityModuleEvents = {\n onChange: (params: ChangeEventPayload) => void;\n};\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ExpoLiveActivityViewProps = {\n url: string;\n onLoad: (event: { nativeEvent: OnLoadEventPayload }) => void;\n style?: StyleProp<ViewStyle>;\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NativeModule } from 'expo';
|
|
2
|
+
import { ExpoLiveActivityModuleEvents } from './ExpoLiveActivity.types';
|
|
3
|
+
declare class ExpoLiveActivityModule extends NativeModule<ExpoLiveActivityModuleEvents> {
|
|
4
|
+
PI: number;
|
|
5
|
+
hello(): string;
|
|
6
|
+
setValueAsync(value: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: ExpoLiveActivityModule;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=ExpoLiveActivityModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivityModule.d.ts","sourceRoot":"","sources":["../src/ExpoLiveActivityModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,OAAO,sBAAuB,SAAQ,YAAY,CAAC,4BAA4B,CAAC;IACrF,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,IAAI,MAAM;IACf,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAC5C;;AAGD,wBAA+E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivityModule.js","sourceRoot":"","sources":["../src/ExpoLiveActivityModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAUzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAyB,kBAAkB,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo';\n\nimport { ExpoLiveActivityModuleEvents } from './ExpoLiveActivity.types';\n\ndeclare class ExpoLiveActivityModule extends NativeModule<ExpoLiveActivityModuleEvents> {\n PI: number;\n hello(): string;\n setValueAsync(value: string): Promise<void>;\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<ExpoLiveActivityModule>('ExpoLiveActivity');\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NativeModule } from 'expo';
|
|
2
|
+
import { ExpoLiveActivityModuleEvents } from './ExpoLiveActivity.types';
|
|
3
|
+
declare class ExpoLiveActivityModule extends NativeModule<ExpoLiveActivityModuleEvents> {
|
|
4
|
+
PI: number;
|
|
5
|
+
setValueAsync(value: string): Promise<void>;
|
|
6
|
+
hello(): string;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: typeof ExpoLiveActivityModule;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=ExpoLiveActivityModule.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivityModule.web.d.ts","sourceRoot":"","sources":["../src/ExpoLiveActivityModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAExE,cAAM,sBAAuB,SAAQ,YAAY,CAAC,4BAA4B,CAAC;IAC7E,EAAE,SAAW;IACP,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGjD,KAAK;CAGN;;AAED,wBAAyD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { registerWebModule, NativeModule } from 'expo';
|
|
2
|
+
class ExpoLiveActivityModule extends NativeModule {
|
|
3
|
+
PI = Math.PI;
|
|
4
|
+
async setValueAsync(value) {
|
|
5
|
+
this.emit('onChange', { value });
|
|
6
|
+
}
|
|
7
|
+
hello() {
|
|
8
|
+
return 'Hello world! 👋';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export default registerWebModule(ExpoLiveActivityModule);
|
|
12
|
+
//# sourceMappingURL=ExpoLiveActivityModule.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivityModule.web.js","sourceRoot":"","sources":["../src/ExpoLiveActivityModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIvD,MAAM,sBAAuB,SAAQ,YAA0C;IAC7E,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;IACb,KAAK,CAAC,aAAa,CAAC,KAAa;QAC/B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,KAAK;QACH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AAED,eAAe,iBAAiB,CAAC,sBAAsB,CAAC,CAAC","sourcesContent":["import { registerWebModule, NativeModule } from 'expo';\n\nimport { ExpoLiveActivityModuleEvents } from './ExpoLiveActivity.types';\n\nclass ExpoLiveActivityModule extends NativeModule<ExpoLiveActivityModuleEvents> {\n PI = Math.PI;\n async setValueAsync(value: string): Promise<void> {\n this.emit('onChange', { value });\n }\n hello() {\n return 'Hello world! 👋';\n }\n}\n\nexport default registerWebModule(ExpoLiveActivityModule);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivityView.d.ts","sourceRoot":"","sources":["../src/ExpoLiveActivityView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAKrE,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,qBAE5E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
const NativeView = requireNativeView('ExpoLiveActivity');
|
|
4
|
+
export default function ExpoLiveActivityView(props) {
|
|
5
|
+
return <NativeView {...props}/>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ExpoLiveActivityView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivityView.js","sourceRoot":"","sources":["../src/ExpoLiveActivityView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,UAAU,GACd,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAgC;IAC3E,OAAO,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACnC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\n\nimport { ExpoLiveActivityViewProps } from './ExpoLiveActivity.types';\n\nconst NativeView: React.ComponentType<ExpoLiveActivityViewProps> =\n requireNativeView('ExpoLiveActivity');\n\nexport default function ExpoLiveActivityView(props: ExpoLiveActivityViewProps) {\n return <NativeView {...props} />;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivityView.web.d.ts","sourceRoot":"","sources":["../src/ExpoLiveActivityView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAErE,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,qBAU5E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export default function ExpoLiveActivityView(props) {
|
|
3
|
+
return (<div>
|
|
4
|
+
<iframe style={{ flex: 1 }} src={props.url} onLoad={() => props.onLoad({ nativeEvent: { url: props.url } })}/>
|
|
5
|
+
</div>);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ExpoLiveActivityView.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLiveActivityView.web.js","sourceRoot":"","sources":["../src/ExpoLiveActivityView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAgC;IAC3E,OAAO,CACL,CAAC,GAAG,CACF;MAAA,CAAC,MAAM,CACL,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CACnB,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CACf,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAEpE;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { ExpoLiveActivityViewProps } from './ExpoLiveActivity.types';\n\nexport default function ExpoLiveActivityView(props: ExpoLiveActivityViewProps) {\n return (\n <div>\n <iframe\n style={{ flex: 1 }}\n src={props.url}\n onLoad={() => props.onLoad({ nativeEvent: { url: props.url } })}\n />\n </div>\n );\n}\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,cAAe,0BAA0B,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Reexport the native module. On web, it will be resolved to ExpoLiveActivityModule.web.ts
|
|
2
|
+
// and on native platforms to ExpoLiveActivityModule.ts
|
|
3
|
+
export { default } from './ExpoLiveActivityModule';
|
|
4
|
+
export { default as ExpoLiveActivityView } from './ExpoLiveActivityView';
|
|
5
|
+
export * from './ExpoLiveActivity.types';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,uDAAuD;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,cAAe,0BAA0B,CAAC","sourcesContent":["// Reexport the native module. On web, it will be resolved to ExpoLiveActivityModule.web.ts\n// and on native platforms to ExpoLiveActivityModule.ts\nexport { default } from './ExpoLiveActivityModule';\nexport { default as ExpoLiveActivityView } from './ExpoLiveActivityView';\nexport * from './ExpoLiveActivity.types';\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 = 'ExpoLiveActivity'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.description = package['description']
|
|
10
|
+
s.license = package['license']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.homepage = package['homepage']
|
|
13
|
+
s.platforms = {
|
|
14
|
+
:ios => '15.1',
|
|
15
|
+
:tvos => '15.1'
|
|
16
|
+
}
|
|
17
|
+
s.swift_version = '5.4'
|
|
18
|
+
s.source = { git: 'https://github.com/kowczarz/expo-live-activity' }
|
|
19
|
+
s.static_framework = true
|
|
20
|
+
|
|
21
|
+
s.dependency 'ExpoModulesCore'
|
|
22
|
+
|
|
23
|
+
# Swift/Objective-C compatibility
|
|
24
|
+
s.pod_target_xcconfig = {
|
|
25
|
+
'DEFINES_MODULE' => 'YES',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
|
|
29
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
public class ExpoLiveActivityModule: Module {
|
|
4
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
5
|
+
// that describes the module's functionality and behavior.
|
|
6
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
7
|
+
public func definition() -> ModuleDefinition {
|
|
8
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
9
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
10
|
+
// The module will be accessible from `requireNativeModule('ExpoLiveActivity')` in JavaScript.
|
|
11
|
+
Name("ExpoLiveActivity")
|
|
12
|
+
|
|
13
|
+
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
|
|
14
|
+
Constants([
|
|
15
|
+
"PI": Double.pi
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
// Defines event names that the module can send to JavaScript.
|
|
19
|
+
Events("onChange")
|
|
20
|
+
|
|
21
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
22
|
+
Function("hello") {
|
|
23
|
+
return "Hello world! 👋"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
27
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
28
|
+
AsyncFunction("setValueAsync") { (value: String) in
|
|
29
|
+
// Send an event to JavaScript.
|
|
30
|
+
self.sendEvent("onChange", [
|
|
31
|
+
"value": value
|
|
32
|
+
])
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of the
|
|
36
|
+
// view definition: Prop, Events.
|
|
37
|
+
View(ExpoLiveActivityView.self) {
|
|
38
|
+
// Defines a setter for the `url` prop.
|
|
39
|
+
Prop("url") { (view: ExpoLiveActivityView, url: URL) in
|
|
40
|
+
if view.webView.url != url {
|
|
41
|
+
view.webView.load(URLRequest(url: url))
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Events("onLoad")
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import WebKit
|
|
3
|
+
|
|
4
|
+
// This view will be used as a native component. Make sure to inherit from `ExpoView`
|
|
5
|
+
// to apply the proper styling (e.g. border radius and shadows).
|
|
6
|
+
class ExpoLiveActivityView: ExpoView {
|
|
7
|
+
let webView = WKWebView()
|
|
8
|
+
let onLoad = EventDispatcher()
|
|
9
|
+
var delegate: WebViewDelegate?
|
|
10
|
+
|
|
11
|
+
required init(appContext: AppContext? = nil) {
|
|
12
|
+
super.init(appContext: appContext)
|
|
13
|
+
clipsToBounds = true
|
|
14
|
+
delegate = WebViewDelegate { url in
|
|
15
|
+
self.onLoad(["url": url])
|
|
16
|
+
}
|
|
17
|
+
webView.navigationDelegate = delegate
|
|
18
|
+
addSubview(webView)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override func layoutSubviews() {
|
|
22
|
+
webView.frame = bounds
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class WebViewDelegate: NSObject, WKNavigationDelegate {
|
|
27
|
+
let onUrlChange: (String) -> Void
|
|
28
|
+
|
|
29
|
+
init(onUrlChange: @escaping (String) -> Void) {
|
|
30
|
+
self.onUrlChange = onUrlChange
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation) {
|
|
34
|
+
if let url = webView.url {
|
|
35
|
+
onUrlChange(url.absoluteString)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-live-activity",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "My new module",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "expo-module build",
|
|
9
|
+
"clean": "expo-module clean",
|
|
10
|
+
"lint": "expo-module lint",
|
|
11
|
+
"test": "expo-module test",
|
|
12
|
+
"prepare": "expo-module prepare",
|
|
13
|
+
"prepublishOnly": "expo-module prepublishOnly",
|
|
14
|
+
"expo-module": "expo-module",
|
|
15
|
+
"open:ios": "xed example/ios",
|
|
16
|
+
"open:android": "open -a \"Android Studio\" example/android"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"react-native",
|
|
20
|
+
"expo",
|
|
21
|
+
"expo-live-activity",
|
|
22
|
+
"ExpoLiveActivity"
|
|
23
|
+
],
|
|
24
|
+
"repository": "https://github.com/kowczarz/expo-live-activity",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/kowczarz/expo-live-activity/issues"
|
|
27
|
+
},
|
|
28
|
+
"author": "Kamil Owczarz <kamil.owczarz@swmansion.com> (https://github.com/kowczarz)",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/kowczarz/expo-live-activity#readme",
|
|
31
|
+
"dependencies": {},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/react": "~18.3.12",
|
|
34
|
+
"expo-module-scripts": "^4.0.4",
|
|
35
|
+
"expo": "~52.0.0",
|
|
36
|
+
"react-native": "0.76.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"expo": "*",
|
|
40
|
+
"react": "*",
|
|
41
|
+
"react-native": "*"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export type OnLoadEventPayload = {
|
|
4
|
+
url: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type ExpoLiveActivityModuleEvents = {
|
|
8
|
+
onChange: (params: ChangeEventPayload) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ChangeEventPayload = {
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type ExpoLiveActivityViewProps = {
|
|
16
|
+
url: string;
|
|
17
|
+
onLoad: (event: { nativeEvent: OnLoadEventPayload }) => void;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NativeModule, requireNativeModule } from 'expo';
|
|
2
|
+
|
|
3
|
+
import { ExpoLiveActivityModuleEvents } from './ExpoLiveActivity.types';
|
|
4
|
+
|
|
5
|
+
declare class ExpoLiveActivityModule extends NativeModule<ExpoLiveActivityModuleEvents> {
|
|
6
|
+
PI: number;
|
|
7
|
+
hello(): string;
|
|
8
|
+
setValueAsync(value: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// This call loads the native module object from the JSI.
|
|
12
|
+
export default requireNativeModule<ExpoLiveActivityModule>('ExpoLiveActivity');
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { registerWebModule, NativeModule } from 'expo';
|
|
2
|
+
|
|
3
|
+
import { ExpoLiveActivityModuleEvents } from './ExpoLiveActivity.types';
|
|
4
|
+
|
|
5
|
+
class ExpoLiveActivityModule extends NativeModule<ExpoLiveActivityModuleEvents> {
|
|
6
|
+
PI = Math.PI;
|
|
7
|
+
async setValueAsync(value: string): Promise<void> {
|
|
8
|
+
this.emit('onChange', { value });
|
|
9
|
+
}
|
|
10
|
+
hello() {
|
|
11
|
+
return 'Hello world! 👋';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default registerWebModule(ExpoLiveActivityModule);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import { ExpoLiveActivityViewProps } from './ExpoLiveActivity.types';
|
|
5
|
+
|
|
6
|
+
const NativeView: React.ComponentType<ExpoLiveActivityViewProps> =
|
|
7
|
+
requireNativeView('ExpoLiveActivity');
|
|
8
|
+
|
|
9
|
+
export default function ExpoLiveActivityView(props: ExpoLiveActivityViewProps) {
|
|
10
|
+
return <NativeView {...props} />;
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { ExpoLiveActivityViewProps } from './ExpoLiveActivity.types';
|
|
4
|
+
|
|
5
|
+
export default function ExpoLiveActivityView(props: ExpoLiveActivityViewProps) {
|
|
6
|
+
return (
|
|
7
|
+
<div>
|
|
8
|
+
<iframe
|
|
9
|
+
style={{ flex: 1 }}
|
|
10
|
+
src={props.url}
|
|
11
|
+
onLoad={() => props.onLoad({ nativeEvent: { url: props.url } })}
|
|
12
|
+
/>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Reexport the native module. On web, it will be resolved to ExpoLiveActivityModule.web.ts
|
|
2
|
+
// and on native platforms to ExpoLiveActivityModule.ts
|
|
3
|
+
export { default } from './ExpoLiveActivityModule';
|
|
4
|
+
export { default as ExpoLiveActivityView } from './ExpoLiveActivityView';
|
|
5
|
+
export * from './ExpoLiveActivity.types';
|
package/tsconfig.json
ADDED