diff --git a/example/.eslintrc.js b/example/.eslintrc.js deleted file mode 100644 index 40c6dcd05f..0000000000 --- a/example/.eslintrc.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - root: true, - extends: '@react-native-community', -}; diff --git a/example/.node-version b/example/.node-version deleted file mode 100644 index b6a7d89c68..0000000000 --- a/example/.node-version +++ /dev/null @@ -1 +0,0 @@ -16 diff --git a/example/.prettierrc.js b/example/.prettierrc.js deleted file mode 100644 index 2b540746a7..0000000000 --- a/example/.prettierrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - arrowParens: 'avoid', - bracketSameLine: true, - bracketSpacing: false, - singleQuote: true, - trailingComma: 'all', -}; diff --git a/example/.watchmanconfig b/example/.watchmanconfig deleted file mode 100644 index 9e26dfeeb6..0000000000 --- a/example/.watchmanconfig +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/example/Gemfile.lock b/example/Gemfile.lock deleted file mode 100644 index cc5d8137fa..0000000000 --- a/example/Gemfile.lock +++ /dev/null @@ -1,100 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - CFPropertyList (3.0.6) - rexml - activesupport (6.1.7.2) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - 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.11.3) - addressable (~> 2.8) - claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.11.3) - cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.4.0, < 2.0) - cocoapods-plugins (>= 1.0.0, < 2.0) - cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.4.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 (>= 1.0, < 3.0) - xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.11.3) - activesupport (>= 5.0, < 7) - 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.0) - 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.17.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) - zeitwerk (2.6.7) - -PLATFORMS - ruby - -DEPENDENCIES - cocoapods (~> 1.11, >= 1.11.3) - -RUBY VERSION - ruby 2.7.6p219 - -BUNDLED WITH - 2.1.4 diff --git a/example/android/app/src/main/res/values/strings.xml b/example/android/app/src/main/res/values/strings.xml deleted file mode 100644 index 1049fe7bd3..0000000000 --- a/example/android/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - RealmExample - diff --git a/example/android/gradle/wrapper/gradle-wrapper.jar b/example/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 41d9927a4d..0000000000 Binary files a/example/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/example/android/settings.gradle b/example/android/settings.gradle deleted file mode 100644 index d6de414b1c..0000000000 --- a/example/android/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name = 'RealmExample' -apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) -include ':app' -includeBuild('../../node_modules/react-native-gradle-plugin') diff --git a/example/app.json b/example/app.json deleted file mode 100644 index b29f45af6c..0000000000 --- a/example/app.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "RealmExample", - "displayName": "RealmExample" -} \ No newline at end of file diff --git a/example/app/AppNonSync.tsx b/example/app/AppNonSync.tsx deleted file mode 100644 index e4e93b4a27..0000000000 --- a/example/app/AppNonSync.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react'; - -import {Task} from './models/Task'; -import {TaskManager} from './components/TaskManager'; - -import {useQuery} from '@realm/react'; - -export const AppNonSync = () => { - const [showDone, setShowDone] = React.useState(false); - const tasks = useQuery( - Task, - collection => - showDone - ? collection.sorted('createdAt') - : collection.filtered('isComplete == false').sorted('createdAt'), - [showDone], - ); - - return ( - - ); -}; diff --git a/example/app/AppSync.tsx b/example/app/AppSync.tsx deleted file mode 100644 index a34ba257c8..0000000000 --- a/example/app/AppSync.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import React, {useEffect, useState} from 'react'; -import {useApp, useAuth, useQuery, useRealm, useUser} from '@realm/react'; -import {Pressable, StyleSheet, Text} from 'react-native'; - -import {Task} from './models/Task'; -import {TaskManager} from './components/TaskManager'; -import {buttonStyles} from './styles/button'; -import {shadows} from './styles/shadows'; -import colors from './styles/colors'; -import {OfflineModeButton} from './components/OfflineModeButton'; - -export const AppSync: React.FC = () => { - const realm = useRealm(); - const user = useUser(); - const app = useApp(); - const {logOut} = useAuth(); - const [showDone, setShowDone] = useState(false); - const tasks = useQuery( - Task, - collection => - showDone - ? collection.sorted('createdAt') - : collection.filtered('isComplete == false').sorted('createdAt'), - [showDone], - ); - - useEffect(() => { - realm.subscriptions.update(mutableSubs => { - mutableSubs.add(tasks); - }); - }, [realm, tasks]); - - return ( - <> - Syncing with app id: {app.id} - - - {`Logout ${user?.profile.email}`} - - - - ); -}; - -const styles = StyleSheet.create({ - idText: { - color: '#999', - paddingHorizontal: 20, - }, - authButton: { - ...buttonStyles.button, - ...shadows, - backgroundColor: colors.purpleDark, - }, - authButtonText: { - ...buttonStyles.text, - }, -}); diff --git a/example/app/AppWrapperNonSync.tsx b/example/app/AppWrapperNonSync.tsx deleted file mode 100644 index 39eb6bf243..0000000000 --- a/example/app/AppWrapperNonSync.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react'; -import {SafeAreaView, StyleSheet} from 'react-native'; - -import colors from './styles/colors'; -import {AppNonSync} from './AppNonSync'; - -import {RealmProvider} from '@realm/react'; -import {schemas} from './models'; - -export const AppWrapperNonSync = () => { - // If sync is disabled, setup the app without any sync functionality and return early - return ( - - - - - - ); -}; - -const styles = StyleSheet.create({ - screen: { - flex: 1, - backgroundColor: colors.darkBlue, - }, -}); diff --git a/example/app/AppWrapperSync.tsx b/example/app/AppWrapperSync.tsx deleted file mode 100644 index 954e5744c6..0000000000 --- a/example/app/AppWrapperSync.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react'; -import {AppProvider, UserProvider} from '@realm/react'; -import {SafeAreaView, StyleSheet} from 'react-native'; - -import {schemas} from './models'; -import {LoginScreen} from './components/LoginScreen'; -import colors from './styles/colors'; -import {AppSync} from './AppSync'; - -import {RealmProvider} from '@realm/react'; -import {OpenRealmBehaviorType, OpenRealmTimeOutBehavior} from 'realm'; - -export const AppWrapperSync: React.FC<{ - appId: string; -}> = ({appId}) => { - // If we are logged in, add the sync configuration the the RealmProvider and render the app - return ( - - - }> - - - - - - - ); -}; - -const styles = StyleSheet.create({ - screen: { - flex: 1, - backgroundColor: colors.darkBlue, - }, -}); - -export default AppWrapperSync; diff --git a/example/app/components/AddTaskForm.tsx b/example/app/components/AddTaskForm.tsx deleted file mode 100644 index 4fb09b64c3..0000000000 --- a/example/app/components/AddTaskForm.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React, {useState} from 'react'; -import { - View, - Text, - TextInput, - Pressable, - Platform, - StyleSheet, -} from 'react-native'; - -import {buttonStyles} from '../styles/button'; -import colors from '../styles/colors'; -import {shadows} from '../styles/shadows'; - -type AddTaskFormProps = { - onSubmit: (description: string) => void; -}; - -export const AddTaskForm: React.FC = ({onSubmit}) => { - const [description, setDescription] = useState(''); - - const handleSubmit = () => { - onSubmit(description); - setDescription(''); - }; - - return ( - - - - - - - ); -}; - -const styles = StyleSheet.create({ - form: { - height: 50, - marginBottom: 20, - flexDirection: 'row', - ...shadows, - }, - textInput: { - flex: 1, - paddingHorizontal: 15, - paddingVertical: Platform.OS === 'ios' ? 15 : 0, - borderRadius: 5, - backgroundColor: colors.white, - fontSize: 17, - }, - submit: { - ...buttonStyles.button, - width: 50, - height: '100%', - paddingHorizontal: 0, - paddingVertical: 0, - marginLeft: 20, - marginRight: 0, - }, - icon: { - ...buttonStyles.text, - }, -}); diff --git a/example/app/components/IntroText.tsx b/example/app/components/IntroText.tsx deleted file mode 100644 index b54ebd8e06..0000000000 --- a/example/app/components/IntroText.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import React from 'react'; -import {View, Text, Pressable, StyleSheet} from 'react-native'; -// @ts-ignore openURLInBrowser will open the url in your machine browser. (This isn't currently typed in React Native) -import openURLInBrowser from 'react-native/Libraries/Core/Devtools/openURLInBrowser'; - -import colors from '../styles/colors'; - -export const IntroText = () => { - return ( - - - Welcome to the Realm React Native TypeScript Template - - - Start adding a task using the form at the top of the screen to see how - they are created in Realm. You can also toggle the task status or remove - it from the list. - - - Learn more about the React Native Realm SDK at: - - - openURLInBrowser('https://docs.mongodb.com/realm/sdk/react-native/') - }> - - docs.mongodb.com/realm/sdk/react-native - - - - ); -}; - -const styles = StyleSheet.create({ - content: { - flex: 1, - marginHorizontal: 20, - justifyContent: 'center', - }, - paragraph: { - marginVertical: 10, - textAlign: 'center', - color: 'white', - fontSize: 17, - fontWeight: '500', - }, - link: { - color: colors.purple, - fontWeight: 'bold', - }, -}); diff --git a/example/app/components/LoginScreen.tsx b/example/app/components/LoginScreen.tsx deleted file mode 100644 index dd780e84d1..0000000000 --- a/example/app/components/LoginScreen.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import React, {useEffect, useState} from 'react'; -import {View, Text, StyleSheet, TextInput, Pressable} from 'react-native'; -import colors from '../styles/colors'; -import {shadows} from '../styles/shadows'; -import {buttonStyles} from '../styles/button'; -import {AuthOperationName, useAuth, useEmailPasswordAuth} from '@realm/react'; - -export const LoginScreen = () => { - const {result, logInWithEmailPassword} = useAuth(); - const {register} = useEmailPasswordAuth(); - const [email, setEmail] = useState(''); - const [password, setPassword] = useState(''); - - // Automatically log in after registration - useEffect(() => { - if (result.success && result.operation === AuthOperationName.Register) { - logInWithEmailPassword({email, password}); - } - }, [result, logInWithEmailPassword, email, password]); - - return ( - - - - - - - - {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})} - style={[styles.button, result.pending && styles.buttonDisabled]} - disabled={result.pending}> - Login - - - register({email, password})} - style={[ - styles.button, - result.pending && styles.buttonDisabled, - styles.registerButton, - ]} - disabled={result.pending}> - Register - - - - ); -}; - -const styles = StyleSheet.create({ - content: { - flex: 1, - alignItems: 'center', - justifyContent: 'center', - backgroundColor: colors.darkBlue, - }, - - inputContainer: { - padding: 10, - alignSelf: 'stretch', - marginHorizontal: 10, - }, - - error: { - textAlign: 'center', - marginTop: 10, - marginBottom: 10, - fontSize: 14, - color: colors.white, - }, - - input: { - borderWidth: 1, - borderColor: colors.gray, - padding: 10, - height: 50, - marginVertical: 8, - backgroundColor: colors.white, - borderRadius: 5, - ...shadows, - }, - - buttons: { - marginTop: 16, - flexDirection: 'row', - }, - - button: { - ...buttonStyles.button, - ...shadows, - }, - - buttonDisabled: { - opacity: 0.5, - }, - - registerButton: { - backgroundColor: colors.purpleDark, - }, -}); diff --git a/example/app/components/OfflineModeButton.tsx b/example/app/components/OfflineModeButton.tsx deleted file mode 100644 index 4795490e20..0000000000 --- a/example/app/components/OfflineModeButton.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import React, {useState} from 'react'; -import {StyleSheet, Switch, Text, View} from 'react-native'; -import {useRealm} from '@realm/react'; - -export function OfflineModeButton() { - const realm = useRealm(); - - const [pauseSync, togglePauseSync] = useState(false); - - return ( - - Disable Sync - { - if (!pauseSync && realm.syncSession?.state === 'active') { - realm.syncSession.pause(); - togglePauseSync(true); - } else if (pauseSync && realm.syncSession?.state === 'inactive') { - realm.syncSession.resume(); - togglePauseSync(false); - } - }} - value={realm.syncSession?.state === 'inactive'} - /> - - ); -} - -const styles = StyleSheet.create({ - icon: {padding: 12}, - toggleRow: { - flexDirection: 'row', - alignItems: 'center', - padding: 12, - }, - toggleText: { - flex: 1, - fontSize: 16, - color: '#fff', - fontWeight: 'bold', - }, -}); diff --git a/example/app/components/TaskItem.tsx b/example/app/components/TaskItem.tsx deleted file mode 100644 index 95aae8ec1d..0000000000 --- a/example/app/components/TaskItem.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import React from 'react'; -import Realm from 'realm'; -import {View, Text, Pressable, StyleSheet} from 'react-native'; - -import {shadows} from '../styles/shadows'; -import colors from '../styles/colors'; -import {Task} from '../models/Task'; - -type TaskItemProps = { - task: Task & Realm.Object; - onToggleStatus: () => void; - onDelete: () => void; -}; - -export const TaskItem = React.memo( - ({task, onToggleStatus, onDelete}) => { - return ( - - - {task.isComplete ? '✓' : '○'} - - - - {task.description} - - - - Delete - - - ); - }, -); - -const styles = StyleSheet.create({ - task: { - height: 50, - alignSelf: 'stretch', - flexDirection: 'row', - marginVertical: 8, - backgroundColor: colors.white, - borderRadius: 5, - ...shadows, - }, - descriptionContainer: { - flex: 1, - justifyContent: 'center', - }, - description: { - paddingHorizontal: 10, - color: colors.black, - fontSize: 17, - }, - status: { - width: 50, - height: '100%', - justifyContent: 'center', - borderTopLeftRadius: 5, - borderBottomLeftRadius: 5, - backgroundColor: colors.gray, - }, - completed: { - backgroundColor: colors.purple, - }, - deleteButton: { - justifyContent: 'center', - }, - deleteText: { - marginHorizontal: 10, - color: colors.gray, - fontSize: 17, - }, - icon: { - color: colors.white, - textAlign: 'center', - fontSize: 17, - fontWeight: 'bold', - }, -}); diff --git a/example/app/components/TaskList.tsx b/example/app/components/TaskList.tsx deleted file mode 100644 index 054fdf2f4d..0000000000 --- a/example/app/components/TaskList.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import React from 'react'; -import {View, FlatList, StyleSheet} from 'react-native'; -import {Realm} from '@realm/react'; - -import {Task} from '../models/Task'; -import {TaskItem} from './TaskItem'; - -type TaskListProps = { - tasks: Realm.Results; - onToggleTaskStatus: (task: Task & Realm.Object) => void; - onDeleteTask: (task: Task & Realm.Object) => void; -}; - -export const TaskList: React.FC = ({ - tasks, - onToggleTaskStatus, - onDeleteTask, -}) => { - return ( - - task._id.toString()} - renderItem={({item}) => ( - onToggleTaskStatus(item)} - onDelete={() => onDeleteTask(item)} - // Don't spread the Realm item as such: {...item} - /> - )} - /> - - ); -}; - -const styles = StyleSheet.create({ - listContainer: { - flex: 1, - justifyContent: 'center', - }, -}); - -export default TaskList; diff --git a/example/app/components/TaskManager.tsx b/example/app/components/TaskManager.tsx deleted file mode 100644 index 22d95955db..0000000000 --- a/example/app/components/TaskManager.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import React, {useCallback} from 'react'; -import {View, StyleSheet, Switch, Text} from 'react-native'; - -import {Task} from '../models/Task'; -import {IntroText} from './IntroText'; -import {AddTaskForm} from './AddTaskForm'; -import TaskList from './TaskList'; - -import {useRealm} from '@realm/react'; -import {shadows} from '../styles/shadows'; - -export const TaskManager: React.FC<{ - tasks: Realm.Results; - userId?: string; - setShowDone: (showDone: boolean) => void; - showDone: boolean; -}> = ({tasks, userId, setShowDone, showDone}) => { - const realm = useRealm(); - - const handleAddTask = useCallback( - (description: string): void => { - if (!description) { - return; - } - - // Everything in the function passed to "realm.write" is a transaction and will - // hence succeed or fail together. A transcation is the smallest unit of transfer - // in Realm so we want to be mindful of how much we put into one single transaction - // and split them up if appropriate (more commonly seen server side). Since clients - // may occasionally be online during short time spans we want to increase the probability - // of sync participants to successfully sync everything in the transaction, otherwise - // no changes propagate and the transaction needs to start over when connectivity allows. - realm.write(() => { - return realm.create(Task, { - description, - userId: userId ?? 'SYNC_DISABLED', - }); - }); - }, - [realm, userId], - ); - - const handleToggleTaskStatus = useCallback( - (task: Task & Realm.Object): void => { - realm.write(() => { - // Normally when updating a record in a NoSQL or SQL database, we have to type - // a statement that will later be interpreted and used as instructions for how - // to update the record. But in RealmDB, the objects are "live" because they are - // actually referencing the object's location in memory on the device (memory mapping). - // So rather than typing a statement, we modify the object directly by changing - // the property values. If the changes adhere to the schema, Realm will accept - // this new version of the object and wherever this object is being referenced - // locally will also see the changes "live". - task.isComplete = !task.isComplete; - }); - - // Alternatively if passing the ID as the argument to handleToggleTaskStatus: - // realm?.write(() => { - // const task = realm?.objectForPrimaryKey('Task', id); // If the ID is passed as an ObjectId - // const task = realm?.objectForPrimaryKey('Task', Realm.BSON.ObjectId(id)); // If the ID is passed as a string - // task.isComplete = !task.isComplete; - // }); - }, - [realm], - ); - - const handleDeleteTask = useCallback( - (task: Task & Realm.Object): void => { - realm.write(() => { - realm.delete(task); - - // Alternatively if passing the ID as the argument to handleDeleteTask: - // realm?.delete(realm?.objectForPrimaryKey('Task', id)); - }); - }, - [realm], - ); - - return ( - <> - - - {tasks.length === 0 ? ( - - ) : ( - - )} - - - Show Completed? - setShowDone(!showDone)} /> - - - ); -}; - -const styles = StyleSheet.create({ - content: { - flex: 1, - paddingTop: 20, - paddingHorizontal: 20, - }, - switchPanel: { - flexDirection: 'row', - backgroundColor: '#fff', - padding: 10, - borderRadius: 5, - marginHorizontal: 10, - marginBottom: 10, - ...shadows, - }, - switchPanelText: { - flex: 1, - fontSize: 16, - padding: 5, - }, -}); diff --git a/example/app/models/Task.ts b/example/app/models/Task.ts deleted file mode 100644 index 054201bac6..0000000000 --- a/example/app/models/Task.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This TS version of the Task model shows how to create Realm objects using -// TypeScript syntax, using `@realm/babel-plugin` -// (https://github.com/realm/realm-js/blob/main/packages/babel-plugin/). -// -// If you are not using TypeScript and `@realm/babel-plugin`, you instead need -// to defining a schema on the class - see `Task.js` in the Realm example app -// for an example of this. - -import Realm, {BSON} from 'realm'; - -// To use a class as a Realm object type in Typescript with the `@realm/babel-plugin` plugin, -// simply define the properties on the class with the correct type and the plugin will convert -// it to a Realm schema automatically. -export class Task extends Realm.Object { - _id: BSON.ObjectId = new BSON.ObjectId(); - description!: string; - isComplete: boolean = false; - createdAt: Date = new Date(); - userId!: string; - - static primaryKey = '_id'; -} diff --git a/example/app/models/index.ts b/example/app/models/index.ts deleted file mode 100644 index d8e88c0efe..0000000000 --- a/example/app/models/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import {Task} from './Task'; - -export const schemas = [Task]; diff --git a/example/app/styles/button.ts b/example/app/styles/button.ts deleted file mode 100644 index 28a096664d..0000000000 --- a/example/app/styles/button.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {StyleSheet} from 'react-native'; -import colors from './colors'; - -export const buttonStyles: StyleSheet.NamedStyles = { - button: { - paddingVertical: 10, - paddingHorizontal: 20, - justifyContent: 'center', - alignItems: 'center', - marginHorizontal: 10, - borderRadius: 5, - backgroundColor: colors.purple, - }, - text: { - color: colors.white, - textAlign: 'center', - fontSize: 17, - fontWeight: 'bold', - }, -}; diff --git a/example/app/styles/colors.ts b/example/app/styles/colors.ts deleted file mode 100644 index 5956c5d54c..0000000000 --- a/example/app/styles/colors.ts +++ /dev/null @@ -1,10 +0,0 @@ -const colors = { - darkBlue: '#2A3642', - purple: '#6E60F9', - purpleDark: '#4238a6', - gray: '#B5B5B5', - white: '#FFFFFF', - black: '#000000', -}; - -export default colors; diff --git a/example/app/styles/shadows.ts b/example/app/styles/shadows.ts deleted file mode 100644 index 105c24848c..0000000000 --- a/example/app/styles/shadows.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {Platform} from 'react-native'; -import colors from './colors'; - -export const shadows = Platform.select({ - ios: { - shadowColor: colors.black, - shadowOffset: { - width: 0, - height: 4, - }, - shadowOpacity: 0.7, - shadowRadius: 3, - }, - android: { - elevation: 3, - }, -}); diff --git a/example/babel.config.js b/example/babel.config.js deleted file mode 100644 index 4723d5e693..0000000000 --- a/example/babel.config.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - presets: ['module:metro-react-native-babel-preset'], - plugins: [ - '@realm/babel-plugin', - ['@babel/plugin-proposal-decorators', {legacy: true}], - ], -}; diff --git a/example/index.js b/example/index.js deleted file mode 100644 index 4872b460a6..0000000000 --- a/example/index.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @format - */ -import 'react-native-get-random-values'; -import React from 'react'; -import {AppRegistry} from 'react-native'; -import {AppWrapperNonSync} from './app/AppWrapperNonSync'; -import {AppWrapperSync} from './app/AppWrapperSync'; -import {name as appName} from './app.json'; -import {SYNC_CONFIG} from './sync.config'; - -const App = () => - SYNC_CONFIG.enabled ? ( - - ) : ( - - ); - -AppRegistry.registerComponent(appName, () => App); diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock deleted file mode 100644 index e6a209b1ce..0000000000 --- a/example/ios/Podfile.lock +++ /dev/null @@ -1,635 +0,0 @@ -PODS: - - boost (1.76.0) - - CocoaAsyncSocket (7.6.5) - - DoubleConversion (1.1.6) - - FBLazyVector (0.71.7) - - FBReactNativeSpec (0.71.7): - - RCT-Folly (= 2021.07.22.00) - - RCTRequired (= 0.71.7) - - RCTTypeSafety (= 0.71.7) - - React-Core (= 0.71.7) - - React-jsi (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - Flipper (0.125.0): - - Flipper-Folly (~> 2.6) - - Flipper-RSocket (~> 1.4) - - Flipper-Boost-iOSX (1.76.0.1.11) - - Flipper-DoubleConversion (3.2.0.1) - - Flipper-Fmt (7.1.7) - - Flipper-Folly (2.6.10): - - Flipper-Boost-iOSX - - Flipper-DoubleConversion - - Flipper-Fmt (= 7.1.7) - - Flipper-Glog - - libevent (~> 2.1.12) - - OpenSSL-Universal (= 1.1.1100) - - Flipper-Glog (0.5.0.5) - - Flipper-PeerTalk (0.0.4) - - Flipper-RSocket (1.4.3): - - Flipper-Folly (~> 2.6) - - FlipperKit (0.125.0): - - FlipperKit/Core (= 0.125.0) - - FlipperKit/Core (0.125.0): - - Flipper (~> 0.125.0) - - FlipperKit/CppBridge - - FlipperKit/FBCxxFollyDynamicConvert - - FlipperKit/FBDefines - - FlipperKit/FKPortForwarding - - SocketRocket (~> 0.6.0) - - FlipperKit/CppBridge (0.125.0): - - Flipper (~> 0.125.0) - - FlipperKit/FBCxxFollyDynamicConvert (0.125.0): - - Flipper-Folly (~> 2.6) - - FlipperKit/FBDefines (0.125.0) - - FlipperKit/FKPortForwarding (0.125.0): - - CocoaAsyncSocket (~> 7.6) - - Flipper-PeerTalk (~> 0.0.4) - - FlipperKit/FlipperKitHighlightOverlay (0.125.0) - - FlipperKit/FlipperKitLayoutHelpers (0.125.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutTextSearchable - - FlipperKit/FlipperKitLayoutIOSDescriptors (0.125.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutHelpers - - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutPlugin (0.125.0): - - FlipperKit/Core - - FlipperKit/FlipperKitHighlightOverlay - - FlipperKit/FlipperKitLayoutHelpers - - FlipperKit/FlipperKitLayoutIOSDescriptors - - FlipperKit/FlipperKitLayoutTextSearchable - - YogaKit (~> 1.18) - - FlipperKit/FlipperKitLayoutTextSearchable (0.125.0) - - FlipperKit/FlipperKitNetworkPlugin (0.125.0): - - FlipperKit/Core - - FlipperKit/FlipperKitReactPlugin (0.125.0): - - FlipperKit/Core - - FlipperKit/FlipperKitUserDefaultsPlugin (0.125.0): - - FlipperKit/Core - - FlipperKit/SKIOSNetworkPlugin (0.125.0): - - FlipperKit/Core - - FlipperKit/FlipperKitNetworkPlugin - - fmt (6.2.1) - - glog (0.3.5) - - hermes-engine (0.71.7): - - hermes-engine/Pre-built (= 0.71.7) - - hermes-engine/Pre-built (0.71.7) - - libevent (2.1.12) - - OpenSSL-Universal (1.1.1100) - - RCT-Folly (2021.07.22.00): - - boost - - DoubleConversion - - fmt (~> 6.2.1) - - glog - - RCT-Folly/Default (= 2021.07.22.00) - - RCT-Folly/Default (2021.07.22.00): - - boost - - DoubleConversion - - fmt (~> 6.2.1) - - glog - - RCT-Folly/Futures (2021.07.22.00): - - boost - - DoubleConversion - - fmt (~> 6.2.1) - - glog - - libevent - - RCTRequired (0.71.7) - - RCTTypeSafety (0.71.7): - - FBLazyVector (= 0.71.7) - - RCTRequired (= 0.71.7) - - React-Core (= 0.71.7) - - React (0.71.7): - - React-Core (= 0.71.7) - - React-Core/DevSupport (= 0.71.7) - - React-Core/RCTWebSocket (= 0.71.7) - - React-RCTActionSheet (= 0.71.7) - - React-RCTAnimation (= 0.71.7) - - React-RCTBlob (= 0.71.7) - - React-RCTImage (= 0.71.7) - - React-RCTLinking (= 0.71.7) - - React-RCTNetwork (= 0.71.7) - - React-RCTSettings (= 0.71.7) - - React-RCTText (= 0.71.7) - - React-RCTVibration (= 0.71.7) - - React-callinvoker (0.71.7) - - React-Codegen (0.71.7): - - FBReactNativeSpec - - hermes-engine - - RCT-Folly - - RCTRequired - - RCTTypeSafety - - React-Core - - React-jsi - - React-jsiexecutor - - ReactCommon/turbomodule/bridging - - ReactCommon/turbomodule/core - - React-Core (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default (= 0.71.7) - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/CoreModulesHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/Default (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/DevSupport (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default (= 0.71.7) - - React-Core/RCTWebSocket (= 0.71.7) - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-jsinspector (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTActionSheetHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTAnimationHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTBlobHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTImageHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTLinkingHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTNetworkHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTSettingsHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTTextHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTVibrationHeaders (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-Core/RCTWebSocket (0.71.7): - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Core/Default (= 0.71.7) - - React-cxxreact (= 0.71.7) - - React-hermes - - React-jsi (= 0.71.7) - - React-jsiexecutor (= 0.71.7) - - React-perflogger (= 0.71.7) - - Yoga - - React-CoreModules (0.71.7): - - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.7) - - React-Codegen (= 0.71.7) - - React-Core/CoreModulesHeaders (= 0.71.7) - - React-jsi (= 0.71.7) - - React-RCTBlob - - React-RCTImage (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - React-cxxreact (0.71.7): - - boost (= 1.76.0) - - DoubleConversion - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-callinvoker (= 0.71.7) - - React-jsi (= 0.71.7) - - React-jsinspector (= 0.71.7) - - React-logger (= 0.71.7) - - React-perflogger (= 0.71.7) - - React-runtimeexecutor (= 0.71.7) - - React-hermes (0.71.7): - - DoubleConversion - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - RCT-Folly/Futures (= 2021.07.22.00) - - React-cxxreact (= 0.71.7) - - React-jsi - - React-jsiexecutor (= 0.71.7) - - React-jsinspector (= 0.71.7) - - React-perflogger (= 0.71.7) - - React-jsi (0.71.7): - - boost (= 1.76.0) - - DoubleConversion - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-jsiexecutor (0.71.7): - - DoubleConversion - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-cxxreact (= 0.71.7) - - React-jsi (= 0.71.7) - - React-perflogger (= 0.71.7) - - React-jsinspector (0.71.7) - - React-logger (0.71.7): - - glog - - react-native-get-random-values (1.9.0): - - React-Core - - React-perflogger (0.71.7) - - React-RCTActionSheet (0.71.7): - - React-Core/RCTActionSheetHeaders (= 0.71.7) - - React-RCTAnimation (0.71.7): - - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.7) - - React-Codegen (= 0.71.7) - - React-Core/RCTAnimationHeaders (= 0.71.7) - - React-jsi (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - React-RCTAppDelegate (0.71.7): - - RCT-Folly - - RCTRequired - - RCTTypeSafety - - React-Core - - ReactCommon/turbomodule/core - - React-RCTBlob (0.71.7): - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-Codegen (= 0.71.7) - - React-Core/RCTBlobHeaders (= 0.71.7) - - React-Core/RCTWebSocket (= 0.71.7) - - React-jsi (= 0.71.7) - - React-RCTNetwork (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - React-RCTImage (0.71.7): - - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.7) - - React-Codegen (= 0.71.7) - - React-Core/RCTImageHeaders (= 0.71.7) - - React-jsi (= 0.71.7) - - React-RCTNetwork (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - React-RCTLinking (0.71.7): - - React-Codegen (= 0.71.7) - - React-Core/RCTLinkingHeaders (= 0.71.7) - - React-jsi (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - React-RCTNetwork (0.71.7): - - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.7) - - React-Codegen (= 0.71.7) - - React-Core/RCTNetworkHeaders (= 0.71.7) - - React-jsi (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - React-RCTSettings (0.71.7): - - RCT-Folly (= 2021.07.22.00) - - RCTTypeSafety (= 0.71.7) - - React-Codegen (= 0.71.7) - - React-Core/RCTSettingsHeaders (= 0.71.7) - - React-jsi (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - React-RCTText (0.71.7): - - React-Core/RCTTextHeaders (= 0.71.7) - - React-RCTVibration (0.71.7): - - RCT-Folly (= 2021.07.22.00) - - React-Codegen (= 0.71.7) - - React-Core/RCTVibrationHeaders (= 0.71.7) - - React-jsi (= 0.71.7) - - ReactCommon/turbomodule/core (= 0.71.7) - - React-runtimeexecutor (0.71.7): - - React-jsi (= 0.71.7) - - ReactCommon/turbomodule/bridging (0.71.7): - - DoubleConversion - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-callinvoker (= 0.71.7) - - React-Core (= 0.71.7) - - React-cxxreact (= 0.71.7) - - React-jsi (= 0.71.7) - - React-logger (= 0.71.7) - - React-perflogger (= 0.71.7) - - ReactCommon/turbomodule/core (0.71.7): - - DoubleConversion - - glog - - hermes-engine - - RCT-Folly (= 2021.07.22.00) - - React-callinvoker (= 0.71.7) - - React-Core (= 0.71.7) - - React-cxxreact (= 0.71.7) - - React-jsi (= 0.71.7) - - React-logger (= 0.71.7) - - React-perflogger (= 0.71.7) - - RealmJS (12.0.0): - - React - - SocketRocket (0.6.0) - - Yoga (1.14.0) - - YogaKit (1.18.1): - - Yoga (~> 1.14) - -DEPENDENCIES: - - boost (from `../../node_modules/react-native/third-party-podspecs/boost.podspec`) - - DoubleConversion (from `../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - - FBLazyVector (from `../../node_modules/react-native/Libraries/FBLazyVector`) - - FBReactNativeSpec (from `../../node_modules/react-native/React/FBReactNativeSpec`) - - Flipper (= 0.125.0) - - Flipper-Boost-iOSX (= 1.76.0.1.11) - - Flipper-DoubleConversion (= 3.2.0.1) - - Flipper-Fmt (= 7.1.7) - - Flipper-Folly (= 2.6.10) - - Flipper-Glog (= 0.5.0.5) - - Flipper-PeerTalk (= 0.0.4) - - Flipper-RSocket (= 1.4.3) - - FlipperKit (= 0.125.0) - - FlipperKit/Core (= 0.125.0) - - FlipperKit/CppBridge (= 0.125.0) - - FlipperKit/FBCxxFollyDynamicConvert (= 0.125.0) - - FlipperKit/FBDefines (= 0.125.0) - - FlipperKit/FKPortForwarding (= 0.125.0) - - FlipperKit/FlipperKitHighlightOverlay (= 0.125.0) - - FlipperKit/FlipperKitLayoutPlugin (= 0.125.0) - - FlipperKit/FlipperKitLayoutTextSearchable (= 0.125.0) - - FlipperKit/FlipperKitNetworkPlugin (= 0.125.0) - - FlipperKit/FlipperKitReactPlugin (= 0.125.0) - - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.125.0) - - FlipperKit/SKIOSNetworkPlugin (= 0.125.0) - - glog (from `../../node_modules/react-native/third-party-podspecs/glog.podspec`) - - hermes-engine (from `../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) - - libevent (~> 2.1.12) - - OpenSSL-Universal (= 1.1.1100) - - RCT-Folly (from `../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) - - RCTRequired (from `../../node_modules/react-native/Libraries/RCTRequired`) - - RCTTypeSafety (from `../../node_modules/react-native/Libraries/TypeSafety`) - - React (from `../../node_modules/react-native/`) - - React-callinvoker (from `../../node_modules/react-native/ReactCommon/callinvoker`) - - React-Codegen (from `build/generated/ios`) - - React-Core (from `../../node_modules/react-native/`) - - React-Core/DevSupport (from `../../node_modules/react-native/`) - - React-Core/RCTWebSocket (from `../../node_modules/react-native/`) - - React-CoreModules (from `../../node_modules/react-native/React/CoreModules`) - - React-cxxreact (from `../../node_modules/react-native/ReactCommon/cxxreact`) - - React-hermes (from `../../node_modules/react-native/ReactCommon/hermes`) - - React-jsi (from `../../node_modules/react-native/ReactCommon/jsi`) - - React-jsiexecutor (from `../../node_modules/react-native/ReactCommon/jsiexecutor`) - - React-jsinspector (from `../../node_modules/react-native/ReactCommon/jsinspector`) - - React-logger (from `../../node_modules/react-native/ReactCommon/logger`) - - react-native-get-random-values (from `../node_modules/react-native-get-random-values`) - - React-perflogger (from `../../node_modules/react-native/ReactCommon/reactperflogger`) - - React-RCTActionSheet (from `../../node_modules/react-native/Libraries/ActionSheetIOS`) - - React-RCTAnimation (from `../../node_modules/react-native/Libraries/NativeAnimation`) - - React-RCTAppDelegate (from `../../node_modules/react-native/Libraries/AppDelegate`) - - React-RCTBlob (from `../../node_modules/react-native/Libraries/Blob`) - - React-RCTImage (from `../../node_modules/react-native/Libraries/Image`) - - React-RCTLinking (from `../../node_modules/react-native/Libraries/LinkingIOS`) - - React-RCTNetwork (from `../../node_modules/react-native/Libraries/Network`) - - React-RCTSettings (from `../../node_modules/react-native/Libraries/Settings`) - - React-RCTText (from `../../node_modules/react-native/Libraries/Text`) - - React-RCTVibration (from `../../node_modules/react-native/Libraries/Vibration`) - - React-runtimeexecutor (from `../../node_modules/react-native/ReactCommon/runtimeexecutor`) - - ReactCommon/turbomodule/core (from `../../node_modules/react-native/ReactCommon`) - - RealmJS (from `../../node_modules/realm`) - - Yoga (from `../../node_modules/react-native/ReactCommon/yoga`) - -SPEC REPOS: - trunk: - - CocoaAsyncSocket - - Flipper - - Flipper-Boost-iOSX - - Flipper-DoubleConversion - - Flipper-Fmt - - Flipper-Folly - - Flipper-Glog - - Flipper-PeerTalk - - Flipper-RSocket - - FlipperKit - - fmt - - libevent - - OpenSSL-Universal - - SocketRocket - - YogaKit - -EXTERNAL SOURCES: - boost: - :podspec: "../../node_modules/react-native/third-party-podspecs/boost.podspec" - DoubleConversion: - :podspec: "../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" - FBLazyVector: - :path: "../../node_modules/react-native/Libraries/FBLazyVector" - FBReactNativeSpec: - :path: "../../node_modules/react-native/React/FBReactNativeSpec" - glog: - :podspec: "../../node_modules/react-native/third-party-podspecs/glog.podspec" - hermes-engine: - :podspec: "../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" - RCT-Folly: - :podspec: "../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" - RCTRequired: - :path: "../../node_modules/react-native/Libraries/RCTRequired" - RCTTypeSafety: - :path: "../../node_modules/react-native/Libraries/TypeSafety" - React: - :path: "../../node_modules/react-native/" - React-callinvoker: - :path: "../../node_modules/react-native/ReactCommon/callinvoker" - React-Codegen: - :path: build/generated/ios - React-Core: - :path: "../../node_modules/react-native/" - React-CoreModules: - :path: "../../node_modules/react-native/React/CoreModules" - React-cxxreact: - :path: "../../node_modules/react-native/ReactCommon/cxxreact" - React-hermes: - :path: "../../node_modules/react-native/ReactCommon/hermes" - React-jsi: - :path: "../../node_modules/react-native/ReactCommon/jsi" - React-jsiexecutor: - :path: "../../node_modules/react-native/ReactCommon/jsiexecutor" - React-jsinspector: - :path: "../../node_modules/react-native/ReactCommon/jsinspector" - React-logger: - :path: "../../node_modules/react-native/ReactCommon/logger" - react-native-get-random-values: - :path: "../node_modules/react-native-get-random-values" - React-perflogger: - :path: "../../node_modules/react-native/ReactCommon/reactperflogger" - React-RCTActionSheet: - :path: "../../node_modules/react-native/Libraries/ActionSheetIOS" - React-RCTAnimation: - :path: "../../node_modules/react-native/Libraries/NativeAnimation" - React-RCTAppDelegate: - :path: "../../node_modules/react-native/Libraries/AppDelegate" - React-RCTBlob: - :path: "../../node_modules/react-native/Libraries/Blob" - React-RCTImage: - :path: "../../node_modules/react-native/Libraries/Image" - React-RCTLinking: - :path: "../../node_modules/react-native/Libraries/LinkingIOS" - React-RCTNetwork: - :path: "../../node_modules/react-native/Libraries/Network" - React-RCTSettings: - :path: "../../node_modules/react-native/Libraries/Settings" - React-RCTText: - :path: "../../node_modules/react-native/Libraries/Text" - React-RCTVibration: - :path: "../../node_modules/react-native/Libraries/Vibration" - React-runtimeexecutor: - :path: "../../node_modules/react-native/ReactCommon/runtimeexecutor" - ReactCommon: - :path: "../../node_modules/react-native/ReactCommon" - RealmJS: - :path: "../../node_modules/realm" - Yoga: - :path: "../../node_modules/react-native/ReactCommon/yoga" - -SPEC CHECKSUMS: - boost: 57d2868c099736d80fcd648bf211b4431e51a558 - CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 - DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 - FBLazyVector: a89a0525bc7ca174675045c2b492b5280d5a2470 - FBReactNativeSpec: ca1f6fb923ad03cad73fda95e9a6d1dd8de72ae2 - Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0 - Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c - Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30 - Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b - Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3 - Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446 - Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 - Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541 - FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86 - fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 - glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b - hermes-engine: 4438d2b8bf8bebaba1b1ac0451160bab59e491f8 - libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 - OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c - RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 - RCTRequired: 5a4a30ac20c86eeadd6844a9328f78d4168cf9b2 - RCTTypeSafety: 279fc5861a89f0f37db3a585f27f971485b4b734 - React: 88307a9be3bd0e71a6822271cf28b84a587fb97f - React-callinvoker: 35fb980c454104ebe82f0afb9826830089248e08 - React-Codegen: a8dbde3b7476d5c19437d2adb9e8ea1b426b9595 - React-Core: 385cb6fa78762c6409ff39faeb0dd9ad664b6e84 - React-CoreModules: c2b7db313b04d9b71954ffd55d0c2e46bc40e9fb - React-cxxreact: 845fefb889132e5d004ff818f7a599e32c52e7d6 - React-hermes: 86135f35e1dd2dfccfb97afe96d0c06f6a3970c4 - React-jsi: 39c116aa6c3d6f3d9874eff6998a670b47882a28 - React-jsiexecutor: eaa5f71eb8f6861cf0e57f1a0f52aeb020d9e18e - React-jsinspector: 9885f6f94d231b95a739ef7bb50536fb87ce7539 - React-logger: 3f8ebad1be1bf3299d1ab6d7f971802d7395c7ef - react-native-get-random-values: dee677497c6a740b71e5612e8dbd83e7539ed5bb - React-perflogger: 2d505bbe298e3b7bacdd9e542b15535be07220f6 - React-RCTActionSheet: 0e96e4560bd733c9b37efbf68f5b1a47615892fb - React-RCTAnimation: fd138e26f120371c87e406745a27535e2c8a04ef - React-RCTAppDelegate: 4a9fd1230a98dc3d4382f8a934dc9f50834d8335 - React-RCTBlob: 38a7185f06a0ce8153a023e63b406a28d67b955d - React-RCTImage: 92b0966e7c1cadda889e961c474397ad5180e194 - React-RCTLinking: b80f8d0c6e94c54294b0048def51f57eaa9a27af - React-RCTNetwork: 491b0c65ac22edbd6695d12d084b4943103b009b - React-RCTSettings: 97af3e8abe0023349ec015910df3bda1a0380117 - React-RCTText: 33c85753bd714d527d2ae538dc56ec24c6783d84 - React-RCTVibration: 08f132cad9896458776f37c112e71d60aef1c6ae - React-runtimeexecutor: c5c89f8f543842dd864b63ded1b0bbb9c9445328 - ReactCommon: dbfbe2f7f3c5ce4ce44f43f2fd0d5950d1eb67c5 - RealmJS: fd89f477b8469188d45243c85bad4e0936d74457 - SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608 - Yoga: d56980c8914db0b51692f55533409e844b66133c - YogaKit: f782866e155069a2cca2517aafea43200b01fd5a - -PODFILE CHECKSUM: dd5c09cddf3cb19ccec399516256a7b048ea0785 - -COCOAPODS: 1.11.3 diff --git a/example/ios/RealmExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/RealmExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d981003d..0000000000 --- a/example/ios/RealmExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/example/metro.config.js b/example/metro.config.js deleted file mode 100644 index 28679c8a85..0000000000 --- a/example/metro.config.js +++ /dev/null @@ -1,6 +0,0 @@ -const config = require('@realm/metro-config')({projectRoot: __dirname}); - -// Prevent .js versions of files from being loaded in preference to TS -config.resolver.sourceExts = ['json', 'ts', 'tsx', 'js', 'jsx']; - -module.exports = config; diff --git a/example/sync.config.js b/example/sync.config.js deleted file mode 100644 index 2d6258edc8..0000000000 --- a/example/sync.config.js +++ /dev/null @@ -1,6 +0,0 @@ -export const SYNC_CONFIG = { - // Set `enabled` to `true` to enable sync. - enabled: false, - // Add your Realm App ID here if sync is enabled. - appId: '', -}; diff --git a/examples/rn-todo-list/README.md b/examples/rn-todo-list/README.md new file mode 100644 index 0000000000..d10d021f5d --- /dev/null +++ b/examples/rn-todo-list/README.md @@ -0,0 +1,218 @@ +# An Offline-First Todo List App Using Atlas Device SDK for React Native + +A todo list (task manager) app showcasing how to create, read, update, and delete data while offline using [MongoDB's Atlas Device SDK for React Native](https://www.mongodb.com/docs/realm/sdk/react-native/) (fka Realm). + +> **TIP:** This app can be run together with the corresponding [Electron example app](../electron-todo-list/) using the same [App Services App](./backend/). + +## Screenshots + +![Todo List Screenshot](./frontend/app/assets/screenshot-login-and-tasks.png) + +## Project Structure + +The following shows the project structure and the most relevant files. + +> To learn more about the backend file structure, see [App Configuration](https://www.mongodb.com/docs/atlas/app-services/reference/config/). + +``` +├── backend - App Services App +│ └── (see link above) +│ +├── frontend - React Native App +│ ├── app +│ │ ├── components +│ │ │ ├── AddTaskForm.tsx - Creates a task +│ │ │ ├── OfflineModeButton.tsx - Pauses/resumes the sync session +│ │ │ ├── TaskItem.tsx - Updates or deletes a task +│ │ │ └── TaskList.tsx - Displays all tasks +│ │ │ +│ │ ├── hooks +│ │ │ ├── useSyncConnection.ts - Functions for re/disconnecting +│ │ │ └── useTaskManager.ts - Functions for managing (CRUD) tasks +│ │ │ +│ │ ├── models +│ │ │ ├── index.ts - Exports all (1) models +│ │ │ └── Task.ts - Data model +│ │ │ +│ │ ├── screens +│ │ │ ├── LoginScreen.tsx - Login and registration +│ │ │ ├── TaskScreen.tsx - Display task components +│ │ │ └── TaskScreenSync.tsx - Task screen with sync-related ops +│ │ │ +│ │ ├── AppNonSync.tsx - Local-only app and opens Realm +│ │ └── AppSync.tsx - Sync-enabled app and opens Realm +│ │ +│ ├── index.js - Entry point +│ └── package.json - Dependencies +│ +├── README.md - Instructions and info +└── sync.config.js - Option to use Device Sync enabled app +``` + +## Use Cases + +This app focuses on showing how to work with data no matter the network connection. + +It specifically addresses the following points: + +* Registering and logging in to an App Services App using [Email/Password Authentication](https://www.mongodb.com/docs/atlas/app-services/authentication/email-password/). +* Accessing and updating data: + * Create + * Query/Read + * Sort and filter the query + * Update + * Delete +* Using offline/local-first reads and writes. + * Shows configuration for opening a synced Realm. + * Realms are opened immediately without waiting for downloads from the server. + * See [Offline Support](#note-offline-support) below. +* Allowing users to only read and write to their own tasks via [data access rules/permissions](https://www.mongodb.com/docs/atlas/app-services/rules/roles/#define-roles---permissions). + * See [Set Data Access Permissions](#set-data-access-permissions) further below. +* The app demonstrates both how to use *either*: + * A) A local-only app (see [AppNonSync.tsx](./frontend/app/AppNonSync.tsx)). + * B) A [Device Sync](https://www.mongodb.com/atlas/app-services/device-sync) enabled app (see [AppSync.tsx](./frontend/app/AppSync.tsx)). + * Choose which one to use via [sync.config.js](./frontend/sync.config.js). + +### Note: Offline Support + +Users who have logged in at least once will have their credentials cached on the client. Thus, a logged in user who restarts the app will remain logged in. [@realm/react's](https://www.npmjs.com/package/@realm/react) `UserProvider` automatically handles this for you by checking if the `app.currentUser` already exists. + +Data that was previously synced to the device will also exist locally in the Realm database. From this point on, users can be offline and still query and update data. Any changes made offline will be synced automatically to Atlas and any other devices once a network connection is established. If multiple users modify the same data either while online or offline, those conflicts are [automatically resolved](https://www.mongodb.com/docs/atlas/app-services/sync/details/conflict-resolution/) before being synced. + +#### Realm Configuration + +When opening a Realm, we can specify the behavior in the Realm configuration when opening it for the first time (via `newRealmFileBehavior`) and for subsequent ones (via `existingRealmFileBehavior`). We can either: +* `OpenRealmBehaviorType.OpenImmediately` + * Opens the Realm file immediately if it exists, otherwise it first creates a new empty Realm file then opens it. + * This lets users use the app with the existing data, while syncing any changes to the device in the background. +* `OpenRealmBehaviorType.DownloadBeforeOpen` + * If there is data to be downloaded, this waits for the data to be fully synced before opening the Realm. + +This app opens a Realm via `RealmProvider` (see [AppSync.tsx](./frontend/app/AppSync.tsx)) and passes the configuration as props. We use `OpenImmediately` for new and existing Realm files in order to use the app while offline. + +> See [OpenRealmBehaviorConfiguration](https://www.mongodb.com/docs/realm-sdks/js/latest/types/OpenRealmBehaviorConfiguration.html) for possible configurations of new and existing Realm file behaviors. + +## Getting Started + +### Prerequisites + +* [Node.js](https://nodejs.org/) +* [React Native development environment](https://reactnative.dev/docs/environment-setup?guide=native) + * Refer to the **"React Native CLI Quickstart"**. + +### Set up an Atlas Database + +Start by [deploying a free Atlas cluster](https://www.mongodb.com/docs/atlas/getting-started/#get-started-with-atlas) and create an Atlas database. + +### Set up an Atlas App Services App + +You can either choose to set up your App via a CLI (this has fewer steps and is much faster since all configurations are already provided in the [backend directory](./backend/)), or via the App Services UI (steps provided below). + +#### Via a CLI (recommended) + +To import and deploy changes from your local directory to App Services you can use the command line interface: + +1. [Set up Realm CLI](https://www.mongodb.com/docs/atlas/app-services/cli/). +2. In the provided [backend directory](./backend/) (the App Services App), update the following: + * Cluster Name + * Update the `"clusterName"` in [data_sources/mongodb-atlas/config.json](./backend/data_sources/mongodb-atlas/config.json) to the name of your cluster. + * (The default name is `Cluster0`.) + * App ID + * There is no `"app_id"` defined in [realm_config.json](./backend/realm_config.json) since we will create a brand new App. **If** you for some reason are updating an existing app, add an `"app_id"` field and its value. +3. [Push and deploy](https://www.mongodb.com/docs/atlas/app-services/cli/realm-cli-push/#std-label-realm-cli-push) the local directory to App Services: +```sh +realm-cli push --local +``` +4. Once pushed, verify that your App shows up in the App Services UI. +5. 🥳 You can now go ahead and [install dependencies and run the React Native app](#install-dependencies). + +#### Via the App Services UI + +To sync data used in this app you must first: + +1. [Create an App Services App](https://www.mongodb.com/docs/atlas/app-services/manage-apps/create/create-with-ui/). +2. [Enable Email/Password Authentication](https://www.mongodb.com/docs/atlas/app-services/authentication/email-password/). + * For this example app, we automatically confirm users' emails. +3. [Enable Flexible Sync](https://www.mongodb.com/docs/atlas/app-services/sync/configure/enable-sync/) with **Development Mode** enabled. + * When Development Mode is enabled, [queryable fields](https://www.mongodb.com/docs/atlas/app-services/sync/configure/sync-settings/#queryable-fields) will be added **automatically**, and schemas will be inferred based on the client Realm data models. + * For information, queryable fields used in this app include: + * Global (all collections): `_id` + * `Task` collection: `isComplete`, `userId` + * (Development Mode should be turned off in production.) +4. Don't forget to click `Review Draft and Deploy`. + +### Install Dependencies + +From the [frontend directory](./frontend/), run: + +```sh +npm install +``` + +If developing with iOS, also run: + +```sh +npx pod-install +``` + +### Run the App + +1. [Copy your Atlas App ID](https://www.mongodb.com/docs/atlas/app-services/reference/find-your-project-or-app-id/#std-label-find-your-app-id) from the App Services UI. +2. Set `SYNC_CONFIG.enabled` to `true` and paste the copied ID as the value of the existing variable `SYNC_CONFIG.appId` in [sync.config.js](./frontend/sync.config.js): +```js +export const SYNC_CONFIG = { + enabled: true, + appId: 'YOUR_APP_ID', +}; +``` +3. Start Metro (the JavaScript bundler) in its own terminal: +```sh +npm start +``` +4. In another terminal, start the app: +```sh +# Open the app on an iOS simulator. +npm run ios + +# Open the app on an Android emulator. +npm run android +``` + +> To run the app on an actual device, see React Native's [Running on Device](https://reactnative.dev/docs/running-on-device). + +### Set Data Access Permissions + +> If you set up your App Services App [via a CLI](#via-a-cli-recommended), you can **skip this step** as the permissions should already be defined for you. + +After running the client app for the first time, [modify the rules](https://www.mongodb.com/docs/atlas/app-services/rules/roles/#define-roles---permissions) for the collection in the App Services UI. + +* Collection: `Task` + * Permissions: `readOwnWriteOwn` (see [corresponding json](./backend/data_sources/mongodb-atlas/TodoList/Task/rules.json)) + * Explanation: + * A user should be able to read and write to their own document (i.e. when `Task.userId === `), but not anyone else's. + +> To learn more and see examples of permissions depending on a certain use case, see [Device Sync Permissions Guide](https://www.mongodb.com/docs/atlas/app-services/sync/app-builder/device-sync-permissions-guide/#std-label-flexible-sync-permissions-guide) and [Data Access Role Examples](https://www.mongodb.com/docs/atlas/app-services/rules/examples/). + +## Troubleshooting + +A great help when troubleshooting is to look at the [Application Logs](https://www.mongodb.com/docs/atlas/app-services/activity/view-logs/) in the App Services UI. + +### Permissions + +If permission is denied: + * Make sure your IP address is on the [IP Access List](https://www.mongodb.com/docs/atlas/app-services/security/network/#ip-access-list) for your App. + * Make sure you have the correct data access permissions for the collections. + * See [Set Data Access Permissions](#set-data-access-permissions) further above. + +### Removing the Local Realm Database + +Removing the local database can be useful for certain errors. + +On an iOS simulator: +1. Press and hold the app icon on the Home Screen. +2. Choose to remove the app and its data. + +On an Android emulator via Android Studio: +1. Quit the emulator if it is running. +2. Open `Device Manager`. +3. Select `Wipe Data` for the relevant emulator. diff --git a/examples/rn-todo-list/backend/README.md b/examples/rn-todo-list/backend/README.md new file mode 100644 index 0000000000..07508bebf5 --- /dev/null +++ b/examples/rn-todo-list/backend/README.md @@ -0,0 +1,7 @@ +# Backend + +This contains the Atlas App Services App and its configurations for the example app. + +Please see the [main README](../README.md) for all instructions. + +> To learn more about the backend file structure, see [App Configuration](https://www.mongodb.com/docs/atlas/app-services/reference/config/). diff --git a/examples/rn-todo-list/backend/auth/custom_user_data.json b/examples/rn-todo-list/backend/auth/custom_user_data.json new file mode 100644 index 0000000000..a82d0fb255 --- /dev/null +++ b/examples/rn-todo-list/backend/auth/custom_user_data.json @@ -0,0 +1,3 @@ +{ + "enabled": false +} diff --git a/examples/rn-todo-list/backend/auth/providers.json b/examples/rn-todo-list/backend/auth/providers.json new file mode 100644 index 0000000000..352f51d7d1 --- /dev/null +++ b/examples/rn-todo-list/backend/auth/providers.json @@ -0,0 +1,22 @@ +{ + "anon-user": { + "name": "anon-user", + "type": "anon-user", + "disabled": false + }, + "api-key": { + "name": "api-key", + "type": "api-key", + "disabled": true + }, + "local-userpass": { + "name": "local-userpass", + "type": "local-userpass", + "config": { + "autoConfirm": true, + "resetPasswordUrl": "https://", + "runConfirmationFunction": false + }, + "disabled": false + } +} diff --git a/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/relationships.json b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/relationships.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/relationships.json @@ -0,0 +1 @@ +{} diff --git a/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/rules.json b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/rules.json new file mode 100644 index 0000000000..6ca1b3345c --- /dev/null +++ b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/rules.json @@ -0,0 +1,23 @@ +{ + "collection": "Task", + "database": "TodoList", + "roles": [ + { + "name": "readOwnWriteOwn", + "apply_when": {}, + "document_filters": { + "write": { + "userId": "%%user.id" + }, + "read": { + "userId": "%%user.id" + } + }, + "read": true, + "write": true, + "insert": true, + "delete": true, + "search": true + } + ] +} diff --git a/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/schema.json b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/schema.json new file mode 100644 index 0000000000..08ef6db636 --- /dev/null +++ b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/TodoList/Task/schema.json @@ -0,0 +1,28 @@ +{ + "properties": { + "_id": { + "bsonType": "objectId" + }, + "createdAt": { + "bsonType": "date" + }, + "description": { + "bsonType": "string" + }, + "isComplete": { + "bsonType": "bool" + }, + "userId": { + "bsonType": "string" + } + }, + "required": [ + "_id", + "createdAt", + "description", + "isComplete", + "userId" + ], + "title": "Task", + "type": "object" +} diff --git a/examples/rn-todo-list/backend/data_sources/mongodb-atlas/config.json b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/config.json new file mode 100644 index 0000000000..9913676dd9 --- /dev/null +++ b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/config.json @@ -0,0 +1,10 @@ +{ + "name": "mongodb-atlas", + "type": "mongodb-atlas", + "config": { + "clusterName": "Cluster0", + "readPreference": "primary", + "wireProtocolEnabled": false + }, + "version": 1 +} diff --git a/examples/rn-todo-list/backend/data_sources/mongodb-atlas/default_rule.json b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/default_rule.json new file mode 100644 index 0000000000..86c55c8767 --- /dev/null +++ b/examples/rn-todo-list/backend/data_sources/mongodb-atlas/default_rule.json @@ -0,0 +1,17 @@ +{ + "roles": [ + { + "name": "readAndWriteAll", + "apply_when": {}, + "document_filters": { + "write": true, + "read": true + }, + "read": true, + "write": true, + "insert": true, + "delete": true, + "search": true + } + ] +} diff --git a/examples/rn-todo-list/backend/environments/development.json b/examples/rn-todo-list/backend/environments/development.json new file mode 100644 index 0000000000..ad7e98e68c --- /dev/null +++ b/examples/rn-todo-list/backend/environments/development.json @@ -0,0 +1,3 @@ +{ + "values": {} +} diff --git a/examples/rn-todo-list/backend/environments/no-environment.json b/examples/rn-todo-list/backend/environments/no-environment.json new file mode 100644 index 0000000000..ad7e98e68c --- /dev/null +++ b/examples/rn-todo-list/backend/environments/no-environment.json @@ -0,0 +1,3 @@ +{ + "values": {} +} diff --git a/examples/rn-todo-list/backend/environments/production.json b/examples/rn-todo-list/backend/environments/production.json new file mode 100644 index 0000000000..ad7e98e68c --- /dev/null +++ b/examples/rn-todo-list/backend/environments/production.json @@ -0,0 +1,3 @@ +{ + "values": {} +} diff --git a/examples/rn-todo-list/backend/environments/qa.json b/examples/rn-todo-list/backend/environments/qa.json new file mode 100644 index 0000000000..ad7e98e68c --- /dev/null +++ b/examples/rn-todo-list/backend/environments/qa.json @@ -0,0 +1,3 @@ +{ + "values": {} +} diff --git a/examples/rn-todo-list/backend/environments/testing.json b/examples/rn-todo-list/backend/environments/testing.json new file mode 100644 index 0000000000..ad7e98e68c --- /dev/null +++ b/examples/rn-todo-list/backend/environments/testing.json @@ -0,0 +1,3 @@ +{ + "values": {} +} diff --git a/examples/rn-todo-list/backend/functions/config.json b/examples/rn-todo-list/backend/functions/config.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/examples/rn-todo-list/backend/functions/config.json @@ -0,0 +1 @@ +[] diff --git a/examples/rn-todo-list/backend/graphql/config.json b/examples/rn-todo-list/backend/graphql/config.json new file mode 100644 index 0000000000..406b1abcde --- /dev/null +++ b/examples/rn-todo-list/backend/graphql/config.json @@ -0,0 +1,4 @@ +{ + "use_natural_pluralization": true, + "disable_schema_introspection": false +} diff --git a/examples/rn-todo-list/backend/http_endpoints/config.json b/examples/rn-todo-list/backend/http_endpoints/config.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/examples/rn-todo-list/backend/http_endpoints/config.json @@ -0,0 +1 @@ +[] diff --git a/examples/rn-todo-list/backend/realm_config.json b/examples/rn-todo-list/backend/realm_config.json new file mode 100644 index 0000000000..aff50a7db3 --- /dev/null +++ b/examples/rn-todo-list/backend/realm_config.json @@ -0,0 +1,7 @@ +{ + "config_version": 20210101, + "name": "Todo-List", + "location": "IE", + "provider_region": "aws-eu-west-1", + "deployment_model": "GLOBAL" +} diff --git a/examples/rn-todo-list/backend/sync/config.json b/examples/rn-todo-list/backend/sync/config.json new file mode 100644 index 0000000000..78f4a71c74 --- /dev/null +++ b/examples/rn-todo-list/backend/sync/config.json @@ -0,0 +1,19 @@ +{ + "type": "flexible", + "state": "enabled", + "development_mode_enabled": true, + "service_name": "mongodb-atlas", + "database_name": "TodoList", + "client_max_offline_days": 30, + "is_recovery_mode_disabled": false, + "permissions": { + "rules": {}, + "defaultRoles": [] + }, + "collection_queryable_fields_names": { + "Task": [ + "isComplete", + "userId" + ] + } +} diff --git a/example/.bundle/config b/examples/rn-todo-list/frontend/.bundle/config similarity index 100% rename from example/.bundle/config rename to examples/rn-todo-list/frontend/.bundle/config diff --git a/examples/rn-todo-list/frontend/.eslintrc.js b/examples/rn-todo-list/frontend/.eslintrc.js new file mode 100644 index 0000000000..308f4ed596 --- /dev/null +++ b/examples/rn-todo-list/frontend/.eslintrc.js @@ -0,0 +1,22 @@ +//////////////////////////////////////////////////////////////////////////// +// +// Copyright 2023 Realm Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////// + +module.exports = { + root: true, + extends: '@react-native', +}; diff --git a/example/.gitignore b/examples/rn-todo-list/frontend/.gitignore similarity index 97% rename from example/.gitignore rename to examples/rn-todo-list/frontend/.gitignore index 16f8c30773..0cab2ac6fc 100644 --- a/example/.gitignore +++ b/examples/rn-todo-list/frontend/.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/examples/rn-todo-list/frontend/.prettierrc.js b/examples/rn-todo-list/frontend/.prettierrc.js new file mode 100644 index 0000000000..6857cd6f1e --- /dev/null +++ b/examples/rn-todo-list/frontend/.prettierrc.js @@ -0,0 +1,25 @@ +//////////////////////////////////////////////////////////////////////////// +// +// Copyright 2023 Realm Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////// + +module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, + bracketSpacing: false, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/example/.ruby-version b/examples/rn-todo-list/frontend/.ruby-version similarity index 100% rename from example/.ruby-version rename to examples/rn-todo-list/frontend/.ruby-version diff --git a/examples/rn-todo-list/frontend/.watchmanconfig b/examples/rn-todo-list/frontend/.watchmanconfig new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/examples/rn-todo-list/frontend/.watchmanconfig @@ -0,0 +1 @@ +{} diff --git a/example/Gemfile b/examples/rn-todo-list/frontend/Gemfile similarity index 53% rename from example/Gemfile rename to examples/rn-todo-list/frontend/Gemfile index 567e59805c..1fa2c2e1ab 100644 --- a/example/Gemfile +++ b/examples/rn-todo-list/frontend/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/examples/rn-todo-list/frontend/README.md b/examples/rn-todo-list/frontend/README.md new file mode 100644 index 0000000000..97c45eac17 --- /dev/null +++ b/examples/rn-todo-list/frontend/README.md @@ -0,0 +1,5 @@ +# Frontend + +This contains the React Native code base for the example app. + +Please see the [main README](../README.md) for all instructions. diff --git a/example/__tests__/App-test.tsx b/examples/rn-todo-list/frontend/__tests__/App.test.tsx similarity index 65% rename from example/__tests__/App-test.tsx rename to examples/rn-todo-list/frontend/__tests__/App.test.tsx index 178476699b..b2ef268594 100644 --- a/example/__tests__/App-test.tsx +++ b/examples/rn-todo-list/frontend/__tests__/App.test.tsx @@ -4,7 +4,10 @@ import 'react-native'; import React from 'react'; -import App from '../App'; +import {App} from '../index'; + +// Note: import explicitly to use the types shipped 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/example/android/app/build.gradle b/examples/rn-todo-list/frontend/android/app/build.gradle similarity index 64% rename from example/android/app/build.gradle rename to examples/rn-todo-list/frontend/android/app/build.gradle index bceecd7e44..28d21fa625 100644 --- a/example/android/app/build.gradle +++ b/examples/rn-todo-list/frontend/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. @@ -12,11 +10,11 @@ react { // The root of your project, i.e. where "package.json" lives. Default is '..' // 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") + // 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 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") + // cliFile = file("../node_modules/react-native/cli.js") /* Variants */ // The list of variants to that are debuggable. For those we're going to @@ -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,38 +68,19 @@ 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 compileSdkVersion rootProject.ext.compileSdkVersion - namespace "com.realmexample" + namespace "com.examplerntodolist" defaultConfig { - applicationId "com.realmexample" + applicationId "com.examplerntodolist" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion 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' @@ -167,4 +120,4 @@ dependencies { } } -apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) +apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) diff --git a/example/android/app/debug.keystore b/examples/rn-todo-list/frontend/android/app/debug.keystore similarity index 100% rename from example/android/app/debug.keystore rename to examples/rn-todo-list/frontend/android/app/debug.keystore diff --git a/example/android/app/proguard-rules.pro b/examples/rn-todo-list/frontend/android/app/proguard-rules.pro similarity index 100% rename from example/android/app/proguard-rules.pro rename to examples/rn-todo-list/frontend/android/app/proguard-rules.pro diff --git a/example/android/app/src/debug/AndroidManifest.xml b/examples/rn-todo-list/frontend/android/app/src/debug/AndroidManifest.xml similarity index 100% rename from example/android/app/src/debug/AndroidManifest.xml rename to examples/rn-todo-list/frontend/android/app/src/debug/AndroidManifest.xml diff --git a/example/android/app/src/debug/java/com/realmexample/ReactNativeFlipper.java b/examples/rn-todo-list/frontend/android/app/src/debug/java/com/examplerntodolist/ReactNativeFlipper.java similarity index 99% rename from example/android/app/src/debug/java/com/realmexample/ReactNativeFlipper.java rename to examples/rn-todo-list/frontend/android/app/src/debug/java/com/examplerntodolist/ReactNativeFlipper.java index 3b5df21548..9ea2348a5b 100644 --- a/example/android/app/src/debug/java/com/realmexample/ReactNativeFlipper.java +++ b/examples/rn-todo-list/frontend/android/app/src/debug/java/com/examplerntodolist/ReactNativeFlipper.java @@ -4,7 +4,7 @@ *

