Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚛️ Enable experimental support for Expo Web #1169

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Commits on Aug 27, 2024

  1. simplify startprefs

    Instead of a fetch() call to get the startup config, let's load the JSON file using ES import syntax. (Rename the file to startupConfig.default.json in the process, get rid of the .sample)
    While here, we can tidy this code with async/await instead of promises.
    I also noticed that this function doesn't return the consent status; returning it simplifies every place where this is invoked.
    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    ab31400 View commit details
    Browse the repository at this point in the history
  2. import label-options.default.json

    instead of using fetch() we can use ES import here. Need to rename to *.json, so calling it label-options.default.json
    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    c53d090 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5232c84 View commit details
    Browse the repository at this point in the history
  4. use directly imported JSON files for local demo surveys

    Two versions of the demographics surveys are kept locally in e-mission-phone
    import them using ES import syntax instead of using fetch()
    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    714da6c View commit details
    Browse the repository at this point in the history
  5. add expo to the project

    New configuration for the repo– when using package.expo.json, we can serve the code as an expo web app
    
    I created a setup_expo script, similar to the other setup_* scripts to enable package.expo.json.
    Since the 'expo' configuration does not have a config.xml file, I modified configure_xml_and_json.js to ignore the xml file if it is not present
    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    06a3692 View commit details
    Browse the repository at this point in the history
  6. add metro.config.js to ignore libxslt

    Metro is like the React Rative ecosystem's version of webpack.
    Just like we tell webpack to ignore libxslt in webpack.config.js, we must also tell Metro to ignore it in metro.config.js
    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    d806962 View commit details
    Browse the repository at this point in the history
  7. add expo/cordova compatibility layer

    The entry point for the Cordova app is index.js, which uses react-native-web to createRoot on the #appRoot element of index.html
    
    The entry point for an Expo app will be App.tsx (defined in app.json)
    
    As such, a few things need to be moved around – index.js should have nothing except the createRoot business, and App.tsx should contain everything needed for the app including Providers, SafeAreaView wrapper, etc.
    
    To account for Cordova plugins not being available, we can leverage the mocks we have been using for testing; they are basically just minimal JS versions of the plugins (ie using localStorage instead of native DB storage, fetch instead of the ServerCommunication plugin, etc). We'll apply these mocks (in expoCompat.ts) if we detect that we are running in Expo web
    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    407f31b View commit details
    Browse the repository at this point in the history
  8. add .expo/ to .gitignore

    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    08e39b2 View commit details
    Browse the repository at this point in the history
  9. more expo compatibility shims

    useAppConfig
    cordova has a 'deviceready' event that we listen for before we can retrieve the config. Expo does not have this event, so we need to check IS_EXPO and only await if IS_EXPO is false
    
    usePermissionStatus
    We will not be needing any permission-enabled functionality on the Expo web version. We can add a usePermissionStatus.web.ts that will automatically be used in place of usePermissionStatus.ts for Expo web, and it has an empty `checkList` so no permissions will be requested.
    
    pushNotifySettings
    Similarly, we do not need push notifications on the web version, so we will export a function that does nothing from pushNotifySettings.web.ts
    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    cc56592 View commit details
    Browse the repository at this point in the history
  10. add the MaterialCommunityIcons font back to index.js

    Expo includes this font by default, but we do still need to include it in index.js for the Cordova configuration or the icons become blank
    JGreenlee committed Aug 27, 2024
    Configuration menu
    Copy the full SHA
    6edac7f View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    3f463ed View commit details
    Browse the repository at this point in the history

Commits on Aug 28, 2024

  1. expand mocks

    JGreenlee committed Aug 28, 2024
    Configuration menu
    Copy the full SHA
    8f4e30d View commit details
    Browse the repository at this point in the history
  2. tsconfig formatting

    JGreenlee committed Aug 28, 2024
    Configuration menu
    Copy the full SHA
    a5f6ce0 View commit details
    Browse the repository at this point in the history
  3. fix prettier

    JGreenlee committed Aug 28, 2024
    Configuration menu
    Copy the full SHA
    2939428 View commit details
    Browse the repository at this point in the history