expo-watch 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/LICENSE +21 -0
- package/README.md +120 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/watch/ExpoWatchModule.kt +47 -0
- package/android/src/main/java/expo/modules/watch/ExpoWatchView.kt +7 -0
- package/app.plugin.js +1 -0
- package/build/ExpoWatch.types.d.ts +7 -0
- package/build/ExpoWatch.types.d.ts.map +1 -0
- package/build/ExpoWatch.types.js +2 -0
- package/build/ExpoWatch.types.js.map +1 -0
- package/build/ExpoWatchModule.d.ts +3 -0
- package/build/ExpoWatchModule.d.ts.map +1 -0
- package/build/ExpoWatchModule.js +5 -0
- package/build/ExpoWatchModule.js.map +1 -0
- package/build/ExpoWatchModule.web.d.ts +7 -0
- package/build/ExpoWatchModule.web.d.ts.map +1 -0
- package/build/ExpoWatchModule.web.js +12 -0
- package/build/ExpoWatchModule.web.js.map +1 -0
- package/build/ExpoWatchView.d.ts +4 -0
- package/build/ExpoWatchView.d.ts.map +1 -0
- package/build/ExpoWatchView.js +7 -0
- package/build/ExpoWatchView.js.map +1 -0
- package/build/ExpoWatchView.web.d.ts +4 -0
- package/build/ExpoWatchView.web.d.ts.map +1 -0
- package/build/ExpoWatchView.web.js +7 -0
- package/build/ExpoWatchView.web.js.map +1 -0
- package/build/index.d.ts +9 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +19 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/ExpoWatch.podspec +27 -0
- package/ios/ExpoWatchModule.swift +44 -0
- package/ios/ExpoWatchView.swift +7 -0
- package/package.json +45 -0
- package/plugin/build/addBuildPhases.d.ts +13 -0
- package/plugin/build/addBuildPhases.js +26 -0
- package/plugin/build/addPbxGroup.d.ts +5 -0
- package/plugin/build/addPbxGroup.js +15 -0
- package/plugin/build/addProductFile.d.ts +5 -0
- package/plugin/build/addProductFile.js +18 -0
- package/plugin/build/addTargetDependency.d.ts +4 -0
- package/plugin/build/addTargetDependency.js +14 -0
- package/plugin/build/addToPbxNativeTargetSection.d.ts +24 -0
- package/plugin/build/addToPbxNativeTargetSection.js +21 -0
- package/plugin/build/addToPbxProjectSection.d.ts +4 -0
- package/plugin/build/addToPbxProjectSection.js +13 -0
- package/plugin/build/addXCConfigurationList.d.ts +9 -0
- package/plugin/build/addXCConfigurationList.js +19 -0
- package/plugin/build/withWatchApp.d.ts +11 -0
- package/plugin/build/withWatchApp.js +51 -0
- package/plugin/src/addBuildPhases.ts +83 -0
- package/plugin/src/addPbxGroup.ts +31 -0
- package/plugin/src/addProductFile.ts +22 -0
- package/plugin/src/addTargetDependency.ts +17 -0
- package/plugin/src/addToPbxNativeTargetSection.ts +35 -0
- package/plugin/src/addToPbxProjectSection.ts +21 -0
- package/plugin/src/addXCConfigurationList.ts +37 -0
- package/plugin/src/withWatchApp.ts +79 -0
- package/plugin/tsconfig.json +9 -0
- package/src/ExpoWatch.types.ts +7 -0
- package/src/ExpoWatchModule.ts +5 -0
- package/src/ExpoWatchModule.web.ts +13 -0
- package/src/ExpoWatchView.tsx +11 -0
- package/src/ExpoWatchView.web.tsx +11 -0
- package/src/index.ts +26 -0
- package/tsconfig.json +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Robert Sasak
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Expo Watch app
|
|
2
|
+
|
|
3
|
+
Extend your Expo managed workflow with a Apple Watch app.
|
|
4
|
+
|
|
5
|
+
## Motivation
|
|
6
|
+
|
|
7
|
+
At some point, you may want to extend your Expo managed app for an Apple Watch app. Typically you would need to eject Expo to do this. This plugin will help you to add a Watch app to your managed Expo project without ejecting.
|
|
8
|
+
|
|
9
|
+
## How it works
|
|
10
|
+
|
|
11
|
+
By leveraging Expo plugin system it essantially adds necesssary build and configuration files to your xcode workspace. This way you do not have to reject Expo app and maintain ios folder. Plugin add a new watch target to your xcode workspace and link native swift code to your Expo app. Native swift code is linked from outside of ios folder.
|
|
12
|
+
|
|
13
|
+
## Before you start
|
|
14
|
+
|
|
15
|
+
This plugin is based on the great work of [Daniel Friyia](https://github.com/friyiajr) and his youtube channel [DanRNLab](https://www.youtube.com/@DanRNLab). In his video [How to build a React Native Expo App with Apple Watch ( Tutorial )](https://www.youtube.com/watch?v=Z6xRCyhrg1A) he provides step by step tutorial how to add Watch app. I strongly recommend to watch his video before you start. Code in this repo is copied from his tutorial and [example repo](https://github.com/friyiajr/RealtimeWatchApp).
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add expo-watch
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# temporary eject Expo app
|
|
25
|
+
npx expo prebuild --platform ios --clean
|
|
26
|
+
# open xcode workspace
|
|
27
|
+
xed ios
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
In you xcode project add new Watch target "<name> Watch app". Develop your Watch app. Once happy add temporary ios folder into git. This will allow you to easily see that expo-watch plugin is generating correct xcode project files for you.
|
|
31
|
+
|
|
32
|
+
Copy your watch app "<name> Watch app" outside of ios folder into root of your project. This is important as plugin will link these files to xcode workspace.
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
Register plugin in `app.json` file.
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"expo": {
|
|
41
|
+
// ...
|
|
42
|
+
"plugins": [
|
|
43
|
+
"expo-watch",
|
|
44
|
+
{
|
|
45
|
+
//...long config file
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Plugin is a simple as possible do not provide many default configuration options. You have to provide all necessary configuration options. This may look very intimidating but it is not that hard and it give you full control over your Watch app.
|
|
53
|
+
|
|
54
|
+
Be aware of how string are escaped in JSON and that string values need to use extra quotes.
|
|
55
|
+
|
|
56
|
+
### Full configuration options
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Options
|
|
63
|
+
|
|
64
|
+
#### targetName?: string (default: "Sample Watch App")
|
|
65
|
+
|
|
66
|
+
How will the target in xcode will be called.
|
|
67
|
+
|
|
68
|
+
#### groupName?: string (default: "Embed Watch Content")
|
|
69
|
+
|
|
70
|
+
#### setVersionFromCompanionApp?: boolean (default: true)
|
|
71
|
+
|
|
72
|
+
If true it will add propert _MARKETING_VERSION_ with version found in from app.json. Watch and iOS app will have the same version. Otherwise you need to provide it manually in build settings.
|
|
73
|
+
|
|
74
|
+
#### buildSettings?: Record<string, string | number> (default: {})
|
|
75
|
+
|
|
76
|
+
This list is intentionally empty by default. Plugin do not provide any hidden build settings. Feel free to copy it from above.
|
|
77
|
+
|
|
78
|
+
#### files?: string[] (default: [])
|
|
79
|
+
|
|
80
|
+
List of files that will be linked to xcode workspace. Here you include all swift and xcassets files.
|
|
81
|
+
|
|
82
|
+
#### compileSources?: string[] (default: [])
|
|
83
|
+
|
|
84
|
+
List of fileds that will be compiled. Here you include all swift files.
|
|
85
|
+
|
|
86
|
+
#### copyBundleResources?: string[] (default: [])
|
|
87
|
+
|
|
88
|
+
List of xcassets files. Typically these two files.
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
"copyBundleResources": [
|
|
92
|
+
"Assets.xcassets",
|
|
93
|
+
"Preview Assets.xcassets"
|
|
94
|
+
]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Contributing
|
|
98
|
+
|
|
99
|
+
As this a niche plugin it is not possible to provide a lot of support. If you have any issues please open an issue on this repo. I will try to help you as much as I can. There are only handful of code files in this plugin so you can easily debug it yourself.
|
|
100
|
+
|
|
101
|
+
Make a clone of this repo and local reference in your project. You can also example folders in this repo to see how it works.
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
"plugins": [
|
|
105
|
+
"../../../expo-watc/plugin/src/app.plugin.js",
|
|
106
|
+
{
|
|
107
|
+
//...long config file
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## TODO
|
|
112
|
+
|
|
113
|
+
- [ ] Add watch files into subfolders. Currently all files are in root folder.
|
|
114
|
+
- [ ] Automatically add all swift files from watch folder to xcode workspace. Currently all swift files need to be listed in config manually.
|
|
115
|
+
- [ ] Automatically add all swift files to build.
|
|
116
|
+
- [ ] Communication between Watch and iOS app.
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
MIT
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
group = 'expo.modules.watch'
|
|
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.watch"
|
|
36
|
+
defaultConfig {
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "0.1.0"
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
abortOnError false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
package expo.modules.watch
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
|
|
6
|
+
class ExpoWatchModule : Module() {
|
|
7
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
8
|
+
// that describes the module's functionality and behavior.
|
|
9
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
10
|
+
override fun definition() = ModuleDefinition {
|
|
11
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
12
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
13
|
+
// The module will be accessible from `requireNativeModule('ExpoWatch')` in JavaScript.
|
|
14
|
+
Name("ExpoWatch")
|
|
15
|
+
|
|
16
|
+
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
|
|
17
|
+
Constants(
|
|
18
|
+
"PI" to Math.PI
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
// Defines event names that the module can send to JavaScript.
|
|
22
|
+
Events("onChange")
|
|
23
|
+
|
|
24
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
25
|
+
Function("hello") {
|
|
26
|
+
"Hello world! 👋"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
30
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
31
|
+
AsyncFunction("setValueAsync") { value: String ->
|
|
32
|
+
// Send an event to JavaScript.
|
|
33
|
+
sendEvent("onChange", mapOf(
|
|
34
|
+
"value" to value
|
|
35
|
+
))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of
|
|
39
|
+
// the view definition: Prop, Events.
|
|
40
|
+
View(ExpoWatchView::class) {
|
|
41
|
+
// Defines a setter for the `name` prop.
|
|
42
|
+
Prop("name") { view: ExpoWatchView, prop: String ->
|
|
43
|
+
println(prop)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build/withWatchApp')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatch.types.d.ts","sourceRoot":"","sources":["../src/ExpoWatch.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatch.types.js","sourceRoot":"","sources":["../src/ExpoWatch.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ChangeEventPayload = {\n value: string;\n};\n\nexport type ExpoWatchViewProps = {\n name: string;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatchModule.d.ts","sourceRoot":"","sources":["../src/ExpoWatchModule.ts"],"names":[],"mappings":";AAIA,wBAAgD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core';
|
|
2
|
+
// It loads the native module object from the JSI or falls back to
|
|
3
|
+
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
|
|
4
|
+
export default requireNativeModule('ExpoWatch');
|
|
5
|
+
//# sourceMappingURL=ExpoWatchModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatchModule.js","sourceRoot":"","sources":["../src/ExpoWatchModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,kEAAkE;AAClE,4EAA4E;AAC5E,eAAe,mBAAmB,CAAC,WAAW,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo-modules-core';\n\n// It loads the native module object from the JSI or falls back to\n// the bridge module (from NativeModulesProxy) if the remote debugger is on.\nexport default requireNativeModule('ExpoWatch');\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatchModule.web.d.ts","sourceRoot":"","sources":["../src/ExpoWatchModule.web.ts"],"names":[],"mappings":";;yBAM6B,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;;;AAFnD,wBAQE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EventEmitter } from 'expo-modules-core';
|
|
2
|
+
const emitter = new EventEmitter({});
|
|
3
|
+
export default {
|
|
4
|
+
PI: Math.PI,
|
|
5
|
+
async setValueAsync(value) {
|
|
6
|
+
emitter.emit('onChange', { value });
|
|
7
|
+
},
|
|
8
|
+
hello() {
|
|
9
|
+
return 'Hello world! 👋';
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=ExpoWatchModule.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatchModule.web.js","sourceRoot":"","sources":["../src/ExpoWatchModule.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,EAAS,CAAC,CAAC;AAE5C,eAAe;IACb,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,KAAK,CAAC,aAAa,CAAC,KAAa;QAC/B,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,KAAK;QACH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF,CAAC","sourcesContent":["import { EventEmitter } from 'expo-modules-core';\n\nconst emitter = new EventEmitter({} as any);\n\nexport default {\n PI: Math.PI,\n async setValueAsync(value: string): Promise<void> {\n emitter.emit('onChange', { value });\n },\n hello() {\n return 'Hello world! 👋';\n },\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatchView.d.ts","sourceRoot":"","sources":["../src/ExpoWatchView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAKvD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,kBAAkB,qBAE9D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
const NativeView = requireNativeViewManager('ExpoWatch');
|
|
4
|
+
export default function ExpoWatchView(props) {
|
|
5
|
+
return <NativeView {...props}/>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ExpoWatchView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatchView.js","sourceRoot":"","sources":["../src/ExpoWatchView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,UAAU,GACd,wBAAwB,CAAC,WAAW,CAAC,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAyB;IAC7D,OAAO,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACnC,CAAC","sourcesContent":["import { requireNativeViewManager } from 'expo-modules-core';\nimport * as React from 'react';\n\nimport { ExpoWatchViewProps } from './ExpoWatch.types';\n\nconst NativeView: React.ComponentType<ExpoWatchViewProps> =\n requireNativeViewManager('ExpoWatch');\n\nexport default function ExpoWatchView(props: ExpoWatchViewProps) {\n return <NativeView {...props} />;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatchView.web.d.ts","sourceRoot":"","sources":["../src/ExpoWatchView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAK,EAAE,kBAAkB,qBAM9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoWatchView.web.js","sourceRoot":"","sources":["../src/ExpoWatchView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,KAAyB;IAC7D,OAAO,CACL,CAAC,GAAG,CACF;MAAA,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,CAC1B;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\n\nimport { ExpoWatchViewProps } from './ExpoWatch.types';\n\nexport default function ExpoWatchView(props: ExpoWatchViewProps) {\n return (\n <div>\n <span>{props.name}</span>\n </div>\n );\n}\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Subscription } from 'expo-modules-core';
|
|
2
|
+
import ExpoWatchView from './ExpoWatchView';
|
|
3
|
+
import { ChangeEventPayload, ExpoWatchViewProps } from './ExpoWatch.types';
|
|
4
|
+
export declare const PI: any;
|
|
5
|
+
export declare function hello(): string;
|
|
6
|
+
export declare function setValueAsync(value: string): Promise<any>;
|
|
7
|
+
export declare function addChangeListener(listener: (event: ChangeEventPayload) => void): Subscription;
|
|
8
|
+
export { ExpoWatchView, ExpoWatchViewProps, ChangeEventPayload };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKnF,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAG3E,eAAO,MAAM,EAAE,KAAqB,CAAC;AAErC,wBAAgB,KAAK,IAAI,MAAM,CAE9B;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,gBAEhD;AAID,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GAAG,YAAY,CAE7F;AAED,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NativeModulesProxy, EventEmitter } from 'expo-modules-core';
|
|
2
|
+
// Import the native module. On web, it will be resolved to ExpoWatch.web.ts
|
|
3
|
+
// and on native platforms to ExpoWatch.ts
|
|
4
|
+
import ExpoWatchModule from './ExpoWatchModule';
|
|
5
|
+
import ExpoWatchView from './ExpoWatchView';
|
|
6
|
+
// Get the native constant value.
|
|
7
|
+
export const PI = ExpoWatchModule.PI;
|
|
8
|
+
export function hello() {
|
|
9
|
+
return ExpoWatchModule.hello();
|
|
10
|
+
}
|
|
11
|
+
export async function setValueAsync(value) {
|
|
12
|
+
return await ExpoWatchModule.setValueAsync(value);
|
|
13
|
+
}
|
|
14
|
+
const emitter = new EventEmitter(ExpoWatchModule ?? NativeModulesProxy.ExpoWatch);
|
|
15
|
+
export function addChangeListener(listener) {
|
|
16
|
+
return emitter.addListener('onChange', listener);
|
|
17
|
+
}
|
|
18
|
+
export { ExpoWatchView };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAgB,MAAM,mBAAmB,CAAC;AAEnF,4EAA4E;AAC5E,0CAA0C;AAC1C,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAG5C,iCAAiC;AACjC,MAAM,CAAC,MAAM,EAAE,GAAG,eAAe,CAAC,EAAE,CAAC;AAErC,MAAM,UAAU,KAAK;IACnB,OAAO,eAAe,CAAC,KAAK,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAa;IAC/C,OAAO,MAAM,eAAe,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,eAAe,IAAI,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAElF,MAAM,UAAU,iBAAiB,CAAC,QAA6C;IAC7E,OAAO,OAAO,CAAC,WAAW,CAAqB,UAAU,EAAE,QAAQ,CAAC,CAAC;AACvE,CAAC;AAED,OAAO,EAAE,aAAa,EAA0C,CAAC","sourcesContent":["import { NativeModulesProxy, EventEmitter, Subscription } from 'expo-modules-core';\n\n// Import the native module. On web, it will be resolved to ExpoWatch.web.ts\n// and on native platforms to ExpoWatch.ts\nimport ExpoWatchModule from './ExpoWatchModule';\nimport ExpoWatchView from './ExpoWatchView';\nimport { ChangeEventPayload, ExpoWatchViewProps } from './ExpoWatch.types';\n\n// Get the native constant value.\nexport const PI = ExpoWatchModule.PI;\n\nexport function hello(): string {\n return ExpoWatchModule.hello();\n}\n\nexport async function setValueAsync(value: string) {\n return await ExpoWatchModule.setValueAsync(value);\n}\n\nconst emitter = new EventEmitter(ExpoWatchModule ?? NativeModulesProxy.ExpoWatch);\n\nexport function addChangeListener(listener: (event: ChangeEventPayload) => void): Subscription {\n return emitter.addListener<ChangeEventPayload>('onChange', listener);\n}\n\nexport { ExpoWatchView, ExpoWatchViewProps, ChangeEventPayload };\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 = 'ExpoWatch'
|
|
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 = { :ios => '13.4', :tvos => '13.4' }
|
|
14
|
+
s.swift_version = '5.4'
|
|
15
|
+
s.source = { git: 'https://github.com/RobertSasak/expo-watch' }
|
|
16
|
+
s.static_framework = true
|
|
17
|
+
|
|
18
|
+
s.dependency 'ExpoModulesCore'
|
|
19
|
+
|
|
20
|
+
# Swift/Objective-C compatibility
|
|
21
|
+
s.pod_target_xcconfig = {
|
|
22
|
+
'DEFINES_MODULE' => 'YES',
|
|
23
|
+
'SWIFT_COMPILATION_MODE' => 'wholemodule'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
s.source_files = "**/*.{h,m,swift}"
|
|
27
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
|
|
3
|
+
public class ExpoWatchModule: 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('ExpoWatch')` in JavaScript.
|
|
11
|
+
Name("ExpoWatch")
|
|
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(ExpoWatchView.self) {
|
|
38
|
+
// Defines a setter for the `name` prop.
|
|
39
|
+
Prop("name") { (view: ExpoWatchView, prop: String) in
|
|
40
|
+
print(prop)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-watch",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Watch companion app for iOS Expo app. ",
|
|
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
|
+
"publish": "npx np"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"react-native",
|
|
21
|
+
"expo",
|
|
22
|
+
"expo-watch",
|
|
23
|
+
"ExpoWatch"
|
|
24
|
+
],
|
|
25
|
+
"repository": "https://github.com/RobertSasak/expo-watch",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/RobertSasak/expo-watch/issues"
|
|
28
|
+
},
|
|
29
|
+
"author": "Robert Sasak <robert.sasak@gmail.com> (https://github.com/RobertSasak)",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"homepage": "https://github.com/RobertSasak/expo-watch#readme",
|
|
32
|
+
"dependencies": {},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/react": "^18.0.25",
|
|
35
|
+
"expo-module-scripts": "^3.5.2",
|
|
36
|
+
"expo-modules-core": "^1.12.20",
|
|
37
|
+
"prettier": "3.3.3"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"expo": "*",
|
|
41
|
+
"react": "*",
|
|
42
|
+
"react-native": "*"
|
|
43
|
+
},
|
|
44
|
+
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
|
|
45
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { XcodeProject } from '@expo/config-plugins';
|
|
2
|
+
export declare function addBuildPhases(xcodeProject: XcodeProject, { targetUuid, groupName, productFile, compileSources, copyBundleResources, }: {
|
|
3
|
+
targetUuid: string;
|
|
4
|
+
groupName: string;
|
|
5
|
+
productFile: {
|
|
6
|
+
uuid: string;
|
|
7
|
+
target: string;
|
|
8
|
+
basename: string;
|
|
9
|
+
group: string;
|
|
10
|
+
};
|
|
11
|
+
compileSources: string[];
|
|
12
|
+
copyBundleResources: string[];
|
|
13
|
+
}): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.addBuildPhases = addBuildPhases;
|
|
7
|
+
const util_1 = __importDefault(require("util"));
|
|
8
|
+
function addBuildPhases(xcodeProject, { targetUuid, groupName, productFile, compileSources, copyBundleResources, }) {
|
|
9
|
+
const buildPath = `"$(CONTENTS_FOLDER_PATH)/Watch"`;
|
|
10
|
+
const folderType = 'watch2_app';
|
|
11
|
+
// Sources build phase
|
|
12
|
+
xcodeProject.addBuildPhase(compileSources, 'PBXSourcesBuildPhase', groupName, targetUuid, folderType, buildPath);
|
|
13
|
+
// Copy files build phase
|
|
14
|
+
xcodeProject.addBuildPhase([], 'PBXCopyFilesBuildPhase', groupName, xcodeProject.getFirstTarget().uuid, folderType, buildPath);
|
|
15
|
+
xcodeProject
|
|
16
|
+
.buildPhaseObject('PBXCopyFilesBuildPhase', groupName, productFile.target)
|
|
17
|
+
.files.push({
|
|
18
|
+
value: productFile.uuid,
|
|
19
|
+
comment: util_1.default.format('%s in %s', productFile.basename, productFile.group), // longComment(file);
|
|
20
|
+
});
|
|
21
|
+
xcodeProject.addToPbxBuildFileSection(productFile);
|
|
22
|
+
// Frameworks build phase
|
|
23
|
+
xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', groupName, targetUuid, folderType, buildPath);
|
|
24
|
+
// Resources build phase
|
|
25
|
+
xcodeProject.addBuildPhase(copyBundleResources, 'PBXResourcesBuildPhase', groupName, targetUuid, folderType, buildPath);
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addPbxGroup = addPbxGroup;
|
|
4
|
+
function addPbxGroup(xcodeProject, { targetName, files, }) {
|
|
5
|
+
const { uuid: pbxGroupUuid } = xcodeProject.addPbxGroup(files, `"${targetName}"`, `"../${targetName}"`);
|
|
6
|
+
const groups = xcodeProject.hash.project.objects['PBXGroup'];
|
|
7
|
+
if (pbxGroupUuid) {
|
|
8
|
+
Object.keys(groups).forEach(function (key) {
|
|
9
|
+
if (groups[key].name === undefined &&
|
|
10
|
+
groups[key].path === undefined) {
|
|
11
|
+
xcodeProject.addToPbxGroup(pbxGroupUuid, key);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|