diff --git a/example/app/components/LoginScreen.tsx b/example/app/components/LoginScreen.tsx index b23426e39d..dd780e84d1 100644 --- a/example/app/components/LoginScreen.tsx +++ b/example/app/components/LoginScreen.tsx @@ -43,19 +43,17 @@ export const LoginScreen = () => { placeholder="Password" /> - - {result?.error?.operation === AuthOperationName.LogIn && ( + {result?.error?.operation === + AuthOperationName.LogInWithEmailPassword && ( There was an error logging in, please try again{' '} )} - {result?.error?.operation === AuthOperationName.Register && ( There was an error registering, please try again )} - logInWithEmailPassword({email, password})} diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 43b9d33eb9..e6a209b1ce 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -415,7 +415,7 @@ PODS: - React-jsi (= 0.71.7) - React-logger (= 0.71.7) - React-perflogger (= 0.71.7) - - RealmJS (12.0.0-alpha.2): + - RealmJS (12.0.0): - React - SocketRocket (0.6.0) - Yoga (1.14.0) @@ -625,7 +625,7 @@ SPEC CHECKSUMS: React-RCTVibration: 08f132cad9896458776f37c112e71d60aef1c6ae React-runtimeexecutor: c5c89f8f543842dd864b63ded1b0bbb9c9445328 ReactCommon: dbfbe2f7f3c5ce4ce44f43f2fd0d5950d1eb67c5 - RealmJS: 496714a3baf2ba320af9e558b205281607ec1fd3 + RealmJS: fd89f477b8469188d45243c85bad4e0936d74457 SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 Yoga: d56980c8914db0b51692f55533409e844b66133c YogaKit: f782866e155069a2cca2517aafea43200b01fd5a diff --git a/package-lock.json b/package-lock.json index 9364b57754..993589741b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30255,7 +30255,7 @@ }, "packages/realm-react": { "name": "@realm/react", - "version": "0.5.2", + "version": "0.6.0", "license": "Apache-2.0", "dependencies": { "lodash": "^4.17.21" @@ -50118,7 +50118,7 @@ "rollup-plugin-dts": "^5.0.0", "rollup-plugin-istanbul": "^4.0.0", "tsm": "^2.2.2", - "typedoc-plugin-missing-exports": "*" + "typedoc-plugin-missing-exports": "^2.0.1" }, "dependencies": { "@types/mocha": { diff --git a/templates/expo-template/README.md b/templates/expo-template/README.md index 44b810fd73..2b88b7b72a 100644 --- a/templates/expo-template/README.md +++ b/templates/expo-template/README.md @@ -10,18 +10,16 @@ Simple Expo template to quickly get started with Realm. ## 🚀 How to use -If you haven't already, install the `expo-cli`: -``` -npm install --global expo-cli -``` +Use the following command to generate your template: + ``` -yarn global add expo-cli +npx create-expo-app MyAwesomeRealmApp --template @realm/expo-template ``` -Then use the following command to generate your template: +NOTE: version of `npm` before v9 may cause problems when initializing the template. If the initialization fails, please upgrade to the latest `npm` and try again. ``` -expo init MyAwesomeRealmApp --template @realm/expo-template +npm install -g npm ``` ## 🏃 How to build and run locally diff --git a/templates/expo-template/app/components/LoginScreen.tsx b/templates/expo-template/app/components/LoginScreen.tsx index b23426e39d..0f92e7fed3 100644 --- a/templates/expo-template/app/components/LoginScreen.tsx +++ b/templates/expo-template/app/components/LoginScreen.tsx @@ -44,7 +44,7 @@ export const LoginScreen = () => { /> - {result?.error?.operation === AuthOperationName.LogIn && ( + {result?.error?.operation === AuthOperationName.LogInWithEmailPassword && ( There was an error logging in, please try again{' '} diff --git a/templates/expo-template/package.json b/templates/expo-template/package.json index 4dec07fbfb..371a6f6932 100644 --- a/templates/expo-template/package.json +++ b/templates/expo-template/package.json @@ -1,6 +1,6 @@ { "name": "@realm/expo-template", - "version": "0.6.0", + "version": "0.7.0", "description": "Realm Template for Expo", "scripts": { "start": "expo start --dev-client", @@ -8,15 +8,15 @@ "ios": "expo run:ios" }, "dependencies": { - "@realm/react": "^0.5.1", - "expo": "~48.0.18", - "expo-dev-client": "~2.2.1", - "expo-splash-screen": "~0.18.2", - "expo-status-bar": "~1.4.4", + "@realm/react": "^0.6.0", + "expo": "^49.0.8", + "expo-dev-client": "~2.4.8", + "expo-splash-screen": "~0.20.5", + "expo-status-bar": "~1.6.0", "react": "18.2.0", - "react-native": "0.71.8", + "react-native": "0.72.4", "react-native-get-random-values": "~1.9.0", - "realm": "11.10.1" + "realm": "12.0.0" }, "devDependencies": { "@babel/core": "^7.22.5", diff --git a/templates/react-native-template/package.json b/templates/react-native-template/package.json index 28d5738ce7..387fd6ac86 100644 --- a/templates/react-native-template/package.json +++ b/templates/react-native-template/package.json @@ -1,6 +1,6 @@ { "name": "@realm/react-native-template", - "version": "0.6.0", + "version": "0.7.0", "description": "Realm Template for React Native", "scripts": { "lint": "cd template && npm run lint" diff --git a/templates/react-native-template/template/Gemfile b/templates/react-native-template/template/Gemfile index 567e59805c..1fa2c2e1ab 100644 --- a/templates/react-native-template/template/Gemfile +++ b/templates/react-native-template/template/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version -ruby File.read(File.join(__dir__, '.ruby-version')).strip +ruby ">= 2.6.10" -gem 'cocoapods', '~> 1.11', '>= 1.11.3' +gem 'cocoapods', '~> 1.12' diff --git a/templates/react-native-template/template/Gemfile.lock b/templates/react-native-template/template/Gemfile.lock deleted file mode 100644 index 3c47f1d247..0000000000 --- a/templates/react-native-template/template/Gemfile.lock +++ /dev/null @@ -1,98 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - CFPropertyList (3.0.6) - rexml - activesupport (7.0.4.3) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) - algoliasearch (1.27.5) - httpclient (~> 2.8, >= 2.8.3) - json (>= 1.5.1) - atomos (0.1.3) - claide (1.1.0) - cocoapods (1.12.0) - addressable (~> 2.8) - claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.12.0) - cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.6.0, < 2.0) - cocoapods-plugins (>= 1.0.0, < 2.0) - cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.6.0, < 2.0) - cocoapods-try (>= 1.1.0, < 2.0) - colored2 (~> 3.1) - escape (~> 0.0.4) - fourflusher (>= 2.3.0, < 3.0) - gh_inspector (~> 1.0) - molinillo (~> 0.8.0) - nap (~> 1.0) - ruby-macho (>= 2.3.0, < 3.0) - xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.12.0) - activesupport (>= 5.0, < 8) - addressable (~> 2.8) - algoliasearch (~> 1.0) - concurrent-ruby (~> 1.1) - fuzzy_match (~> 2.0.4) - nap (~> 1.0) - netrc (~> 0.11) - public_suffix (~> 4.0) - typhoeus (~> 1.0) - cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.6.3) - cocoapods-plugins (1.0.0) - nap - cocoapods-search (1.0.1) - cocoapods-trunk (1.6.0) - nap (>= 0.8, < 2.0) - netrc (~> 0.11) - cocoapods-try (1.2.0) - colored2 (3.1.2) - concurrent-ruby (1.2.2) - escape (0.0.4) - ethon (0.16.0) - ffi (>= 1.15.0) - ffi (1.15.5) - fourflusher (2.3.1) - fuzzy_match (2.0.4) - gh_inspector (1.1.3) - httpclient (2.8.3) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - json (2.6.3) - minitest (5.18.0) - molinillo (0.8.0) - nanaimo (0.3.0) - nap (1.1.0) - netrc (0.11.0) - public_suffix (4.0.7) - rexml (3.2.5) - ruby-macho (2.5.1) - typhoeus (1.4.0) - ethon (>= 0.9.0) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - xcodeproj (1.22.0) - CFPropertyList (>= 2.3.3, < 4.0) - atomos (~> 0.1.3) - claide (>= 1.0.2, < 2.0) - colored2 (~> 3.1) - nanaimo (~> 0.3.0) - rexml (~> 3.2.4) - -PLATFORMS - ruby - -DEPENDENCIES - cocoapods (~> 1.11, >= 1.11.3) - -RUBY VERSION - ruby 2.7.6p219 - -BUNDLED WITH - 2.1.4 diff --git a/templates/react-native-template/template/README.md b/templates/react-native-template/template/README.md new file mode 100644 index 0000000000..57d825adfb --- /dev/null +++ b/templates/react-native-template/template/README.md @@ -0,0 +1,85 @@ +Simple React Native template to quickly get started with Realm. + +This app implements a simple todo list, using Realm for persistence and the [Realm React](https://github.com/realm/realm-js/tree/master/packages/realm-react) hooks for React integration. It supports sync, allowing users to login and sync their todo lists across multiple devices. + +# Getting Started + +>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding. + +## 🔀 Setting up sync + +See https://github.com/realm/realm-js/blob/main/templates/docs/sync-setup.md for instructions. + +## Step 1: Start the Metro Server + +First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native. + +To start Metro, run the following command from the _root_ of your React Native project: + +```bash +# using npm +npm start + +# OR using Yarn +yarn start +``` + +## Step 2: Start your Application + +Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app: + +### For Android + +```bash +# using npm +npm run android + +# OR using Yarn +yarn android +``` + +### For iOS + +```bash +# using npm +npm run ios + +# OR using Yarn +yarn ios +``` + +If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly. + +This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively. + +## Step 3: Modifying your App + +Now that you have successfully run the app, let's modify it. + +1. Open `App.tsx` in your text editor of choice and edit some lines. +2. For **Android**: Press the R key twice or select **"Reload"** from the **Developer Menu** (Ctrl + M (on Window and Linux) or Cmd ⌘ + M (on macOS)) to see your changes! + + For **iOS**: Hit Cmd ⌘ + R in your iOS Simulator to reload the app and see your changes! + +## Congratulations! :tada: + +You've successfully run and modified your React Native App. :partying_face: + +### Now what? + +- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps). +- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started). + +# Troubleshooting + +If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page. + +# Learn More + +To learn more about React Native, take a look at the following resources: + +- [React Native Website](https://reactnative.dev) - learn more about React Native. +- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment. +- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**. +- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts. +- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native. diff --git a/templates/react-native-template/template/__tests__/App-test.tsx b/templates/react-native-template/template/__tests__/App.test.tsx similarity index 73% rename from templates/react-native-template/template/__tests__/App-test.tsx rename to templates/react-native-template/template/__tests__/App.test.tsx index 178476699b..3413ac1c40 100644 --- a/templates/react-native-template/template/__tests__/App-test.tsx +++ b/templates/react-native-template/template/__tests__/App.test.tsx @@ -6,6 +6,9 @@ import 'react-native'; import React from 'react'; import App from '../App'; +// Note: import explicitly to use the types shiped with jest. +import {it} from '@jest/globals'; + // Note: test renderer must be required after react-native. import renderer from 'react-test-renderer'; diff --git a/templates/react-native-template/template/_eslintrc.js b/templates/react-native-template/template/_eslintrc.js index 40c6dcd05f..187894b6af 100644 --- a/templates/react-native-template/template/_eslintrc.js +++ b/templates/react-native-template/template/_eslintrc.js @@ -1,4 +1,4 @@ module.exports = { root: true, - extends: '@react-native-community', + extends: '@react-native', }; diff --git a/templates/react-native-template/template/_gitignore b/templates/react-native-template/template/_gitignore index 16f8c30773..0cab2ac6fc 100644 --- a/templates/react-native-template/template/_gitignore +++ b/templates/react-native-template/template/_gitignore @@ -61,3 +61,6 @@ yarn-error.log # Temporary files created by Metro to check the health of the file watcher .metro-health-check* + +# testing +/coverage diff --git a/templates/react-native-template/template/_node-version b/templates/react-native-template/template/_node-version deleted file mode 100644 index 3c032078a4..0000000000 --- a/templates/react-native-template/template/_node-version +++ /dev/null @@ -1 +0,0 @@ -18 diff --git a/templates/react-native-template/template/_ruby-version b/templates/react-native-template/template/_ruby-version deleted file mode 100644 index 49cdd668e1..0000000000 --- a/templates/react-native-template/template/_ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.7.6 diff --git a/templates/react-native-template/template/_watchmanconfig b/templates/react-native-template/template/_watchmanconfig index 9e26dfeeb6..0967ef424b 100644 --- a/templates/react-native-template/template/_watchmanconfig +++ b/templates/react-native-template/template/_watchmanconfig @@ -1 +1 @@ -{} \ No newline at end of file +{} diff --git a/templates/react-native-template/template/android/app/build.gradle b/templates/react-native-template/template/android/app/build.gradle index 8f24a2d835..7cc22030af 100644 --- a/templates/react-native-template/template/android/app/build.gradle +++ b/templates/react-native-template/template/android/app/build.gradle @@ -1,8 +1,6 @@ apply plugin: "com.android.application" apply plugin: "com.facebook.react" -import com.android.build.OutputFile - /** * This is the configuration block to customize your React Native Android app. * By default you don't need to apply any configuration, just uncomment the lines you need. @@ -13,8 +11,8 @@ react { // root = file("../") // The folder where the react-native NPM package is. Default is ../node_modules/react-native // reactNativeDir = file("../node_modules/react-native") - // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen - // codegenDir = file("../node_modules/react-native-codegen") + // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen + // codegenDir = file("../node_modules/@react-native/codegen") // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js // cliFile = file("../node_modules/react-native/cli.js") @@ -52,14 +50,6 @@ react { // hermesFlags = ["-O", "-output-source-map"] } -/** - * Set this to true to create four separate APKs instead of one, - * one for each native architecture. This is useful if you don't - * use App Bundles (https://developer.android.com/guide/app-bundle/) - * and want to have separate APKs to upload to the Play Store. - */ -def enableSeparateBuildPerCPUArchitecture = false - /** * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ @@ -78,16 +68,6 @@ def enableProguardInReleaseBuilds = false */ def jscFlavor = 'org.webkit:android-jsc:+' -/** - * Private function to get the list of Native Architectures you want to build. - * This reads the value from reactNativeArchitectures in your gradle.properties - * file and works together with the --active-arch-only flag of react-native run-android. - */ -def reactNativeArchitectures() { - def value = project.getProperties().get("reactNativeArchitectures") - return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] -} - android { ndkVersion rootProject.ext.ndkVersion @@ -101,15 +81,6 @@ android { versionCode 1 versionName "1.0" } - - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include (*reactNativeArchitectures()) - } - } signingConfigs { debug { storeFile file('debug.keystore') @@ -130,30 +101,12 @@ android { proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } - - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // https://developer.android.com/studio/build/configure-apk-splits.html - // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. - def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - defaultConfig.versionCode * 1000 + versionCodes.get(abi) - } - - } - } } dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android") - implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") - debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group:'com.squareup.okhttp3', module:'okhttp' diff --git a/templates/react-native-template/template/android/app/src/main/java/com/realmtemplate/MainActivity.java b/templates/react-native-template/template/android/app/src/main/java/com/realmtemplate/MainActivity.java index e638593c4e..9624c0b580 100644 --- a/templates/react-native-template/template/android/app/src/main/java/com/realmtemplate/MainActivity.java +++ b/templates/react-native-template/template/android/app/src/main/java/com/realmtemplate/MainActivity.java @@ -27,9 +27,6 @@ protected ReactActivityDelegate createReactActivityDelegate() { this, getMainComponentName(), // If you opted-in for the New Architecture, we enable the Fabric Renderer. - DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled - // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18). - DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled - ); + DefaultNewArchitectureEntryPoint.getFabricEnabled()); } } diff --git a/templates/react-native-template/template/android/app/src/main/res/drawable/rn_edit_text_material.xml b/templates/react-native-template/template/android/app/src/main/res/drawable/rn_edit_text_material.xml index f35d996202..73b37e4d99 100644 --- a/templates/react-native-template/template/android/app/src/main/res/drawable/rn_edit_text_material.xml +++ b/templates/react-native-template/template/android/app/src/main/res/drawable/rn_edit_text_material.xml @@ -20,7 +20,7 @@ android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"> -