diff --git a/.cspell/backend_custom_words.txt b/.cspell/backend_custom_words.txt
new file mode 100644
index 000000000..4df68be4e
--- /dev/null
+++ b/.cspell/backend_custom_words.txt
@@ -0,0 +1,36 @@
+tauri
+rustup
+aarch
+sdcore
+dotenv
+dotenvy
+prismjs
+actix
+rtype
+healthcheck
+sdserver
+ipfs
+impls
+crdt
+quicktime
+creationdate
+imageops
+thumbnailer
+HEXLOWER
+chrono
+walkdir
+thiserror
+thumbstrip
+repr
+Deque
+oneshot
+sdlibrary
+sdconfig
+DOTFILE
+sysinfo
+initialising
+struct
+UHLC
+CRDTs
+PRRTT
+filesystems
\ No newline at end of file
diff --git a/.cspell/frontend_custom_words.txt b/.cspell/frontend_custom_words.txt
new file mode 100644
index 000000000..5506b5162
--- /dev/null
+++ b/.cspell/frontend_custom_words.txt
@@ -0,0 +1,84 @@
+pnpm
+titlebar
+consts
+pallete
+unlisten
+svgr
+middlewares
+clsx
+SDWEB
+tryghost
+tsparticles
+Opencollective
+Waitlist
+heroicons
+roadmap
+semibold
+noreferer
+Rescan
+subpackage
+photoslibrary
+fontsource
+audiomp
+audioogg
+audiowav
+browserslist
+bsconfig
+cheader
+compodoc
+cssmap
+dartlang
+dockerdebug
+folderlight
+folderopen
+fontotf
+fontttf
+fontwoff
+gopackage
+haml
+imagegif
+imageico
+imagejpg
+imagepng
+ipynb
+jsmap
+lighteditorconfig
+nestjscontroller
+nestjs
+nestjsdecorator
+nestjsfilter
+nestjsguard
+nestjsmodule
+nestjsservice
+npmlock
+nuxt
+opengl
+photoshop
+postcssconfig
+powershelldata
+reactjs
+rjson
+symfony
+testjs
+tmpl
+typescriptdef
+windi
+yarnerror
+unlisten
+imagewebp
+powershellmodule
+reactts
+testts
+zustand
+overscan
+webp
+headlessui
+falsey
+nums
+lacie
+classname
+wunsub
+immer
+tada
+moti
+pressable
\ No newline at end of file
diff --git a/.cspell/project_words.txt b/.cspell/project_words.txt
new file mode 100644
index 000000000..882cf4dda
--- /dev/null
+++ b/.cspell/project_words.txt
@@ -0,0 +1,42 @@
+spacedrive
+spacedriveapp
+vdfs
+haoyuan
+brendonovich
+codegen
+elon
+deel
+haden
+akar
+benja
+haris
+mehrzad
+OSSC
+josephjacks
+rauch
+ravikant
+neha
+narkhede
+allred
+lütke
+tobiaslutke
+justinhoffman
+rywalker
+zacharysmith
+sanjay
+poonen
+mytton
+davidmytton
+richelsen
+lesterlee
+alluxio
+augusto
+marietti
+vijay
+sharma
+naveen
+noco
+rspc
+rspcws
+stringly
+specta
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index ebfdf771d..bb30b4082 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -8,9 +8,11 @@
# frontend apps (Rust bridges and tech functionality -- no real visual implications)
/apps/desktop/ @jamiepine @Brendonovich @oscartbeaumont
-/apps/mobile/ @jamiepine @Brendonovich @oscartbeaumont
/apps/web/ @jamiepine @maxichrome
+# mobile
+/apps/mobile/ @jamiepine @Brendonovich @oscartbeaumont @utkubakir
+
# core logic
/core/ @jamiepine @Brendonovich @oscartbeaumont
/packages/macos/ @jamiepine @Brendonovich @oscartbeaumont
@@ -22,8 +24,9 @@
/apps/landing/ @jamiepine @maxichrome
# UI
-/packages/interface/ @jamiepine @maxichrome
+/packages/interface/ @jamiepine @maxichrome @utkubakir
/packages/ui/ @jamiepine @maxichrome
+/packages/assets/ @jamiepine @utkubakir
# base config files
/* @jamiepine
diff --git a/.github/scripts/setup-system.ps1 b/.github/scripts/setup-system.ps1
index 9a8a206b5..cb098db7c 100644
--- a/.github/scripts/setup-system.ps1
+++ b/.github/scripts/setup-system.ps1
@@ -1,10 +1,181 @@
-Write-Host "This script is currently being used by CI and will need some more work before anyone can use it like the 'setup-system.sh' script for macOS and Linux!"
+# Get ci parameter to check if running with ci
+param(
+ [Parameter()]
+ [Switch]$ci
+)
-$VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
-Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n"
-Invoke-WebRequest "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-full-shared.7z" -OutFile ffmpeg-release-full-shared.7z
-7z x ffmpeg-release-full-shared.7z
-mkdir ffmpeg
-mv ffmpeg-*/* ffmpeg/
-Add-Content $env:GITHUB_ENV "FFMPEG_DIR=${pwd}\ffmpeg`n"
-Add-Content $env:GITHUB_PATH "${pwd}\ffmpeg\bin`n"
\ No newline at end of file
+# Get temp folder
+$temp = [System.IO.Path]::GetTempPath()
+
+# Get current running dir
+$currentLocation = $((Get-Location).path)
+
+# Check to see if a command exists (eg if an app is installed)
+Function CheckCommand {
+
+ Param ($command)
+
+ $oldPreference = $ErrorActionPreference
+
+ $ErrorActionPreference = 'stop'
+
+ try { if (Get-Command $command) { RETURN $true } }
+
+ Catch { RETURN $false }
+
+ Finally { $ErrorActionPreference = $oldPreference }
+
+}
+
+Write-Host "Spacedrive Development Environment Setup" -ForegroundColor Magenta
+Write-Host @"
+
+To set up your machine for Spacedrive development, this script will do the following:
+
+1) Check for Rust and Cargo
+
+2) Install pnpm (if not installed)
+
+3) Install the latest version of Node.js using pnpm
+
+4) Install LLVM (compiler for ffmpeg-rust)
+
+4) Download ffmpeg and set as an environment variable
+
+"@
+
+Write-Host "Checking for Rust and Cargo..." -ForegroundColor Yellow
+Start-Sleep -Milliseconds 150
+
+$cargoCheck = CheckCommand cargo
+
+if ($cargoCheck -eq $false) {
+ Write-Host @"
+Cargo is not installed.
+
+To use Spacedrive on Windows, Cargo needs to be installed.
+The Visual Studio C++ Build tools are also required.
+Instructions can be found here:
+
+https://tauri.app/v1/guides/getting-started/prerequisites/#setting-up-windows
+
+Once you have installed Cargo, re-run this script.
+
+"@
+ Exit
+}
+else {
+ Write-Host "Cargo is installed."
+}
+
+Write-Host
+Write-Host "Checking for pnpm..." -ForegroundColor Yellow
+Start-Sleep -Milliseconds 150
+
+$pnpmCheck = CheckCommand pnpm
+if ($pnpmCheck -eq $false) {
+
+ Write-Host "pnpm is not installed. Installing now."
+ Write-Host "Running the pnpm installer..."
+
+ #pnpm installer taken from https://pnpm.io
+ Invoke-WebRequest https://get.pnpm.io/install.ps1 -useb | Invoke-Expression
+
+ # Reset the PATH env variables to make sure pnpm is accessible
+ $env:PNPM_HOME = [System.Environment]::GetEnvironmentVariable("PNPM_HOME", "User")
+ $env:Path = [System.Environment]::ExpandEnvironmentVariables([System.Environment]::GetEnvironmentVariable("Path", "User"))
+
+}
+else {
+ Write-Host "pnpm is installed."
+}
+
+# A GitHub Action takes care of installing node, so this isn't necessary if running in the ci.
+if ($ci -eq $True) {
+ Write-Host
+ Write-Host "Running with Ci, skipping Node install." -ForegroundColor Yellow
+}
+else {
+ Write-Host
+ Write-Host "Using pnpm to install the latest version of Node..." -ForegroundColor Yellow
+ Write-Host "This will set your global Node version to the latest!"
+ Start-Sleep -Milliseconds 150
+
+ # Runs the pnpm command to use the latest version of node, which also installs it
+ Start-Process -Wait -FilePath "pnpm" -ArgumentList "env use --global latest" -PassThru -Verb runAs
+}
+
+
+
+# The ci has LLVM installed already, so we instead just set the env variables.
+if ($ci -eq $True) {
+ Write-Host
+ Write-Host "Running with Ci, skipping LLVM install." -ForegroundColor Yellow
+
+ $VCINSTALLDIR = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath)
+ Add-Content $env:GITHUB_ENV "LIBCLANG_PATH=${VCINSTALLDIR}\VC\Tools\LLVM\x64\bin`n"
+
+} else {
+ Write-Host
+ Write-Host "Downloading the LLVM installer..." -ForegroundColor Yellow
+ # Downloads latest installer for LLVM
+ $filenamePattern = "*-win64.exe"
+ $releasesUri = "https://api.github.com/repos/llvm/llvm-project/releases/latest"
+ $downloadUri = ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url
+
+ Start-BitsTransfer -Source $downloadUri -Destination "$temp\llvm.exe"
+
+ Write-Host
+ Write-Host "Running the LLVM installer..." -ForegroundColor Yellow
+ Write-Host "Please follow the instructions to install LLVM."
+ Write-Host "Ensure you add LLVM to your PATH."
+
+ Start-Process "$temp\llvm.exe" -Wait
+}
+
+
+
+Write-Host
+Write-Host "Downloading the latest ffmpeg build..." -ForegroundColor Yellow
+
+# Downloads the latest shared build of ffmpeg from GitHub
+# $filenamePattern = "*-full_build-shared.zip"
+# $releasesUri = "https://api.github.com/repos/GyanD/codexffmpeg/releases/latest"
+$downloadUri = "https://github.com/GyanD/codexffmpeg/releases/download/5.0.1/ffmpeg-5.0.1-full_build-shared.zip" # ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).browser_download_url
+$filename = "ffmpeg-5.0.1-full_build-shared.zip" # ((Invoke-RestMethod -Method GET -Uri $releasesUri).assets | Where-Object name -like $filenamePattern ).name
+$remove = ".zip"
+$foldername = $filename.Substring(0, ($filename.Length - $remove.Length))
+
+Start-BitsTransfer -Source $downloadUri -Destination "$temp\ffmpeg.zip"
+
+Write-Host
+Write-Host "Expanding ffmpeg zip..." -ForegroundColor Yellow
+
+Expand-Archive "$temp\ffmpeg.zip" $HOME -ErrorAction SilentlyContinue
+
+Remove-Item "$temp\ffmpeg.zip"
+
+Write-Host
+Write-Host "Setting environment variables..." -ForegroundColor Yellow
+
+if ($ci -eq $True) {
+ # If running in ci, we need to use GITHUB_ENV and GITHUB_PATH instead of the normal PATH env variables, so we set them here
+ Add-Content $env:GITHUB_ENV "FFMPEG_DIR=$HOME\$foldername`n"
+ Add-Content $env:GITHUB_PATH "$HOME\$foldername\bin`n"
+}
+else {
+ # Sets environment variable for ffmpeg
+ [System.Environment]::SetEnvironmentVariable('FFMPEG_DIR', "$HOME\$foldername", [System.EnvironmentVariableTarget]::User)
+}
+
+Write-Host
+Write-Host "Copying Required .dll files..." -ForegroundColor Yellow
+
+# Create target\debug folder, continue if already exists
+New-Item -Path $currentLocation\target\debug -ItemType Directory -ErrorAction SilentlyContinue
+
+# Copies all .dll required for rust-ffmpeg to target\debug folder
+Get-ChildItem "$HOME\$foldername\bin" -recurse -filter *.dll | Copy-Item -Destination "$currentLocation\target\debug"
+
+Write-Host
+Write-Host "Your machine has been setup for Spacedrive development!"
diff --git a/.github/scripts/setup-system.sh b/.github/scripts/setup-system.sh
index 68d0df0ab..433f73112 100755
--- a/.github/scripts/setup-system.sh
+++ b/.github/scripts/setup-system.sh
@@ -2,17 +2,23 @@
set -e
+script_failure() {
+ echo "An error occurred while performing the task on line $1" >&2
+ echo "Setup for Spacedrive development failed" >&2
+}
+
+trap 'script_failure $LINENO' ERR
+
echo "Setting up your system for Spacedrive development!"
-which cargo &> /dev/null
-if [ $? -eq 1 ]; then
+if ! which cargo &> /dev/null; then
echo "Rust was not detected on your system. Ensure the 'rustc' and 'cargo' binaries are in your \$PATH."
exit 1
fi
if [ "${SPACEDRIVE_SKIP_PNPM_CHECK:-}" != "true" ]; then
- which pnpm &> /dev/null
- if [ $? -eq 1 ]; then
+
+ if ! which pnpm &> /dev/null; then
echo "PNPM was not detected on your system. Ensure the 'pnpm' command is in your \$PATH. You are not able to use Yarn or NPM."
exit 1
fi
@@ -20,11 +26,52 @@ else
echo "Skipped PNPM check!"
fi
+if [ "$1" == "mobile" ]; then
+ echo "Setting up for mobile development!"
+
+ # IOS targets
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ echo "Installing IOS Rust targets..."
+
+ if ! /usr/bin/xcodebuild -version; then
+ echo "Xcode is not installed! Ensure you have it installed!"
+ exit 1
+ fi
+
+ rustup target add aarch64-apple-ios
+ fi
+
+ # Android requires python
+ if ! command -v python3 &> /dev/null
+ then
+ echo "Python3 could not be found. This is required for Android mobile development!"
+ exit 1
+ fi
+
+ # Android targets
+ echo "Installing Android Rust targets..."
+ rustup target add armv7-linux-androideabi # for arm
+ rustup target add i686-linux-android # for x86
+ rustup target add aarch64-linux-android # for arm64
+ rustup target add x86_64-linux-android # for x86_64
+ rustup target add x86_64-unknown-linux-gnu # for linux-x86-64
+ rustup target add x86_64-apple-darwin # for darwin x86_64 (if you have an Intel MacOS)
+ rustup target add aarch64-apple-darwin # for darwin arm64 (if you have a M1 MacOS)
+ rustup target add x86_64-pc-windows-gnu # for win32-x86-64-gnu
+ rustup target add x86_64-pc-windows-msvc # for win32-x86-64-msvc
+fi
+
+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if which apt-get &> /dev/null; then
echo "Detected 'apt' based distro!"
- DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libappindicator3-dev librsvg2-dev" # Tauri dependencies
- DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavresample-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg" # FFMPEG dependencies
+
+ if [[ "$(lsb_release -si)" == "Pop" ]]; then
+ DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg" # FFMPEG dependencies
+ else
+ DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavresample-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg" # FFMPEG dependencies
+ fi
+ DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev" # Tauri dependencies
DEBIAN_BINDGEN_DEPS="pkg-config clang" # Bindgen dependencies - it's used by a dependency of Spacedrive
sudo apt-get -y update
@@ -53,9 +100,16 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Your machine has been setup for Spacedrive development!"
elif [[ "$OSTYPE" == "darwin"* ]]; then
- brew install ffmpeg
+ if ! brew tap | grep spacedriveapp/deps > /dev/null; then
+ brew tap-new spacedriveapp/deps > /dev/null
+ fi
+ brew extract --force --version 5.0.1 ffmpeg spacedriveapp/deps > /dev/null
+ brew unlink ffmpeg &> /dev/null || true
+ brew install spacedriveapp/deps/ffmpeg@5.0.1 &> /dev/null
+
+ echo "ffmpeg v5.0.1 has been installed and is now being used on your system."
else
echo "Your OS '$OSTYPE' is not supported by this script. We would welcome a PR or some help adding your OS to this script. https://github.com/spacedriveapp/spacedrive/issues"
exit 1
-fi
\ No newline at end of file
+fi
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 013354f45..d78d7b382 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -36,7 +36,7 @@ jobs:
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
-
+
- uses: actions/cache@v3
name: Setup pnpm cache
with:
@@ -44,7 +44,7 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
-
+
- name: Install pnpm dependencies
run: pnpm --frozen-lockfile i
@@ -81,7 +81,7 @@ jobs:
with:
version: 7
run_install: false
-
+
- name: Install Rust stable
uses: actions-rs/toolchain@v1
with:
@@ -89,7 +89,7 @@ jobs:
profile: minimal
override: true
components: rustfmt, rust-src
-
+
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v1
with:
@@ -98,10 +98,10 @@ jobs:
- name: Run 'setup-system.sh' script
if: matrix.platform == 'ubuntu-latest' || matrix.platform == 'macos-latest'
run: ./.github/scripts/setup-system.sh
-
+
- name: Run 'setup-system.ps1' script
if: matrix.platform == 'windows-latest'
- run: ./.github/scripts/setup-system.ps1
+ run: ./.github/scripts/setup-system.ps1 -ci
- name: Get pnpm store directory
id: pnpm-cache
@@ -116,7 +116,7 @@ jobs:
${{ runner.os }}-pnpm-store-
- name: Install pnpm dependencies
run: pnpm --frozen-lockfile i
-
+
- name: Cache Prisma codegen
id: cache-prisma
uses: actions/cache@v3
@@ -127,13 +127,13 @@ jobs:
- name: Generate Prisma client
working-directory: core
if: steps.cache-prisma.outputs.cache-hit != 'true'
- run: cargo run --frozen -p prisma-cli --release -- generate
+ run: cargo run -p prisma-cli --release -- generate
- name: Cargo fetch
run: cargo fetch
- name: Check Core
- run: cargo check --frozen -p sdcore --release
+ run: cargo check -p sdcore --release
- name: Bundle Desktop
run: pnpm desktop tauri build
@@ -141,7 +141,7 @@ jobs:
- name: Build Server
if: matrix.platform == 'ubuntu-latest'
run: |
- cargo build --frozen -p server --release
+ cargo build -p server --release
cp ./target/release/server ./apps/server/server
- name: Determine image name & tag
diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml
index 1a11968c4..3de8c04df 100644
--- a/.github/workflows/clippy.yml
+++ b/.github/workflows/clippy.yml
@@ -47,10 +47,10 @@ jobs:
- name: Generate Prisma client
working-directory: core
if: steps.cache-prisma.outputs.cache-hit != 'true'
- run: cargo run --frozen -p prisma-cli --release -- generate
-
+ run: cargo run -p prisma-cli --release -- generate
+
- name: Run Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- args: --all-features
\ No newline at end of file
+ args: --all-features
diff --git a/.github/workflows/org-readme.yml b/.github/workflows/org-readme.yml
index fbf405dc7..10d6a3dfc 100644
--- a/.github/workflows/org-readme.yml
+++ b/.github/workflows/org-readme.yml
@@ -18,7 +18,7 @@ jobs:
- name: Update README
uses: dmnemec/copy_file_to_another_repo_action@main
env:
- API_TOKEN_GITHUB: ${{ secrets.REPOS_PAT }}
+ API_TOKEN_GITHUB: ${{ secrets.SD_BOT_PAT }}
with:
source_file: 'README.md'
destination_repo: 'spacedriveapp/.github'
diff --git a/.gitignore b/.gitignore
index 53da2a22b..500449750 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
node_modules
.next
dist
+!apps/desktop/dist
*.tsbuildinfo
package-lock.json
.eslintcache
@@ -15,7 +16,6 @@ storybook-static/
cache
.env
vendor/
-dist
data
node_modules
packages/turbo-server/data/
@@ -61,4 +61,4 @@ todos.md
examples/*/*.lock
/target
-/sdserver_data
\ No newline at end of file
+/sdserver_data
diff --git a/apps/desktop/dist/.placeholder b/.prettierignore
similarity index 100%
rename from apps/desktop/dist/.placeholder
rename to .prettierignore
diff --git a/.vscode/settings.json b/.vscode/settings.json
index cedc4f182..a21f04485 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -12,6 +12,7 @@
"ipfs",
"Keepsafe",
"nodestate",
+ "overscan",
"pathctx",
"prismjs",
"proptype",
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 942c66d63..26e2000ab 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -37,27 +37,43 @@ This project uses [Cargo](https://doc.rust-lang.org/cargo/getting-started/instal
> Note: MacOS M1 users should choose the customize option in the rustup init script and enter `x86_64-apple-darwin` as the default host triple instead of the default `aarch64-apple-darwin`
-- `$ git clone https://github.com/spacedriveapp/spacedrive`
-- `$ cd spacedrive`
+- `git clone https://github.com/spacedriveapp/spacedrive`
+- `cd spacedrive`
- For Linux or MacOS users run: `./.github/scripts/setup-system.sh`
- This will install FFMPEG and any other required dependencies for Spacedrive to build.
-- `$ pnpm i`
-- `$ pnpm prep` - Runs all necessary codegen & builds required dependencies.
+- For Windows users run using PowerShell: `.\.github\scripts\setup-system.ps1`
+ - This will install pnpm, LLVM, FFMPEG and any other required dependencies for Spacedrive to build.
+ - Ensure you run it like documented above as it expects it is executed from the root of the repository.
+- `pnpm i`
+- `pnpm prep` - Runs all necessary codegen & builds required dependencies.
To quickly run only the desktop app after `prep` you can use:
-- `$ pnpm desktop dev`
+- `pnpm desktop dev`
To run the landing page
-- `$ pnpm web dev` - runs the web app for the embed
-- `$ pnpm landing dev`
+- `pnpm web dev` - runs the web app for the embed
+- `pnpm landing dev`
If you are having issues ensure you are using the following versions of Rust and Node:
-- Rust version: **1.60.0**
+- Rust version: **1.63.0**
- Node version: **17**
+##### Mobile app
+
+To run mobile app
+
+- Install [Android Studio](https://developer.android.com/studio) for Android and [Xcode](https://apps.apple.com/au/app/xcode/id497799835) for IOS development
+- `./.github/scripts/setup-system.sh mobile`
+ - The should setup most of the dependencies for the mobile app to build.
+- You must also ensure [you must have NDK 24.0.8215888 and CMake](https://developer.android.com/studio/projects/install-ndk#default-version) in Android Studio
+- `cd apps/mobile && pnpm i` - This is a separate workspace, you need to do this!
+- `pnpm android` - runs on Android Emulator
+- `pnpm ios` - runs on iOS Emulator
+- `pnpm dev` - For already bundled app - This is only temporarily supported. The final app will require the Spacedrive Rust code which isn't included in Expo Go.
+
### Pull Request
When you're finished with the changes, create a pull request, also known as a PR.
@@ -76,6 +92,16 @@ Congratulations :tada::tada: The Spacedrive team thanks you :sparkles:.
Once your PR is merged, your contributions will be included in the next release of the application.
+### Common Errors
+
+#### `xcrun: error: unable to find utility "xctest", not a developer tool or in PATH`
+
+You either don't have Xcode installed, or don't have the Xcode command line tools in your `PATH`.
+
+- Install XCode from the Mac App Store
+- Run `xcode-select -s /Applications/Xcode.app/Contents/Developer`.
+ This will use Xcode's developer tools instead of macOS's default tools.
+
### Credits
This CONTRIBUTING.md file was modelled after the [github/docs CONTRIBUTING.md](https://github.com/github/docs/blob/main/CONTRIBUTING.md) file, and we thank the original author.
diff --git a/Cargo.lock b/Cargo.lock
index ca71bf05e..a61940408 100644
Binary files a/Cargo.lock and b/Cargo.lock differ
diff --git a/Cargo.toml b/Cargo.toml
index 5b06d38b2..507f92891 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,8 +1,13 @@
[workspace]
+resolver = "2"
members = [
"apps/desktop/src-tauri",
+ "apps/mobile/rust",
"core",
"core/prisma",
- "core/derive",
"apps/server"
]
+
+[patch.crates-io]
+# We use this patch so we can compile for the IOS simulator on M1
+openssl-sys = { git = "https://github.com/spacedriveapp/rust-openssl" }
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index a6509367e..b3ce5ea17 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,25 +1,23 @@
Copyright (c) 2021-present Spacedrive Technology Inc.
+
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
+our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
+software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@@ -28,44 +26,34 @@ them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
The precise terms and conditions for copying, distribution and
modification follow.
@@ -74,7 +62,7 @@ modification follow.
0. Definitions.
- "This License" refers to version 3 of the GNU General Public License.
+ "This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
@@ -551,35 +539,45 @@ to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
- 13. Use with the GNU Affero General Public License.
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
+under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
+Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
+GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
+versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
@@ -637,40 +635,29 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ GNU Affero General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
+For more information on this, and how to apply and follow the GNU AGPL, see
+.
\ No newline at end of file
diff --git a/README.md b/README.md
index ae9203fd8..36891b3e6 100644
--- a/README.md
+++ b/README.md
@@ -59,7 +59,7 @@ For independent creatives, hoarders and those that want to own their digital foo
# What is a VDFS?
-A VDFS (virtual distributed filesystem) is a filesystem designed to work across a variety of storage layers. With a uniform API to manipulate and access content across many devices, VSFS is not restricted to a single machine. It achieves this by maintaining a virtual index of all storage locations, synchronizing the database between clients in realtime. This implementation also uses [CAS](https://en.wikipedia.org/wiki/Content-addressable_storage) (Content-addressable storage) to uniquely identify files, while keeping record of logical file paths relative to the storage locations.
+A VDFS (virtual distributed filesystem) is a filesystem designed to work across a variety of storage layers. With a uniform API to manipulate and access content across many devices, VDFS is not restricted to a single machine. It achieves this by maintaining a virtual index of all storage locations, synchronizing the database between clients in realtime. This implementation also uses [CAS](https://en.wikipedia.org/wiki/Content-addressable_storage) (Content-addressable storage) to uniquely identify files, while keeping record of logical file paths relative to the storage locations.
The first implementation of a VDFS can be found in this UC Berkeley [paper](https://www2.eecs.berkeley.edu/Pubs/TechRpts/2018/EECS-2018-29.pdf) by Haoyuan Li. This paper describes its use for cloud computing, however the underlying concepts can be translated to open consumer software.
@@ -85,7 +85,7 @@ _Note: Links are for highlight purposes only until feature specific documentatio
**To be developed (MVP):**
- **[Photos](#features)** - Photo and video albums similar to Apple/Google photos.
-- **[Search](#features)** - Deep search into your filesystem with a keybind, including offline locations.
+- **[Search](#features)** - Deep search into your filesystem with a keybinding, including offline locations.
- **[Tags](#features)** - Define routines on custom tags to automate workflows, easily tag files individually, in bulk and automatically via rules.
- **[Extensions](#features)** - Build tools on top of Spacedrive, extend functionality and integrate third party services. Extension directory on [spacedrive.com/extensions](#features).
@@ -124,16 +124,16 @@ This project is using what I'm calling the **"PRRTT"** stack (Prisma, Rust, Reac
### Core:
-- `core`: The [Rust](#) core, referred to internally as `sdcore`. Contains filesystem, database and networking logic. Can be deployed in a variety of host applications.
+- `core`: The [Rust](https://www.rust-lang.org) core, referred to internally as `sdcore`. Contains filesystem, database and networking logic. Can be deployed in a variety of host applications.
### Packages:
-- `client`: A [TypeScript](#) client library to handle dataflow via RPC between UI and the Rust core.
-- `ui`: A [React](<[#](https://reactjs.org)>) Shared component library.
+- `client`: A [TypeScript](https://www.typescriptlang.org/) client library to handle dataflow via RPC between UI and the Rust core.
+- `ui`: A [React](https://reactjs.org) Shared component library.
- `interface`: The complete user interface in React (used by apps `desktop`, `web` and `landing`)
- `config`: `eslint` configurations (includes `eslint-config-next`, `eslint-config-prettier` and all `tsconfig.json` configs used throughout the monorepo.
-- `macos`: A [Swift](#) Native binary for MacOS system extensions.
-- `ios`: A [Swift](#) Native binary (planned).
-- `windows`: A [C#](#) Native binary (planned).
-- `android`: A [Kotlin](#) Native binary (planned).
+- `macos`: A [Swift](https://developer.apple.com/swift/) Native binary for MacOS system extensions.
+- `ios`: A [Swift](https://developer.apple.com/swift/) Native binary (planned).
+- `windows`: A [C#](https://docs.microsoft.com/en-us/dotnet/csharp/) Native binary (planned).
+- `android`: A [Kotlin](https://kotlinlang.org/) Native binary (planned).
diff --git a/apps/desktop/dist/.gitignore b/apps/desktop/dist/.gitignore
new file mode 100644
index 000000000..c53272268
--- /dev/null
+++ b/apps/desktop/dist/.gitignore
@@ -0,0 +1,5 @@
+# Ignore everything in this directory
+*
+# Except this file
+!.gitignore
+# This is done so that Tauri never complains that '../dist does not exist'
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 7218ea08f..7b6dfae6f 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -11,31 +11,33 @@
"build": "tauri build"
},
"dependencies": {
+ "@rspc/client": "^0.0.5",
"@sd/client": "workspace:*",
"@sd/core": "workspace:*",
"@sd/interface": "workspace:*",
"@sd/ui": "workspace:*",
- "@tauri-apps/api": "1.0.0",
- "react": "^18.1.0",
- "react-dom": "^18.1.0"
+ "@tanstack/react-query": "^4.0.10",
+ "@tauri-apps/api": "1.0.2",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0"
},
"devDependencies": {
- "@tauri-apps/cli": "1.0.0",
+ "@tauri-apps/cli": "1.0.5",
"@tauri-apps/tauricon": "github:tauri-apps/tauricon",
"@types/babel-core": "^6.25.7",
"@types/byte-size": "^8.1.0",
- "@types/react": "^18.0.9",
- "@types/react-dom": "^18.0.5",
+ "@types/react": "^18.0.15",
+ "@types/react-dom": "^18.0.6",
"@types/react-router-dom": "^5.3.3",
"@types/react-window": "^1.8.5",
- "@types/tailwindcss": "^3.0.10",
- "@vitejs/plugin-react": "^1.3.2",
- "concurrently": "^7.2.1",
- "prettier": "^2.6.2",
- "sass": "^1.52.1",
- "typescript": "^4.7.2",
- "vite": "^2.9.9",
+ "@types/tailwindcss": "^3.1.0",
+ "@vitejs/plugin-react": "^2.0.0",
+ "concurrently": "^7.3.0",
+ "prettier": "^2.7.1",
+ "sass": "^1.54.0",
+ "typescript": "^4.7.4",
+ "vite": "^3.0.3",
"vite-plugin-filter-replace": "^0.1.9",
- "vite-plugin-svgr": "^2.1.0"
+ "vite-plugin-svgr": "^2.2.1"
}
}
diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml
index ab91a3359..9bbcfb57c 100644
--- a/apps/desktop/src-tauri/Cargo.toml
+++ b/apps/desktop/src-tauri/Cargo.toml
@@ -9,25 +9,20 @@ default-run = "spacedrive"
edition = "2021"
build = "build.rs"
-[build-dependencies]
-tauri-build = { version = "1.0.0", features = [] }
-
[dependencies]
-# Project dependencies
-tauri = { version = "1.0.0", features = ["api-all", "macos-private-api"] }
+tauri = { version = "1.0.4", features = ["api-all", "macos-private-api"] }
+rspc = { version = "0.0.4", features = ["tauri"] }
sdcore = { path = "../../../core" }
-# tauri-plugin-shadows = { git = "https://github.com/tauri-apps/tauri-plugin-shadows", features = ["tauri-impl"] }
-
-# Universal Dependencies
tokio = { version = "1.17.0", features = ["sync"] }
window-shadows = "0.1.2"
-env_logger = "0.9.0"
-dotenvy = "0.15.1"
+tracing = "0.1.35"
-# macOS system libs
[target.'cfg(target_os = "macos")'.dependencies]
swift-rs = { git = "https://github.com/Brendonovich/swift-rs.git", branch = "autorelease" }
+[build-dependencies]
+tauri-build = { version = "1.0.0", features = [] }
+
[target.'cfg(target_os = "macos")'.build-dependencies]
swift-rs = { git = "https://github.com/Brendonovich/swift-rs.git", branch = "autorelease", features = ["build"] }
diff --git a/apps/desktop/src-tauri/rustfmt.toml b/apps/desktop/src-tauri/rustfmt.toml
index a231bfab7..054510e14 100644
--- a/apps/desktop/src-tauri/rustfmt.toml
+++ b/apps/desktop/src-tauri/rustfmt.toml
@@ -10,4 +10,3 @@ merge_derives = true
use_try_shorthand = false
use_field_init_shorthand = false
force_explicit_abi = true
-imports_granularity = "Crate"
diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs
index 3dcad488c..8ae8ba8e3 100644
--- a/apps/desktop/src-tauri/src/main.rs
+++ b/apps/desktop/src-tauri/src/main.rs
@@ -1,41 +1,12 @@
-use std::time::{Duration, Instant};
+use std::path::PathBuf;
-use dotenvy::dotenv;
-use sdcore::{ClientCommand, ClientQuery, CoreController, CoreEvent, CoreResponse, Node};
-use tauri::api::path;
-use tauri::Manager;
+use sdcore::Node;
+use tauri::{api::path, Manager, RunEvent};
+use tracing::{debug, error};
#[cfg(target_os = "macos")]
mod macos;
mod menu;
-#[tauri::command(async)]
-async fn client_query_transport(
- core: tauri::State<'_, CoreController>,
- data: ClientQuery,
-) -> Result {
- match core.query(data).await {
- Ok(response) => Ok(response),
- Err(err) => {
- println!("query error: {:?}", err);
- Err(err.to_string())
- }
- }
-}
-
-#[tauri::command(async)]
-async fn client_command_transport(
- core: tauri::State<'_, CoreController>,
- data: ClientCommand,
-) -> Result {
- match core.command(data).await {
- Ok(response) => Ok(response),
- Err(err) => {
- println!("command error: {:?}", err);
- Err(err.to_string())
- }
- }
-}
-
#[tauri::command(async)]
async fn app_ready(app_handle: tauri::AppHandle) {
let window = app_handle.get_window("main").unwrap();
@@ -45,24 +16,17 @@ async fn app_ready(app_handle: tauri::AppHandle) {
#[tokio::main]
async fn main() {
- dotenv().ok();
- env_logger::init();
+ let data_dir = path::data_dir()
+ .unwrap_or_else(|| PathBuf::from("./"))
+ .join("spacedrive");
- let data_dir = path::data_dir().unwrap_or(std::path::PathBuf::from("./"));
- // create an instance of the core
- let (mut node, mut event_receiver) = Node::new(data_dir).await;
- // run startup tasks
- node.initializer().await;
- // extract the node controller
- let controller = node.get_controller();
- // throw the node into a dedicated thread
- tokio::spawn(async move {
- node.start().await;
- });
- // create tauri app
- tauri::Builder::default()
- // pass controller to the tauri state manager
- .manage(controller)
+ let (node, router) = Node::new(data_dir).await;
+
+ let app = tauri::Builder::default()
+ .plugin(rspc::integrations::tauri::plugin(router, {
+ let node = node.clone();
+ move || node.get_request_context()
+ }))
.setup(|app| {
let app = app.handle();
@@ -89,35 +53,29 @@ async fn main() {
}
});
- // core event transport
- tokio::spawn(async move {
- let mut last = Instant::now();
- // handle stream output
- while let Some(event) = event_receiver.recv().await {
- match event {
- CoreEvent::InvalidateQueryDebounced(_) => {
- let current = Instant::now();
- if current.duration_since(last) > Duration::from_millis(1000 / 60) {
- last = current;
- app.emit_all("core_event", &event).unwrap();
- }
- }
- event => {
- app.emit_all("core_event", &event).unwrap();
- }
- }
- }
- });
-
Ok(())
})
- .on_menu_event(|event| menu::handle_menu_event(event))
- .invoke_handler(tauri::generate_handler![
- client_query_transport,
- client_command_transport,
- app_ready,
- ])
+ .on_menu_event(menu::handle_menu_event)
+ .invoke_handler(tauri::generate_handler![app_ready,])
.menu(menu::get_menu())
- .run(tauri::generate_context!())
- .expect("error while running tauri application");
+ .build(tauri::generate_context!())
+ .expect("error while building tauri application");
+
+ app.run(move |app_handler, event| {
+ if let RunEvent::ExitRequested { .. } = event {
+ debug!("Closing all open windows...");
+ app_handler
+ .windows()
+ .iter()
+ .for_each(|(window_name, window)| {
+ debug!("closing window: {window_name}");
+ if let Err(e) = window.close() {
+ error!("failed to close window '{}': {:#?}", window_name, e);
+ }
+ });
+
+ node.shutdown();
+ app_handler.exit(0);
+ }
+ })
}
diff --git a/apps/desktop/src-tauri/src/menu.rs b/apps/desktop/src-tauri/src/menu.rs
index 8e501161b..acc467b59 100644
--- a/apps/desktop/src-tauri/src/menu.rs
+++ b/apps/desktop/src-tauri/src/menu.rs
@@ -1,6 +1,8 @@
use std::env::consts;
-use tauri::{AboutMetadata, CustomMenuItem, Menu, MenuItem, Submenu, WindowMenuEvent, Wry};
+use tauri::{
+ AboutMetadata, CustomMenuItem, Manager, Menu, MenuItem, Submenu, WindowMenuEvent, Wry,
+};
pub(crate) fn get_menu() -> Menu {
match consts::OS {
@@ -35,12 +37,14 @@ fn custom_menu_bar() -> Menu {
);
let edit_menu = Menu::new()
.add_native_item(MenuItem::Copy)
- .add_native_item(MenuItem::Paste);
+ .add_native_item(MenuItem::Paste)
+ .add_native_item(MenuItem::SelectAll);
let view_menu = Menu::new()
- .add_item(
- CustomMenuItem::new("command_pallete".to_string(), "Command Pallete")
- .accelerator("CmdOrCtrl+P"),
- )
+ .add_item(CustomMenuItem::new("search".to_string(), "Search").accelerator("CmdOrCtrl+L"))
+ // .add_item(
+ // CustomMenuItem::new("command_pallete".to_string(), "Command Pallete")
+ // .accelerator("CmdOrCtrl+P"),
+ // )
.add_item(CustomMenuItem::new("layout".to_string(), "Layout").disabled());
let window_menu = Menu::new().add_native_item(MenuItem::EnterFullScreen);
@@ -53,28 +57,25 @@ fn custom_menu_bar() -> Menu {
CustomMenuItem::new("reload_app".to_string(), "Reload").accelerator("CmdOrCtrl+R"),
);
- let view_menu = view_menu.add_item(
+ view_menu.add_item(
CustomMenuItem::new("toggle_devtools".to_string(), "Toggle Developer Tools")
.accelerator("CmdOrCtrl+Alt+I"),
- );
-
- view_menu
+ )
};
- let menu = Menu::new()
+ Menu::new()
.add_submenu(Submenu::new("Spacedrive", app_menu))
.add_submenu(Submenu::new("File", file_menu))
.add_submenu(Submenu::new("Edit", edit_menu))
.add_submenu(Submenu::new("View", view_menu))
- .add_submenu(Submenu::new("Window", window_menu));
-
- menu
+ .add_submenu(Submenu::new("Window", window_menu))
}
pub(crate) fn handle_menu_event(event: WindowMenuEvent) {
match event.menu_item_id() {
"quit" => {
- std::process::exit(0);
+ let app = event.window().app_handle();
+ app.exit(0);
}
"close" => {
let window = event.window();
@@ -82,7 +83,6 @@ pub(crate) fn handle_menu_event(event: WindowMenuEvent) {
#[cfg(debug_assertions)]
if window.is_devtools_open() {
window.close_devtools();
- return;
} else {
window.close().unwrap();
}
@@ -91,17 +91,17 @@ pub(crate) fn handle_menu_event(event: WindowMenuEvent) {
window.close().unwrap();
}
"reload_app" => {
- event
- .window()
- .with_webview(|webview| {
- #[cfg(target_os = "macos")]
- {
+ #[cfg(target_os = "macos")]
+ {
+ event
+ .window()
+ .with_webview(|webview| {
use crate::macos::reload_webview;
reload_webview(webview.inner() as _);
- }
- })
- .unwrap();
+ })
+ .unwrap();
+ }
}
#[cfg(debug_assertions)]
"toggle_devtools" => {
diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json
index 5ebb80265..7c5bfc74c 100644
--- a/apps/desktop/src-tauri/tauri.conf.json
+++ b/apps/desktop/src-tauri/tauri.conf.json
@@ -63,7 +63,7 @@
"windows": [
{
"title": "Spacedrive",
- "width": 1200,
+ "width": 1400,
"height": 725,
"minWidth": 700,
"minHeight": 500,
diff --git a/apps/desktop/src-tauri/tauri.linux.conf.json b/apps/desktop/src-tauri/tauri.linux.conf.json
index 51b5a339d..5fc781e7f 100644
--- a/apps/desktop/src-tauri/tauri.linux.conf.json
+++ b/apps/desktop/src-tauri/tauri.linux.conf.json
@@ -15,7 +15,13 @@
"active": true,
"targets": "all",
"identifier": "com.spacedrive.desktop",
- "icon": ["icons/icon.icns"],
+ "icon": [
+ "icons/32x32.png",
+ "icons/128x128.png",
+ "icons/128x128@2x.png",
+ "icons/icon.icns",
+ "icons/icon.ico"
+ ],
"resources": [],
"externalBin": [],
"copyright": "Spacedrive Technology Inc.",
diff --git a/apps/desktop/src/index.tsx b/apps/desktop/src/index.tsx
index 692f7149e..d1f54a364 100644
--- a/apps/desktop/src/index.tsx
+++ b/apps/desktop/src/index.tsx
@@ -1,10 +1,7 @@
// import Spacedrive JS client
-import { BaseTransport } from '@sd/client';
-// import types from Spacedrive core (TODO: re-export from client would be cleaner)
-import { ClientCommand, ClientQuery, CoreEvent } from '@sd/core';
-// import Spacedrive interface
+import { TauriTransport, createClient } from '@rspc/client';
+import { Operations, queryClient, rspc } from '@sd/client';
import SpacedriveInterface, { Platform } from '@sd/interface';
-// import tauri apis
import { dialog, invoke, os, shell } from '@tauri-apps/api';
import { Event, listen } from '@tauri-apps/api/event';
import { convertFileSrc } from '@tauri-apps/api/tauri';
@@ -14,22 +11,9 @@ import { createRoot } from 'react-dom/client';
import '@sd/ui/style';
-// bind state to core via Tauri
-class Transport extends BaseTransport {
- constructor() {
- super();
-
- listen('core_event', (e: Event) => {
- this.emit('core_event', e.payload);
- });
- }
- async query(query: ClientQuery) {
- return await invoke('client_query_transport', { data: query });
- }
- async command(query: ClientCommand) {
- return await invoke('client_command_transport', { data: query });
- }
-}
+const client = createClient({
+ transport: new TauriTransport()
+});
function App() {
function getPlatform(platform: string): Platform {
@@ -45,7 +29,7 @@ function App() {
}
}
- const [platform, setPlatform] = useState('macOS');
+ const [platform, setPlatform] = useState('unknown');
const [focused, setFocused] = useState(true);
useEffect(() => {
@@ -64,23 +48,24 @@ function App() {
}, []);
return (
- {
- return dialog.open(options);
- }}
- isFocused={focused}
- onClose={() => appWindow.close()}
- onFullscreen={() => appWindow.setFullscreen(true)}
- onMinimize={() => appWindow.minimize()}
- onOpen={(path: string) => shell.open(path)}
- />
+
+ {
+ return dialog.open(options);
+ }}
+ isFocused={focused}
+ onClose={() => appWindow.close()}
+ onFullscreen={() => appWindow.setFullscreen(true)}
+ onMinimize={() => appWindow.minimize()}
+ onOpen={(path: string) => shell.open(path)}
+ />
+
);
}
diff --git a/apps/mobile/.buckconfig b/apps/mobile/.buckconfig
new file mode 100644
index 000000000..934256cb2
--- /dev/null
+++ b/apps/mobile/.buckconfig
@@ -0,0 +1,6 @@
+
+[android]
+ target = Google Inc.:Google APIs:23
+
+[maven_repositories]
+ central = https://repo1.maven.org/maven2
diff --git a/apps/mobile/.eslintrc.js b/apps/mobile/.eslintrc.js
new file mode 100644
index 000000000..d440a4ae9
--- /dev/null
+++ b/apps/mobile/.eslintrc.js
@@ -0,0 +1,42 @@
+module.exports = {
+ env: {
+ 'react-native/react-native': true
+ },
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ ecmaFeatures: {
+ jsx: true
+ },
+ ecmaVersion: 12,
+ sourceType: 'module'
+ },
+ extends: [
+ 'eslint:recommended',
+ 'plugin:react/recommended',
+ 'plugin:react-hooks/recommended',
+ 'plugin:@typescript-eslint/recommended'
+ ],
+ plugins: ['react', 'react-native'],
+ rules: {
+ 'react/display-name': 'off',
+ 'react/prop-types': 'off',
+ 'react/no-unescaped-entities': 'off',
+ 'react/react-in-jsx-scope': 'off',
+ 'react-hooks/rules-of-hooks': 'error',
+ 'react-hooks/exhaustive-deps': 'warn',
+ '@typescript-eslint/no-unused-vars': 'off',
+ '@typescript-eslint/ban-ts-comment': 'off',
+ '@typescript-eslint/no-explicit-any': 'off',
+ '@typescript-eslint/no-var-requires': 'off',
+ '@typescript-eslint/no-non-null-assertion': 'off',
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
+ 'no-control-regex': 'off',
+ 'no-mixed-spaces-and-tabs': ['warn', 'smart-tabs']
+ },
+ ignorePatterns: ['**/*.js', '**/*.json', 'node_modules', 'android', 'ios', '.expo'],
+ settings: {
+ react: {
+ version: 'detect'
+ }
+ }
+};
diff --git a/apps/mobile/.gitattributes b/apps/mobile/.gitattributes
new file mode 100644
index 000000000..d42ff1835
--- /dev/null
+++ b/apps/mobile/.gitattributes
@@ -0,0 +1 @@
+*.pbxproj -text
diff --git a/apps/mobile/.gitignore b/apps/mobile/.gitignore
new file mode 100644
index 000000000..c8eb0f9a6
--- /dev/null
+++ b/apps/mobile/.gitignore
@@ -0,0 +1,55 @@
+# OSX
+#
+.DS_Store
+
+# Xcode
+#
+build/
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+xcuserdata
+*.xccheckout
+*.moved-aside
+DerivedData
+*.hmap
+*.ipa
+*.xcuserstate
+project.xcworkspace
+
+# Android/IntelliJ
+#
+build/
+.idea
+.gradle
+local.properties
+*.iml
+*.hprof
+
+# node.js
+#
+node_modules/
+npm-debug.log
+yarn-error.log
+
+# BUCK
+buck-out/
+\.buckd/
+*.keystore
+!debug.keystore
+
+# Bundle artifacts
+*.jsbundle
+
+# CocoaPods
+/ios/Pods/
+
+# Expo
+.expo/
+web-build/
+dist/
diff --git a/apps/mobile/.npmrc b/apps/mobile/.npmrc
new file mode 100644
index 000000000..a8fd4724d
--- /dev/null
+++ b/apps/mobile/.npmrc
@@ -0,0 +1,3 @@
+strict-peer-dependencies = false
+ignore-workspace-root-check = true
+shamefully-hoist = true
diff --git a/apps/mobile/README.md b/apps/mobile/README.md
new file mode 100644
index 000000000..8a79c0202
--- /dev/null
+++ b/apps/mobile/README.md
@@ -0,0 +1,3 @@
+Make sure to run `pnpm i` in this folder after making changes to the `packages`.
+
+- Note: If you add/remove something from `packages/assets` folder, you need to delete node_modules and run `pnpm i` again to link it.
diff --git a/apps/mobile/android/.gitignore b/apps/mobile/android/.gitignore
new file mode 100644
index 000000000..64436baaf
--- /dev/null
+++ b/apps/mobile/android/.gitignore
@@ -0,0 +1,21 @@
+# OSX
+#
+.DS_Store
+
+# Android/IntelliJ
+#
+build/
+.idea
+.gradle
+local.properties
+*.iml
+*.hprof
+
+# BUCK
+buck-out/
+\.buckd/
+*.keystore
+!debug.keystore
+
+# Bundle artifacts
+*.jsbundle
diff --git a/apps/mobile/android/app/BUCK b/apps/mobile/android/app/BUCK
new file mode 100644
index 000000000..cabced2a6
--- /dev/null
+++ b/apps/mobile/android/app/BUCK
@@ -0,0 +1,55 @@
+# To learn about Buck see [Docs](https://buckbuild.com/).
+# To run your application with Buck:
+# - install Buck
+# - `npm start` - to start the packager
+# - `cd android`
+# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
+# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
+# - `buck install -r android/app` - compile, install and run application
+#
+
+load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
+
+lib_deps = []
+
+create_aar_targets(glob(["libs/*.aar"]))
+
+create_jar_targets(glob(["libs/*.jar"]))
+
+android_library(
+ name = "all-libs",
+ exported_deps = lib_deps,
+)
+
+android_library(
+ name = "app-code",
+ srcs = glob([
+ "src/main/java/**/*.java",
+ ]),
+ deps = [
+ ":all-libs",
+ ":build_config",
+ ":res",
+ ],
+)
+
+android_build_config(
+ name = "build_config",
+ package = "com.spacedrive.app",
+)
+
+android_resource(
+ name = "res",
+ package = "com.spacedrive.app",
+ res = "src/main/res",
+)
+
+android_binary(
+ name = "app",
+ keystore = "//android/keystores:debug",
+ manifest = "src/main/AndroidManifest.xml",
+ package_type = "debug",
+ deps = [
+ ":app-code",
+ ],
+)
diff --git a/apps/mobile/android/app/build.gradle b/apps/mobile/android/app/build.gradle
new file mode 100644
index 000000000..d825f46f4
--- /dev/null
+++ b/apps/mobile/android/app/build.gradle
@@ -0,0 +1,394 @@
+apply plugin: "com.android.application"
+
+import com.android.build.OutputFile
+import org.apache.tools.ant.taskdefs.condition.Os
+
+apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
+
+cargo {
+ module = "../../rust"
+ libname = "sdcore"
+ // profile = 'release',
+ pythonCommand = 'python3'
+ targets = ["arm", "arm64", "x86", "x86_64"]
+ targetDirectory = "../.././../../target" // Monorepo moment
+
+}
+
+tasks.whenTaskAdded { task ->
+ if ((task.name == 'javaPreCompileDebug' || task.name == 'javaPreCompileRelease')) {
+ task.dependsOn 'cargoBuild'
+ }
+}
+
+/**
+ * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
+ * and bundleReleaseJsAndAssets).
+ * These basically call `react-native bundle` with the correct arguments during the Android build
+ * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
+ * bundle directly from the development server. Below you can see all the possible configurations
+ * and their defaults. If you decide to add a configuration block, make sure to add it before the
+ * `apply from: "../../node_modules/react-native/react.gradle"` line.
+ *
+ * project.ext.react = [
+ * // the name of the generated asset file containing your JS bundle
+ * bundleAssetName: "index.android.bundle",
+ *
+ * // the entry file for bundle generation. If none specified and
+ * // "index.android.js" exists, it will be used. Otherwise "index.js" is
+ * // default. Can be overridden with ENTRY_FILE environment variable.
+ * entryFile: "index.android.js",
+ *
+ * // https://reactnative.dev/docs/performance#enable-the-ram-format
+ * bundleCommand: "ram-bundle",
+ *
+ * // whether to bundle JS and assets in debug mode
+ * bundleInDebug: false,
+ *
+ * // whether to bundle JS and assets in release mode
+ * bundleInRelease: true,
+ *
+ * // whether to bundle JS and assets in another build variant (if configured).
+ * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
+ * // The configuration property can be in the following formats
+ * // 'bundleIn${productFlavor}${buildType}'
+ * // 'bundleIn${buildType}'
+ * // bundleInFreeDebug: true,
+ * // bundleInPaidRelease: true,
+ * // bundleInBeta: true,
+ *
+ * // whether to disable dev mode in custom build variants (by default only disabled in release)
+ * // for example: to disable dev mode in the staging build type (if configured)
+ * devDisabledInStaging: true,
+ * // The configuration property can be in the following formats
+ * // 'devDisabledIn${productFlavor}${buildType}'
+ * // 'devDisabledIn${buildType}'
+ *
+ * // the root of your project, i.e. where "package.json" lives
+ * root: "../../",
+ *
+ * // where to put the JS bundle asset in debug mode
+ * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
+ *
+ * // where to put the JS bundle asset in release mode
+ * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
+ *
+ * // where to put drawable resources / React Native assets, e.g. the ones you use via
+ * // require('./image.png')), in debug mode
+ * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
+ *
+ * // where to put drawable resources / React Native assets, e.g. the ones you use via
+ * // require('./image.png')), in release mode
+ * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
+ *
+ * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
+ * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
+ * // date; if you have any other folders that you want to ignore for performance reasons (gradle
+ * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
+ * // for example, you might want to remove it from here.
+ * inputExcludes: ["android/**", "ios/**"],
+ *
+ * // override which node gets called and with what additional arguments
+ * nodeExecutableAndArgs: ["node"],
+ *
+ * // supply additional arguments to the packager
+ * extraPackagerArgs: []
+ * ]
+ */
+
+def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
+
+def reactNativeRoot = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath()
+
+project.ext.react = [
+ entryFile: ["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android"].execute(null, rootDir).text.trim(),
+ enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes",
+ hermesCommand: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc",
+ cliPath: "${reactNativeRoot}/cli.js",
+ composeSourceMapsPath: "${reactNativeRoot}/scripts/compose-source-maps.js",
+]
+
+apply from: new File(reactNativeRoot, "react.gradle")
+
+/**
+ * Set this to true to create two separate APKs instead of one:
+ * - An APK that only works on ARM devices
+ * - An APK that only works on x86 devices
+ * The advantage is the size of the APK is reduced by about 4MB.
+ * Upload all the APKs to the Play Store and people will download
+ * the correct one based on the CPU architecture of their device.
+ */
+def enableSeparateBuildPerCPUArchitecture = false
+
+/**
+ * Run Proguard to shrink the Java bytecode in release builds.
+ */
+def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean()
+
+/**
+ * The preferred build flavor of JavaScriptCore.
+ *
+ * For example, to use the international variant, you can use:
+ * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
+ *
+ * The international variant includes ICU i18n library and necessary data
+ * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
+ * give correct results when using with locales other than en-US. Note that
+ * this variant is about 6MiB larger per architecture than default.
+ */
+def jscFlavor = 'org.webkit:android-jsc:+'
+
+/**
+ * Whether to enable the Hermes VM.
+ *
+ * This should be set on project.ext.react and that value will be read here. If it is not set
+ * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
+ * and the benefits of using Hermes will therefore be sharply reduced.
+ */
+def enableHermes = project.ext.react.get("enableHermes", false);
+
+/**
+ * Architectures to build native code for.
+ */
+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
+
+ defaultConfig {
+ applicationId 'com.spacedrive.app'
+ minSdkVersion rootProject.ext.minSdkVersion
+ targetSdkVersion rootProject.ext.targetSdkVersion
+ versionCode 1
+ versionName "0.0.1"
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
+
+ if (isNewArchitectureEnabled()) {
+ // We configure the NDK build only if you decide to opt-in for the New Architecture.
+ externalNativeBuild {
+ ndkBuild {
+ arguments "APP_PLATFORM=android-21",
+ "APP_STL=c++_shared",
+ "NDK_TOOLCHAIN_VERSION=clang",
+ "GENERATED_SRC_DIR=$buildDir/generated/source",
+ "PROJECT_BUILD_DIR=$buildDir",
+ "REACT_ANDROID_DIR=${reactNativeRoot}/ReactAndroid",
+ "REACT_ANDROID_BUILD_DIR=${reactNativeRoot}/ReactAndroid/build",
+ "NODE_MODULES_DIR=$rootDir/../node_modules"
+ cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
+ cppFlags "-std=c++17"
+ // Make sure this target name is the same you specify inside the
+ // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
+ targets "spacedrive_appmodules"
+
+ // Fix for windows limit on number of character in file paths and in command lines
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+ arguments "NDK_APP_SHORT_COMMANDS=true"
+ }
+ }
+ }
+ if (!enableSeparateBuildPerCPUArchitecture) {
+ ndk {
+ abiFilters (*reactNativeArchitectures())
+ }
+ }
+ }
+ }
+
+ if (isNewArchitectureEnabled()) {
+ // We configure the NDK build only if you decide to opt-in for the New Architecture.
+ externalNativeBuild {
+ ndkBuild {
+ path "$projectDir/src/main/jni/Android.mk"
+ }
+ }
+ def reactAndroidProjectDir = project(':ReactAndroid').projectDir
+ def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
+ dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
+ from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
+ into("$buildDir/react-ndk/exported")
+ }
+ def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
+ dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
+ from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
+ into("$buildDir/react-ndk/exported")
+ }
+ afterEvaluate {
+ // If you wish to add a custom TurboModule or component locally,
+ // you should uncomment this line.
+ // preBuild.dependsOn("generateCodegenArtifactsFromSchema")
+ preDebugBuild.dependsOn(packageReactNdkDebugLibs)
+ preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
+
+ // Due to a bug inside AGP, we have to explicitly set a dependency
+ // between configureNdkBuild* tasks and the preBuild tasks.
+ // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
+ configureNdkBuildRelease.dependsOn(preReleaseBuild)
+ configureNdkBuildDebug.dependsOn(preDebugBuild)
+ reactNativeArchitectures().each { architecture ->
+ tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
+ dependsOn("preDebugBuild")
+ }
+ tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
+ dependsOn("preReleaseBuild")
+ }
+ }
+ }
+ }
+
+ splits {
+ abi {
+ reset()
+ enable enableSeparateBuildPerCPUArchitecture
+ universalApk false // If true, also generate a universal APK
+ include (*reactNativeArchitectures())
+ }
+ }
+ signingConfigs {
+ debug {
+ storeFile file('debug.keystore')
+ storePassword 'android'
+ keyAlias 'androiddebugkey'
+ keyPassword 'android'
+ }
+ }
+ buildTypes {
+ debug {
+ signingConfig signingConfigs.debug
+ }
+ release {
+ // Caution! In production, you need to generate your own keystore file.
+ // see https://reactnative.dev/docs/signed-apk-android.
+ signingConfig signingConfigs.debug
+ minifyEnabled enableProguardInReleaseBuilds
+ 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
+ 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 =
+ versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
+ }
+
+ }
+ }
+}
+
+// Apply static values from `gradle.properties` to the `android.packagingOptions`
+// Accepts values in comma delimited lists, example:
+// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
+["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
+ // Split option: 'foo,bar' -> ['foo', 'bar']
+ def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
+ // Trim all elements in place.
+ for (i in 0.. 0) {
+ println "android.packagingOptions.$prop += $options ($options.length)"
+ // Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
+ options.each {
+ android.packagingOptions[prop] += it
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: "libs", include: ["*.jar"])
+
+ //noinspection GradleDynamicVersion
+ implementation "com.facebook.react:react-native:+" // From node_modules
+
+ def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
+ def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
+ def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
+ def frescoVersion = rootProject.ext.frescoVersion
+
+ // If your app supports Android versions before Ice Cream Sandwich (API level 14)
+ if (isGifEnabled || isWebpEnabled) {
+ implementation "com.facebook.fresco:fresco:${frescoVersion}"
+ implementation "com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}"
+ }
+
+ if (isGifEnabled) {
+ // For animated gif support
+ implementation "com.facebook.fresco:animated-gif:${frescoVersion}"
+ }
+
+ if (isWebpEnabled) {
+ // For webp support
+ implementation "com.facebook.fresco:webpsupport:${frescoVersion}"
+ if (isWebpAnimatedEnabled) {
+ // Animated webp support
+ implementation "com.facebook.fresco:animated-webp:${frescoVersion}"
+ }
+ }
+
+ implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
+ exclude group:'com.facebook.fbjni'
+ }
+ debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
+ exclude group:'com.facebook.flipper'
+ exclude group:'com.squareup.okhttp3', module:'okhttp'
+ }
+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
+ exclude group:'com.facebook.flipper'
+ }
+
+ if (enableHermes) {
+ //noinspection GradleDynamicVersion
+ implementation("com.facebook.react:hermes-engine:+") { // From node_modules
+ exclude group:'com.facebook.fbjni'
+ }
+ } else {
+ implementation jscFlavor
+ }
+}
+
+if (isNewArchitectureEnabled()) {
+ // If new architecture is enabled, we let you build RN from source
+ // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
+ // This will be applied to all the imported transtitive dependency.
+ configurations.all {
+ resolutionStrategy.dependencySubstitution {
+ substitute(module("com.facebook.react:react-native"))
+ .using(project(":ReactAndroid"))
+ .because("On New Architecture we're building React Native from source")
+ substitute(module("com.facebook.react:hermes-engine"))
+ .using(project(":ReactAndroid:hermes-engine"))
+ .because("On New Architecture we're building Hermes from source")
+ }
+ }
+}
+
+// Run this once to be able to run the application with BUCK
+// puts all compile dependencies into folder libs for BUCK to use
+task copyDownloadableDepsToLibs(type: Copy) {
+ from configurations.implementation
+ into 'libs'
+}
+
+apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
+applyNativeModulesAppBuildGradle(project)
+
+def isNewArchitectureEnabled() {
+ // To opt-in for the New Architecture, you can either:
+ // - Set `newArchEnabled` to true inside the `gradle.properties` file
+ // - Invoke gradle with `-newArchEnabled=true`
+ // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
+}
diff --git a/apps/mobile/android/app/build_defs.bzl b/apps/mobile/android/app/build_defs.bzl
new file mode 100644
index 000000000..fff270f8d
--- /dev/null
+++ b/apps/mobile/android/app/build_defs.bzl
@@ -0,0 +1,19 @@
+"""Helper definitions to glob .aar and .jar targets"""
+
+def create_aar_targets(aarfiles):
+ for aarfile in aarfiles:
+ name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
+ lib_deps.append(":" + name)
+ android_prebuilt_aar(
+ name = name,
+ aar = aarfile,
+ )
+
+def create_jar_targets(jarfiles):
+ for jarfile in jarfiles:
+ name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
+ lib_deps.append(":" + name)
+ prebuilt_jar(
+ name = name,
+ binary_jar = jarfile,
+ )
diff --git a/apps/mobile/android/app/debug.keystore b/apps/mobile/android/app/debug.keystore
new file mode 100644
index 000000000..364e105ed
Binary files /dev/null and b/apps/mobile/android/app/debug.keystore differ
diff --git a/apps/mobile/android/app/proguard-rules.pro b/apps/mobile/android/app/proguard-rules.pro
new file mode 100644
index 000000000..551eb41da
--- /dev/null
+++ b/apps/mobile/android/app/proguard-rules.pro
@@ -0,0 +1,14 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# react-native-reanimated
+-keep class com.swmansion.reanimated.** { *; }
+-keep class com.facebook.react.turbomodule.** { *; }
+
+# Add any project specific keep options here:
diff --git a/apps/mobile/android/app/src/debug/AndroidManifest.xml b/apps/mobile/android/app/src/debug/AndroidManifest.xml
new file mode 100644
index 000000000..99e38fc5f
--- /dev/null
+++ b/apps/mobile/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
diff --git a/apps/mobile/android/app/src/debug/java/com/spacedrive/app/ReactNativeFlipper.java b/apps/mobile/android/app/src/debug/java/com/spacedrive/app/ReactNativeFlipper.java
new file mode 100644
index 000000000..00c9f2231
--- /dev/null
+++ b/apps/mobile/android/app/src/debug/java/com/spacedrive/app/ReactNativeFlipper.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ *
This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
+ */
+package com.spacedrive.app;
+
+import android.content.Context;
+import com.facebook.flipper.android.AndroidFlipperClient;
+import com.facebook.flipper.android.utils.FlipperUtils;
+import com.facebook.flipper.core.FlipperClient;
+import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
+import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
+import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
+import com.facebook.flipper.plugins.inspector.DescriptorMapping;
+import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
+import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
+import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
+import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
+import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
+import com.facebook.react.ReactInstanceManager;
+import com.facebook.react.bridge.ReactContext;
+import com.facebook.react.modules.network.NetworkingModule;
+import okhttp3.OkHttpClient;
+
+public class ReactNativeFlipper {
+ public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
+ if (FlipperUtils.shouldEnableFlipper(context)) {
+ final FlipperClient client = AndroidFlipperClient.getInstance(context);
+ client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
+ client.addPlugin(new ReactFlipperPlugin());
+ client.addPlugin(new DatabasesFlipperPlugin(context));
+ client.addPlugin(new SharedPreferencesFlipperPlugin(context));
+ client.addPlugin(CrashReporterPlugin.getInstance());
+ NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
+ NetworkingModule.setCustomClientBuilder(
+ new NetworkingModule.CustomClientBuilder() {
+ @Override
+ public void apply(OkHttpClient.Builder builder) {
+ builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
+ }
+ });
+ client.addPlugin(networkFlipperPlugin);
+ client.start();
+ // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
+ // Hence we run if after all native modules have been initialized
+ ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
+ if (reactContext == null) {
+ reactInstanceManager.addReactInstanceEventListener(
+ new ReactInstanceManager.ReactInstanceEventListener() {
+ @Override
+ public void onReactContextInitialized(ReactContext reactContext) {
+ reactInstanceManager.removeReactInstanceEventListener(this);
+ reactContext.runOnNativeModulesQueueThread(
+ new Runnable() {
+ @Override
+ public void run() {
+ client.addPlugin(new FrescoFlipperPlugin());
+ }
+ });
+ }
+ });
+ } else {
+ client.addPlugin(new FrescoFlipperPlugin());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/mobile/android/app/src/main/AndroidManifest.xml b/apps/mobile/android/app/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..72543be31
--- /dev/null
+++ b/apps/mobile/android/app/src/main/AndroidManifest.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/mobile/android/app/src/main/java/com/spacedrive/app/MainActivity.java b/apps/mobile/android/app/src/main/java/com/spacedrive/app/MainActivity.java
new file mode 100644
index 000000000..94ac57750
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/spacedrive/app/MainActivity.java
@@ -0,0 +1,83 @@
+package com.spacedrive.app;
+
+import android.os.Build;
+import android.os.Bundle;
+
+import com.facebook.react.ReactActivity;
+import com.facebook.react.ReactActivityDelegate;
+import com.facebook.react.ReactRootView;
+
+import expo.modules.ReactActivityDelegateWrapper;
+
+public class MainActivity extends ReactActivity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ // Set the theme to AppTheme BEFORE onCreate to support
+ // coloring the background, status bar, and navigation bar.
+ // This is required for expo-splash-screen.
+ setTheme(R.style.AppTheme);
+ super.onCreate(null);
+ }
+
+ /**
+ * Returns the name of the main component registered from JavaScript.
+ * This is used to schedule rendering of the component.
+ */
+ @Override
+ protected String getMainComponentName() {
+ return "main";
+ }
+
+ /**
+ * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
+ * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
+ * (Paper).
+ */
+ @Override
+ protected ReactActivityDelegate createReactActivityDelegate() {
+ return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
+ new MainActivityDelegate(this, getMainComponentName())
+ );
+ }
+
+ /**
+ * Align the back button behavior with Android S
+ * where moving root activities to background instead of finishing activities.
+ * @see onBackPressed
+ */
+ @Override
+ public void invokeDefaultOnBackPressed() {
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
+ if (!moveTaskToBack(false)) {
+ // For non-root activities, use the default implementation to finish them.
+ super.invokeDefaultOnBackPressed();
+ }
+ return;
+ }
+
+ // Use the default back button implementation on Android S
+ // because it's doing more than {@link Activity#moveTaskToBack} in fact.
+ super.invokeDefaultOnBackPressed();
+ }
+
+ public static class MainActivityDelegate extends ReactActivityDelegate {
+ public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
+ super(activity, mainComponentName);
+ }
+
+ @Override
+ protected ReactRootView createRootView() {
+ ReactRootView reactRootView = new ReactRootView(getContext());
+ // If you opted-in for the New Architecture, we enable the Fabric Renderer.
+ reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
+ return reactRootView;
+ }
+
+ @Override
+ protected boolean isConcurrentRootEnabled() {
+ // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
+ // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
+ return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
+ }
+ }
+}
diff --git a/apps/mobile/android/app/src/main/java/com/spacedrive/app/MainApplication.java b/apps/mobile/android/app/src/main/java/com/spacedrive/app/MainApplication.java
new file mode 100644
index 000000000..1d47d6150
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/spacedrive/app/MainApplication.java
@@ -0,0 +1,106 @@
+package com.spacedrive.app;
+
+import android.app.Application;
+import android.content.Context;
+import android.content.res.Configuration;
+import androidx.annotation.NonNull;
+
+import com.facebook.react.PackageList;
+import com.facebook.react.ReactApplication;
+import com.facebook.react.ReactInstanceManager;
+import com.facebook.react.ReactNativeHost;
+import com.facebook.react.ReactPackage;
+import com.facebook.react.config.ReactFeatureFlags;
+import com.facebook.soloader.SoLoader;
+import com.spacedrive.app.newarchitecture.MainApplicationReactNativeHost;
+
+import expo.modules.ApplicationLifecycleDispatcher;
+import expo.modules.ReactNativeHostWrapper;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+public class MainApplication extends Application implements ReactApplication {
+ private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
+ this,
+ new ReactNativeHost(this) {
+ @Override
+ public boolean getUseDeveloperSupport() {
+ return BuildConfig.DEBUG;
+ }
+
+ @Override
+ protected List getPackages() {
+ @SuppressWarnings("UnnecessaryLocalVariable")
+ List packages = new PackageList(this).getPackages();
+ // Packages that cannot be autolinked yet can be added manually here, for example:
+ packages.add(new com.spacedrive.app.SpacedrivePackage());
+ return packages;
+ }
+
+ @Override
+ protected String getJSMainModuleName() {
+ return "index";
+ }
+ });
+
+ private final ReactNativeHost mNewArchitectureNativeHost =
+ new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));
+
+ @Override
+ public ReactNativeHost getReactNativeHost() {
+ if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
+ return mNewArchitectureNativeHost;
+ } else {
+ return mReactNativeHost;
+ }
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ // If you opted-in for the New Architecture, we enable the TurboModule system
+ ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
+ SoLoader.init(this, /* native exopackage */ false);
+
+ initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
+ ApplicationLifecycleDispatcher.onApplicationCreate(this);
+ }
+
+ @Override
+ public void onConfigurationChanged(@NonNull Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
+ }
+
+ /**
+ * Loads Flipper in React Native templates. Call this in the onCreate method with something like
+ * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
+ *
+ * @param context
+ * @param reactInstanceManager
+ */
+ private static void initializeFlipper(
+ Context context, ReactInstanceManager reactInstanceManager) {
+ if (BuildConfig.DEBUG) {
+ try {
+ /*
+ We use reflection here to pick up the class that initializes Flipper,
+ since Flipper library is not available in release mode
+ */
+ Class> aClass = Class.forName("com.spacedrive.app.ReactNativeFlipper");
+ aClass
+ .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
+ .invoke(null, context, reactInstanceManager);
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
diff --git a/apps/mobile/android/app/src/main/java/com/spacedrive/app/SDCore.java b/apps/mobile/android/app/src/main/java/com/spacedrive/app/SDCore.java
new file mode 100644
index 000000000..782f44a1b
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/spacedrive/app/SDCore.java
@@ -0,0 +1,76 @@
+package com.spacedrive.app;
+
+import android.content.Context;
+import android.os.Build;
+
+import androidx.annotation.RequiresApi;
+
+import com.facebook.react.bridge.Promise;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.bridge.ReactContext;
+import com.facebook.react.bridge.ReactContextBaseJavaModule;
+import com.facebook.react.bridge.ReactMethod;
+import com.facebook.react.bridge.WritableMap;
+import com.facebook.react.modules.core.DeviceEventManagerModule;
+
+import javax.annotation.Nullable;
+
+public class SDCore extends ReactContextBaseJavaModule {
+ SDCore(ReactApplicationContext context) { super(context); }
+
+ private boolean registeredWithRust = false;
+ private int listeners = 0;
+
+ @Override
+ public String getName()
+ {
+ return "SDCore";
+ }
+
+ static {
+ System.loadLibrary("sdcore");
+ }
+
+ // is exposed by Rust and is used to register the subscription
+ private native void registerCoreEventListener();
+
+ private native void handleCoreMsg(String query, Promise promise);
+
+ @ReactMethod
+ public void sd_core_msg(String query, Promise promise)
+ {
+ this.handleCoreMsg(query, promise);
+ }
+
+ public String getDataDirectory()
+ {
+ return getCurrentActivity().getFilesDir().toString();
+ }
+
+ @ReactMethod
+ public void addListener(String eventName)
+ {
+ if (!registeredWithRust)
+ {
+ this.registerCoreEventListener();
+ }
+
+ this.listeners++;
+ }
+
+ @ReactMethod
+ public void removeListeners(Integer count)
+ {
+ this.listeners--;
+ }
+
+ public void sendCoreEvent(String body)
+ {
+ if (this.listeners > 0)
+ {
+ this.getReactApplicationContext()
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
+ .emit("SDCoreEvent", body);
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/mobile/android/app/src/main/java/com/spacedrive/app/SpacedrivePackage.java b/apps/mobile/android/app/src/main/java/com/spacedrive/app/SpacedrivePackage.java
new file mode 100644
index 000000000..b9fe3bc95
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/spacedrive/app/SpacedrivePackage.java
@@ -0,0 +1,28 @@
+package com.spacedrive.app;
+import com.facebook.react.ReactPackage;
+import com.facebook.react.bridge.NativeModule;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.uimanager.ViewManager;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class SpacedrivePackage implements ReactPackage {
+
+ @Override
+ public List createViewManagers(ReactApplicationContext reactContext) {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List createNativeModules(
+ ReactApplicationContext reactContext) {
+ List modules = new ArrayList<>();
+
+ modules.add(new SDCore(reactContext));
+
+ return modules;
+ }
+
+}
\ No newline at end of file
diff --git a/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/MainApplicationReactNativeHost.java b/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/MainApplicationReactNativeHost.java
new file mode 100644
index 000000000..1a3e3aa1d
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/MainApplicationReactNativeHost.java
@@ -0,0 +1,117 @@
+package com.spacedrive.app.newarchitecture;
+
+import android.app.Application;
+import androidx.annotation.NonNull;
+import com.facebook.react.PackageList;
+import com.facebook.react.ReactInstanceManager;
+import com.facebook.react.ReactNativeHost;
+import com.facebook.react.ReactPackage;
+import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
+import com.facebook.react.bridge.JSIModulePackage;
+import com.facebook.react.bridge.JSIModuleProvider;
+import com.facebook.react.bridge.JSIModuleSpec;
+import com.facebook.react.bridge.JSIModuleType;
+import com.facebook.react.bridge.JavaScriptContextHolder;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.react.bridge.UIManager;
+import com.facebook.react.fabric.ComponentFactory;
+import com.facebook.react.fabric.CoreComponentsRegistry;
+import com.facebook.react.fabric.EmptyReactNativeConfig;
+import com.facebook.react.fabric.FabricJSIModuleProvider;
+import com.facebook.react.fabric.ReactNativeConfig;
+import com.facebook.react.uimanager.ViewManagerRegistry;
+import com.spacedrive.app.BuildConfig;
+import com.spacedrive.app.newarchitecture.components.MainComponentsRegistry;
+import com.spacedrive.app.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
+ * TurboModule delegates and the Fabric Renderer.
+ *
+ *
Please note that this class is used ONLY if you opt-in for the New Architecture (see the
+ * `newArchEnabled` property). Is ignored otherwise.
+ */
+public class MainApplicationReactNativeHost extends ReactNativeHost {
+ public MainApplicationReactNativeHost(Application application) {
+ super(application);
+ }
+
+ @Override
+ public boolean getUseDeveloperSupport() {
+ return BuildConfig.DEBUG;
+ }
+
+ @Override
+ protected List getPackages() {
+ List packages = new PackageList(this).getPackages();
+ // Packages that cannot be autolinked yet can be added manually here, for example:
+ // packages.add(new MyReactNativePackage());
+ // TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
+ // packages.add(new TurboReactPackage() { ... });
+ // If you have custom Fabric Components, their ViewManagers should also be loaded here
+ // inside a ReactPackage.
+ return packages;
+ }
+
+ @Override
+ protected String getJSMainModuleName() {
+ return "index";
+ }
+
+ @NonNull
+ @Override
+ protected ReactPackageTurboModuleManagerDelegate.Builder
+ getReactPackageTurboModuleManagerDelegateBuilder() {
+ // Here we provide the ReactPackageTurboModuleManagerDelegate Builder. This is necessary
+ // for the new architecture and to use TurboModules correctly.
+ return new MainApplicationTurboModuleManagerDelegate.Builder();
+ }
+
+ @Override
+ protected JSIModulePackage getJSIModulePackage() {
+ return new JSIModulePackage() {
+ @Override
+ public List getJSIModules(
+ final ReactApplicationContext reactApplicationContext,
+ final JavaScriptContextHolder jsContext) {
+ final List specs = new ArrayList<>();
+
+ // Here we provide a new JSIModuleSpec that will be responsible of providing the
+ // custom Fabric Components.
+ specs.add(
+ new JSIModuleSpec() {
+ @Override
+ public JSIModuleType getJSIModuleType() {
+ return JSIModuleType.UIManager;
+ }
+
+ @Override
+ public JSIModuleProvider getJSIModuleProvider() {
+ final ComponentFactory componentFactory = new ComponentFactory();
+ CoreComponentsRegistry.register(componentFactory);
+
+ // Here we register a Components Registry.
+ // The one that is generated with the template contains no components
+ // and just provides you the one from React Native core.
+ MainComponentsRegistry.register(componentFactory);
+
+ final ReactInstanceManager reactInstanceManager = getReactInstanceManager();
+
+ ViewManagerRegistry viewManagerRegistry =
+ new ViewManagerRegistry(
+ reactInstanceManager.getOrCreateViewManagers(reactApplicationContext));
+
+ return new FabricJSIModuleProvider(
+ reactApplicationContext,
+ componentFactory,
+ ReactNativeConfig.DEFAULT_CONFIG,
+ viewManagerRegistry);
+ }
+ });
+ return specs;
+ }
+ };
+ }
+}
diff --git a/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/components/MainComponentsRegistry.java b/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/components/MainComponentsRegistry.java
new file mode 100644
index 000000000..0c5bce1e3
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/components/MainComponentsRegistry.java
@@ -0,0 +1,36 @@
+package com.spacedrive.app.newarchitecture.components;
+
+import com.facebook.jni.HybridData;
+import com.facebook.proguard.annotations.DoNotStrip;
+import com.facebook.react.fabric.ComponentFactory;
+import com.facebook.soloader.SoLoader;
+
+/**
+ * Class responsible to load the custom Fabric Components. This class has native methods and needs a
+ * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
+ * folder for you).
+ *
+ *
Please note that this class is used ONLY if you opt-in for the New Architecture (see the
+ * `newArchEnabled` property). Is ignored otherwise.
+ */
+@DoNotStrip
+public class MainComponentsRegistry {
+ static {
+ SoLoader.loadLibrary("fabricjni");
+ }
+
+ @DoNotStrip private final HybridData mHybridData;
+
+ @DoNotStrip
+ private native HybridData initHybrid(ComponentFactory componentFactory);
+
+ @DoNotStrip
+ private MainComponentsRegistry(ComponentFactory componentFactory) {
+ mHybridData = initHybrid(componentFactory);
+ }
+
+ @DoNotStrip
+ public static MainComponentsRegistry register(ComponentFactory componentFactory) {
+ return new MainComponentsRegistry(componentFactory);
+ }
+}
diff --git a/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java b/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
new file mode 100644
index 000000000..a2cd752da
--- /dev/null
+++ b/apps/mobile/android/app/src/main/java/com/spacedrive/app/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java
@@ -0,0 +1,48 @@
+package com.spacedrive.app.newarchitecture.modules;
+
+import com.facebook.jni.HybridData;
+import com.facebook.react.ReactPackage;
+import com.facebook.react.ReactPackageTurboModuleManagerDelegate;
+import com.facebook.react.bridge.ReactApplicationContext;
+import com.facebook.soloader.SoLoader;
+import java.util.List;
+
+/**
+ * Class responsible to load the TurboModules. This class has native methods and needs a
+ * corresponding C++ implementation/header file to work correctly (already placed inside the jni/
+ * folder for you).
+ *
+ *