This source code is licensed under the MIT license found in the LICENSE file in the root * directory of this source tree. */ -package com.realmexample; +package com.examplerntodolist; import android.content.Context; import com.facebook.flipper.android.AndroidFlipperClient; diff --git a/example/android/app/src/main/AndroidManifest.xml b/examples/rn-todo-list/frontend/android/app/src/main/AndroidManifest.xml similarity index 100% rename from example/android/app/src/main/AndroidManifest.xml rename to examples/rn-todo-list/frontend/android/app/src/main/AndroidManifest.xml diff --git a/example/android/app/src/main/java/com/realmexample/MainActivity.java b/examples/rn-todo-list/frontend/android/app/src/main/java/com/examplerntodolist/MainActivity.java similarity index 74% rename from example/android/app/src/main/java/com/realmexample/MainActivity.java rename to examples/rn-todo-list/frontend/android/app/src/main/java/com/examplerntodolist/MainActivity.java index d7550543a1..e4a8493c92 100644 --- a/example/android/app/src/main/java/com/realmexample/MainActivity.java +++ b/examples/rn-todo-list/frontend/android/app/src/main/java/com/examplerntodolist/MainActivity.java @@ -1,4 +1,4 @@ -package com.realmexample; +package com.examplerntodolist; import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; @@ -13,7 +13,7 @@ public class MainActivity extends ReactActivity { */ @Override protected String getMainComponentName() { - return "RealmExample"; + return "ExampleRnTodoList"; } /** @@ -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/example/android/app/src/main/java/com/realmexample/MainApplication.java b/examples/rn-todo-list/frontend/android/app/src/main/java/com/examplerntodolist/MainApplication.java similarity index 98% rename from example/android/app/src/main/java/com/realmexample/MainApplication.java rename to examples/rn-todo-list/frontend/android/app/src/main/java/com/examplerntodolist/MainApplication.java index d438b8e4a2..34eb221c40 100644 --- a/example/android/app/src/main/java/com/realmexample/MainApplication.java +++ b/examples/rn-todo-list/frontend/android/app/src/main/java/com/examplerntodolist/MainApplication.java @@ -1,4 +1,4 @@ -package com.realmexample; +package com.examplerntodolist; import android.app.Application; import com.facebook.react.PackageList; diff --git a/example/android/app/src/main/res/drawable/rn_edit_text_material.xml b/examples/rn-todo-list/frontend/android/app/src/main/res/drawable/rn_edit_text_material.xml similarity index 99% rename from example/android/app/src/main/res/drawable/rn_edit_text_material.xml rename to examples/rn-todo-list/frontend/android/app/src/main/res/drawable/rn_edit_text_material.xml index f35d996202..73b37e4d99 100644 --- a/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +++ b/examples/rn-todo-list/frontend/android/app/src/main/res/drawable/rn_edit_text_material.xml @@ -20,7 +20,7 @@ android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"> -