diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..eaeef23
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,48 @@
+name: CI
+
+on:
+ push:
+ branches: [master, dev]
+ pull_request:
+
+concurrency:
+ group: ci-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ check:
+ strategy:
+ fail-fast: false
+ matrix:
+ platform: [windows-latest, macos-latest, ubuntu-22.04]
+
+ runs-on: ${{ matrix.platform }}
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Install Linux system dependencies
+ if: matrix.platform == 'ubuntu-22.04'
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
+
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@stable
+
+ - name: Rust cache
+ uses: swatinem/rust-cache@v2
+ with:
+ workspaces: 'src-tauri -> target'
+
+ - name: Install Bun
+ uses: oven-sh/setup-bun@v2
+
+ - name: Install frontend dependencies
+ run: bun install --frozen-lockfile
+
+ - name: Typecheck and build frontend
+ run: bun run build
+
+ - name: Check backend
+ run: cargo check --manifest-path src-tauri/Cargo.toml --locked
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 74249ff..1c3d0cb 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,60 +1,91 @@
name: Release
on:
- push:
- tags:
- - 'flicker-v*'
+ release:
+ types: [published]
workflow_dispatch:
permissions:
contents: write
+concurrency:
+ group: release-${{ github.event.release.tag_name || github.ref }}
+ cancel-in-progress: false
+
jobs:
- # Create (or reuse) a single draft release first. Matrix build jobs below
- # upload into this release by id instead of each trying to create their
- # own - running them all in parallel without this step causes GitHub
- # Actions to race and create duplicate draft releases.
- create-release:
+ prepare:
runs-on: ubuntu-latest
outputs:
- release_id: ${{ steps.release.outputs.result }}
- tag_name: ${{ steps.version.outputs.tag }}
+ release_id: ${{ steps.release.outputs.id }}
+ skip: ${{ steps.release.outputs.skip }}
steps:
- uses: actions/checkout@v4
- - name: Read version
+ - name: Check versions match
id: version
+ env:
+ TAG: ${{ github.event.release.tag_name }}
run: |
VERSION=$(jq -r .version src-tauri/tauri.conf.json)
- echo "tag=flicker-v$VERSION" >> "$GITHUB_OUTPUT"
+ fail() { echo "::error::$1"; exit 1; }
+ [ "$(jq -r .version package.json)" = "$VERSION" ] || fail "package.json is $(jq -r .version package.json) but tauri.conf.json is $VERSION"
+ CARGO=$(grep -m1 '^version' src-tauri/Cargo.toml | cut -d'"' -f2)
+ [ "$CARGO" = "$VERSION" ] || fail "src-tauri/Cargo.toml is $CARGO but tauri.conf.json is $VERSION"
+ grep -q "APP_VERSION = '$VERSION'" src/constants.ts || fail "APP_VERSION in src/constants.ts doesn't match $VERSION"
+ if [ -n "$TAG" ] && [ "${TAG##*v}" != "$VERSION" ]; then fail "Release tag $TAG doesn't match version $VERSION"; fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- - name: Create or reuse draft release
+ - name: Release notes from CHANGELOG
+ env:
+ VERSION: ${{ steps.version.outputs.version }}
+ run: |
+ awk -v v="$VERSION" '
+ index($0, "## [" v "]") == 1 { found = 1; next }
+ found && /^## \[/ { exit }
+ found && /^---$/ { exit }
+ found { print }
+ ' CHANGELOG.md > notes.md
+ [ -s notes.md ] || echo "See CHANGELOG.md for details." > notes.md
+
+ - name: Find or create release
id: release
uses: actions/github-script@v7
+ env:
+ VERSION: ${{ steps.version.outputs.version }}
with:
script: |
- const tag = '${{ steps.version.outputs.tag }}';
- const version = '${{ steps.version.outputs.version }}';
- const { owner, repo } = context.repo;
- try {
- const { data } = await github.rest.repos.getReleaseByTag({ owner, repo, tag });
- return data.id;
- } catch (error) {
- if (error.status !== 404) throw error;
- const { data } = await github.rest.repos.createRelease({
- owner,
- repo,
- tag_name: tag,
- name: `Flicker v${version}`,
- draft: true,
- prerelease: false,
- });
- return data.id;
+ const fs = require('fs')
+ const { owner, repo } = context.repo
+ const version = process.env.VERSION
+
+ let release = context.payload.release
+ if (!release) {
+ const tag = `v${version}`
+ try {
+ release = (await github.rest.repos.getReleaseByTag({ owner, repo, tag })).data
+ } catch (error) {
+ if (error.status !== 404) throw error
+ release = (await github.rest.repos.createRelease({
+ owner,
+ repo,
+ tag_name: tag,
+ target_commitish: context.sha,
+ name: `Flicker v${version}`,
+ body: fs.readFileSync('notes.md', 'utf8'),
+ draft: true,
+ })).data
+ }
}
+ const assets = await github.rest.repos.listReleaseAssets({ owner, repo, release_id: release.id })
+ const built = assets.data.some(a => a.name === 'latest.json')
+ if (built) core.notice(`Release ${release.tag_name} already has build files; skipping.`)
+ core.setOutput('id', release.id)
+ core.setOutput('skip', built ? 'true' : 'false')
+
build:
- needs: create-release
+ needs: prepare
+ if: needs.prepare.outputs.skip != 'true'
strategy:
fail-fast: false
matrix:
@@ -77,12 +108,7 @@ jobs:
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
- sudo apt-get install -y \
- libwebkit2gtk-4.1-dev \
- libappindicator3-dev \
- librsvg2-dev \
- patchelf \
- xdg-utils
+ sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
@@ -98,16 +124,14 @@ jobs:
uses: oven-sh/setup-bun@v2
- name: Install frontend dependencies
- run: bun install
+ run: bun install --frozen-lockfile
- name: Build and upload
uses: tauri-apps/tauri-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- # Only needed once updater signing is configured (see README's
- # Distribution section) - safe to leave unset until then.
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
- releaseId: ${{ needs.create-release.outputs.release_id }}
+ releaseId: ${{ needs.prepare.outputs.release_id }}
args: ${{ matrix.args }}
diff --git a/.gitignore b/.gitignore
index 0596718..9a123d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,3 +25,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?
+
+*.key
+*.key.pub
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a4e1a19..387e9ed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,12 +6,168 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Planned
-- Region screenshot capture with selection UI
- Custom theme creation
- Multiple monitor support improvements
---
+## [0.4.0] - 2026-10-23
+
+Flicker gets the new Emberly look: an ember-orange theme matching embrly.ca,
+a new icon, and a cleaner design throughout. It also captures any region of
+any screen and behaves properly as a menu bar app on macOS.
+
+### Added
+- **Sign in with your browser**: Flicker shows a short code and opens
+ embrly.ca/activate. Approve it there and Flicker gets its own upload key,
+ named after this device, which you can revoke from your dashboard at any
+ time. Email and password sign-in and pasting an upload token still work.
+- **Choose your server at sign-in**: the sign-in screen shows which Emberly
+ server you're signing in to, with **Change** to point Flicker at a
+ self-hosted one. Flicker checks it's really an Emberly server before
+ switching, and browser sign-in, email sign-in and the sign-up link all use
+ it.
+- **Open Flicker with a shortcut**: Ctrl+Alt+F (Control+Option+F on macOS)
+ brings the window back from anywhere, or hides it if it's already in front.
+ Change it in Settings → Hotkeys.
+- **Choose what closing the window does** in Settings → Preferences → Window:
+ keep running in the tray (menu bar on macOS), minimize to the taskbar (Dock
+ on macOS), or quit. The first time closing hides Flicker, a notification
+ says where it went and how to get it back.
+- **Self-hosted servers**: Flicker asks the server what it supports. When
+ billing is off it hides plans and perks, and the domain picker only shows
+ when the server offers custom domains.
+- **Quick actions on the Upload page**: region, screen, all screens,
+ clipboard and record, each showing its shortcut, plus your recent uploads.
+- **Shorten** copies the short link as soon as it's ready, fills in a link
+ you've already copied, and keeps a list of recent short links.
+- **Stats** shows uploads over the last 14 days and your recent uploads with
+ views and downloads.
+- **Reset to defaults** for hotkeys.
+- The "Update now" button on update notifications opens Settings → About,
+ where the update downloads with progress.
+- **Ember theme**, the new default, using the same palette as embrly.ca and
+ the docs. Everyone is moved to it once on first launch after updating;
+ pick another theme in Settings → Preferences and it sticks.
+- **New icon**: the Emberly flame framed by capture corners, on every
+ platform. The macOS menu bar gets a monochrome icon that adapts to light
+ and dark menu bars.
+- **System-wide region capture**: a transparent overlay on every monitor.
+ Drag to select an area, or click once to capture the window under the
+ cursor. Flicker hides itself first, so it no longer appears in its own
+ screenshots.
+- **macOS permissions**: Settings shows Screen Recording, Accessibility and
+ Login Items status with buttons to grant them, and Flicker nudges you at
+ startup if any are missing. It can also start at login.
+- **History from your account**: Upload History now loads your latest 100
+ files from Emberly, so uploads from the website, ShareX or another device
+ show up too, with real image previews for public files. Files you deleted
+ on the website disappear from History as well.
+- **New sounds**: a warm chime when an upload is ready, a shutter click on
+ capture, a pop when copying a link, a soft tone on errors, and gentle
+ ticks for saves and notifications. They now actually play during uploads,
+ captures and copies (previously only the Settings previews made a sound),
+ and each can be turned off and previewed in Settings → Preferences.
+- **Activity log and console logs that work**: the Activity log records
+ uploads, failures, sign-ins, saved settings, update checks, hotkey problems
+ and app errors. Console Logs captures everything from the moment Flicker
+ starts, including the core app's output, with copy and clear.
+- **Update checking**: Settings → About checks for a newer release, and signed
+ updates download and install in place. If the updater can't reach a
+ release, Flicker falls back to GitHub and links to the download.
+- **Automatic release builds**: publishing a GitHub release builds Flicker
+ for Windows, macOS (Apple silicon and Intel) and Linux, signs the updates,
+ and attaches the installers and `latest.json` to the release. Pull requests
+ are type-checked and compiled on all three platforms.
+- Inter is bundled with the app, so the interface no longer depends on
+ loading fonts from the internet.
+
+### Changed
+- **Redesigned to match embrly.ca**: the sidebar, settings tabs and option
+ buttons use the site's quieter style (a filled background with an orange
+ icon instead of solid orange blocks), cards and panels use the site's
+ surfaces, and the header no longer repeats the page title.
+- **Settings**: Save Changes only appears when something on the tab has
+ changed, and sits at the bottom right instead of across the whole page.
+- **macOS menu bar app**: Flicker has a Dock icon and appears in Cmd+Tab
+ while its window is open. When you close the window it moves to the menu
+ bar with no Dock icon, and hotkey captures from other apps never pop the
+ main window open.
+- **Faster, honest start-up screen**: it used to hold you for 8 seconds of
+ fake "connecting" steps. It now only checks for updates, opens in about a
+ second, and shows a spinning ember ring. When an update installs, it shows
+ the real download progress.
+- **The whole app redesigned**: every page and settings tab now uses the same
+ rows, switches and segmented controls as Preferences. Settings → Capture
+ groups screenshots, uploads and recording; Hotkeys lists each shortcut with
+ what it does; About puts updates, diagnostics and links on one page; and
+ macOS permissions only appear on macOS.
+- **History** has a quieter toolbar, and image cards show real previews more
+ reliably.
+- **Notifications** open as a simple list with actions on hover, and close
+ with Esc.
+- **Preferences redesigned**: themes show a small preview of the app in
+ their colours, and display and sound options are clear rows with switches
+ and segmented controls.
+- **Upload dialog** uses the new design and retries the preview while the
+ image is still processing, instead of showing a false "404".
+- Region selection, notifications, toasts and history icons use ember or
+ neutral colours instead of indigo, blue and purple. Green, red and amber
+ still mean success, error and warning.
+- The window is titled "Flicker" instead of "Emberly Uploader".
+- New installs default to Inter and larger rounded corners.
+
+### Fixed
+- **"Save Local" did nothing**: every capture was kept in
+ `Pictures/Flicker Screenshots` forever. The setting is now called **Keep
+ local copies**; when it's off, captures are deleted once they've uploaded.
+ Settings → Capture shows the folder with an **Open folder** button. Files
+ you upload yourself are never deleted.
+- **Hotkeys that silently failed**: when another app (or Windows itself)
+ already owns a shortcut, the Hotkeys tab now says so under that shortcut,
+ and also flags one shortcut assigned to two actions. Previously it just
+ didn't work.
+- The default video hotkey is now Ctrl+Alt+R on Windows and Linux, since
+ Windows 11 reserves Win+Shift+R for the Snipping Tool. macOS keeps
+ Cmd+Shift+R.
+- **Windows builds**: the app no longer fails to compile on Windows. An
+ unused screen-capture library didn't build against its own dependency, and
+ macOS-only permission commands weren't limited to macOS.
+- **Stats page failed to load** ("invalid type: floating point"): Emberly
+ reports storage in megabytes with decimals, which Flicker expected as a
+ whole number of bytes. Storage and file sizes now display correctly.
+- **Duplicate History entries**: one upload could be added two or three
+ times, depending on which part of the app finished first.
+- **Missing previews** in History for older links ending in `/`.
+- **Profile details went stale**: your name, email and avatar were saved at
+ sign-in and never refreshed. Flicker now refreshes them on start-up.
+- **Avatar not loading** in Settings → Account: avatar paths from Emberly are
+ now resolved against your server, with a fallback icon if one fails.
+- **Toggle switches looked like circles**: a touch-screen sizing rule
+ applied to every button on desktop. It now only applies on touch devices.
+- One shortcut assigned to two actions no longer fires both; the first one
+ wins.
+- macOS: the Command key is recognised in hotkeys (e.g. Cmd+Shift+S).
+- Upload History's filter dropdown is no longer hidden behind the mobile menu
+ or clipped.
+- Image previews show at their real size, with scrolling for large
+ screenshots.
+- **Short links pointed to the wrong address**: links made in Flicker now use
+ the same `/u/` path as the website.
+- The notifications panel opened behind the page, and its buttons did
+ nothing.
+- **No way back after closing the window**: once closed, Flicker could only
+ be reopened from its tray icon. Opening Flicker again from the Start menu,
+ Dock, Finder or a desktop shortcut now brings back the copy that's already
+ running instead of doing nothing, and the new shortcut works too.
+- **Uploads from the Upload page went to embrly.ca** even when you were
+ signed in to a self-hosted server. They now go to your server, like
+ captures do.
+- The README listed the wrong download names, and missed the separate Apple
+ silicon and Intel downloads for macOS.
+
+---
+
## [0.3.0] - 2026-07-26
Flicker moves out of beta. It's stable enough for daily use, but still
diff --git a/README.md b/README.md
index 83735e9..16a5233 100644
--- a/README.md
+++ b/README.md
@@ -34,9 +34,24 @@ Download the latest release for your platform from the [Releases](https://github
| Platform | Download |
|----------|----------|
-| Windows | `flicker_x.x.x_x64-setup.exe` |
-| macOS | `flicker_x.x.x_x64.dmg` |
-| Linux | `flicker_x.x.x_amd64.deb` |
+| Windows | `Flicker_x.x.x_x64-setup.exe` |
+| macOS (Apple silicon: M1 and later) | `Flicker_x.x.x_aarch64.dmg` |
+| macOS (Intel) | `Flicker_x.x.x_x64.dmg` |
+| Linux | `Flicker_x.x.x_amd64.deb` or `.AppImage` |
+
+#### First launch on macOS
+
+Flicker isn't signed with an Apple Developer certificate yet, so macOS may say
+it "is damaged and can't be opened" or "can't be checked for malicious
+software". After moving Flicker to Applications, run this once in Terminal:
+
+```bash
+xattr -cr /Applications/Flicker.app
+```
+
+Then open Flicker and grant **Screen Recording** (and **Accessibility**, for
+shortcuts) when asked. macOS only applies Screen Recording after Flicker
+restarts.
### Build from Source
@@ -67,20 +82,32 @@ bun run tauri:build
# or: npm run tauri:build
```
-### Distribution / Cross-Platform Builds
+### Releasing
+
+Each platform has to be built on that platform, so releases are built by GitHub
+Actions:
+
+- **`ci.yml`** typechecks the frontend and compiles the backend on Windows,
+ macOS and Linux for every push to `master`/`dev` and every pull request.
+- **`release.yml`** builds installers for Windows, macOS (Apple Silicon and
+ Intel) and Linux and attaches them, with their update signatures and
+ `latest.json`, to a GitHub release.
+
+To release:
-Tauri apps embed the OS's native webview and produce OS-native installers, so a
-Windows machine cannot produce a macOS `.dmg` or a Linux AppImage/`.deb`/`.rpm` —
-each platform must be built natively. `.github/workflows/release.yml` handles
-this with a GitHub Actions matrix (`windows-latest`, `macos-latest` for both
-Apple Silicon and Intel, `ubuntu-22.04`) that builds and drafts a GitHub Release
-whenever a `flicker-v*` tag is pushed, or on demand via workflow dispatch.
+1. Bump the version in `package.json`, `src-tauri/tauri.conf.json`,
+ `src-tauri/Cargo.toml` and `src/constants.ts`, and add a section to
+ `CHANGELOG.md`. The workflow refuses to build if these don't match.
+2. Either **publish a release** on GitHub with a tag like `v0.4.0`, and the
+ builds are attached to it; or **run the Release workflow by hand**, which
+ creates a draft release with notes from the changelog for you to review and
+ publish.
-Code signing and notarization (required for a smooth install experience on
-Windows and macOS) and updater-artifact signing are not yet configured — the
-workflow will still produce unsigned installers without them. See
-[Tauri's distribution docs](https://v2.tauri.app/distribute/) for setting up
-signing when ready.
+Updates are signed with the key in the `TAURI_SIGNING_PRIVATE_KEY` and
+`TAURI_SIGNING_PRIVATE_KEY_PASSWORD` repository secrets, and verified by the
+app against `plugins.updater.pubkey` in `tauri.conf.json`. Installed copies
+update themselves from the latest release. Windows and macOS code signing
+(which removes the "unknown publisher" warnings) isn't set up yet.
## Quick Start
@@ -96,13 +123,13 @@ signing when ready.
| Fullscreen Screenshot | `Ctrl + Shift + S` |
| All Monitors Screenshot | `Ctrl + Shift + A` |
| Upload from Clipboard | `Ctrl + Alt + U` |
-| Region Screenshot | Not yet implemented |
+| Region Screenshot | `Ctrl + Shift + X` |
All hotkeys can be customized in Settings → Hotkeys.
## Themes
-Flicker includes a set of built-in dark color themes (Stranger Things, Emberly Classic, Dracula, Tokyo Night, Nord, Rose Pine, Catppuccin, Cyberpunk Neon, Vaporwave, Dark Matrix, Aurora Borealis, Sunset, Ocean Deep, and seasonal variants), selectable from Settings → Preferences.
+Flicker includes a set of built-in dark color themes (Ember, the default, plus Stranger Things, Emberly Classic, Dracula, Tokyo Night, Nord, Rose Pine, Catppuccin, Cyberpunk Neon, Vaporwave, Dark Matrix, Aurora Borealis, Sunset, Ocean Deep, and seasonal variants), selectable from Settings → Preferences.
## Configuration
diff --git a/index.html b/index.html
index a644041..cad38d7 100644
--- a/index.html
+++ b/index.html
@@ -3,12 +3,12 @@
- Emberly Uploader
-
-
+ Flicker
+
+
-
+
diff --git a/package.json b/package.json
index 68aa47f..c0e1709 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "@emberly/flicker",
"description": "Flicker - Screenshot & Upload Tool for Emberly",
"license": "AGPL-3.0-only",
- "version": "0.3.0",
+ "version": "0.4.0",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/public/fonts/Inter.ttf b/public/fonts/Inter.ttf
new file mode 100644
index 0000000..e31b51e
Binary files /dev/null and b/public/fonts/Inter.ttf differ
diff --git a/public/icon.svg b/public/icon.svg
index 27ade03..5fb3381 100644
--- a/public/icon.svg
+++ b/public/icon.svg
@@ -1 +1,28 @@
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index a35e7e4..0f1ebd2 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -32,28 +32,6 @@ dependencies = [
"alloc-no-stdlib",
]
-[[package]]
-name = "alsa"
-version = "0.9.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43"
-dependencies = [
- "alsa-sys",
- "bitflags 2.10.0",
- "cfg-if",
- "libc",
-]
-
-[[package]]
-name = "alsa-sys"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527"
-dependencies = [
- "libc",
- "pkg-config",
-]
-
[[package]]
name = "android_system_properties"
version = "0.1.5"
@@ -63,16 +41,6 @@ dependencies = [
"libc",
]
-[[package]]
-name = "annotate-snippets"
-version = "0.9.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ccaf7e9dfbb6ab22c82e473cd1a8a7bd313c19a5b7e40970f3d89ef5a5c9e81e"
-dependencies = [
- "unicode-width",
- "yansi-term",
-]
-
[[package]]
name = "anyhow"
version = "1.0.100"
@@ -298,45 +266,6 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
-[[package]]
-name = "bindgen"
-version = "0.69.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
-dependencies = [
- "annotate-snippets",
- "bitflags 2.10.0",
- "cexpr",
- "clang-sys",
- "itertools 0.12.1",
- "lazy_static",
- "lazycell",
- "proc-macro2",
- "quote",
- "regex",
- "rustc-hash 1.1.0",
- "shlex",
- "syn 2.0.112",
-]
-
-[[package]]
-name = "bindgen"
-version = "0.72.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
-dependencies = [
- "bitflags 2.10.0",
- "cexpr",
- "clang-sys",
- "itertools 0.13.0",
- "proc-macro2",
- "quote",
- "regex",
- "rustc-hash 2.1.1",
- "shlex",
- "syn 2.0.112",
-]
-
[[package]]
name = "bit-set"
version = "0.8.0"
@@ -373,12 +302,6 @@ dependencies = [
"serde_core",
]
-[[package]]
-name = "block"
-version = "0.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
-
[[package]]
name = "block-buffer"
version = "0.10.4"
@@ -549,15 +472,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
-[[package]]
-name = "cexpr"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
-dependencies = [
- "nom 7.1.3",
-]
-
[[package]]
name = "cfb"
version = "0.7.3"
@@ -605,33 +519,6 @@ dependencies = [
"windows-link 0.2.1",
]
-[[package]]
-name = "cidre"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c7a105a9a8dd9e625e1e5938aa8442f63551990bfb2ab4bd606b1b30ccbfd8cf"
-dependencies = [
- "cidre-macros",
- "parking_lot",
-]
-
-[[package]]
-name = "cidre-macros"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f07a383a232853874a9b0b3e80e6eefe9bea73495b8ab4bdd960bc7c1db4c6d"
-
-[[package]]
-name = "clang-sys"
-version = "1.9.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a"
-dependencies = [
- "glob",
- "libc",
- "libloading 0.8.9",
-]
-
[[package]]
name = "clipboard-win"
version = "5.4.1"
@@ -641,36 +528,6 @@ dependencies = [
"error-code",
]
-[[package]]
-name = "cocoa"
-version = "0.25.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f6140449f97a6e97f9511815c5632d84c8aacf8ac271ad77c559218161a1373c"
-dependencies = [
- "bitflags 1.3.2",
- "block",
- "cocoa-foundation",
- "core-foundation 0.9.4",
- "core-graphics 0.23.2",
- "foreign-types 0.5.0",
- "libc",
- "objc",
-]
-
-[[package]]
-name = "cocoa-foundation"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7"
-dependencies = [
- "bitflags 1.3.2",
- "block",
- "core-foundation 0.9.4",
- "core-graphics-types 0.1.3",
- "libc",
- "objc",
-]
-
[[package]]
name = "color_quant"
version = "1.1.0"
@@ -702,15 +559,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
-[[package]]
-name = "convert_case"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
-dependencies = [
- "unicode-segmentation",
-]
-
[[package]]
name = "cookie"
version = "0.18.1"
@@ -721,15 +569,6 @@ dependencies = [
"version_check",
]
-[[package]]
-name = "cookie-factory"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9885fa71e26b8ab7855e2ec7cae6e9b380edff76cd052e07c683a0319d51b3a2"
-dependencies = [
- "futures",
-]
-
[[package]]
name = "core-foundation"
version = "0.9.4"
@@ -795,19 +634,6 @@ dependencies = [
"libc",
]
-[[package]]
-name = "core-graphics-helmer-fork"
-version = "0.24.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32eb7c354ae9f6d437a6039099ce7ecd049337a8109b23d73e48e8ffba8e9cd5"
-dependencies = [
- "bitflags 2.10.0",
- "core-foundation 0.9.4",
- "core-graphics-types 0.1.3",
- "foreign-types 0.5.0",
- "libc",
-]
-
[[package]]
name = "core-graphics-types"
version = "0.1.3"
@@ -830,49 +656,6 @@ dependencies = [
"libc",
]
-[[package]]
-name = "coreaudio-rs"
-version = "0.11.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace"
-dependencies = [
- "bitflags 1.3.2",
- "core-foundation-sys",
- "coreaudio-sys",
-]
-
-[[package]]
-name = "coreaudio-sys"
-version = "0.2.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b9b4739a805a62757a83e5654fa3faabec0442666b263bb2287d5a8185bfd953"
-dependencies = [
- "bindgen 0.72.1",
-]
-
-[[package]]
-name = "cpal"
-version = "0.15.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779"
-dependencies = [
- "alsa",
- "core-foundation-sys",
- "coreaudio-rs",
- "dasp_sample",
- "jni 0.21.1",
- "js-sys",
- "libc",
- "mach2",
- "ndk 0.8.0",
- "ndk-context",
- "oboe",
- "wasm-bindgen",
- "wasm-bindgen-futures",
- "web-sys",
- "windows 0.54.0",
-]
-
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -1032,12 +815,6 @@ dependencies = [
"syn 2.0.112",
]
-[[package]]
-name = "dasp_sample"
-version = "0.11.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
-
[[package]]
name = "dbus"
version = "0.9.10"
@@ -1076,7 +853,7 @@ version = "0.99.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f"
dependencies = [
- "convert_case 0.4.0",
+ "convert_case",
"proc-macro2",
"quote",
"rustc_version",
@@ -1529,7 +1306,7 @@ dependencies = [
[[package]]
name = "flicker"
-version = "0.3.0"
+version = "0.4.0"
dependencies = [
"chrono",
"core-foundation 0.9.4",
@@ -1546,7 +1323,6 @@ dependencies = [
"once_cell",
"openh264",
"reqwest 0.11.27",
- "scap",
"screenshots",
"serde",
"serde_json",
@@ -1559,6 +1335,7 @@ dependencies = [
"tauri-plugin-global-shortcut",
"tauri-plugin-notification",
"tauri-plugin-opener",
+ "tauri-plugin-single-instance",
"tauri-plugin-updater",
"tokio",
"tokio-util",
@@ -1645,21 +1422,6 @@ dependencies = [
"new_debug_unreachable",
]
-[[package]]
-name = "futures"
-version = "0.3.31"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
-dependencies = [
- "futures-channel",
- "futures-core",
- "futures-executor",
- "futures-io",
- "futures-sink",
- "futures-task",
- "futures-util",
-]
-
[[package]]
name = "futures-channel"
version = "0.3.31"
@@ -1667,7 +1429,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
dependencies = [
"futures-core",
- "futures-sink",
]
[[package]]
@@ -1735,7 +1496,6 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
dependencies = [
- "futures-channel",
"futures-core",
"futures-io",
"futures-macro",
@@ -2616,24 +2376,6 @@ dependencies = [
"once_cell",
]
-[[package]]
-name = "itertools"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
-dependencies = [
- "either",
-]
-
-[[package]]
-name = "itertools"
-version = "0.13.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
-dependencies = [
- "either",
-]
-
[[package]]
name = "itoa"
version = "1.0.17"
@@ -2809,18 +2551,6 @@ dependencies = [
"selectors 0.24.0",
]
-[[package]]
-name = "lazy_static"
-version = "1.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
-
-[[package]]
-name = "lazycell"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
-
[[package]]
name = "lebe"
version = "0.5.3"
@@ -2898,34 +2628,6 @@ dependencies = [
"redox_syscall 0.7.0",
]
-[[package]]
-name = "libspa"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "65f3a4b81b2a2d8c7f300643676202debd1b7c929dbf5c9bb89402ea11d19810"
-dependencies = [
- "bitflags 2.10.0",
- "cc",
- "convert_case 0.6.0",
- "cookie-factory",
- "libc",
- "libspa-sys",
- "nix 0.27.1",
- "nom 7.1.3",
- "system-deps",
-]
-
-[[package]]
-name = "libspa-sys"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf0d9716420364790e85cbb9d3ac2c950bde16a7dd36f3209b7dfdfc4a24d01f"
-dependencies = [
- "bindgen 0.69.5",
- "cc",
- "system-deps",
-]
-
[[package]]
name = "libwayshot"
version = "0.2.0"
@@ -2987,24 +2689,6 @@ dependencies = [
"time",
]
-[[package]]
-name = "mach2"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44"
-dependencies = [
- "libc",
-]
-
-[[package]]
-name = "malloc_buf"
-version = "0.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
-dependencies = [
- "libc",
-]
-
[[package]]
name = "markup5ever"
version = "0.14.1"
@@ -3096,12 +2780,6 @@ dependencies = [
"unicase",
]
-[[package]]
-name = "minimal-lexical"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
-
[[package]]
name = "minisign-verify"
version = "0.2.4"
@@ -3200,20 +2878,6 @@ dependencies = [
"tempfile",
]
-[[package]]
-name = "ndk"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7"
-dependencies = [
- "bitflags 2.10.0",
- "jni-sys 0.3.0",
- "log",
- "ndk-sys 0.5.0+25.2.9519653",
- "num_enum",
- "thiserror 1.0.69",
-]
-
[[package]]
name = "ndk"
version = "0.9.0"
@@ -3223,27 +2887,12 @@ dependencies = [
"bitflags 2.10.0",
"jni-sys 0.3.0",
"log",
- "ndk-sys 0.6.0+11769913",
+ "ndk-sys",
"num_enum",
"raw-window-handle",
"thiserror 1.0.69",
]
-[[package]]
-name = "ndk-context"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
-
-[[package]]
-name = "ndk-sys"
-version = "0.5.0+25.2.9519653"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691"
-dependencies = [
- "jni-sys 0.3.0",
-]
-
[[package]]
name = "ndk-sys"
version = "0.6.0+11769913"
@@ -3272,17 +2921,6 @@ dependencies = [
"pin-utils",
]
-[[package]]
-name = "nix"
-version = "0.27.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
-dependencies = [
- "bitflags 2.10.0",
- "cfg-if",
- "libc",
-]
-
[[package]]
name = "nix"
version = "0.30.1"
@@ -3302,16 +2940,6 @@ version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
-[[package]]
-name = "nom"
-version = "7.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
-dependencies = [
- "memchr",
- "minimal-lexical",
-]
-
[[package]]
name = "nom"
version = "8.0.0"
@@ -3335,15 +2963,6 @@ dependencies = [
"zbus",
]
-[[package]]
-name = "ntapi"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"
-dependencies = [
- "winapi",
-]
-
[[package]]
name = "num-bigint"
version = "0.4.8"
@@ -3360,17 +2979,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
-[[package]]
-name = "num-derive"
-version = "0.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.112",
-]
-
[[package]]
name = "num-integer"
version = "0.1.47"
@@ -3433,15 +3041,6 @@ dependencies = [
"syn 2.0.112",
]
-[[package]]
-name = "objc"
-version = "0.2.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
-dependencies = [
- "malloc_buf",
-]
-
[[package]]
name = "objc2"
version = "0.6.4"
@@ -3651,29 +3250,6 @@ dependencies = [
"objc2-foundation",
]
-[[package]]
-name = "oboe"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb"
-dependencies = [
- "jni 0.21.1",
- "ndk 0.8.0",
- "ndk-context",
- "num-derive",
- "num-traits",
- "oboe-sys",
-]
-
-[[package]]
-name = "oboe-sys"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d"
-dependencies = [
- "cc",
-]
-
[[package]]
name = "once_cell"
version = "1.21.3"
@@ -4076,34 +3652,6 @@ dependencies = [
"futures-io",
]
-[[package]]
-name = "pipewire"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08e645ba5c45109106d56610b3ee60eb13a6f2beb8b74f8dc8186cf261788dda"
-dependencies = [
- "anyhow",
- "bitflags 2.10.0",
- "libc",
- "libspa",
- "libspa-sys",
- "nix 0.27.1",
- "once_cell",
- "pipewire-sys",
- "thiserror 1.0.69",
-]
-
-[[package]]
-name = "pipewire-sys"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "849e188f90b1dda88fe2bfe1ad31fe5f158af2c98f80fb5d13726c44f3f01112"
-dependencies = [
- "bindgen 0.69.5",
- "libspa-sys",
- "system-deps",
-]
-
[[package]]
name = "pkg-config"
version = "0.3.32"
@@ -4687,12 +4235,6 @@ dependencies = [
"windows-sys 0.52.0",
]
-[[package]]
-name = "rustc-hash"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
-
[[package]]
name = "rustc-hash"
version = "2.1.1"
@@ -4833,27 +4375,6 @@ dependencies = [
"winapi-util",
]
-[[package]]
-name = "scap"
-version = "0.1.0-beta.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36b5187a2336cbb98d29647050d336ce16bf4806da8fcf04934a4c8788bc17bc"
-dependencies = [
- "cidre",
- "cocoa",
- "core-graphics-helmer-fork",
- "cpal",
- "dbus",
- "futures",
- "objc",
- "pipewire",
- "rand 0.8.5",
- "sysinfo",
- "thiserror 2.0.17",
- "windows 0.58.0",
- "windows-capture",
-]
-
[[package]]
name = "schannel"
version = "0.1.28"
@@ -5013,7 +4534,7 @@ dependencies = [
"phf 0.13.1",
"phf_codegen 0.13.1",
"precomputed-hash",
- "rustc-hash 2.1.1",
+ "rustc-hash",
"servo_arc 0.4.3",
"smallvec",
]
@@ -5308,7 +4829,7 @@ checksum = "aac18da81ebbf05109ab275b157c22a653bb3c12cf884450179942f81bcbf6c3"
dependencies = [
"bytemuck",
"js-sys",
- "ndk 0.9.0",
+ "ndk",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
@@ -5480,21 +5001,6 @@ dependencies = [
"syn 2.0.112",
]
-[[package]]
-name = "sysinfo"
-version = "0.30.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3"
-dependencies = [
- "cfg-if",
- "core-foundation-sys",
- "libc",
- "ntapi",
- "once_cell",
- "rayon",
- "windows 0.52.0",
-]
-
[[package]]
name = "system-configuration"
version = "0.5.1"
@@ -5550,8 +5056,8 @@ dependencies = [
"jni 0.21.1",
"libc",
"log",
- "ndk 0.9.0",
- "ndk-sys 0.6.0+11769913",
+ "ndk",
+ "ndk-sys",
"objc2",
"objc2-app-kit",
"objc2-foundation",
@@ -5855,6 +5361,22 @@ dependencies = [
"zbus",
]
+[[package]]
+name = "tauri-plugin-single-instance"
+version = "2.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db817fe9295e19b7d8357e900af31edb93703dd9fb6de524b007b47b6afc63b0"
+dependencies = [
+ "serde",
+ "serde_json",
+ "tauri",
+ "thiserror 2.0.17",
+ "tokio",
+ "tracing",
+ "windows-sys 0.60.2",
+ "zbus",
+]
+
[[package]]
name = "tauri-plugin-updater"
version = "2.10.1"
@@ -6427,7 +5949,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6"
dependencies = [
"memchr",
- "nom 8.0.0",
+ "nom",
"petgraph",
]
@@ -6519,12 +6041,6 @@ version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
-[[package]]
-name = "unicode-width"
-version = "0.1.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
-
[[package]]
name = "untrusted"
version = "0.9.0"
@@ -6967,8 +6483,8 @@ dependencies = [
"webview2-com-sys",
"windows 0.61.3",
"windows-core 0.61.2",
- "windows-implement 0.60.2",
- "windows-interface 0.59.3",
+ "windows-implement",
+ "windows-interface",
]
[[package]]
@@ -7081,26 +6597,6 @@ dependencies = [
"windows-targets 0.52.6",
]
-[[package]]
-name = "windows"
-version = "0.54.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49"
-dependencies = [
- "windows-core 0.54.0",
- "windows-targets 0.52.6",
-]
-
-[[package]]
-name = "windows"
-version = "0.58.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
-dependencies = [
- "windows-core 0.58.0",
- "windows-targets 0.52.6",
-]
-
[[package]]
name = "windows"
version = "0.61.3"
@@ -7114,19 +6610,6 @@ dependencies = [
"windows-numerics",
]
-[[package]]
-name = "windows-capture"
-version = "1.5.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3a4df73e95feddb9ec1a7e9c2ca6323b8c97d5eeeff78d28f1eccdf19c882b24"
-dependencies = [
- "parking_lot",
- "rayon",
- "thiserror 2.0.17",
- "windows 0.61.3",
- "windows-future",
-]
-
[[package]]
name = "windows-collections"
version = "0.2.0"
@@ -7154,37 +6637,14 @@ dependencies = [
"windows-targets 0.52.6",
]
-[[package]]
-name = "windows-core"
-version = "0.54.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65"
-dependencies = [
- "windows-result 0.1.2",
- "windows-targets 0.52.6",
-]
-
-[[package]]
-name = "windows-core"
-version = "0.58.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
-dependencies = [
- "windows-implement 0.58.0",
- "windows-interface 0.58.0",
- "windows-result 0.2.0",
- "windows-strings 0.1.0",
- "windows-targets 0.52.6",
-]
-
[[package]]
name = "windows-core"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
dependencies = [
- "windows-implement 0.60.2",
- "windows-interface 0.59.3",
+ "windows-implement",
+ "windows-interface",
"windows-link 0.1.3",
"windows-result 0.3.4",
"windows-strings 0.4.2",
@@ -7196,8 +6656,8 @@ version = "0.62.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
dependencies = [
- "windows-implement 0.60.2",
- "windows-interface 0.59.3",
+ "windows-implement",
+ "windows-interface",
"windows-link 0.2.1",
"windows-result 0.4.1",
"windows-strings 0.5.1",
@@ -7214,17 +6674,6 @@ dependencies = [
"windows-threading",
]
-[[package]]
-name = "windows-implement"
-version = "0.58.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.112",
-]
-
[[package]]
name = "windows-implement"
version = "0.60.2"
@@ -7236,17 +6685,6 @@ dependencies = [
"syn 2.0.112",
]
-[[package]]
-name = "windows-interface"
-version = "0.58.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 2.0.112",
-]
-
[[package]]
name = "windows-interface"
version = "0.59.3"
@@ -7280,24 +6718,6 @@ dependencies = [
"windows-link 0.1.3",
]
-[[package]]
-name = "windows-result"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
-dependencies = [
- "windows-targets 0.52.6",
-]
-
-[[package]]
-name = "windows-result"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
-dependencies = [
- "windows-targets 0.52.6",
-]
-
[[package]]
name = "windows-result"
version = "0.3.4"
@@ -7316,16 +6736,6 @@ dependencies = [
"windows-link 0.2.1",
]
-[[package]]
-name = "windows-strings"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
-dependencies = [
- "windows-result 0.2.0",
- "windows-targets 0.52.6",
-]
-
[[package]]
name = "windows-strings"
version = "0.4.2"
@@ -7762,7 +7172,7 @@ dependencies = [
"javascriptcore-rs",
"jni 0.21.1",
"libc",
- "ndk 0.9.0",
+ "ndk",
"objc2",
"objc2-app-kit",
"objc2-core-foundation",
@@ -7851,15 +7261,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
-[[package]]
-name = "yansi-term"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1"
-dependencies = [
- "winapi",
-]
-
[[package]]
name = "yoke"
version = "0.8.1"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 8597acd..1cbd4db 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "flicker"
-version = "0.3.0"
+version = "0.4.0"
description = "Flicker - Screenshot & Upload Tool for Emberly"
authors = ["CodeMeAPixel"]
edition = "2021"
@@ -17,7 +17,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
# Feature flags for cross-platform support
[features]
default = ["desktop"]
-desktop = ["screenshots", "scap", "openh264", "mp4"] # Enable native screenshot + screen recording (no ffmpeg)
+desktop = ["screenshots", "openh264", "mp4"] # Enable native screenshot + screen recording (no ffmpeg)
mobile = [] # Mobile build (minimal features)
android = ["mobile"] # Android-specific build
ios = ["mobile"] # iOS-specific build
@@ -48,7 +48,6 @@ tokio-util = { version = "0.7", features = ["io"] }
futures-util = "0.3"
chrono = "0.4"
screenshots = { version = "0.8", optional = true } # Desktop screenshot support
-scap = { version = "0.1.0-beta.1", optional = true }
openh264 = { version = "0.6", optional = true }
mp4 = { version = "0.14", optional = true }
image = "0.24"
@@ -57,6 +56,9 @@ dirs = "5"
num_cpus = "1.16"
once_cell = "1.19" # Lazy static initialization
+[target.'cfg(any(target_os = "windows", target_os = "macos", target_os = "linux"))'.dependencies]
+tauri-plugin-single-instance = "2"
+
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["sysinfoapi"] }
libloading = "0.8"
diff --git a/src-tauri/Info.plist b/src-tauri/Info.plist
index e29198c..cf5e3fe 100644
--- a/src-tauri/Info.plist
+++ b/src-tauri/Info.plist
@@ -2,16 +2,11 @@
-
- LSUIElement
-
NSScreenCaptureUsageDescription
Flicker requires screen recording permission to take screenshots and record screen videos.
NSMicrophoneUsageDescription
Flicker requires microphone access to record audio during screen video recordings.
NSAudioCaptureUsageDescription
Flicker requires system audio access to record your Mac's output audio (e.g., YouTube, games) during screen recordings. This is used only when you enable “System Audio” in video settings.
- NSCameraUsageDescription
- Flicker does not use the camera, but this description is included to support future features that may require it.
diff --git a/src-tauri/icons/128x128.png b/src-tauri/icons/128x128.png
index 882d567..f397066 100644
Binary files a/src-tauri/icons/128x128.png and b/src-tauri/icons/128x128.png differ
diff --git a/src-tauri/icons/128x128@2x.png b/src-tauri/icons/128x128@2x.png
index 60337c4..743003f 100644
Binary files a/src-tauri/icons/128x128@2x.png and b/src-tauri/icons/128x128@2x.png differ
diff --git a/src-tauri/icons/32x32.png b/src-tauri/icons/32x32.png
index 88b03a9..3c5474e 100644
Binary files a/src-tauri/icons/32x32.png and b/src-tauri/icons/32x32.png differ
diff --git a/src-tauri/icons/64x64.png b/src-tauri/icons/64x64.png
index aec7f84..f72acb1 100644
Binary files a/src-tauri/icons/64x64.png and b/src-tauri/icons/64x64.png differ
diff --git a/src-tauri/icons/Square107x107Logo.png b/src-tauri/icons/Square107x107Logo.png
index 49f4838..e1900dc 100644
Binary files a/src-tauri/icons/Square107x107Logo.png and b/src-tauri/icons/Square107x107Logo.png differ
diff --git a/src-tauri/icons/Square142x142Logo.png b/src-tauri/icons/Square142x142Logo.png
index b803a1a..bd13a25 100644
Binary files a/src-tauri/icons/Square142x142Logo.png and b/src-tauri/icons/Square142x142Logo.png differ
diff --git a/src-tauri/icons/Square150x150Logo.png b/src-tauri/icons/Square150x150Logo.png
index 745c8ed..e6ba39a 100644
Binary files a/src-tauri/icons/Square150x150Logo.png and b/src-tauri/icons/Square150x150Logo.png differ
diff --git a/src-tauri/icons/Square284x284Logo.png b/src-tauri/icons/Square284x284Logo.png
index 7e3961d..802f757 100644
Binary files a/src-tauri/icons/Square284x284Logo.png and b/src-tauri/icons/Square284x284Logo.png differ
diff --git a/src-tauri/icons/Square30x30Logo.png b/src-tauri/icons/Square30x30Logo.png
index 0eeeb90..bbdc754 100644
Binary files a/src-tauri/icons/Square30x30Logo.png and b/src-tauri/icons/Square30x30Logo.png differ
diff --git a/src-tauri/icons/Square310x310Logo.png b/src-tauri/icons/Square310x310Logo.png
index fedef24..aaa5271 100644
Binary files a/src-tauri/icons/Square310x310Logo.png and b/src-tauri/icons/Square310x310Logo.png differ
diff --git a/src-tauri/icons/Square44x44Logo.png b/src-tauri/icons/Square44x44Logo.png
index f2cae82..6c2d12d 100644
Binary files a/src-tauri/icons/Square44x44Logo.png and b/src-tauri/icons/Square44x44Logo.png differ
diff --git a/src-tauri/icons/Square71x71Logo.png b/src-tauri/icons/Square71x71Logo.png
index 7afa2f4..7b88063 100644
Binary files a/src-tauri/icons/Square71x71Logo.png and b/src-tauri/icons/Square71x71Logo.png differ
diff --git a/src-tauri/icons/Square89x89Logo.png b/src-tauri/icons/Square89x89Logo.png
index 22423ce..248239d 100644
Binary files a/src-tauri/icons/Square89x89Logo.png and b/src-tauri/icons/Square89x89Logo.png differ
diff --git a/src-tauri/icons/StoreLogo.png b/src-tauri/icons/StoreLogo.png
index eb0ca01..3f4e9b8 100644
Binary files a/src-tauri/icons/StoreLogo.png and b/src-tauri/icons/StoreLogo.png differ
diff --git a/src-tauri/icons/android/mipmap-hdpi/ic_launcher.png b/src-tauri/icons/android/mipmap-hdpi/ic_launcher.png
index f994c68..cc77ebc 100644
Binary files a/src-tauri/icons/android/mipmap-hdpi/ic_launcher.png and b/src-tauri/icons/android/mipmap-hdpi/ic_launcher.png differ
diff --git a/src-tauri/icons/android/mipmap-hdpi/ic_launcher_foreground.png b/src-tauri/icons/android/mipmap-hdpi/ic_launcher_foreground.png
index 7e93d0d..15740a7 100644
Binary files a/src-tauri/icons/android/mipmap-hdpi/ic_launcher_foreground.png and b/src-tauri/icons/android/mipmap-hdpi/ic_launcher_foreground.png differ
diff --git a/src-tauri/icons/android/mipmap-hdpi/ic_launcher_round.png b/src-tauri/icons/android/mipmap-hdpi/ic_launcher_round.png
index 3dcfe24..5f3905d 100644
Binary files a/src-tauri/icons/android/mipmap-hdpi/ic_launcher_round.png and b/src-tauri/icons/android/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/src-tauri/icons/android/mipmap-mdpi/ic_launcher.png b/src-tauri/icons/android/mipmap-mdpi/ic_launcher.png
index 74dcb10..0838d51 100644
Binary files a/src-tauri/icons/android/mipmap-mdpi/ic_launcher.png and b/src-tauri/icons/android/mipmap-mdpi/ic_launcher.png differ
diff --git a/src-tauri/icons/android/mipmap-mdpi/ic_launcher_foreground.png b/src-tauri/icons/android/mipmap-mdpi/ic_launcher_foreground.png
index d89cb97..3621f99 100644
Binary files a/src-tauri/icons/android/mipmap-mdpi/ic_launcher_foreground.png and b/src-tauri/icons/android/mipmap-mdpi/ic_launcher_foreground.png differ
diff --git a/src-tauri/icons/android/mipmap-mdpi/ic_launcher_round.png b/src-tauri/icons/android/mipmap-mdpi/ic_launcher_round.png
index 4d122ef..12864c9 100644
Binary files a/src-tauri/icons/android/mipmap-mdpi/ic_launcher_round.png and b/src-tauri/icons/android/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/src-tauri/icons/android/mipmap-xhdpi/ic_launcher.png b/src-tauri/icons/android/mipmap-xhdpi/ic_launcher.png
index 0bb4cbd..fecbd88 100644
Binary files a/src-tauri/icons/android/mipmap-xhdpi/ic_launcher.png and b/src-tauri/icons/android/mipmap-xhdpi/ic_launcher.png differ
diff --git a/src-tauri/icons/android/mipmap-xhdpi/ic_launcher_foreground.png b/src-tauri/icons/android/mipmap-xhdpi/ic_launcher_foreground.png
index 78d4cc9..a157861 100644
Binary files a/src-tauri/icons/android/mipmap-xhdpi/ic_launcher_foreground.png and b/src-tauri/icons/android/mipmap-xhdpi/ic_launcher_foreground.png differ
diff --git a/src-tauri/icons/android/mipmap-xhdpi/ic_launcher_round.png b/src-tauri/icons/android/mipmap-xhdpi/ic_launcher_round.png
index 1f771f1..9d2d891 100644
Binary files a/src-tauri/icons/android/mipmap-xhdpi/ic_launcher_round.png and b/src-tauri/icons/android/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher.png b/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher.png
index 8e525c5..9c98a6c 100644
Binary files a/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher.png and b/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png b/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png
index be570ff..edd0bf6 100644
Binary files a/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png and b/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_foreground.png differ
diff --git a/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_round.png b/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_round.png
index 29dcdda..18b4dc4 100644
Binary files a/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_round.png and b/src-tauri/icons/android/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher.png b/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher.png
index 48d4ac1..074dea3 100644
Binary files a/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher.png and b/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png b/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png
index 5cdaf5b..0d2c560 100644
Binary files a/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png and b/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_foreground.png differ
diff --git a/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_round.png b/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_round.png
index b9c043d..8bd7d6d 100644
Binary files a/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_round.png and b/src-tauri/icons/android/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/src-tauri/icons/icon.icns b/src-tauri/icons/icon.icns
index c588e94..199ce9e 100644
Binary files a/src-tauri/icons/icon.icns and b/src-tauri/icons/icon.icns differ
diff --git a/src-tauri/icons/icon.ico b/src-tauri/icons/icon.ico
index 23d705d..d9e1611 100644
Binary files a/src-tauri/icons/icon.ico and b/src-tauri/icons/icon.ico differ
diff --git a/src-tauri/icons/icon.png b/src-tauri/icons/icon.png
index 277bfe9..81bd6ae 100644
Binary files a/src-tauri/icons/icon.png and b/src-tauri/icons/icon.png differ
diff --git a/src-tauri/icons/ios/AppIcon-20x20@1x.png b/src-tauri/icons/ios/AppIcon-20x20@1x.png
index 5f61849..144952a 100644
Binary files a/src-tauri/icons/ios/AppIcon-20x20@1x.png and b/src-tauri/icons/ios/AppIcon-20x20@1x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-20x20@2x-1.png b/src-tauri/icons/ios/AppIcon-20x20@2x-1.png
index aa73fa3..5235ca4 100644
Binary files a/src-tauri/icons/ios/AppIcon-20x20@2x-1.png and b/src-tauri/icons/ios/AppIcon-20x20@2x-1.png differ
diff --git a/src-tauri/icons/ios/AppIcon-20x20@2x.png b/src-tauri/icons/ios/AppIcon-20x20@2x.png
index aa73fa3..5235ca4 100644
Binary files a/src-tauri/icons/ios/AppIcon-20x20@2x.png and b/src-tauri/icons/ios/AppIcon-20x20@2x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-20x20@3x.png b/src-tauri/icons/ios/AppIcon-20x20@3x.png
index c7d7d4e..950a392 100644
Binary files a/src-tauri/icons/ios/AppIcon-20x20@3x.png and b/src-tauri/icons/ios/AppIcon-20x20@3x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-29x29@1x.png b/src-tauri/icons/ios/AppIcon-29x29@1x.png
index 91ee9ee..966d9b8 100644
Binary files a/src-tauri/icons/ios/AppIcon-29x29@1x.png and b/src-tauri/icons/ios/AppIcon-29x29@1x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-29x29@2x-1.png b/src-tauri/icons/ios/AppIcon-29x29@2x-1.png
index 5c9a64a..94e16d0 100644
Binary files a/src-tauri/icons/ios/AppIcon-29x29@2x-1.png and b/src-tauri/icons/ios/AppIcon-29x29@2x-1.png differ
diff --git a/src-tauri/icons/ios/AppIcon-29x29@2x.png b/src-tauri/icons/ios/AppIcon-29x29@2x.png
index 5c9a64a..94e16d0 100644
Binary files a/src-tauri/icons/ios/AppIcon-29x29@2x.png and b/src-tauri/icons/ios/AppIcon-29x29@2x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-29x29@3x.png b/src-tauri/icons/ios/AppIcon-29x29@3x.png
index f7ef3e7..19cbf38 100644
Binary files a/src-tauri/icons/ios/AppIcon-29x29@3x.png and b/src-tauri/icons/ios/AppIcon-29x29@3x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-40x40@1x.png b/src-tauri/icons/ios/AppIcon-40x40@1x.png
index aa73fa3..5235ca4 100644
Binary files a/src-tauri/icons/ios/AppIcon-40x40@1x.png and b/src-tauri/icons/ios/AppIcon-40x40@1x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-40x40@2x-1.png b/src-tauri/icons/ios/AppIcon-40x40@2x-1.png
index b227a4c..9e29d1a 100644
Binary files a/src-tauri/icons/ios/AppIcon-40x40@2x-1.png and b/src-tauri/icons/ios/AppIcon-40x40@2x-1.png differ
diff --git a/src-tauri/icons/ios/AppIcon-40x40@2x.png b/src-tauri/icons/ios/AppIcon-40x40@2x.png
index b227a4c..9e29d1a 100644
Binary files a/src-tauri/icons/ios/AppIcon-40x40@2x.png and b/src-tauri/icons/ios/AppIcon-40x40@2x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-40x40@3x.png b/src-tauri/icons/ios/AppIcon-40x40@3x.png
index fe489e5..ed79632 100644
Binary files a/src-tauri/icons/ios/AppIcon-40x40@3x.png and b/src-tauri/icons/ios/AppIcon-40x40@3x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-512@2x.png b/src-tauri/icons/ios/AppIcon-512@2x.png
index 3d268c9..6922bdb 100644
Binary files a/src-tauri/icons/ios/AppIcon-512@2x.png and b/src-tauri/icons/ios/AppIcon-512@2x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-60x60@2x.png b/src-tauri/icons/ios/AppIcon-60x60@2x.png
index fe489e5..ed79632 100644
Binary files a/src-tauri/icons/ios/AppIcon-60x60@2x.png and b/src-tauri/icons/ios/AppIcon-60x60@2x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-60x60@3x.png b/src-tauri/icons/ios/AppIcon-60x60@3x.png
index 166fe13..16076a2 100644
Binary files a/src-tauri/icons/ios/AppIcon-60x60@3x.png and b/src-tauri/icons/ios/AppIcon-60x60@3x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-76x76@1x.png b/src-tauri/icons/ios/AppIcon-76x76@1x.png
index 2ae9f05..0f85712 100644
Binary files a/src-tauri/icons/ios/AppIcon-76x76@1x.png and b/src-tauri/icons/ios/AppIcon-76x76@1x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-76x76@2x.png b/src-tauri/icons/ios/AppIcon-76x76@2x.png
index 8a14be7..2b774fd 100644
Binary files a/src-tauri/icons/ios/AppIcon-76x76@2x.png and b/src-tauri/icons/ios/AppIcon-76x76@2x.png differ
diff --git a/src-tauri/icons/ios/AppIcon-83.5x83.5@2x.png b/src-tauri/icons/ios/AppIcon-83.5x83.5@2x.png
index eac5fc2..40d4f39 100644
Binary files a/src-tauri/icons/ios/AppIcon-83.5x83.5@2x.png and b/src-tauri/icons/ios/AppIcon-83.5x83.5@2x.png differ
diff --git a/src-tauri/icons/tray-template.png b/src-tauri/icons/tray-template.png
new file mode 100644
index 0000000..07ffe3e
Binary files /dev/null and b/src-tauri/icons/tray-template.png differ
diff --git a/src-tauri/src/common/audit.rs b/src-tauri/src/common/audit.rs
index 0c88ff0..cd58afd 100644
--- a/src-tauri/src/common/audit.rs
+++ b/src-tauri/src/common/audit.rs
@@ -1,14 +1,9 @@
-/// Audit logging system for tracking events, errors, and device information
-///
-/// Provides centralized logging for diagnostic purposes and user support
-
use serde::{Deserialize, Serialize};
use std::fs;
use std::path::PathBuf;
use std::sync::Mutex;
use chrono::Utc;
-/// Device information snapshot
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeviceInfo {
pub os_name: String,
@@ -20,7 +15,6 @@ pub struct DeviceInfo {
pub timestamp: String,
}
-/// Individual audit log entry
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuditLogEntry {
#[serde(default = "new_log_id")]
@@ -28,7 +22,7 @@ pub struct AuditLogEntry {
pub timestamp: String,
pub event_type: String,
pub message: String,
- pub level: String, // "info", "warning", "error"
+ pub level: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -39,10 +33,8 @@ fn new_log_id() -> String {
uuid::Uuid::new_v4().to_string()
}
-/// Audit log manager (singleton pattern with mutex for thread safety)
static AUDIT_LOG: Mutex>> = Mutex::new(None);
-/// Get the audit logs directory path
fn get_audit_dir() -> Result {
let config_dir = crate::common::file::get_screenshots_dir()?
.parent()
@@ -52,7 +44,6 @@ fn get_audit_dir() -> Result {
Ok(config_dir.join("audit"))
}
-/// Initialize audit logs from disk
fn init_audit_logs() -> Result, String> {
let audit_dir = get_audit_dir()?;
let logs_file = audit_dir.join("audit.json");
@@ -68,14 +59,13 @@ fn init_audit_logs() -> Result, String> {
serde_json::from_str(&contents)
.map_err(|e| format!("Failed to parse audit logs: {}", e))
} else {
- // Create directory if it doesn't exist
+
fs::create_dir_all(&audit_dir)
.map_err(|e| format!("Failed to create audit directory: {}", e))?;
Ok(Vec::new())
}
}
-/// Save audit logs to disk
fn save_audit_logs(logs: &[AuditLogEntry]) -> Result<(), String> {
let audit_dir = get_audit_dir()?;
fs::create_dir_all(&audit_dir)
@@ -91,10 +81,9 @@ fn save_audit_logs(logs: &[AuditLogEntry]) -> Result<(), String> {
Ok(())
}
-/// Get system information for audit logs
pub fn get_device_info() -> DeviceInfo {
let os_name = std::env::consts::OS.to_string();
-
+
#[cfg(target_os = "windows")]
let os_version = get_windows_version();
#[cfg(target_os = "macos")]
@@ -106,7 +95,7 @@ pub fn get_device_info() -> DeviceInfo {
let architecture = std::env::consts::ARCH.to_string();
let cpu_count = num_cpus::get();
-
+
let available_memory_mb = get_available_memory_mb();
let app_version = env!("CARGO_PKG_VERSION").to_string();
let timestamp = Utc::now().to_rfc3339();
@@ -122,7 +111,6 @@ pub fn get_device_info() -> DeviceInfo {
}
}
-/// Add an event to the audit log
pub fn log_event(
event_type: &str,
message: &str,
@@ -130,14 +118,13 @@ pub fn log_event(
metadata: Option,
) -> Result<(), String> {
let mut logs = AUDIT_LOG.lock().unwrap();
-
- // Initialize if needed
+
if logs.is_none() {
*logs = Some(init_audit_logs()?);
}
let logs = logs.as_mut().unwrap();
-
+
let entry = AuditLogEntry {
id: new_log_id(),
timestamp: Utc::now().to_rfc3339(),
@@ -145,10 +132,9 @@ pub fn log_event(
message: message.to_string(),
level: level.to_string(),
metadata,
- device_info: None, // Only add on demand to reduce log size
+ device_info: None,
};
- // Keep only last 1000 entries
if logs.len() >= 1000 {
logs.remove(0);
}
@@ -158,17 +144,15 @@ pub fn log_event(
Ok(())
}
-/// Get audit logs, optionally limited to last N entries
pub fn get_audit_logs(limit: Option) -> Result, String> {
let mut logs = AUDIT_LOG.lock().unwrap();
- // Initialize if needed
if logs.is_none() {
*logs = Some(init_audit_logs()?);
}
let logs = logs.as_ref().unwrap();
-
+
let result: Vec = if let Some(n) = limit {
logs.iter()
.rev()
@@ -185,12 +169,10 @@ pub fn get_audit_logs(limit: Option) -> Result, String
Ok(result)
}
-/// Get audit logs with device info for support export
pub fn get_audit_logs_with_device_info(limit: Option) -> Result, String> {
let device_info = get_device_info();
let mut logs = get_audit_logs(limit)?;
- // Add device info to the last entry (most recent)
if let Some(last) = logs.last_mut() {
last.device_info = Some(device_info);
}
@@ -198,7 +180,6 @@ pub fn get_audit_logs_with_device_info(limit: Option) -> Result Result<(), String> {
let audit_dir = get_audit_dir()?;
let logs_file = audit_dir.join("audit.json");
@@ -214,7 +195,6 @@ pub fn clear_audit_logs() -> Result<(), String> {
Ok(())
}
-/// Export audit logs as JSON string for user sharing
pub fn export_audit_logs() -> Result {
let device_info = get_device_info();
let logs = get_audit_logs(None)?;
@@ -229,18 +209,15 @@ pub fn export_audit_logs() -> Result {
.map_err(|e| format!("Failed to serialize export: {}", e))
}
-// Platform-specific version detection helpers
-
#[cfg(target_os = "windows")]
fn get_windows_version() -> String {
use winapi::um::winnt::OSVERSIONINFOEXW;
use std::mem;
-
+
unsafe {
let mut info: OSVERSIONINFOEXW = mem::zeroed();
info.dwOSVersionInfoSize = mem::size_of::() as u32;
-
- // Try using RtlGetVersion
+
let ntdll = libloading::Library::new("ntdll.dll").ok();
if let Some(lib) = ntdll {
type RtlGetVersionFn = unsafe extern "system" fn(*mut OSVERSIONINFOEXW) -> i32;
@@ -249,8 +226,7 @@ fn get_windows_version() -> String {
let _ = f(&mut info);
}
}
-
- // Fallback to simple string
+
format!(
"Windows {}.{}",
info.dwMajorVersion, info.dwMinorVersion
@@ -266,7 +242,7 @@ fn get_windows_version() -> String {
#[cfg(target_os = "macos")]
#[allow(dead_code)]
fn get_macos_version() -> String {
- // On macOS, we can use system_profiler or sw_vers
+
std::process::Command::new("sw_vers")
.arg("-productVersion")
.output()
@@ -285,7 +261,7 @@ fn get_macos_version() -> String {
#[cfg(target_os = "linux")]
#[allow(dead_code)]
fn get_linux_version() -> String {
- // Try to read /etc/os-release
+
if let Ok(contents) = fs::read_to_string("/etc/os-release") {
for line in contents.lines() {
if line.starts_with("PRETTY_NAME=") {
@@ -293,8 +269,7 @@ fn get_linux_version() -> String {
}
}
}
-
- // Fallback to uname
+
std::process::Command::new("uname")
.arg("-r")
.output()
@@ -310,7 +285,6 @@ fn get_linux_version() -> String {
"Unknown".to_string()
}
-/// Get available memory in MB
fn get_available_memory_mb() -> u64 {
#[cfg(target_os = "windows")]
{
@@ -318,7 +292,7 @@ fn get_available_memory_mb() -> u64 {
unsafe {
let mut memory: u64 = 0;
if GetPhysicallyInstalledSystemMemory(&mut memory) != 0 {
- return memory / 1024; // Convert from KB to MB
+ return memory / 1024;
}
}
0
@@ -348,7 +322,7 @@ fn get_available_memory_mb() -> u64 {
if line.starts_with("MemTotal:") {
if let Some(size_str) = line.split_whitespace().nth(1) {
if let Ok(kb) = size_str.parse::() {
- return kb / 1024; // Convert from KB to MB
+ return kb / 1024;
}
}
}
@@ -385,3 +359,7 @@ mod tests {
assert!(result.is_ok());
}
}
+
+pub fn record(event_type: &str, message: &str, level: &str) {
+ let _ = log_event(event_type, message, level, None);
+}
diff --git a/src-tauri/src/common/config.rs b/src-tauri/src/common/config.rs
index 889e4e8..57582cf 100644
--- a/src-tauri/src/common/config.rs
+++ b/src-tauri/src/common/config.rs
@@ -1,14 +1,14 @@
-/// Configuration file management
-///
-/// Handles loading and saving app configuration to the system config directory
-
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
fn default_fps() -> u32 { 30 }
fn default_max_duration() -> u32 { 600 }
-fn default_record_video() -> String { "Super+Shift+R".to_string() }
+fn default_record_video() -> String {
+ if cfg!(target_os = "macos") { "Super+Shift+R" } else { "Control+Alt+R" }.to_string()
+}
fn default_true() -> bool { true }
+fn default_close_action() -> String { "tray".to_string() }
+pub const DEFAULT_OPEN_APP_HOTKEY: &str = "Control+Alt+F";
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppConfig {
@@ -16,22 +16,22 @@ pub struct AppConfig {
pub upload_token: String,
#[serde(alias = "uploadUrl")]
pub upload_url: Option,
- pub visibility: String, // "PUBLIC" or "PRIVATE"
+ pub visibility: String,
pub password: Option,
#[serde(alias = "autoUpload", default)]
pub auto_upload: bool,
#[serde(alias = "defaultNotification", default)]
pub default_notification: bool,
-
+
#[serde(default, alias = "appearance")]
pub appearance: AppearanceConfig,
-
+
#[serde(default, alias = "behavior")]
pub behavior: BehaviorConfig,
-
+
#[serde(default, alias = "capture")]
pub capture: CaptureConfig,
-
+
#[serde(default, alias = "hotkeys")]
pub hotkeys: HotkeyConfig,
@@ -45,7 +45,7 @@ pub struct AppearanceConfig {
#[serde(alias = "backgroundOpacity", default)]
pub background_opacity: f32,
#[serde(alias = "fontScale", default)]
- pub font_scale: String, // "small", "medium", "large"
+ pub font_scale: String,
#[serde(default, alias = "customColors")]
pub custom_colors: Option,
}
@@ -60,20 +60,23 @@ pub struct CustomColors {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BehaviorConfig {
#[serde(alias = "postUploadAction", default)]
- pub post_upload_action: String, // "copy", "open", "none"
+ pub post_upload_action: String,
#[serde(alias = "clipboardFormat", default)]
- pub clipboard_format: String, // "url", "raw-url", "markdown", "html"
+ pub clipboard_format: String,
#[serde(alias = "playSound", default)]
pub play_sound: bool,
#[serde(alias = "startAtLogin", default)]
pub start_at_login: bool,
+ /// "tray" keeps Flicker running in the tray or menu bar, "minimize" sends it to the taskbar or Dock, "quit" exits.
+ #[serde(alias = "closeAction", default = "default_close_action")]
+ pub close_action: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CaptureConfig {
- pub format: String, // "png" or "jpg"
- pub quality: u32, // 1-100 for jpg
- pub delay: u32, // seconds
+ pub format: String,
+ pub quality: u32,
+ pub delay: u32,
#[serde(alias = "filenamePattern", default)]
pub filename_pattern: String,
#[serde(alias = "saveLocally", default)]
@@ -132,6 +135,7 @@ impl Default for BehaviorConfig {
clipboard_format: "url".to_string(),
play_sound: true,
start_at_login: false,
+ close_action: default_close_action(),
}
}
}
@@ -169,8 +173,8 @@ impl Default for HotkeyConfig {
screenshot_region: "Control+Shift+X".to_string(),
screenshot_all_monitors: "Control+Shift+A".to_string(),
upload_clipboard: "Control+Alt+U".to_string(),
- open_app: String::new(),
- record_video: "Super+Shift+R".to_string(),
+ open_app: DEFAULT_OPEN_APP_HOTKEY.to_string(),
+ record_video: default_record_video(),
}
}
}
@@ -193,55 +197,52 @@ impl Default for AppConfig {
}
}
-/// Get the config directory path (~/.config/flicker on Linux/macOS, %APPDATA%\Emberly\Flicker on Windows)
pub fn get_config_dir() -> Result {
let config_dir = dirs::config_dir()
.ok_or("Could not find config directory")?
.join("Emberly")
.join("Flicker");
-
+
if !config_dir.exists() {
std::fs::create_dir_all(&config_dir)
.map_err(|e| format!("Failed to create config directory: {}", e))?;
}
-
+
Ok(config_dir)
}
-/// Load configuration from disk
pub fn load_config() -> Result {
let config_dir = get_config_dir()?;
let config_path = config_dir.join("config.json");
-
+
if !config_path.exists() {
- println!("[Flicker] load_config: no file at {:?}, using default (token empty)", config_path);
+ crate::flog!("load_config: no file at {:?}, using default (token empty)", config_path);
return Ok(AppConfig::default());
}
-
+
let content = std::fs::read_to_string(&config_path)
.map_err(|e| format!("Failed to read config file: {}", e))?;
- println!("[Flicker] load_config: read {} bytes from {:?}", content.len(), config_path);
-
+ crate::flog!("load_config: read {} bytes from {:?}", content.len(), config_path);
+
let cfg: AppConfig = serde_json::from_str(&content)
.map_err(|e| format!("Failed to parse config file: {}", e))?;
- println!("[Flicker] load_config: token_len={} hotkeys: fullscreen='{}' region='{}' record_video='{}' video: sys_audio={} mic={} fps={}",
+ crate::flog!("load_config: token_len={} hotkeys: fullscreen='{}' region='{}' record_video='{}' video: sys_audio={} mic={} fps={}",
cfg.upload_token.len(), cfg.hotkeys.screenshot_fullscreen, cfg.hotkeys.screenshot_region, cfg.hotkeys.record_video,
cfg.video.include_system_audio, cfg.video.include_mic, cfg.video.fps);
Ok(cfg)
}
-/// Save configuration to disk
pub fn save_config(config: &AppConfig) -> Result<(), String> {
let config_dir = get_config_dir()?;
let config_path = config_dir.join("config.json");
-
+
let json = serde_json::to_string_pretty(config)
.map_err(|e| format!("Failed to serialize config: {}", e))?;
- println!("[Flicker] save_config: writing {} bytes token_len={} to {:?}", json.len(), config.upload_token.len(), config_path);
-
+ crate::flog!("save_config: writing {} bytes token_len={} to {:?}", json.len(), config.upload_token.len(), config_path);
+
std::fs::write(&config_path, json)
.map_err(|e| format!("Failed to write config file: {}", e))?;
-
- println!("[Flicker] save_config: done");
+
+ crate::flog!("save_config: done");
Ok(())
}
diff --git a/src-tauri/src/common/emberly_api.rs b/src-tauri/src/common/emberly_api.rs
index c0aed4c..b89b13a 100644
--- a/src-tauri/src/common/emberly_api.rs
+++ b/src-tauri/src/common/emberly_api.rs
@@ -1,18 +1,11 @@
-/// Emberly API client module
-///
-/// Provides a clean, reusable interface for interacting with the Emberly API
-/// Handles authentication, file uploads, and user operations
-
use serde::{Deserialize, Serialize};
-/// Emberly API client configuration
#[derive(Clone)]
pub struct EmberlyCient {
base_url: String,
client: reqwest::Client,
}
-/// Login request payload
#[derive(Debug, Serialize)]
pub struct LoginRequest {
#[serde(rename = "emailOrUsername")]
@@ -22,7 +15,6 @@ pub struct LoginRequest {
pub two_factor_code: Option,
}
-/// Login response from API
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct LoginResponse {
pub success: bool,
@@ -32,12 +24,12 @@ pub struct LoginResponse {
pub requires_2fa: Option,
}
-/// User information returned from login
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct LoginUser {
pub id: String,
pub name: Option,
- pub email: String,
+ #[serde(default)]
+ pub email: Option,
#[serde(rename = "uploadToken")]
pub upload_token: String,
pub image: Option,
@@ -45,32 +37,25 @@ pub struct LoginUser {
pub url_id: String,
}
-/// User profile information (subset of `GET /api/profile`'s response —
-/// that endpoint also returns embedded `files`/`shortenedUrls` arrays we
-/// don't need here and intentionally leave untyped so serde ignores them).
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct UserProfile {
pub id: String,
pub name: Option,
- pub email: String,
+ #[serde(default)]
+ pub email: Option,
pub image: Option,
#[serde(rename = "urlId")]
pub url_id: String,
}
-/// Envelope used by endpoints that wrap their payload as `{ success, data }`
-/// (e.g. `/api/profile`, `/api/urls`).
#[derive(Debug, Deserialize)]
struct DataEnvelope {
data: T,
}
-/// File upload response
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct UploadResponse {
- /// The uploaded file's database id. Optional for resilience against
- /// older server versions or transitional deploys — always present on a
- /// current server.
+
pub id: Option,
pub url: String,
pub name: String,
@@ -79,7 +64,6 @@ pub struct UploadResponse {
pub file_type: String,
}
-/// A single custom domain (`GET /api/domains`)
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct DomainInfo {
pub id: String,
@@ -91,7 +75,6 @@ pub struct DomainInfo {
pub cf_status: Option,
}
-/// Domain slot usage/limits, embedded in the `/api/domains` response
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct DomainLimit {
pub allowed: Option,
@@ -104,8 +87,6 @@ pub struct DomainLimit {
pub unlimited: bool,
}
-/// `GET /api/domains` response (returned as a raw object, not wrapped in
-/// `{success, data}` — confirmed against the actual route handler).
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct DomainsResponse {
pub domains: Vec,
@@ -113,7 +94,6 @@ pub struct DomainsResponse {
pub domain_limit: DomainLimit,
}
-/// Perk bonus summary fields (`GET /api/profile/perks`)
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct PerkBonuses {
pub storage: Option,
@@ -129,16 +109,12 @@ pub struct PerksSummary {
pub bonuses: PerkBonuses,
}
-/// `GET /api/profile/perks` response (raw object, not `{success, data}`).
-/// Individual perk entries vary in shape by perk type, so they're left as
-/// loosely-typed JSON values — only the summary is rendered in Settings.
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct PerksResponse {
pub perks: Vec,
pub summary: PerksSummary,
}
-/// A shortened URL (`POST`/`GET /api/urls`)
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ShortenedUrlResponse {
pub id: String,
@@ -151,13 +127,12 @@ pub struct ShortenedUrlResponse {
pub created_at: String,
}
-/// Basic usage aggregates embedded in `/api/analytics/summary`
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AnalyticsBasic {
#[serde(rename = "totalFiles")]
pub total_files: u64,
#[serde(rename = "storageUsed")]
- pub storage_used: u64,
+ pub storage_used: f64,
#[serde(rename = "totalUrls")]
pub total_urls: u64,
#[serde(rename = "totalUrlClicks")]
@@ -188,7 +163,7 @@ pub struct AnalyticsAllowed {
pub struct RecentUpload {
pub id: String,
pub name: String,
- pub size: u64,
+ pub size: f64,
#[serde(rename = "uploadedAt")]
pub uploaded_at: String,
pub views: u64,
@@ -201,10 +176,6 @@ pub struct UploadsPerDay {
pub count: u64,
}
-/// `GET /api/analytics/summary` response (raw object, not `{success, data}`).
-/// The server also includes plan-gated extra lists (`topFiles`,
-/// `topStorageFiles`, `topUrls`, `files`) that aren't modeled here — serde
-/// ignores unknown fields by default, and the Stats page MVP doesn't need them.
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AnalyticsSummary {
pub plan: String,
@@ -216,7 +187,6 @@ pub struct AnalyticsSummary {
pub uploads_per_day: Vec,
}
-/// API error response
#[derive(Debug, Deserialize)]
pub struct ApiError {
pub success: bool,
@@ -225,7 +195,7 @@ pub struct ApiError {
}
impl EmberlyCient {
- /// Create a new Emberly API client
+
pub fn new(base_url: String) -> Self {
Self {
base_url,
@@ -233,12 +203,64 @@ impl EmberlyCient {
}
}
- /// Create a new client with the default Emberly URL
+ pub async fn start_device_sign_in(&self, device_name: &str) -> Result {
+ let response = self
+ .client
+ .post(format!("{}/api/device/code", self.base_url))
+ .json(&serde_json::json!({ "clientId": "flicker", "deviceName": device_name }))
+ .send()
+ .await
+ .map_err(|e| format!("Could not reach Emberly: {}", e))?;
+ let ok = response.status().is_success();
+ let body: serde_json::Value = response
+ .json()
+ .await
+ .map_err(|e| format!("Unexpected response from Emberly: {}", e))?;
+ if !ok {
+ return Err(body.get("error").and_then(|e| e.as_str()).unwrap_or("Sign-in isn't available").to_string());
+ }
+ Ok(body.get("data").cloned().unwrap_or(body))
+ }
+
+ pub async fn poll_device_sign_in(&self, device_code: &str) -> Result {
+ let response = self
+ .client
+ .post(format!("{}/api/device/token", self.base_url))
+ .json(&serde_json::json!({ "deviceCode": device_code }))
+ .send()
+ .await
+ .map_err(|e| format!("Could not reach Emberly: {}", e))?;
+ let body: serde_json::Value = response
+ .json()
+ .await
+ .map_err(|e| format!("Unexpected response from Emberly: {}", e))?;
+ if let Some(error) = body.get("error").and_then(|e| e.as_str()) {
+ return Err(error.to_string());
+ }
+ Ok(body.get("data").cloned().unwrap_or(body))
+ }
+
+ pub async fn get_instance(&self) -> Result {
+ let response = self
+ .client
+ .get(format!("{}/api/instance", self.base_url))
+ .send()
+ .await
+ .map_err(|e| format!("Could not reach Emberly: {}", e))?;
+ if !response.status().is_success() {
+ return Err(format!("Instance info unavailable ({})", response.status()));
+ }
+ let body: serde_json::Value = response
+ .json()
+ .await
+ .map_err(|e| format!("Unexpected response from Emberly: {}", e))?;
+ Ok(body.get("data").cloned().unwrap_or(body))
+ }
+
pub fn default_client() -> Self {
Self::new("https://embrly.ca".to_string())
}
- /// Login to Emberly with email/username and password
pub async fn login(
&self,
email_or_username: String,
@@ -275,7 +297,6 @@ impl EmberlyCient {
.map_err(|e| format!("Failed to parse login response: {}", e))
}
- /// Get user profile information
pub async fn get_profile(&self, token: &str) -> Result {
let url = format!("{}/api/profile", self.base_url);
@@ -303,14 +324,10 @@ impl EmberlyCient {
Ok(envelope.data)
}
- /// Validate an upload token. There's no dedicated validation endpoint on
- /// the server, so this just checks whether the token can successfully
- /// fetch the profile it authenticates.
pub async fn validate_token(&self, token: &str) -> Result {
Ok(self.get_profile(token).await.is_ok())
}
- /// Get the user's custom domains and domain-slot usage
pub async fn get_domains(&self, token: &str) -> Result {
let url = format!("{}/api/domains", self.base_url);
@@ -336,7 +353,31 @@ impl EmberlyCient {
.map_err(|e| format!("Failed to parse domains response: {}", e))
}
- /// Get the user's active perk bonuses (Discord booster / GitHub contributor)
+ pub async fn list_files(&self, token: &str, page: u32, limit: u32) -> Result {
+ let url = format!("{}/api/files?page={}&limit={}&sortBy=newest", self.base_url, page, limit);
+
+ let response = self
+ .client
+ .get(&url)
+ .header("Authorization", format!("Bearer {}", token))
+ .send()
+ .await
+ .map_err(|e| format!("Files request failed: {}", e))?;
+
+ if !response.status().is_success() {
+ return Err(format!(
+ "Failed to list files with status {}: {}",
+ response.status(),
+ response.text().await.unwrap_or_default()
+ ));
+ }
+
+ response
+ .json::()
+ .await
+ .map_err(|e| format!("Failed to parse files response: {}", e))
+ }
+
pub async fn get_perks(&self, token: &str) -> Result {
let url = format!("{}/api/profile/perks", self.base_url);
@@ -362,7 +403,6 @@ impl EmberlyCient {
.map_err(|e| format!("Failed to parse perks response: {}", e))
}
- /// Shorten a URL
pub async fn shorten_url(
&self,
token: &str,
@@ -395,7 +435,6 @@ impl EmberlyCient {
Ok(envelope.data)
}
- /// Update a file's visibility and/or password
pub async fn update_file(
&self,
token: &str,
@@ -433,8 +472,6 @@ impl EmberlyCient {
Ok(())
}
- /// Upload a file to Emberly, optionally reporting progress as bytes are
- /// streamed from disk to the request body (called as `(uploaded, total)`).
pub async fn upload_file(
&self,
token: &str,
@@ -468,8 +505,6 @@ impl EmberlyCient {
.unwrap_or("application/octet-stream")
.to_string();
- // Stream the file so we can report upload progress as chunks are read,
- // instead of loading the whole file into memory up front.
let uploaded = std::sync::Arc::new(std::sync::atomic::AtomicU64::new(0));
let stream = tokio_util::io::ReaderStream::new(file).map(move |chunk| {
if let Ok(bytes) = &chunk {
@@ -488,7 +523,6 @@ impl EmberlyCient {
.mime_str(&mime_type)
.map_err(|e| e.to_string())?;
- // Create multipart form
let mut form = reqwest::multipart::Form::new()
.part("file", part)
.text("visibility", visibility.to_string());
@@ -530,7 +564,6 @@ impl EmberlyCient {
.map_err(|e| format!("Failed to parse upload response: {}", e))
}
- /// Chunked upload — initialize session
pub async fn init_chunked_upload(
&self,
token: &str,
@@ -548,7 +581,7 @@ impl EmberlyCient {
if let Some(d) = domain {
body["domain"] = serde_json::Value::String(d);
}
- println!("[Flicker] init_chunked: POST {} body={} token_len={}", url, body, token.len());
+ crate::flog!("init_chunked: POST {} body={} token_len={}", url, body, token.len());
let resp = self
.client
.post(&url)
@@ -559,12 +592,12 @@ impl EmberlyCient {
.map_err(|e| format!("Init chunked upload failed: {}", e))?;
let status = resp.status();
let text = resp.text().await.unwrap_or_default();
- println!("[Flicker] init_chunked resp status={} body={}", status, text);
+ crate::flog!("init_chunked resp status={} body={}", status, text);
if !status.is_success() {
return Err(format!("Init chunked failed {}: {}", status, text));
}
let json: serde_json::Value = serde_json::from_str(&text).map_err(|e| e.to_string())?;
- // Server may wrap in {success, data: {uploadId, partSize}} or return flat
+
let data = json.get("data").unwrap_or(&json);
let upload_id = data
.get("uploadId")
@@ -581,7 +614,7 @@ impl EmberlyCient {
.or_else(|| json.get("part_size"))
.and_then(|v| v.as_u64())
.unwrap_or(5 * 1024 * 1024);
- println!("[Flicker] init_chunked: uploadId={} partSize={} raw={}", upload_id, part_size, json);
+ crate::flog!("init_chunked: uploadId={} partSize={} raw={}", upload_id, part_size, json);
Ok((upload_id, part_size))
}
@@ -595,7 +628,7 @@ impl EmberlyCient {
"{}/api/files/chunks/{}/part/{}",
self.base_url, upload_id, part_number
);
- println!("[Flicker] get_chunk_url: GET {} part={}", url, part_number);
+ crate::flog!("get_chunk_url: GET {} part={}", url, part_number);
let resp = self
.client
.get(&url)
@@ -605,7 +638,7 @@ impl EmberlyCient {
.map_err(|e| format!("Get chunk URL failed: {}", e))?;
let status = resp.status();
let text = resp.text().await.unwrap_or_default();
- println!("[Flicker] get_chunk_url resp status={} body={}", status, text);
+ crate::flog!("get_chunk_url resp status={} body={}", status, text);
if !status.is_success() {
return Err(format!("Get chunk URL failed {}: {}", status, text));
}
@@ -650,7 +683,6 @@ impl EmberlyCient {
serde_json::from_value(data.clone()).map_err(|e| e.to_string())
}
- /// Delete a file from Emberly
pub async fn delete_file(&self, token: &str, file_id: &str) -> Result<(), String> {
let url = format!("{}/api/files/{}", self.base_url, file_id);
@@ -673,38 +705,6 @@ impl EmberlyCient {
Ok(())
}
- /// Get list of user's files
- pub async fn list_files(&self, token: &str) -> Result, String> {
- let url = format!("{}/api/files", self.base_url);
-
- let response = self
- .client
- .get(&url)
- .header("Authorization", format!("Bearer {}", token))
- .send()
- .await
- .map_err(|e| format!("List files request failed: {}", e))?;
-
- if !response.status().is_success() {
- return Err(format!(
- "Failed to list files with status {}: {}",
- response.status(),
- response.text().await.unwrap_or_default()
- ));
- }
-
- let body: serde_json::Value = response
- .json()
- .await
- .map_err(|e| format!("Failed to parse response: {}", e))?;
-
- let data = body.get("data").ok_or("Missing 'data' in response")?;
-
- serde_json::from_value(data.clone())
- .map_err(|e| format!("Failed to parse files list: {}", e))
- }
-
- /// Get user upload/usage statistics
pub async fn get_stats(&self, token: &str) -> Result {
let url = format!("{}/api/analytics/summary", self.base_url);
diff --git a/src-tauri/src/common/file.rs b/src-tauri/src/common/file.rs
index 0614f2f..2c4717f 100644
--- a/src-tauri/src/common/file.rs
+++ b/src-tauri/src/common/file.rs
@@ -1,49 +1,43 @@
-/// File system operations and directory management
-
use std::path::PathBuf;
use uuid::Uuid;
-/// Get the app data directory for config/state storage
pub fn get_app_data_dir() -> Result {
let base_dir = dirs::data_dir()
.or_else(dirs::config_dir)
.or_else(dirs::home_dir)
.ok_or("Could not find app data directory")?;
-
+
let app_dir = base_dir.join("Flicker");
-
+
if !app_dir.exists() {
std::fs::create_dir_all(&app_dir)
.map_err(|e| format!("Failed to create app data directory: {}", e))?;
}
-
+
Ok(app_dir)
}
-/// Get the screenshots directory, creating it if it doesn't exist
pub fn get_screenshots_dir() -> Result {
let base_dir = dirs::picture_dir()
.or_else(dirs::home_dir)
.ok_or("Could not find pictures directory")?;
-
+
let screenshots_dir = base_dir.join("Flicker Screenshots");
-
+
if !screenshots_dir.exists() {
std::fs::create_dir_all(&screenshots_dir)
.map_err(|e| format!("Failed to create screenshots directory: {}", e))?;
}
-
+
Ok(screenshots_dir)
}
-/// Generate a unique filename for a screenshot with timestamp and UUID
pub fn generate_screenshot_filename(prefix: &str) -> String {
let timestamp = chrono::Local::now().format("%Y%m%d_%H%M%S");
let uuid_short = &Uuid::new_v4().to_string()[..8];
format!("{}_{}{}.png", prefix, timestamp, uuid_short)
}
-/// Get the recordings directory, creating it if it doesn't exist
pub fn get_recordings_dir() -> Result {
let base_dir = dirs::video_dir()
.or_else(dirs::picture_dir)
@@ -57,31 +51,27 @@ pub fn get_recordings_dir() -> Result {
Ok(recordings_dir)
}
-/// Generate a unique filename for a recording with timestamp and UUID
pub fn generate_recording_filename() -> String {
let timestamp = chrono::Local::now().format("%Y%m%d_%H%M%S");
let uuid_short = &Uuid::new_v4().to_string()[..8];
format!("Recording_{}{}.mp4", timestamp, uuid_short)
}
-/// Save bytes to a file in the screenshots directory
pub fn save_screenshot(filename: &str, data: &[u8]) -> Result {
let screenshots_dir = get_screenshots_dir()?;
let file_path = screenshots_dir.join(filename);
-
+
std::fs::write(&file_path, data)
.map_err(|e| format!("Failed to save screenshot: {}", e))?;
-
+
Ok(file_path)
}
-/// Read a file and return its contents as bytes
pub fn read_file(path: &str) -> Result, String> {
std::fs::read(path)
.map_err(|e| format!("Failed to read file: {}", e))
}
-/// Get file name from a path
pub fn get_file_name(path: &str) -> Result {
PathBuf::from(path)
.file_name()
@@ -92,7 +82,6 @@ pub fn get_file_name(path: &str) -> Result {
.map_err(|_| "Invalid file name".to_string())
}
-/// Get the MIME type for a file
pub fn get_mime_type(path: &str) -> String {
mime_guess::from_path(path)
.first_raw()
@@ -117,3 +106,18 @@ mod tests {
assert_eq!(get_mime_type("test.txt"), "text/plain");
}
}
+
+pub fn discard_capture(path: &str) {
+ if crate::common::load_config().map(|c| c.capture.save_locally).unwrap_or(true) {
+ return;
+ }
+ let dir = match get_screenshots_dir().and_then(|d| d.canonicalize().map_err(|e| e.to_string())) {
+ Ok(dir) => dir,
+ Err(_) => return,
+ };
+ if let Ok(file) = std::path::Path::new(path).canonicalize() {
+ if file.starts_with(&dir) {
+ let _ = std::fs::remove_file(file);
+ }
+ }
+}
diff --git a/src-tauri/src/common/history.rs b/src-tauri/src/common/history.rs
index 2df7057..e8173e4 100644
--- a/src-tauri/src/common/history.rs
+++ b/src-tauri/src/common/history.rs
@@ -1,7 +1,3 @@
-/// Upload history management
-///
-/// Handles loading and saving upload history
-
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
@@ -18,66 +14,60 @@ pub struct UploadHistoryItem {
pub thumbnail_url: Option,
}
-/// Get the config directory path
fn get_config_dir() -> Result {
let config_dir = dirs::config_dir()
.ok_or("Could not find config directory")?
.join("Emberly")
.join("Flicker");
-
+
if !config_dir.exists() {
std::fs::create_dir_all(&config_dir)
.map_err(|e| format!("Failed to create config directory: {}", e))?;
}
-
+
Ok(config_dir)
}
-/// Load upload history from disk (max 100 items)
pub fn load_history() -> Result, String> {
let config_dir = get_config_dir()?;
let history_path = config_dir.join("history.json");
-
+
if !history_path.exists() {
return Ok(vec![]);
}
-
+
let content = std::fs::read_to_string(&history_path)
.map_err(|e| format!("Failed to read history file: {}", e))?;
-
+
serde_json::from_str(&content)
.map_err(|e| format!("Failed to parse history file: {}", e))
}
-/// Save upload history to disk (keeps only last 100 items)
pub fn save_history(history: &[UploadHistoryItem]) -> Result<(), String> {
let config_dir = get_config_dir()?;
let history_path = config_dir.join("history.json");
-
- // Keep only last 100 items
+
let truncated = if history.len() > 100 {
&history[..100]
} else {
history
};
-
+
let json = serde_json::to_string_pretty(truncated)
.map_err(|e| format!("Failed to serialize history: {}", e))?;
-
+
std::fs::write(&history_path, json)
.map_err(|e| format!("Failed to write history file: {}", e))?;
-
+
Ok(())
}
-/// Add an item to the upload history (newest first)
pub fn add_to_history(item: UploadHistoryItem) -> Result<(), String> {
let mut history = load_history()?;
history.insert(0, item);
save_history(&history)
}
-/// Clear upload history
pub fn clear_history() -> Result<(), String> {
save_history(&[])
}
diff --git a/src-tauri/src/common/logs.rs b/src-tauri/src/common/logs.rs
new file mode 100644
index 0000000..b2e7dfe
--- /dev/null
+++ b/src-tauri/src/common/logs.rs
@@ -0,0 +1,35 @@
+use std::collections::VecDeque;
+use std::sync::Mutex;
+
+const MAX_LINES: usize = 1000;
+
+static LINES: Mutex> = Mutex::new(VecDeque::new());
+
+pub fn push(level: &str, message: String) {
+ let line = format!("{} {} {}", chrono::Local::now().format("%H:%M:%S"), level, message);
+ if level == "ERROR" {
+ eprintln!("{}", line);
+ } else {
+ println!("{}", line);
+ }
+ if let Ok(mut lines) = LINES.lock() {
+ if lines.len() >= MAX_LINES {
+ lines.pop_front();
+ }
+ lines.push_back(line);
+ }
+}
+
+pub fn recent() -> Vec {
+ LINES.lock().map(|l| l.iter().cloned().collect()).unwrap_or_default()
+}
+
+#[macro_export]
+macro_rules! flog {
+ ($($arg:tt)*) => { $crate::common::logs::push("INFO", format!($($arg)*)) };
+}
+
+#[macro_export]
+macro_rules! flog_err {
+ ($($arg:tt)*) => { $crate::common::logs::push("ERROR", format!($($arg)*)) };
+}
diff --git a/src-tauri/src/common/mod.rs b/src-tauri/src/common/mod.rs
index 75ab0e2..058c59c 100644
--- a/src-tauri/src/common/mod.rs
+++ b/src-tauri/src/common/mod.rs
@@ -1,5 +1,3 @@
-//! Common functionality shared between desktop and mobile platforms
-
pub mod types;
pub mod file;
pub mod upload;
@@ -9,8 +7,8 @@ pub mod history;
pub mod emberly_api;
pub mod audit;
pub mod notifications;
+pub mod logs;
-// Re-export commonly used types and functions
pub use types::*;
pub use file::*;
pub use upload::*;
@@ -19,13 +17,11 @@ pub use config::*;
pub use history::*;
pub use emberly_api::EmberlyCient;
-// Re-export audit types and functions
pub use audit::{
AuditLogEntry, DeviceInfo, get_audit_logs, get_audit_logs_with_device_info,
export_audit_logs, clear_audit_logs, log_event, get_device_info,
};
-// Re-export notification types and functions
pub use notifications::{
add_notification, clear_notifications, check_system_notifications, delete_notification,
dismiss_notification, get_notifications, get_unread_count, mark_all_as_read, mark_as_read,
diff --git a/src-tauri/src/common/notifications.rs b/src-tauri/src/common/notifications.rs
index c12b4da..404e9ac 100644
--- a/src-tauri/src/common/notifications.rs
+++ b/src-tauri/src/common/notifications.rs
@@ -1,29 +1,22 @@
-//! Notification system backend
-//!
-//! Handles notification storage, persistence, and management.
-//! The frontend can add/query/update notifications through Tauri commands.
-
use serde::{Deserialize, Serialize};
use std::fs;
use std::sync::Mutex;
use once_cell::sync::Lazy;
use super::get_app_data_dir;
-/// Notification priority levels
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum NotificationPriority {
- /// System-level alerts (admin, security warnings) - always visible
+
System,
- /// Important but not critical - shows in notification center prominently
+
Important,
- /// Regular notifications - standard notification center
+
Default,
- /// Temporary notifications - auto-dismiss toasts
+
Transient,
}
-/// Notification categories for styling/filtering
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum NotificationCategory {
@@ -37,79 +30,72 @@ pub enum NotificationCategory {
Success,
}
-/// A notification entry
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Notification {
- /// Unique identifier
+
pub id: String,
- /// Priority level determines where/how it's displayed
+
pub priority: NotificationPriority,
- /// Category for styling
+
pub category: NotificationCategory,
- /// Short title
+
pub title: String,
- /// Detailed message
+
pub message: String,
- /// Unix timestamp (milliseconds)
+
pub timestamp: u64,
- /// Whether the user has seen this
+
pub read: bool,
- /// Whether the user dismissed this
+
pub dismissed: bool,
- /// If true, survives app restart (for system notifications)
+
pub persistent: bool,
- /// Optional action button label
+
#[serde(skip_serializing_if = "Option::is_none")]
pub action_label: Option,
- /// Optional action identifier for handling clicks
+
#[serde(skip_serializing_if = "Option::is_none")]
pub action_id: Option,
- /// Optional metadata
+
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option,
}
-/// Notification store - holds all notifications in memory with disk persistence
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct NotificationStore {
pub notifications: Vec,
- /// Version for future migrations
+
pub version: u32,
}
-/// Global notification store
static NOTIFICATION_STORE: Lazy> = Lazy::new(|| {
Mutex::new(load_notifications_from_disk().unwrap_or_default())
});
-/// Get the notifications file path
fn get_notifications_path() -> Result {
let dir = get_app_data_dir()?;
Ok(dir.join("notifications.json"))
}
-/// Load notifications from disk
fn load_notifications_from_disk() -> Result {
let path = get_notifications_path()?;
-
+
if !path.exists() {
return Ok(NotificationStore::default());
}
-
+
let content = fs::read_to_string(&path)
.map_err(|e| format!("Failed to read notifications: {}", e))?;
-
+
let store: NotificationStore = serde_json::from_str(&content)
.map_err(|e| format!("Failed to parse notifications: {}", e))?;
-
+
Ok(store)
}
-/// Save notifications to disk
fn save_notifications_to_disk(store: &NotificationStore) -> Result<(), String> {
let path = get_notifications_path()?;
-
- // Only persist non-transient, persistent notifications
+
let persistent_store = NotificationStore {
notifications: store.notifications.iter()
.filter(|n| n.persistent && n.priority != NotificationPriority::Transient)
@@ -117,17 +103,16 @@ fn save_notifications_to_disk(store: &NotificationStore) -> Result<(), String> {
.collect(),
version: store.version,
};
-
+
let content = serde_json::to_string_pretty(&persistent_store)
.map_err(|e| format!("Failed to serialize notifications: {}", e))?;
-
+
fs::write(&path, content)
.map_err(|e| format!("Failed to write notifications: {}", e))?;
-
+
Ok(())
}
-/// Generate a unique notification ID
fn generate_id() -> String {
use std::time::{SystemTime, UNIX_EPOCH};
let timestamp = SystemTime::now()
@@ -137,7 +122,6 @@ fn generate_id() -> String {
format!("notif_{}", timestamp)
}
-/// Get current timestamp in milliseconds
fn current_timestamp() -> u64 {
use std::time::{SystemTime, UNIX_EPOCH};
SystemTime::now()
@@ -146,11 +130,6 @@ fn current_timestamp() -> u64 {
.as_millis() as u64
}
-// ============================================================================
-// Public API
-// ============================================================================
-
-/// Add a new notification
pub fn add_notification(
priority: NotificationPriority,
category: NotificationCategory,
@@ -175,28 +154,26 @@ pub fn add_notification(
action_id,
metadata,
};
-
+
let mut store = NOTIFICATION_STORE.lock()
.map_err(|e| format!("Failed to lock notification store: {}", e))?;
-
+
store.notifications.push(notification.clone());
-
- // Save to disk if persistent
+
if notification.persistent {
save_notifications_to_disk(&store)?;
}
-
+
Ok(notification)
}
-/// Get all notifications (optionally filtered by priority)
pub fn get_notifications(
priority_filter: Option,
include_dismissed: bool,
) -> Result, String> {
let store = NOTIFICATION_STORE.lock()
.map_err(|e| format!("Failed to lock notification store: {}", e))?;
-
+
let notifications: Vec = store.notifications.iter()
.filter(|n| {
let priority_match = priority_filter.as_ref()
@@ -207,110 +184,97 @@ pub fn get_notifications(
})
.cloned()
.collect();
-
+
Ok(notifications)
}
-/// Get unread notification count
pub fn get_unread_count() -> Result {
let store = NOTIFICATION_STORE.lock()
.map_err(|e| format!("Failed to lock notification store: {}", e))?;
-
+
let count = store.notifications.iter()
.filter(|n| !n.read && !n.dismissed)
.count();
-
+
Ok(count)
}
-/// Mark a notification as read
pub fn mark_as_read(id: &str) -> Result<(), String> {
let mut store = NOTIFICATION_STORE.lock()
.map_err(|e| format!("Failed to lock notification store: {}", e))?;
-
+
if let Some(notification) = store.notifications.iter_mut().find(|n| n.id == id) {
notification.read = true;
-
+
if notification.persistent {
save_notifications_to_disk(&store)?;
}
}
-
+
Ok(())
}
-/// Mark all notifications as read
pub fn mark_all_as_read() -> Result<(), String> {
let mut store = NOTIFICATION_STORE.lock()
.map_err(|e| format!("Failed to lock notification store: {}", e))?;
-
+
for notification in store.notifications.iter_mut() {
notification.read = true;
}
-
+
save_notifications_to_disk(&store)?;
-
+
Ok(())
}
-/// Dismiss a notification (hide it but keep in history)
pub fn dismiss_notification(id: &str) -> Result<(), String> {
let mut store = NOTIFICATION_STORE.lock()
.map_err(|e| format!("Failed to lock notification store: {}", e))?;
-
+
if let Some(notification) = store.notifications.iter_mut().find(|n| n.id == id) {
notification.dismissed = true;
notification.read = true;
-
+
if notification.persistent {
save_notifications_to_disk(&store)?;
}
}
-
+
Ok(())
}
-/// Delete a notification permanently
pub fn delete_notification(id: &str) -> Result<(), String> {
let mut store = NOTIFICATION_STORE.lock()
.map_err(|e| format!("Failed to lock notification store: {}", e))?;
-
+
store.notifications.retain(|n| n.id != id);
save_notifications_to_disk(&store)?;
-
+
Ok(())
}
-/// Clear all non-system notifications
pub fn clear_notifications(include_system: bool) -> Result<(), String> {
let mut store = NOTIFICATION_STORE.lock()
.map_err(|e| format!("Failed to lock notification store: {}", e))?;
-
+
if include_system {
store.notifications.clear();
} else {
store.notifications.retain(|n| n.priority == NotificationPriority::System);
}
-
+
save_notifications_to_disk(&store)?;
-
+
Ok(())
}
-/// Check for system-level notifications (admin status, etc.)
-/// This is called on app startup to create necessary system notifications
pub fn check_system_notifications() -> Vec {
- // With Tauri v2 capability system, we don't need admin checks
- // All permissions are granted at build time through capabilities
+
Vec::new()
}
-// ============================================================================
-// Convenience constructors
-// ============================================================================
-
impl Notification {
- /// Create a system-level admin notification
+
pub fn admin(title: impl Into, message: impl Into) -> Self {
Notification {
id: generate_id(),
@@ -327,8 +291,7 @@ impl Notification {
metadata: None,
}
}
-
- /// Create a security warning
+
pub fn security(title: impl Into, message: impl Into) -> Self {
Notification {
id: generate_id(),
@@ -345,8 +308,7 @@ impl Notification {
metadata: None,
}
}
-
- /// Create an account warning
+
pub fn account_warning(title: impl Into, message: impl Into) -> Self {
Notification {
id: generate_id(),
@@ -363,8 +325,7 @@ impl Notification {
metadata: None,
}
}
-
- /// Create an update notification
+
pub fn update(title: impl Into, message: impl Into, version: Option) -> Self {
Notification {
id: generate_id(),
@@ -381,8 +342,7 @@ impl Notification {
metadata: version.map(|v| serde_json::json!({ "version": v })),
}
}
-
- /// Create a transient toast notification
+
pub fn toast(message: impl Into, category: NotificationCategory) -> Self {
Notification {
id: generate_id(),
@@ -399,15 +359,13 @@ impl Notification {
metadata: None,
}
}
-
- /// Add an action button to this notification
+
pub fn with_action(mut self, label: impl Into, action_id: impl Into) -> Self {
self.action_label = Some(label.into());
self.action_id = Some(action_id.into());
self
}
-
- /// Add metadata to this notification
+
pub fn with_metadata(mut self, metadata: serde_json::Value) -> Self {
self.metadata = Some(metadata);
self
diff --git a/src-tauri/src/common/permissions.rs b/src-tauri/src/common/permissions.rs
index b976f78..7d7f833 100644
--- a/src-tauri/src/common/permissions.rs
+++ b/src-tauri/src/common/permissions.rs
@@ -1,5 +1,3 @@
-//! Permission status - simplified for Tauri v2 capability system
-
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -9,12 +7,10 @@ pub struct PermissionStatus {
pub can_access_files: bool,
}
-/// Get current permission status
-/// With Tauri v2 capabilities, permissions are granted at build time
pub fn get_permission_status() -> PermissionStatus {
PermissionStatus {
- can_screenshot: true, // Granted via desktop screenshot capability
- can_access_clipboard: true, // Granted via clipboard-manager:default
- can_access_files: true, // Granted via fs:default + scopes
+ can_screenshot: true,
+ can_access_clipboard: true,
+ can_access_files: true,
}
}
diff --git a/src-tauri/src/common/types.rs b/src-tauri/src/common/types.rs
index b0321d2..73a74c2 100644
--- a/src-tauri/src/common/types.rs
+++ b/src-tauri/src/common/types.rs
@@ -1,8 +1,5 @@
-/// Shared types and data structures for the Flicker application
-
use serde::{Deserialize, Serialize};
-/// Response from the Emberly file upload API
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UploadResponse {
pub id: Option,
@@ -13,7 +10,6 @@ pub struct UploadResponse {
pub file_type: String,
}
-/// Screenshot result with file path and dimensions
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ScreenshotResult {
pub path: String,
@@ -21,7 +17,6 @@ pub struct ScreenshotResult {
pub height: u32,
}
-/// Upload result with URL for clipboard
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UploadCompleteEvent {
pub id: Option,
@@ -32,7 +27,6 @@ pub struct UploadCompleteEvent {
pub screenshot_path: Option,
}
-/// Emitted repeatedly while a file is being streamed to the server
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UploadProgressEvent {
pub file_path: String,
@@ -41,7 +35,6 @@ pub struct UploadProgressEvent {
pub percentage: f64,
}
-/// Monitor information
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MonitorInfo {
pub index: usize,
@@ -54,7 +47,6 @@ pub struct MonitorInfo {
pub scale_factor: f64,
}
-/// System information
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SystemInfo {
pub platform: String,
@@ -63,7 +55,6 @@ pub struct SystemInfo {
pub screenshots_dir: Option,
}
-/// Platform capabilities - what the app can do on this system
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PlatformCapabilities {
pub platform: String,
@@ -72,11 +63,10 @@ pub struct PlatformCapabilities {
pub multi_monitor: bool,
pub system_tray: bool,
pub clipboard_access: bool,
- pub file_access: String, // "full" or "restricted"
+ pub file_access: String,
pub elevation_support: bool,
}
-/// Visibility levels for uploads
#[derive(Debug, Clone, PartialEq)]
pub enum UploadVisibility {
Public,
diff --git a/src-tauri/src/common/upload.rs b/src-tauri/src/common/upload.rs
index 8c112be..37bc2dc 100644
--- a/src-tauri/src/common/upload.rs
+++ b/src-tauri/src/common/upload.rs
@@ -1,11 +1,6 @@
-/// File upload functionality for the Emberly API
-///
-/// Uses the EmberlyCient from emberly_api module for all HTTP operations
-
use crate::common::emberly_api::EmberlyCient;
use crate::common::types::{UploadResponse, UploadCompleteEvent};
-/// Upload a file to the Emberly instance
pub async fn upload_file(
file_path: String,
api_url: String,
@@ -15,22 +10,19 @@ pub async fn upload_file(
domain: Option,
on_progress: Option>,
) -> Result {
- // Validate inputs
+
validate_api_url(&api_url)?;
validate_upload_token(&upload_token)?;
- // For very large files (>400MB, e.g., long video) use chunked; otherwise single POST like images
- // User asked to "just upload it like you upload the image" — so default to single for typical 10m video (~50-150MB)
let metadata = tokio::fs::metadata(&file_path)
.await
.map_err(|e| format!("Failed to read file metadata: {}", e))?;
let total_size = metadata.len();
const CHUNK_THRESHOLD: u64 = 400 * 1024 * 1024;
- // Need to handle on_progress move: take it for chunked, fallback to None for single if chunked was tried
let mut on_progress_opt = on_progress;
if total_size > CHUNK_THRESHOLD {
- println!("[Flicker] upload_file: {} bytes > threshold, using chunked", total_size);
+ crate::flog!("upload_file: {} bytes > threshold, using chunked", total_size);
let res = upload_file_chunked(
file_path.clone(),
api_url.clone(),
@@ -44,22 +36,34 @@ pub async fn upload_file(
match res {
Ok(r) => return Ok(r),
Err(e) => {
- eprintln!("[Flicker] chunked failed ({}), falling back to single POST", e);
- // fall through to single attempt with no progress
+ crate::flog_err!("chunked failed ({}), falling back to single POST", e);
+
on_progress_opt = None;
}
}
} else {
- println!("[Flicker] upload_file: {} bytes single POST to {}", total_size, api_url);
+ crate::flog!("upload_file: {} bytes single POST to {}", total_size, api_url);
}
- // Create API client and upload (single part)
let client = EmberlyCient::new(api_url);
- let api_response = client
+ let file_name = std::path::Path::new(&file_path)
+ .file_name()
+ .map(|n| n.to_string_lossy().to_string())
+ .unwrap_or_else(|| file_path.clone());
+ let api_response = match client
.upload_file(&upload_token, &file_path, &visibility, password, domain, on_progress_opt)
- .await?;
+ .await
+ {
+ Ok(r) => {
+ crate::common::audit::record("upload", &format!("Uploaded {} ({})", file_name, r.url), "info");
+ r
+ }
+ Err(e) => {
+ crate::common::audit::record("upload_failed", &format!("Upload of {} failed: {}", file_name, e), "error");
+ return Err(e);
+ }
+ };
- // Convert API response to our UploadResponse type
Ok(UploadResponse {
id: api_response.id,
url: api_response.url,
@@ -93,18 +97,15 @@ async fn upload_file_chunked(
.map_err(|e| e.to_string())?
.len();
- // 1. Init
let (upload_id, part_size) = client
.init_chunked_upload(&upload_token, &file_name, &mime_type, total_size, domain.clone())
.await?;
- // 2. Upload parts
let mut parts = Vec::new();
let mut offset: u64 = 0;
let mut part_number: u32 = 1;
let mut uploaded: u64 = 0;
- // Open file for reading
let mut file = tokio::fs::File::open(&file_path)
.await
.map_err(|e| e.to_string())?;
@@ -119,7 +120,6 @@ async fn upload_file_chunked(
.get_chunk_url(&upload_token, &upload_id, part_number)
.await?;
- // PUT to S3
let resp = reqwest::Client::new()
.put(&presigned_url)
.header("Content-Type", mime_type.clone())
@@ -142,7 +142,7 @@ async fn upload_file_chunked(
.and_then(|v| v.to_str().ok())
.unwrap_or("")
.to_string();
- // Ensure ETag is quoted as S3 expects
+
let etag = if etag.starts_with('"') {
etag
} else {
@@ -158,12 +158,10 @@ async fn upload_file_chunked(
part_number += 1;
}
- // 3. Complete
let api_resp = client
.complete_chunked_upload(&upload_token, &upload_id, parts, None)
.await?;
- // Chunked uploads are PUBLIC by default — patch visibility/password if needed
if visibility != "PUBLIC" || _password.is_some() {
let _ = client
.update_file(
@@ -184,7 +182,6 @@ async fn upload_file_chunked(
})
}
-/// Create an upload complete event from an upload response
pub fn create_upload_event(
response: UploadResponse,
screenshot_path: Option,
@@ -199,25 +196,23 @@ pub fn create_upload_event(
}
}
-/// Validate API URL format
pub fn validate_api_url(url: &str) -> Result<(), String> {
if url.is_empty() {
return Err("API URL cannot be empty".to_string());
}
-
+
if !url.starts_with("http://") && !url.starts_with("https://") {
return Err("API URL must start with http:// or https://".to_string());
}
-
+
Ok(())
}
-/// Validate upload token
pub fn validate_upload_token(token: &str) -> Result<(), String> {
if token.is_empty() {
return Err("Upload token cannot be empty".to_string());
}
-
+
Ok(())
}
diff --git a/src-tauri/src/desktop/app.rs b/src-tauri/src/desktop/app.rs
index ee3fd8d..ca418f1 100644
--- a/src-tauri/src/desktop/app.rs
+++ b/src-tauri/src/desktop/app.rs
@@ -1,8 +1,5 @@
-/// Desktop platform app initialization and window management
-
use tauri::Manager;
-/// Initialize the system tray with menu and event handlers
pub fn setup_system_tray(app: &mut tauri::App) -> Result<(), Box> {
use tauri::menu::{Menu, MenuItem, PredefinedMenuItem};
@@ -14,19 +11,21 @@ pub fn setup_system_tray(app: &mut tauri::App) -> Result<(), Box)?;
let menu = Menu::with_items(app, &[&show_item, &capture_region_item, &capture_screen_item, &capture_all_item, &separator, &quit_item])?;
- let _tray = tauri::tray::TrayIconBuilder::new()
- .icon(app.default_window_icon().unwrap().clone())
+ let tray = tauri::tray::TrayIconBuilder::new();
+ #[cfg(target_os = "macos")]
+ let tray = tray
+ .icon(tauri::image::Image::from_bytes(include_bytes!("../../icons/tray-template.png"))?)
+ .icon_as_template(true);
+ #[cfg(not(target_os = "macos"))]
+ let tray = tray.icon(app.default_window_icon().unwrap().clone());
+
+ let _tray = tray
.tooltip("Flicker - Click to open")
.menu(&menu)
.on_menu_event(|app, event| {
match event.id.as_ref() {
"show" => {
- if let Some(window) = app.get_webview_window("main") {
- crate::desktop::region::mark_main_shown();
- let _ = window.show();
- let _ = window.unminimize();
- let _ = window.set_focus();
- }
+ let _ = show_window(app);
}
"capture-region" => {
let handle = app.clone();
@@ -37,8 +36,6 @@ pub fn setup_system_tray(app: &mut tauri::App) -> Result<(), Box {
let handle = app.clone();
tauri::async_runtime::spawn(async move {
- // Fully backgrounded: capture+upload in Rust, no window/JS needed.
- // Stays hidden in menu bar, never pops the main window.
crate::desktop::hotkeys::do_capture(handle, false).await;
});
}
@@ -56,13 +53,7 @@ pub fn setup_system_tray(app: &mut tauri::App) -> Result<(), Box Result<(), Box Result<(), Box> {
if let Some(window) = app.get_webview_window("main") {
+ let handle = app.handle().clone();
let window_clone = window.clone();
window.on_window_event(move |event| {
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
- // Prevent the window from closing, hide it instead
api.prevent_close();
- crate::desktop::region::mark_main_hidden_by_user();
- let _ = window_clone.hide();
+ let config = crate::common::config::load_config().unwrap_or_default();
+ match config.behavior.close_action.as_str() {
+ "quit" => handle.exit(0),
+ "minimize" => {
+ let _ = window_clone.minimize();
+ }
+ _ => {
+ let _ = hide_window(&handle);
+ notify_still_running(&handle, &config.hotkeys.open_app);
+ }
+ }
}
});
}
-
+
Ok(())
}
-/// Setup all plugins required by the application
+/// Tells the user once where Flicker went the first time closing hides it.
+fn notify_still_running(app: &tauri::AppHandle, open_hotkey: &str) {
+ let Ok(dir) = crate::common::config::get_config_dir() else { return };
+ let marker = dir.join("close-notice-shown");
+ if marker.exists() {
+ return;
+ }
+ let _ = std::fs::write(&marker, "1");
+ let place = if cfg!(target_os = "macos") { "menu bar" } else { "system tray" };
+ let body = if open_hotkey.trim().is_empty() {
+ format!("Open it again from the Flicker icon in your {}.", place)
+ } else {
+ let keys = if cfg!(target_os = "macos") {
+ open_hotkey.replace("Super", "Cmd").replace("Alt", "Option")
+ } else {
+ open_hotkey.replace("Super", "Win").replace("Control", "Ctrl")
+ };
+ format!("Press {} or use the Flicker icon in your {} to open it again.", keys, place)
+ };
+ send_os_notification(app, "Flicker is still running", &body);
+}
+
pub fn setup_plugins(builder: tauri::Builder) -> tauri::Builder {
+ // Must be the first plugin: launching Flicker again shows the copy that's already running.
+ #[cfg(desktop)]
+ let builder = builder.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
+ let _ = show_window(app);
+ }));
builder
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
@@ -103,7 +128,6 @@ pub fn setup_plugins(builder: tauri::Builder) -> tauri::Builder Result<(), String> {
if let Some(window) = app.get_webview_window("main") {
crate::desktop::region::mark_main_shown();
+ #[cfg(target_os = "macos")]
+ let _ = app.set_activation_policy(tauri::ActivationPolicy::Regular);
window.show()
.map_err(|e| format!("Failed to show window: {}", e))?;
window.unminimize()
@@ -127,21 +152,36 @@ pub fn show_window(app: &tauri::AppHandle) -> Result<(), String> {
Ok(())
}
-/// Hide the main window
pub fn hide_window(app: &tauri::AppHandle) -> Result<(), String> {
if let Some(window) = app.get_webview_window("main") {
+ crate::desktop::region::mark_main_hidden_by_user();
window.hide()
.map_err(|e| format!("Failed to hide window: {}", e))?;
+ // Without a window there's nothing to switch to, so drop the Dock icon and stay in the menu bar.
+ #[cfg(target_os = "macos")]
+ let _ = app.set_activation_policy(tauri::ActivationPolicy::Accessory);
}
Ok(())
}
-/// Exit the application
+/// Brings Flicker to the front, or hides it when it's already the focused window.
+pub fn toggle_window(app: &tauri::AppHandle) {
+ if let Some(window) = app.get_webview_window("main") {
+ let visible = window.is_visible().unwrap_or(false);
+ let minimized = window.is_minimized().unwrap_or(false);
+ let focused = window.is_focused().unwrap_or(false);
+ if visible && !minimized && focused {
+ let _ = hide_window(app);
+ } else {
+ let _ = show_window(app);
+ }
+ }
+}
+
pub fn exit_app(app: &tauri::AppHandle) {
app.exit(0);
}
-/// Send OS notification — uses tauri plugin which correctly handles dev (Terminal) vs prod (Flicker)
pub fn send_os_notification(app: &tauri::AppHandle, title: &str, body: &str) {
use tauri_plugin_notification::NotificationExt;
let _ = app.notification().builder().title(title).body(body).show();
diff --git a/src-tauri/src/desktop/hotkeys.rs b/src-tauri/src/desktop/hotkeys.rs
index 1bfe8ab..5caffe1 100644
--- a/src-tauri/src/desktop/hotkeys.rs
+++ b/src-tauri/src/desktop/hotkeys.rs
@@ -1,27 +1,51 @@
-/// Rust-side global hotkey manager — ensures captures work even when app is hidden/backgrounded
-/// Mirrors the JS `useHotkeys` but runs in the backend so uploads happen without needing to return to the app.
-/// Also shows OS notifications and copies to clipboard directly in Rust.
-
use tauri::{AppHandle, Manager, Emitter};
use tauri_plugin_clipboard_manager::ClipboardExt as _;
use tauri_plugin_global_shortcut::{GlobalShortcutExt, ShortcutState};
+use std::collections::HashMap;
+use std::sync::Mutex;
+
+static HOTKEY_FAILURES: Mutex>> = Mutex::new(None);
+
+const IN_USE: &str = "Another app is already using this shortcut";
+const DUPLICATE: &str = "Also assigned to another Flicker action";
+
+fn field_for(name: &str) -> &'static str {
+ match name {
+ "fullscreen" => "screenshotFullscreen",
+ "all-monitors" => "screenshotAllMonitors",
+ "region" => "screenshotRegion",
+ "clipboard" => "uploadClipboard",
+ "open-app" => "openApp",
+ _ => "recordVideo",
+ }
+}
+
+fn record_failure(name: &str, reason: &str) {
+ crate::common::audit::record("hotkey", &format!("{} shortcut not registered: {}", name, reason), "warning");
+ if let Ok(mut guard) = HOTKEY_FAILURES.lock() {
+ guard.get_or_insert_with(HashMap::new).insert(field_for(name).to_string(), reason.to_string());
+ }
+}
+
+pub fn hotkey_failures() -> HashMap {
+ HOTKEY_FAILURES.lock().ok().and_then(|g| g.clone()).unwrap_or_default()
+}
-/// Register (or re-register) all global hotkeys from the config file.
-/// Call on startup and after hotkey config changes.
pub fn reregister_hotkeys(app: &AppHandle) -> Result<(), String> {
- println!("[Flicker] reregister_hotkeys: called");
- // Unregister all previous — ignore errors (e.g., nothing registered yet)
+ crate::flog!("reregister_hotkeys: called");
+
let unregister_res = app.global_shortcut().unregister_all();
- println!("[Flicker] reregister_hotkeys: unregister_all result: {:?}", unregister_res.is_ok());
+ if let Ok(mut guard) = HOTKEY_FAILURES.lock() {
+ *guard = Some(HashMap::new());
+ }
+ crate::flog!("reregister_hotkeys: unregister_all result: {:?}", unregister_res.is_ok());
let config = crate::common::load_config().unwrap_or_default();
- println!("[Flicker] reregister_hotkeys: loaded hotkeys fullscreen='{}' region='{}' all='{}' clipboard='{}' record='{}' token_len={}",
+ crate::flog!("reregister_hotkeys: loaded hotkeys fullscreen='{}' region='{}' all='{}' clipboard='{}' record='{}' token_len={}",
config.hotkeys.screenshot_fullscreen, config.hotkeys.screenshot_region, config.hotkeys.screenshot_all_monitors, config.hotkeys.upload_clipboard, config.hotkeys.record_video, config.upload_token.len());
let hk = config.hotkeys;
- // Guard against the same accelerator being assigned to multiple actions
- // (one press would otherwise fire screenshot AND video, looking like it
- // needs "press twice"). First registration wins.
+ // A shortcut bound to two actions would fire both on one press, so the first registration wins.
let mut seen: std::collections::HashSet = std::collections::HashSet::new();
let mut claim = |name: &str, shortcut: &str| -> bool {
let key = shortcut.trim().to_lowercase();
@@ -29,121 +53,127 @@ pub fn reregister_hotkeys(app: &AppHandle) -> Result<(), String> {
return false;
}
if !seen.insert(key) {
- eprintln!("[Flicker] hotkey '{}' ({}) already registered — skipping duplicate", shortcut, name);
+ record_failure(name, DUPLICATE);
+ crate::flog_err!("hotkey '{}' ({}) already registered — skipping duplicate", shortcut, name);
return false;
}
true
};
- // Fullscreen
if claim("fullscreen", &hk.screenshot_fullscreen) {
let app_c = app.clone();
let shortcut = hk.screenshot_fullscreen.clone();
- println!("[Flicker] registering fullscreen hotkey: '{}'", shortcut);
+ crate::flog!("registering fullscreen hotkey: '{}'", shortcut);
let res = app.global_shortcut().on_shortcut(shortcut.as_str(), move |_app, _sc, event| {
- println!("[Flicker] hotkey event fullscreen: state={:?} sc={:?}", event.state, _sc);
+ crate::flog!("hotkey event fullscreen: state={:?} sc={:?}", event.state, _sc);
if event.state != ShortcutState::Pressed { return; }
- println!("[Flicker] fullscreen hotkey PRESSED, spawning do_capture");
+ crate::flog!("fullscreen hotkey PRESSED, spawning do_capture");
let handle = app_c.clone();
tauri::async_runtime::spawn(async move {
do_capture(handle, false).await;
});
});
- println!("[Flicker] register fullscreen result: {:?}", res.is_ok());
- if let Err(e) = &res { eprintln!("[Flicker] failed to register fullscreen '{}': {}", shortcut, e); }
+ crate::flog!("register fullscreen result: {:?}", res.is_ok());
+ if let Err(e) = &res { record_failure("fullscreen", IN_USE); crate::flog_err!("failed to register fullscreen '{}': {}", shortcut, e); }
} else {
- println!("[Flicker] fullscreen hotkey empty, skipping");
+ crate::flog!("fullscreen hotkey empty, skipping");
}
- // All monitors
if claim("all-monitors", &hk.screenshot_all_monitors) {
let app_c = app.clone();
let shortcut = hk.screenshot_all_monitors.clone();
- println!("[Flicker] registering all-monitors hotkey: '{}'", shortcut);
+ crate::flog!("registering all-monitors hotkey: '{}'", shortcut);
let res = app.global_shortcut().on_shortcut(shortcut.as_str(), move |_app, _sc, event| {
- println!("[Flicker] hotkey event all-monitors: state={:?} sc={:?}", event.state, _sc);
+ crate::flog!("hotkey event all-monitors: state={:?} sc={:?}", event.state, _sc);
if event.state != ShortcutState::Pressed { return; }
- println!("[Flicker] all-monitors hotkey PRESSED");
+ crate::flog!("all-monitors hotkey PRESSED");
let handle = app_c.clone();
tauri::async_runtime::spawn(async move {
do_capture(handle, true).await;
});
});
- println!("[Flicker] register all-monitors result: {:?}", res.is_ok());
- if let Err(e) = res { eprintln!("[Flicker] failed to register all-monitors '{}': {}", shortcut, e); }
+ crate::flog!("register all-monitors result: {:?}", res.is_ok());
+ if let Err(e) = res { record_failure("all-monitors", IN_USE); crate::flog_err!("failed to register all-monitors '{}': {}", shortcut, e); }
} else {
- println!("[Flicker] all-monitors hotkey empty, skipping");
+ crate::flog!("all-monitors hotkey empty, skipping");
}
- // Region
if claim("region", &hk.screenshot_region) {
let app_c = app.clone();
let shortcut = hk.screenshot_region.clone();
- println!("[Flicker] registering region hotkey: '{}'", shortcut);
+ crate::flog!("registering region hotkey: '{}'", shortcut);
let res = app.global_shortcut().on_shortcut(shortcut.as_str(), move |_app, _sc, event| {
- println!("[Flicker] hotkey event region: state={:?} sc={:?}", event.state, _sc);
+ crate::flog!("hotkey event region: state={:?} sc={:?}", event.state, _sc);
if event.state != ShortcutState::Pressed { return; }
- println!("[Flicker] region hotkey PRESSED, spawning start_region_capture");
+ crate::flog!("region hotkey PRESSED, spawning start_region_capture");
let handle = app_c.clone();
tauri::async_runtime::spawn(async move {
let r = crate::desktop::region::start_region_capture(handle).await;
- println!("[Flicker] start_region_capture result: {:?}", r);
+ crate::flog!("start_region_capture result: {:?}", r);
});
});
- println!("[Flicker] register region result: {:?}", res.is_ok());
- if let Err(e) = res { eprintln!("[Flicker] failed to register region '{}': {}", shortcut, e); }
+ crate::flog!("register region result: {:?}", res.is_ok());
+ if let Err(e) = res { record_failure("region", IN_USE); crate::flog_err!("failed to register region '{}': {}", shortcut, e); }
} else {
- println!("[Flicker] region hotkey empty, skipping");
+ crate::flog!("region hotkey empty, skipping");
}
- // Clipboard upload
if claim("clipboard", &hk.upload_clipboard) {
let app_c = app.clone();
let shortcut = hk.upload_clipboard.clone();
- println!("[Flicker] registering clipboard hotkey: '{}'", shortcut);
+ crate::flog!("registering clipboard hotkey: '{}'", shortcut);
let res = app.global_shortcut().on_shortcut(shortcut.as_str(), move |_app, _sc, event| {
- println!("[Flicker] hotkey event clipboard: state={:?} sc={:?}", event.state, _sc);
+ crate::flog!("hotkey event clipboard: state={:?} sc={:?}", event.state, _sc);
if event.state != ShortcutState::Pressed { return; }
- println!("[Flicker] clipboard hotkey PRESSED");
+ crate::flog!("clipboard hotkey PRESSED");
let handle = app_c.clone();
tauri::async_runtime::spawn(async move {
do_clipboard_upload(handle).await;
});
});
- println!("[Flicker] register clipboard result: {:?}", res.is_ok());
- if let Err(e) = res { eprintln!("[Flicker] failed to register clipboard '{}': {}", shortcut, e); }
+ crate::flog!("register clipboard result: {:?}", res.is_ok());
+ if let Err(e) = res { record_failure("clipboard", IN_USE); crate::flog_err!("failed to register clipboard '{}': {}", shortcut, e); }
} else {
- println!("[Flicker] clipboard hotkey empty, skipping");
+ crate::flog!("clipboard hotkey empty, skipping");
+ }
+
+ if claim("open-app", &hk.open_app) {
+ let app_c = app.clone();
+ let shortcut = hk.open_app.clone();
+ crate::flog!("registering open-app hotkey: '{}'", shortcut);
+ let res = app.global_shortcut().on_shortcut(shortcut.as_str(), move |_app, _sc, event| {
+ if event.state != ShortcutState::Pressed { return; }
+ crate::desktop::app::toggle_window(&app_c);
+ });
+ if let Err(e) = res { record_failure("open-app", IN_USE); crate::flog_err!("failed to register open-app '{}': {}", shortcut, e); }
}
- // Video recording — same hotkey toggles start/stop and auto-uploads mp4 (10m max)
let video_hk = hk.record_video.clone();
if claim("video", &video_hk) {
let app_c = app.clone();
- println!("[Flicker] registering video hotkey: '{}'", video_hk);
+ crate::flog!("registering video hotkey: '{}'", video_hk);
let res = app.global_shortcut().on_shortcut(video_hk.as_str(), move |_app, _sc, event| {
- println!("[Flicker] hotkey event video: state={:?} sc={:?}", event.state, _sc);
+ crate::flog!("hotkey event video: state={:?} sc={:?}", event.state, _sc);
if event.state != ShortcutState::Pressed { return; }
- println!("[Flicker] video hotkey PRESSED, toggling");
+ crate::flog!("video hotkey PRESSED, toggling");
let handle = app_c.clone();
tauri::async_runtime::spawn(async move {
let r = crate::desktop::video::toggle_video_recording(handle).await;
- println!("[Flicker] toggle_video_recording result: {:?}", r);
+ crate::flog!("toggle_video_recording result: {:?}", r);
});
});
- println!("[Flicker] register video result: {:?}", res.is_ok());
- if let Err(e) = res { eprintln!("[Flicker] failed to register video '{}': {}", video_hk, e); }
+ crate::flog!("register video result: {:?}", res.is_ok());
+ if let Err(e) = res { record_failure("video", IN_USE); crate::flog_err!("failed to register video '{}': {}", video_hk, e); }
} else {
- println!("[Flicker] video hotkey empty, skipping");
+ crate::flog!("video hotkey empty, skipping");
}
+ let _ = app.emit("hotkeys_status", hotkey_failures());
Ok(())
}
pub async fn do_capture(app: AppHandle, capture_all: bool) {
- // Guard against concurrent captures (reuse lib's static)
- // Use a simple file or just try; the lib's screenshot_and_upload already has guard,
- // but we implement direct capture here without that guard — use our own.
+
use std::sync::atomic::{AtomicBool, Ordering};
static CAPTURING: AtomicBool = AtomicBool::new(false);
if CAPTURING.swap(true, Ordering::SeqCst) {
@@ -184,10 +214,7 @@ pub async fn do_capture(app: AppHandle, capture_all: bool) {
},
)
.await;
- // Background hotkey: stay hidden. Never auto-show the main window here —
- // the user triggered this from another app and Flicker popping open is
- // exactly what we want to avoid. Tray "Show Flicker" reopens explicitly.
- // (Foreground in-app captures via `screenshot_and_upload` still restore.)
+ // Triggered from another app, so stay hidden.
let screenshot = capture_res
.map_err(|_| "Screenshot capture timed out — check Screen Recording permission".to_string())??;
@@ -201,13 +228,12 @@ pub async fn do_capture(app: AppHandle, capture_all: bool) {
None,
).await?;
+ crate::common::discard_capture(&screenshot.path);
let event = crate::common::create_upload_event(upload, Some(screenshot.path));
- // Clipboard + notification (Rust side — works backgrounded)
let _ = app.clipboard().write_text(event.url.clone());
crate::desktop::app::send_os_notification(&app, "Upload Complete", "URL copied to clipboard");
- // History
let _ = crate::common::add_to_history(crate::common::UploadHistoryItem {
url: event.url.clone(),
name: event.name.clone(),
@@ -217,7 +243,6 @@ pub async fn do_capture(app: AppHandle, capture_all: bool) {
thumbnail_url: Some(event.url.clone()),
});
- // Emit to main window — frontend's AppContext listens for upload_complete
if let Some(main) = app.get_webview_window("main") {
let _ = main.emit("upload_complete", &event);
let _ = main.emit("screenshot_uploaded", &event);
@@ -243,8 +268,6 @@ async fn do_clipboard_upload(app: AppHandle) {
let api_url = config.upload_url.clone().unwrap_or_else(|| "https://embrly.ca".to_string());
let visibility = config.visibility.clone();
- // Use the existing command logic for clipboard image: read clipboard image, save, upload
- // Duplicate logic from lib.rs upload_clipboard_image but without window param
use tauri_plugin_clipboard_manager::ClipboardExt;
let clipboard_image = match app.clipboard().read_image() {
Ok(img) => img,
@@ -287,6 +310,7 @@ async fn do_clipboard_upload(app: AppHandle) {
).await;
match upload {
Ok(resp) => {
+ crate::common::discard_capture(&file_path_str);
let event = crate::common::create_upload_event(resp, Some(file_path_str));
let _ = app.clipboard().write_text(event.url.clone());
crate::desktop::app::send_os_notification(&app, "Upload Complete", "URL copied to clipboard");
diff --git a/src-tauri/src/desktop/linux.rs b/src-tauri/src/desktop/linux.rs
index 4921e3c..701e6de 100644
--- a/src-tauri/src/desktop/linux.rs
+++ b/src-tauri/src/desktop/linux.rs
@@ -1,8 +1,5 @@
-/// Linux-specific functionality
-
use tauri::Emitter;
-/// Check if running with elevated privileges on Linux (root)
pub fn is_admin() -> bool {
#[cfg(unix)]
{
@@ -12,7 +9,6 @@ pub fn is_admin() -> bool {
false
}
-/// Request elevation on Linux
pub fn request_elevation(window: &tauri::WebviewWindow) {
if !is_admin() {
let _ = window.emit(
@@ -25,7 +21,6 @@ pub fn request_elevation(window: &tauri::WebviewWindow) {
}
}
-/// Get Linux-specific system info
pub fn get_os_version() -> String {
"Linux".to_string()
}
diff --git a/src-tauri/src/desktop/macos.rs b/src-tauri/src/desktop/macos.rs
index 3671256..b908ba3 100644
--- a/src-tauri/src/desktop/macos.rs
+++ b/src-tauri/src/desktop/macos.rs
@@ -1,5 +1,3 @@
-/// macOS-specific functionality
-
use tauri::Emitter;
#[cfg(target_os = "macos")]
@@ -15,7 +13,6 @@ extern "C" {
fn AXIsProcessTrusted() -> bool;
}
-/// Check if running with elevated privileges on macOS (root)
pub fn is_admin() -> bool {
#[cfg(unix)]
{
@@ -25,7 +22,6 @@ pub fn is_admin() -> bool {
false
}
-/// Request elevation on macOS
pub fn request_elevation(window: &tauri::WebviewWindow) {
if !is_admin() {
let _ = window.emit(
@@ -38,13 +34,10 @@ pub fn request_elevation(window: &tauri::WebviewWindow) {
}
}
-/// Get macOS-specific system info
pub fn get_os_version() -> String {
"macOS".to_string()
}
-/// Check if the app has Screen Recording permission (macOS 10.15+)
-/// Uses CGPreflightScreenCaptureAccess - returns true if granted
#[cfg(target_os = "macos")]
pub fn has_screen_recording_permission() -> bool {
unsafe { CGPreflightScreenCaptureAccess() }
@@ -55,8 +48,6 @@ pub fn has_screen_recording_permission() -> bool {
true
}
-/// Request Screen Recording permission (macOS 10.15+)
-/// This will show the system prompt if not yet decided, or return current status
#[cfg(target_os = "macos")]
pub fn request_screen_recording_permission() -> bool {
unsafe { CGRequestScreenCaptureAccess() }
@@ -67,7 +58,6 @@ pub fn request_screen_recording_permission() -> bool {
true
}
-/// Open System Settings to the Screen Recording privacy pane
pub fn open_screen_recording_settings() {
#[cfg(target_os = "macos")]
{
@@ -87,7 +77,6 @@ pub fn open_screen_recording_settings() {
}
}
-/// Check if the app has Accessibility permission (macOS) — needed for global shortcuts in background
#[cfg(target_os = "macos")]
pub fn has_accessibility_permission() -> bool {
unsafe { AXIsProcessTrusted() }
@@ -98,7 +87,6 @@ pub fn has_accessibility_permission() -> bool {
true
}
-/// Open System Settings to the Accessibility privacy pane
pub fn open_accessibility_settings() {
#[cfg(target_os = "macos")]
{
@@ -114,8 +102,6 @@ pub fn open_accessibility_settings() {
}
}
-/// Check if the app is allowed to run in background (Login Item / Background Item on macOS 13+)
-/// Uses tauri-plugin-autostart's is_enabled check
pub fn is_background_enabled(app: &tauri::AppHandle) -> bool {
#[cfg(target_os = "macos")]
{
@@ -124,13 +110,12 @@ pub fn is_background_enabled(app: &tauri::AppHandle) -> bool {
}
#[cfg(not(target_os = "macos"))]
{
- // On Windows/Linux, autostart check — still considered "background"
+
use tauri_plugin_autostart::ManagerExt;
app.autolaunch().is_enabled().unwrap_or(true)
}
}
-/// Enable background execution (adds app to Login Items / Background Items)
pub fn enable_background(app: &tauri::AppHandle) -> Result {
use tauri_plugin_autostart::ManagerExt;
app.autolaunch()
@@ -139,7 +124,6 @@ pub fn enable_background(app: &tauri::AppHandle) -> Result {
Ok(app.autolaunch().is_enabled().unwrap_or(false))
}
-/// Disable background execution
pub fn disable_background(app: &tauri::AppHandle) -> Result {
use tauri_plugin_autostart::ManagerExt;
app.autolaunch()
@@ -148,11 +132,10 @@ pub fn disable_background(app: &tauri::AppHandle) -> Result {
Ok(!app.autolaunch().is_enabled().unwrap_or(true))
}
-/// Open System Settings to Login Items / Background Items
pub fn open_background_settings() {
#[cfg(target_os = "macos")]
{
- // macOS 13+ Ventura: General → Login Items
+
let urls = [
"x-apple.systempreferences:com.apple.LoginItems-Settings.extension",
"x-apple.systempreferences:com.apple.preference.general?LoginItems",
@@ -166,6 +149,6 @@ pub fn open_background_settings() {
}
#[cfg(not(target_os = "macos"))]
{
- // On other platforms, autostart is managed differently — just log
+
}
}
diff --git a/src-tauri/src/desktop/mod.rs b/src-tauri/src/desktop/mod.rs
index eab9966..7026a5a 100644
--- a/src-tauri/src/desktop/mod.rs
+++ b/src-tauri/src/desktop/mod.rs
@@ -1,5 +1,3 @@
-/// Desktop platform module - Windows, macOS, Linux specific code
-
pub mod screenshot;
pub mod app;
pub mod region;
diff --git a/src-tauri/src/desktop/region.rs b/src-tauri/src/desktop/region.rs
index e26508f..1a9c998 100644
--- a/src-tauri/src/desktop/region.rs
+++ b/src-tauri/src/desktop/region.rs
@@ -1,7 +1,3 @@
-/// Global region capture overlay - system-wide screenshot region selector
-/// Works even when main window is hidden/backgrounded.
-/// Inspired by ShareX / CharEx: fullscreen transparent overlay with drag-to-select.
-
use tauri::{AppHandle, Manager, WebviewUrl, WebviewWindowBuilder, Emitter};
use std::sync::atomic::{AtomicBool, Ordering};
use tauri_plugin_clipboard_manager::ClipboardExt as _;
@@ -18,17 +14,13 @@ pub fn mark_main_shown() {
MAIN_HIDDEN_BY_USER.store(false, Ordering::SeqCst);
}
-/// Check if any region overlay window is currently open
pub fn is_overlay_open(app: &AppHandle) -> bool {
app.webview_windows()
.keys()
.any(|label| label.starts_with("region-overlay"))
}
-/// Hide main window before capture so Flicker itself is not included in the screenshot.
-/// Records whether it was visible so we can restore it afterwards.
-/// Never treats a minimized / user-hidden window as visible — those must stay
-/// hidden so background hotkeys never pop the main window open.
+// Minimized or user-hidden windows must never count as visible, or background hotkeys would pop them open.
pub fn hide_main_for_capture(app: &AppHandle) {
if MAIN_HIDDEN_BY_USER.load(Ordering::SeqCst) {
MAIN_WAS_VISIBLE.store(false, Ordering::SeqCst);
@@ -37,7 +29,7 @@ pub fn hide_main_for_capture(app: &AppHandle) {
if let Some(main) = app.get_webview_window("main") {
let minimized = main.is_minimized().unwrap_or(false);
if minimized {
- // Minimized windows live in the Dock — leave them there, don't pop.
+
MAIN_WAS_VISIBLE.store(false, Ordering::SeqCst);
return;
}
@@ -52,7 +44,6 @@ pub fn hide_main_for_capture(app: &AppHandle) {
}
}
-/// Restore main window if we hid it for capture.
pub fn restore_main_after_capture(app: &AppHandle) {
if MAIN_WAS_VISIBLE.swap(false, Ordering::SeqCst)
&& !MAIN_HIDDEN_BY_USER.load(Ordering::SeqCst)
@@ -65,7 +56,6 @@ pub fn restore_main_after_capture(app: &AppHandle) {
}
}
-/// Close all region overlay windows (without restoring main — caller decides)
pub fn close_region_overlay(app: &AppHandle) -> Result<(), String> {
let labels: Vec = app
.webview_windows()
@@ -82,26 +72,23 @@ pub fn close_region_overlay(app: &AppHandle) -> Result<(), String> {
Ok(())
}
-/// Cancel region capture — close overlay and restore main window if we hid it
pub fn cancel_region_capture(app: &AppHandle) -> Result<(), String> {
close_region_overlay(app)?;
restore_main_after_capture(app);
Ok(())
}
-/// Start region capture - creates fullscreen transparent overlay(s) covering all monitors
pub async fn start_region_capture(app: AppHandle) -> Result<(), String> {
- println!("[Flicker] start_region_capture invoked");
- // Permission check on macOS
+ crate::flog!("start_region_capture invoked");
+
#[cfg(target_os = "macos")]
{
if !crate::desktop::macos::has_screen_recording_permission() {
let was_requested = crate::desktop::macos::request_screen_recording_permission();
- // Even after request, it will be false until user grants and restarts
- // Check again
+
if !crate::desktop::macos::has_screen_recording_permission() {
let _ = crate::desktop::macos::open_screen_recording_settings();
- // Emit event to frontend to show friendly dialog
+
if let Some(main) = app.get_webview_window("main") {
let _ = main.emit(
"screen_recording_permission_required",
@@ -118,23 +105,20 @@ pub async fn start_region_capture(app: AppHandle) -> Result<(), String> {
}
}
- // If already open, close first (toggle behavior)
if is_overlay_open(&app) {
close_region_overlay(&app)?;
- // small delay to allow close animation
+
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
}
- // Hide main window so it doesn't appear in the screenshot (user reported Flicker always in capture)
hide_main_for_capture(&app);
- // Give window manager time to hide before we freeze the overlay
+
tokio::time::sleep(std::time::Duration::from_millis(120)).await;
- // Get monitors via Tauri (logical positions), fallback to screenshots crate
let monitors = app.available_monitors().unwrap_or_default();
if monitors.is_empty() {
- // Fallback: try screenshots crate
+
#[cfg(feature = "desktop")]
{
let screens = screenshots::Screen::all()
@@ -151,9 +135,6 @@ pub async fn start_region_capture(app: AppHandle) -> Result<(), String> {
return Err("No screens found".to_string());
}
- // Create overlay for each monitor using Tauri monitor info
- // We also need screenshots::Screen to map index correctly - assume same order
- // For positioning we use Tauri monitor's physical position/size
for (idx, monitor) in monitors.iter().enumerate() {
let label = format!("region-overlay-{}", idx);
if app.get_webview_window(&label).is_some() {
@@ -164,7 +145,6 @@ pub async fn start_region_capture(app: AppHandle) -> Result<(), String> {
let size = monitor.size();
let scale = monitor.scale_factor();
- // URL with monitor index so frontend knows which monitor it is
let url = WebviewUrl::App(format!("index.html?overlay=region&monitor={}", idx).into());
let mut builder = WebviewWindowBuilder::new(&app, &label, url)
@@ -180,7 +160,6 @@ pub async fn start_region_capture(app: AppHandle) -> Result<(), String> {
.focused(idx == 0)
.accept_first_mouse(true);
- // macOS specific: ensure window is on all spaces
#[cfg(target_os = "macos")]
{
builder = builder.hidden_title(true);
@@ -188,8 +167,6 @@ pub async fn start_region_capture(app: AppHandle) -> Result<(), String> {
let window = builder.build().map_err(|e| format!("Failed to create overlay: {}", e))?;
- // Ensure correct position/size via explicit calls (more reliable than builder)
- // Use logical for position
let _ = window.set_position(tauri::Position::Logical(tauri::LogicalPosition {
x: position.x as f64 / scale,
y: position.y as f64 / scale,
@@ -203,8 +180,6 @@ pub async fn start_region_capture(app: AppHandle) -> Result<(), String> {
let _ = window.show();
}
- // Also ensure main window stays hidden? Don't hide, just let overlay be on top
-
Ok(())
}
@@ -218,7 +193,7 @@ fn create_overlay_for_screen(
let scale = info.scale_factor as f64;
let logical_x = info.x as f64;
let logical_y = info.y as f64;
- // screenshots width/height are physical; convert to logical for window
+
let logical_w = info.width as f64 / scale;
let logical_h = info.height as f64 / scale;
@@ -257,8 +232,6 @@ fn create_overlay_for_screen(
Ok(())
}
-/// Confirm region capture - called from overlay window after user selects region
-/// x, y, width, height are in LOGICAL pixels relative to that monitor's overlay window (0,0 = top-left of that monitor)
pub async fn confirm_region_capture(
app: AppHandle,
monitor_index: usize,
@@ -268,21 +241,19 @@ pub async fn confirm_region_capture(
height: f64,
scale_factor: Option,
) -> Result {
- // Validate dimensions
+
if width < 5.0 || height < 5.0 {
return Err("Selection too small".to_string());
}
- // Close overlay BEFORE capture so it doesn't appear in screenshot
close_region_overlay(&app)?;
- // Wait for window to disappear (important on macOS where close is animated)
+
tokio::time::sleep(std::time::Duration::from_millis(180)).await;
- // Determine scale factor - use provided or lookup from monitor/screens
let scale = if let Some(s) = scale_factor {
s
} else {
- // Try to get from Tauri monitors
+
if let Ok(monitors) = app.available_monitors() {
if let Some(m) = monitors.get(monitor_index) {
m.scale_factor()
@@ -290,7 +261,7 @@ pub async fn confirm_region_capture(
1.0
}
} else {
- // fallback to screenshots
+
#[cfg(feature = "desktop")]
{
screenshots::Screen::all()
@@ -303,14 +274,11 @@ pub async fn confirm_region_capture(
}
};
- // Convert logical to physical pixels for screenshots crate
let phys_x = (x * scale).round() as i32;
let phys_y = (y * scale).round() as i32;
let phys_w = (width * scale).round() as u32;
let phys_h = (height * scale).round() as u32;
- // Perform capture on the specific monitor using physical coords relative to that monitor
- // Main window is already hidden (hide_main_for_capture in start), so Flicker won't be in the shot
let result = crate::desktop::screenshot::capture_region(
phys_x,
phys_y,
@@ -320,15 +288,11 @@ pub async fn confirm_region_capture(
)
.await;
- // Restore main window now that capture is done (upload will happen next if via capture_and_upload)
restore_main_after_capture(&app);
result
}
-/// Capture region and immediately upload using stored config (disk config fallback)
-/// This is an alternative single-call flow that does capture+upload in Rust
-/// Includes guard against concurrent/duplicate calls (fixes “billion uploads”)
pub async fn capture_region_and_upload(
app: AppHandle,
monitor_index: usize,
@@ -342,7 +306,7 @@ pub async fn capture_region_and_upload(
visibility: Option,
domain: Option,
) -> Result {
- // Guard: prevent concurrent/billion uploads — only one region capture at a time
+
if REGION_CAPTURING.swap(true, Ordering::SeqCst) {
return Err("Region capture already in progress".to_string());
}
@@ -350,7 +314,6 @@ pub async fn capture_region_and_upload(
let result: Result = async {
let screenshot = confirm_region_capture(app.clone(), monitor_index, x, y, width, height, scale_factor).await?;
- // Load config to get upload credentials if not provided
let config = crate::common::load_config().unwrap_or_default();
let api_url = api_url
@@ -365,10 +328,9 @@ pub async fn capture_region_and_upload(
}
let visibility = visibility.unwrap_or(config.visibility.clone());
- // domain is separate from upload_url — don't derive from upload_url
+ // The domain is chosen separately from upload_url and must not be derived from it.
let domain_clone = domain.clone();
- // Upload
let upload_result = crate::common::upload_file(
screenshot.path.clone(),
api_url,
@@ -380,9 +342,9 @@ pub async fn capture_region_and_upload(
)
.await?;
+ crate::common::discard_capture(&screenshot.path);
let event = crate::common::create_upload_event(upload_result, Some(screenshot.path));
- // Persist to disk history (so history survives even if frontend is backgrounded)
let _ = crate::common::add_to_history(crate::common::UploadHistoryItem {
url: event.url.clone(),
name: event.name.clone(),
@@ -392,19 +354,15 @@ pub async fn capture_region_and_upload(
thumbnail_url: Some(event.url.clone()),
});
- // Copy to clipboard (Rust side — works even when app is backgrounded)
let _ = app.clipboard().write_text(event.url.clone());
- // OS notification (Rust side — guaranteed even when app hidden)
crate::desktop::app::send_os_notification(&app, "Region Captured", "URL copied to clipboard");
- // Emit to main window for in-app history/toast update
if let Some(main) = app.get_webview_window("main") {
let _ = main.emit("region_upload_complete", &event);
let _ = main.emit("upload_complete", &event);
}
- // Also emit globally
let _ = app.emit("region_upload_complete", &event);
Ok(event)
@@ -420,8 +378,6 @@ pub async fn capture_region_and_upload(
result
}
-/// Capture the window under the cursor (single-click without drag) and upload
-/// Fixes Helium browser tabs not captured — uses window bounds via screencapture -R
pub async fn capture_window_and_upload(
app: AppHandle,
x: f64,
@@ -438,18 +394,17 @@ pub async fn capture_window_and_upload(
}
let result: Result = async {
- // Close overlay first (if any) — but keep main hidden until after capture
+
close_region_overlay(&app)?;
tokio::time::sleep(std::time::Duration::from_millis(180)).await;
- // Convert local click point to global screen point for window lookup
let scale = scale_factor.unwrap_or_else(|| {
app.available_monitors()
.ok()
.and_then(|m| m.get(monitor_index).map(|mon| mon.scale_factor()))
.unwrap_or(1.0)
});
- // x,y are logical relative to monitor; need global logical
+
let global_x = {
if let Ok(monitors) = app.available_monitors() {
if let Some(mon) = monitors.get(monitor_index) {
@@ -474,9 +429,7 @@ pub async fn capture_window_and_upload(
y
}
};
- // For window capture, we need physical or logical? Our helper expects logical screen points
- // Pass global logical * scale? Actually our helper now expects logical points (since we use screencapture -R with logical)
- // So use global_x, global_y as logical
+
let screenshot = crate::desktop::screenshot::capture_window_at_point(
global_x.round() as i32,
global_y.round() as i32,
@@ -484,7 +437,6 @@ pub async fn capture_window_and_upload(
)
.await?;
- // Restore main after capture
restore_main_after_capture(&app);
let config = crate::common::load_config().unwrap_or_default();
@@ -509,6 +461,7 @@ pub async fn capture_window_and_upload(
)
.await?;
+ crate::common::discard_capture(&screenshot.path);
let event = crate::common::create_upload_event(upload_result, Some(screenshot.path));
let _ = crate::common::add_to_history(crate::common::UploadHistoryItem {
@@ -533,7 +486,6 @@ pub async fn capture_window_and_upload(
}
.await;
- // Ensure main is restored even on error (if we hid it in start)
restore_main_after_capture(&app);
REGION_CAPTURING.store(false, Ordering::SeqCst);
diff --git a/src-tauri/src/desktop/screenshot.rs b/src-tauri/src/desktop/screenshot.rs
index 1d29eeb..d6046af 100644
--- a/src-tauri/src/desktop/screenshot.rs
+++ b/src-tauri/src/desktop/screenshot.rs
@@ -1,49 +1,43 @@
-/// Desktop screenshot capture functionality
-
use crate::common::file;
use crate::common::types::ScreenshotResult;
#[cfg(feature = "desktop")]
use screenshots::Screen;
-/// Capture a screenshot of the entire screen or specified monitor
#[cfg(feature = "desktop")]
pub async fn capture_screenshot(monitor_index: Option) -> Result {
- // On macOS, prefer the native `screencapture` CLI — it's instant and avoids
- // the screenshots-crate ScreenCaptureKit path that shows the recording
- // indicator and can take seconds. Fall back to the crate on failure.
+
#[cfg(target_os = "macos")]
{
if let Ok(result) = capture_screenshot_macos_cli(monitor_index).await {
return Ok(result);
}
- // Fall through to screenshots crate on failure
+
}
let screens = Screen::all().map_err(|e| format!("Failed to get screens: {}", e))?;
-
+
if screens.is_empty() {
return Err("No screens found".to_string());
}
-
+
let screen_idx = monitor_index.unwrap_or(0);
let screen = screens.get(screen_idx)
.ok_or_else(|| format!("Monitor {} not found", screen_idx))?;
-
+
let image = screen.capture()
.map_err(|e| format!("Failed to capture screen: {}", e))?;
-
+
let width = image.width();
let height = image.height();
-
- // Generate unique filename
+
let filename = file::generate_screenshot_filename("screenshot");
-
+
let screenshots_dir = file::get_screenshots_dir()?;
let file_path = screenshots_dir.join(&filename);
image.save(&file_path)
.map_err(|e| format!("Failed to save screenshot: {}", e))?;
-
+
Ok(ScreenshotResult {
path: file_path.to_string_lossy().to_string(),
width,
@@ -68,7 +62,7 @@ async fn capture_screenshot_macos_cli(
cmd.arg("-m");
}
Some(idx) => {
- // -D 1 is main, -D 2 secondary, etc.
+
cmd.arg(format!("-D{}", idx + 1));
}
}
@@ -90,7 +84,6 @@ async fn capture_screenshot_macos_cli(
})
}
-/// Capture a specific region of the screen on a given monitor
#[cfg(feature = "desktop")]
pub async fn capture_region(
x: i32,
@@ -99,39 +92,38 @@ pub async fn capture_region(
height: u32,
monitor_index: Option,
) -> Result {
- // On macOS, try screencapture CLI first for better Chromium window support (Helium tabs)
- // which are sometimes missing with the screenshots crate's CGDisplay path.
+
#[cfg(target_os = "macos")]
{
if let Ok(result) = capture_region_macos_screencapture(x, y, width, height, monitor_index).await {
return Ok(result);
}
- // Fall through to screenshots crate on failure
+
}
let screens = Screen::all().map_err(|e| format!("Failed to get screens: {}", e))?;
-
+
if screens.is_empty() {
return Err("No screens found".to_string());
}
-
+
let screen_idx = monitor_index.unwrap_or(0);
let screen = screens.get(screen_idx)
.ok_or_else(|| format!("Monitor {} not found", screen_idx))?;
-
+
let image = screen.capture_area(x, y, width, height)
.map_err(|e| format!("Failed to capture region: {}", e))?;
-
+
let img_width = image.width();
let img_height = image.height();
-
+
let filename = file::generate_screenshot_filename("screenshot");
-
+
let screenshots_dir = file::get_screenshots_dir()?;
let file_path = screenshots_dir.join(&filename);
image.save(&file_path)
.map_err(|e| format!("Failed to save screenshot: {}", e))?;
-
+
Ok(ScreenshotResult {
path: file_path.to_string_lossy().to_string(),
width: img_width,
@@ -148,9 +140,7 @@ async fn capture_region_macos_screencapture(
monitor_index: Option,
) -> Result {
use std::process::Command;
- // screencapture -R expects logical points (not physical pixels) on Retina.
- // Our x,y,width,height are already physical (scaled). Convert back to logical for screencapture.
- // Try to get scale for this monitor to convert.
+
let scale = if let Some(idx) = monitor_index {
Screen::all().ok().and_then(|s| s.get(idx).map(|sc| sc.display_info.scale_factor as f64)).unwrap_or(1.0)
} else {
@@ -172,7 +162,7 @@ async fn capture_region_macos_screencapture(
if !output.status.success() {
return Err(format!("screencapture failed: {:?}", String::from_utf8_lossy(&output.stderr)));
}
- // Verify file exists and get dimensions via image crate
+
let img = image::open(&file_path).map_err(|e| format!("Failed to open capture: {}", e))?;
Ok(ScreenshotResult {
path: file_path.to_string_lossy().to_string(),
@@ -181,8 +171,6 @@ async fn capture_region_macos_screencapture(
})
}
-/// Capture the window under the given screen point (for single-click region capture)
-/// On macOS, uses CGWindowList + screencapture -l to include full window chrome (tabs) — fixes Helium not capturing tabs
#[cfg(feature = "desktop")]
pub async fn capture_window_at_point(
x: i32,
@@ -194,10 +182,9 @@ pub async fn capture_window_at_point(
if let Ok(result) = capture_window_macos(x, y, monitor_index).await {
return Ok(result);
}
- // Fallback: capture a small region around the point if window capture fails
+
}
- // Fallback on other platforms or if macOS window capture failed: capture 1px and let caller handle
- // For now, capture the monitor's full area as fallback
+
capture_screenshot(monitor_index).await
}
@@ -228,7 +215,7 @@ async fn capture_window_macos(
for dict_cf in cf_array.iter() {
let dict: CFDictionary = unsafe { CFDictionary::wrap_under_get_rule(dict_cf.as_CFTypeRef() as *mut _) };
- // Get bounds
+
let bounds_ptr = match unsafe { dict.find(kCGWindowBounds as *const _ as *const _) } {
Some(v) => v,
None => continue,
@@ -246,7 +233,7 @@ async fn capture_window_macos(
let wh = get_num("Height").unwrap_or(0.0);
if ww < 50.0 || wh < 50.0 {
- continue; // Skip tiny windows (shadows, etc.)
+ continue;
}
let px = x as f64;
@@ -255,7 +242,6 @@ async fn capture_window_macos(
continue;
}
- // Skip Flicker itself
if let Some(owner_ptr) = unsafe { dict.find(kCGWindowOwnerName as *const _ as *const _) } {
let owner: CFString = unsafe { CFString::wrap_under_get_rule(*owner_ptr as *mut _) };
if owner.to_string() == "Flicker" {
@@ -263,21 +249,16 @@ async fn capture_window_macos(
}
}
- // Skip transparent overlay windows (they have very low alpha or are Flicker overlay)
- // We already filtered Flicker, but also check for overlay by bounds being full-screen transparent
- // Just take first matching non-Flicker window
target_bounds = Some((wx, wy, ww, wh));
break;
}
let (wx, wy, ww, wh) = target_bounds.ok_or("No window found at point".to_string())?;
- // Capture the window's bounds as a region — this includes chrome (tabs) unlike content-only captures
- // Use screencapture -R which correctly handles Retina and window chrome on macOS
let filename = file::generate_screenshot_filename("window");
let screenshots_dir = file::get_screenshots_dir()?;
let file_path = screenshots_dir.join(&filename);
- // screencapture -R expects logical points on macOS (Retina aware), our wx/wy/ww/wh are already in points
+
let rect = format!("{},{},{},{}", wx.round() as i32, wy.round() as i32, ww.round() as u32, wh.round() as u32);
let output = Command::new("screencapture")
.args(["-x", "-R", &rect, &file_path.to_string_lossy().to_string()])
@@ -295,21 +276,19 @@ async fn capture_window_macos(
})
}
-/// Capture all monitors combined into a single image
#[cfg(feature = "desktop")]
pub async fn capture_all_monitors() -> Result {
let screens = Screen::all().map_err(|e| format!("Failed to get screens: {}", e))?;
-
+
if screens.is_empty() {
return Err("No screens found".to_string());
}
-
- // Calculate the bounding box for all monitors
+
let mut min_x = i32::MAX;
let mut min_y = i32::MAX;
let mut max_x = i32::MIN;
let mut max_y = i32::MIN;
-
+
for screen in &screens {
let info = &screen.display_info;
min_x = min_x.min(info.x);
@@ -317,24 +296,20 @@ pub async fn capture_all_monitors() -> Result {
max_x = max_x.max(info.x + info.width as i32);
max_y = max_y.max(info.y + info.height as i32);
}
-
+
let total_width = (max_x - min_x) as u32;
let total_height = (max_y - min_y) as u32;
-
- // Create a new image buffer for the combined screenshot
+
let mut combined = image::RgbaImage::new(total_width, total_height);
-
- // Capture each screen and composite them
+
for screen in &screens {
let info = &screen.display_info;
let capture = screen.capture()
.map_err(|e| format!("Failed to capture screen: {}", e))?;
-
- // Calculate where this screen goes in the combined image
+
let offset_x = (info.x - min_x) as u32;
let offset_y = (info.y - min_y) as u32;
-
- // Copy pixels from the capture to the combined image
+
for (x, y, pixel) in capture.enumerate_pixels() {
let dest_x = offset_x + x;
let dest_y = offset_y + y;
@@ -343,15 +318,14 @@ pub async fn capture_all_monitors() -> Result {
}
}
}
-
- // Generate unique filename
+
let filename = file::generate_screenshot_filename("screenshot_all");
-
+
let screenshots_dir = file::get_screenshots_dir()?;
let file_path = screenshots_dir.join(&filename);
combined.save(&file_path)
.map_err(|e| format!("Failed to save screenshot: {}", e))?;
-
+
Ok(ScreenshotResult {
path: file_path.to_string_lossy().to_string(),
width: total_width,
@@ -359,11 +333,10 @@ pub async fn capture_all_monitors() -> Result {
})
}
-/// Get list of all available monitors
#[cfg(feature = "desktop")]
pub fn get_monitors() -> Result, String> {
let screens = Screen::all().map_err(|e| format!("Failed to get screens: {}", e))?;
-
+
Ok(screens.iter().enumerate().map(|(i, screen)| {
let info = &screen.display_info;
crate::common::types::MonitorInfo {
@@ -379,23 +352,22 @@ pub fn get_monitors() -> Result, String>
}).collect())
}
-/// Get the monitor index at a specific screen coordinate
#[cfg(feature = "desktop")]
pub fn get_monitor_at_point(x: i32, y: i32) -> Result, String> {
let screens = Screen::all().map_err(|e| format!("Failed to get screens: {}", e))?;
-
+
for (i, screen) in screens.iter().enumerate() {
let info = &screen.display_info;
let screen_x = info.x;
let screen_y = info.y;
let screen_width = info.width as i32;
let screen_height = info.height as i32;
-
+
if x >= screen_x && x < screen_x + screen_width &&
y >= screen_y && y < screen_y + screen_height {
return Ok(Some(i));
}
}
-
+
Ok(None)
}
diff --git a/src-tauri/src/desktop/video.rs b/src-tauri/src/desktop/video.rs
index c0650c2..8fdf430 100644
--- a/src-tauri/src/desktop/video.rs
+++ b/src-tauri/src/desktop/video.rs
@@ -1,7 +1,3 @@
-/// Native video recording functionality (macOS)
-/// Uses macOS's built-in ScreenCaptureKit / AVFoundation pipeline via screencapture
-/// without requiring any external dependencies like FFmpeg.
-
use std::path::PathBuf;
use std::sync::Mutex;
use std::time::Instant;
@@ -20,8 +16,7 @@ async fn start_scap_mp4_recording(
_show_clicks: bool,
_fps: u32,
) -> Result, String> {
- // Placeholder — system audio via scap will be fully implemented next iteration (openh264 + mp4 muxing).
- // Returning Err forces fallback to screencapture in start_video_recording, which at least captures video (mic if enabled).
+
Err("scap mp4 system-audio path not yet enabled — using screencapture fallback".to_string())
}
@@ -36,7 +31,7 @@ pub struct VideoRegion {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VideoRecordOptions {
pub region: Option,
- pub include_audio: Option, // legacy: maps to system audio
+ pub include_audio: Option,
pub include_system_audio: Option,
pub include_mic: Option,
pub show_clicks: Option,
@@ -52,7 +47,7 @@ pub struct VideoRecordingStatus {
}
pub struct ActiveRecording {
- pub pid: Option, // for screencapture child
+ pub pid: Option,
pub output_path: PathBuf,
pub start_time: Instant,
pub has_audio: bool,
@@ -64,12 +59,10 @@ pub struct ActiveRecording {
static RECORDING_SESSION: Mutex> = Mutex::new(None);
-/// Check if video recording is currently in progress
pub fn is_recording() -> bool {
RECORDING_SESSION.lock().map(|guard| guard.is_some()).unwrap_or(false)
}
-/// Get current recording status
pub fn get_recording_status() -> VideoRecordingStatus {
if let Ok(guard) = RECORDING_SESSION.lock() {
if let Some(ref session) = *guard {
@@ -91,24 +84,23 @@ pub fn get_recording_status() -> VideoRecordingStatus {
}
}
-/// Start native screen video recording
pub async fn start_video_recording(
app: &AppHandle,
options: Option,
) -> Result {
- println!("[Flicker] start_video_recording invoked options={:?}", options);
- // Prevent concurrent recordings
+ crate::flog!("start_video_recording invoked options={:?}", options);
+
{
let guard = RECORDING_SESSION.lock().map_err(|e| e.to_string())?;
if guard.is_some() {
- eprintln!("[Flicker] start_video_recording blocked: already recording");
+ crate::flog_err!("start_video_recording blocked: already recording");
return Err("A video recording is already in progress.".to_string());
}
}
#[cfg(target_os = "macos")]
{
- // 1. Permission check on macOS
+
if !crate::desktop::macos::has_screen_recording_permission() {
let _ = crate::desktop::macos::request_screen_recording_permission();
if !crate::desktop::macos::has_screen_recording_permission() {
@@ -117,7 +109,6 @@ pub async fn start_video_recording(
}
}
- // 2. Prepare directory and filename — always .mp4, 10 min max
let dir = get_recordings_dir()?;
let filename = generate_recording_filename();
let output_path = dir.join(&filename);
@@ -133,13 +124,11 @@ pub async fn start_video_recording(
let has_system_audio = opts.include_system_audio.or(opts.include_audio).unwrap_or(config.video.include_system_audio);
let has_mic = opts.include_mic.unwrap_or(config.video.include_mic);
- // screencapture -g captures mic; system audio is captured automatically via ScreenCaptureKit on macOS 13+ when has_system_audio
+
let has_audio = has_system_audio || has_mic;
let show_clicks = opts.show_clicks.unwrap_or(config.video.show_clicks);
let is_region = opts.region.is_some();
- // 3. Build native recording — system audio requires scap (ScreenCaptureKit) — screencapture -v can't do system audio, -g is mic only
- // For now, system audio capture via scap is in beta; we fallback to video without system audio and toast
let _scap_handle_opt: Option> = None;
let child = if has_system_audio {
crate::desktop::app::send_os_notification(&app, "System Audio", "System audio capture via native ScreenCaptureKit is in beta — falling back to video without system audio for now. Mic will still be captured if enabled.");
@@ -165,7 +154,6 @@ pub async fn start_video_recording(
};
let pid = child.id();
- // 5. Store active session
let session = ActiveRecording {
pid: Some(pid),
output_path: output_path.clone(),
@@ -182,7 +170,6 @@ pub async fn start_video_recording(
*guard = Some(session);
}
- // Auto-stop after max_duration (10 mins = 600s) — prevents runaway recordings
let max_duration = config.video.max_duration_secs as u64;
let app_clone = app.clone();
tauri::async_runtime::spawn(async move {
@@ -201,7 +188,6 @@ pub async fn start_video_recording(
is_region,
};
- // Notify app and frontend
let _ = app.emit("video_recording_started", &status);
if let Some(main) = app.get_webview_window("main") {
let _ = main.emit("video_recording_started", &status);
@@ -224,31 +210,28 @@ pub async fn start_video_recording(
}
}
-/// Stop native screen video recording and optionally upload
pub async fn stop_video_recording(
app: &AppHandle,
auto_upload: Option,
) -> Result, String> {
- println!("[Flicker] stop_video_recording invoked auto_upload={:?}", auto_upload);
+ crate::flog!("stop_video_recording invoked auto_upload={:?}", auto_upload);
let session = {
let mut guard = RECORDING_SESSION.lock().map_err(|e| e.to_string())?;
let s = guard.take().ok_or_else(|| "No active video recording to stop.".to_string());
- if s.is_err() { eprintln!("[Flicker] stop_video_recording: no active session"); }
+ if s.is_err() { crate::flog_err!("stop_video_recording: no active session"); }
s?
};
- println!("[Flicker] stopping pid={:?} path={:?}", session.pid, session.output_path);
+ crate::flog!("stopping pid={:?} path={:?}", session.pid, session.output_path);
#[cfg(target_os = "macos")]
{
- // 1. Send SIGINT to screencapture so it finalizes the MP4/MOV container cleanly
- // Handle both pid (screencapture) and scap_handle (scap)
+
if let Some(pid) = session.pid {
#[cfg(unix)]
unsafe {
libc::kill(pid as i32, libc::SIGINT);
}
- // 2. Wait up to 10 seconds for process to exit and finalize file writing
let mut terminated = false;
for _ in 0..100 {
#[cfg(unix)]
@@ -261,7 +244,6 @@ pub async fn stop_video_recording(
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
}
- // Fallback: if not finished after 10s, send SIGTERM
if !terminated {
#[cfg(unix)]
unsafe {
@@ -270,12 +252,11 @@ pub async fn stop_video_recording(
tokio::time::sleep(std::time::Duration::from_millis(300)).await;
}
} else if let Some(handle) = session.scap_handle {
- // For scap, abort the capture task
+
handle.abort();
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
}
- // 3. Verify output file exists and has valid size
if !session.output_path.exists() {
return Err("Recorded video file was not found on disk.".to_string());
}
@@ -304,7 +285,6 @@ pub async fn stop_video_recording(
let _ = main.emit("video_recording_stopped", &stop_payload);
}
- // 4. Check whether to upload
let config = crate::common::load_config().unwrap_or_default();
let should_upload = auto_upload.unwrap_or(config.video.auto_upload);
@@ -321,7 +301,7 @@ pub async fn stop_video_recording(
.clone()
.unwrap_or_else(|| "https://embrly.ca".to_string());
- println!("[Flicker] video upload: starting {} ({} bytes) to {} visibility={}", file_path_str, file_size, api_url, config.visibility);
+ crate::flog!("video upload: starting {} ({} bytes) to {} visibility={}", file_path_str, file_size, api_url, config.visibility);
let upload_resp = crate::common::upload_file(
file_path_str.clone(),
api_url,
@@ -333,20 +313,17 @@ pub async fn stop_video_recording(
)
.await
.map_err(|e| {
- eprintln!("[Flicker] video upload failed: {}", e);
+ crate::flog_err!("video upload failed: {}", e);
e
})?;
- println!("[Flicker] video upload success: url={} id={:?}", upload_resp.url, upload_resp.id);
+ crate::flog!("video upload success: url={} id={:?}", upload_resp.url, upload_resp.id);
let event = crate::common::create_upload_event(upload_resp, Some(file_path_str));
- // Copy to clipboard
let _ = app.clipboard().write_text(event.url.clone());
- // Notification
crate::desktop::app::send_os_notification(&app, "Video Upload Complete", "URL copied to clipboard");
- // Add to upload history
let _ = crate::common::add_to_history(crate::common::UploadHistoryItem {
url: event.url.clone(),
name: event.name.clone(),
@@ -356,7 +333,6 @@ pub async fn stop_video_recording(
thumbnail_url: None,
});
- // Emit completion event to app & window
let _ = app.emit("upload_complete", &event);
if let Some(main) = app.get_webview_window("main") {
let _ = main.emit("upload_complete", &event);
@@ -375,7 +351,6 @@ pub async fn stop_video_recording(
}
}
-/// Cancel active video recording and discard file
pub async fn cancel_video_recording(app: &AppHandle) -> Result<(), String> {
let session = {
let mut guard = RECORDING_SESSION.lock().map_err(|e| e.to_string())?;
@@ -390,7 +365,6 @@ pub async fn cancel_video_recording(app: &AppHandle) -> Result<(), String> {
libc::kill(pid as i32, libc::SIGINT);
}
- // Wait up to 3 seconds for termination
for _ in 0..30 {
#[cfg(unix)]
unsafe {
@@ -405,7 +379,6 @@ pub async fn cancel_video_recording(app: &AppHandle) -> Result<(), String> {
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
}
- // Delete the incomplete/cancelled recording file
if session.output_path.exists() {
let _ = std::fs::remove_file(&session.output_path);
}
@@ -426,7 +399,6 @@ pub async fn cancel_video_recording(app: &AppHandle) -> Result<(), String> {
}
}
-/// Toggle video recording: if recording, stops and uploads; if not, starts recording
pub async fn toggle_video_recording(app: AppHandle) -> Result<(), String> {
if is_recording() {
let _ = stop_video_recording(&app, Some(true)).await?;
diff --git a/src-tauri/src/desktop/windows.rs b/src-tauri/src/desktop/windows.rs
index 8f2213e..8fa53cd 100644
--- a/src-tauri/src/desktop/windows.rs
+++ b/src-tauri/src/desktop/windows.rs
@@ -1,22 +1,17 @@
-/// Windows-specific functionality
-
use tauri::Emitter;
-/// Check if running with admin privileges on Windows
pub fn is_admin() -> bool {
use std::os::windows::process::CommandExt;
use std::process::Command;
- // Try to run a simple command that requires admin privileges
let output = Command::new("net")
.args(&["session"])
- .creation_flags(0x08000000) // CREATE_NO_WINDOW
+ .creation_flags(0x08000000)
.output();
matches!(output, Ok(out) if out.status.success())
}
-/// Request elevation on Windows
pub fn request_elevation(window: &tauri::WebviewWindow) {
if !is_admin() {
let _ = window.emit(
@@ -31,7 +26,6 @@ pub fn request_elevation(window: &tauri::WebviewWindow) {
}
}
-/// Get Windows-specific system info
pub fn get_os_version() -> String {
std::env::var("OS").unwrap_or_else(|_| "Windows".to_string())
}
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index eb6826f..9629f43 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -1,8 +1,3 @@
-/// Flicker Tauri Backend - Screenshot and upload tool
-///
-/// This module provides a modular architecture for screenshot capture,
-/// file operations, and upload functionality with desktop and mobile support.
-
pub mod common;
pub mod platform;
pub mod desktop;
@@ -16,22 +11,18 @@ use common::{
use tauri_plugin_clipboard_manager::ClipboardExt as _;
use std::sync::atomic::{AtomicBool, Ordering};
-/// Global guard to prevent concurrent screenshot captures (fixes spam on rapid triggers)
static SCREENSHOT_CAPTURING: AtomicBool = AtomicBool::new(false);
-// Platform-specific screenshot module
#[cfg(feature = "desktop")]
use desktop::screenshot;
#[cfg(feature = "mobile")]
use mobile::screenshot;
-/// Capture a screenshot of the entire screen or primary monitor
#[tauri::command]
async fn capture_screenshot(monitor_index: Option) -> Result {
screenshot::capture_screenshot(monitor_index).await
}
-/// Capture a specific region of the screen
#[tauri::command]
async fn capture_region(
x: i32,
@@ -43,7 +34,6 @@ async fn capture_region(
screenshot::capture_region(x, y, width, height, monitor_index).await
}
-/// Get list of available monitors
#[tauri::command]
fn get_monitors() -> Result, String> {
let monitors = screenshot::get_monitors()?;
@@ -61,19 +51,16 @@ fn get_monitors() -> Result, String> {
}).collect())
}
-/// Get the monitor index at a specific screen coordinate
#[tauri::command]
fn get_monitor_at_point(x: i32, y: i32) -> Result, String> {
screenshot::get_monitor_at_point(x, y)
}
-/// Capture all monitors combined into a single image
#[tauri::command]
async fn capture_all_monitors() -> Result {
screenshot::capture_all_monitors().await
}
-/// Uploads a file to the Emberly instance
#[tauri::command]
async fn upload_file(
window: tauri::Window,
@@ -83,6 +70,7 @@ async fn upload_file(
visibility: String,
password: Option,
domain: Option,
+ discard_after: Option,
) -> Result {
let progress_path = file_path.clone();
let progress_window = window.clone();
@@ -111,10 +99,12 @@ async fn upload_file(
)
.await?;
- // Emit success event with file path for preview
+ if discard_after.unwrap_or(false) {
+ common::discard_capture(&file_path);
+ }
let event = common::create_upload_event(response.clone(), Some(file_path.clone()));
desktop::app::emit_event(&window, "upload_complete", &event);
- // Also ensure OS notification + history + clipboard even when app hidden (like other upload paths)
+
let app_handle = window.app_handle();
let _ = app_handle.clipboard().write_text(event.url.clone());
desktop::app::send_os_notification(&app_handle, "Upload Complete", "URL copied to clipboard");
@@ -131,9 +121,6 @@ async fn upload_file(
Ok(response)
}
-/// Uploads whatever image is currently on the OS clipboard.
-/// Saves it to the screenshots directory first so it has a real file path,
-/// then reuses the standard upload flow.
#[tauri::command]
async fn upload_clipboard_image(
app: tauri::AppHandle,
@@ -176,9 +163,10 @@ async fn upload_clipboard_image(
)
.await?;
+ common::discard_capture(&file_path);
let event = common::create_upload_event(response.clone(), Some(file_path.clone()));
desktop::app::emit_event(&window, "upload_complete", &event);
- // Also ensure OS notification + clipboard + disk history (works even when app hidden)
+
let app_handle = app.clone();
let _ = app_handle.clipboard().write_text(event.url.clone());
desktop::app::send_os_notification(&app_handle, "Upload Complete", "URL copied to clipboard");
@@ -196,8 +184,6 @@ async fn upload_clipboard_image(
Ok(response)
}
-/// Take screenshot, upload it, and return the URL
-/// Now handles clipboard + OS notification + history in Rust so it works even when frontend is hidden/backgrounded
#[tauri::command]
async fn screenshot_and_upload(
window: tauri::Window,
@@ -208,15 +194,15 @@ async fn screenshot_and_upload(
capture_all: Option,
domain: Option,
) -> Result {
- println!("[Flicker] screenshot_and_upload invoked: capture_all={:?} monitor={:?} token_len={} api_url={}", capture_all, monitor_index, upload_token.len(), api_url);
- eprintln!("[Flicker] screenshot_and_upload: visibility={} domain={:?}", visibility, domain);
- // Guard against concurrent captures
+ crate::flog!("screenshot_and_upload invoked: capture_all={:?} monitor={:?} token_len={} api_url={}", capture_all, monitor_index, upload_token.len(), api_url);
+ crate::flog_err!("screenshot_and_upload: visibility={} domain={:?}", visibility, domain);
+
if SCREENSHOT_CAPTURING.swap(true, Ordering::SeqCst) {
return Err("Capture already in progress".to_string());
}
let result: Result = async {
- // Check screen recording permission on macOS (same as region — prevents hang when denied)
+
#[cfg(target_os = "macos")]
{
if !desktop::macos::has_screen_recording_permission() {
@@ -228,15 +214,12 @@ async fn screenshot_and_upload(
}
}
- // Emit that we're starting
desktop::app::emit_event(&window, "screenshot_started", serde_json::json!({}));
- // Hide main window so Flicker doesn't appear in its own screenshot (user reported always included)
let app_handle = window.app_handle().clone();
desktop::region::hide_main_for_capture(&app_handle);
tokio::time::sleep(std::time::Duration::from_millis(120)).await;
- // Capture screenshot based on mode — wrap in timeout to avoid hanging “Capturing…” forever
let capture_res = tokio::time::timeout(
std::time::Duration::from_secs(8),
async {
@@ -248,14 +231,13 @@ async fn screenshot_and_upload(
},
)
.await;
- // Restore immediately after capture attempt (before upload, so user sees app again quickly) — even on timeout/error
+
desktop::region::restore_main_after_capture(&app_handle);
let screenshot_result = capture_res
.map_err(|_| "Screenshot capture timed out after 8s — check Screen Recording permission".to_string())??;
desktop::app::emit_event(&window, "screenshot_captured", &screenshot_result);
- // Upload it
let upload_result = common::upload_file(
screenshot_result.path.clone(),
api_url,
@@ -267,9 +249,9 @@ async fn screenshot_and_upload(
)
.await?;
+ common::discard_capture(&screenshot_result.path);
let event = common::create_upload_event(upload_result, Some(screenshot_result.path));
- // Persist to disk history (so it survives app restarts and is visible when app returns)
let _ = common::add_to_history(common::UploadHistoryItem {
url: event.url.clone(),
name: event.name.clone(),
@@ -279,15 +261,13 @@ async fn screenshot_and_upload(
thumbnail_url: Some(event.url.clone()),
});
- // Copy URL to system clipboard (Rust side — works even when window hidden)
let app_handle = window.app_handle();
let _ = app_handle.clipboard().write_text(event.url.clone());
desktop::app::send_os_notification(&app_handle, "Upload Complete", "URL copied to clipboard");
- // Emit final event for frontend (in-app notification, history refresh)
desktop::app::emit_event(&window, "screenshot_uploaded", &event);
- // Also emit globally — frontend listens for upload_complete
+
let _ = window.app_handle().emit("upload_complete", &event);
Ok(event)
@@ -296,7 +276,6 @@ async fn screenshot_and_upload(
SCREENSHOT_CAPTURING.store(false, Ordering::SeqCst);
- // On error, also try to notify via OS notification
if let Err(ref e) = result {
desktop::app::send_os_notification(window.app_handle(), "Screenshot Failed", e);
}
@@ -304,23 +283,20 @@ async fn screenshot_and_upload(
result
}
-/// Gets system information
#[tauri::command]
fn get_system_info() -> common::SystemInfo {
platform::get_system_info()
}
-/// Get screenshots directory path
#[tauri::command]
fn get_screenshots_path() -> Result {
let dir = get_screenshots_dir()?;
Ok(dir.to_string_lossy().to_string())
}
-/// Get test image path (icon.png)
#[tauri::command]
fn get_test_image_path(app_handle: tauri::AppHandle) -> Result {
- // 1. Try resource directory (Production)
+
if let Ok(resource_dir) = app_handle.path().resource_dir() {
let resource_path = resource_dir.join("icons").join("icon.png");
if resource_path.exists() {
@@ -328,21 +304,18 @@ fn get_test_image_path(app_handle: tauri::AppHandle) -> Result {
}
}
- // 2. Try development icons directory (Relative to current dir)
if let Ok(current_dir) = std::env::current_dir() {
let dev_path = current_dir.join("src-tauri").join("icons").join("icon.png");
if dev_path.exists() {
return Ok(dev_path.to_string_lossy().to_string());
}
- // Try public dir fallback
let public_path = current_dir.join("public").join("icon.png");
if public_path.exists() {
return Ok(public_path.to_string_lossy().to_string());
}
}
- // 3. Try to find it in the project root if we're in src-tauri
if let Ok(current_dir) = std::env::current_dir() {
if current_dir.ends_with("src-tauri") {
let root_path = current_dir
@@ -360,7 +333,6 @@ fn get_test_image_path(app_handle: tauri::AppHandle) -> Result {
Err("Could not find test image (icon.png) in any expected location".to_string())
}
-/// Get current permission status
#[tauri::command]
fn get_permission_status() -> serde_json::Value {
let status = common::get_permission_status();
@@ -371,7 +343,6 @@ fn get_permission_status() -> serde_json::Value {
})
}
-/// Get platform capabilities (what features are available)
#[tauri::command]
fn get_platform_capabilities() -> serde_json::Value {
let caps = platform::get_capabilities();
@@ -389,7 +360,6 @@ fn get_platform_capabilities() -> serde_json::Value {
})
}
-/// Load app configuration from disk
#[tauri::command]
fn load_config() -> Result {
let config = common::load_config()?;
@@ -397,26 +367,33 @@ fn load_config() -> Result {
.map_err(|e| format!("Failed to serialize config: {}", e))?)
}
-/// Save app configuration to disk
#[tauri::command]
fn save_config(app: tauri::AppHandle, config: serde_json::Value) -> Result<(), String> {
let app_config: common::AppConfig = serde_json::from_value(config)
.map_err(|e| format!("Failed to parse config: {}", e))?;
let result = common::save_config(&app_config);
if result.is_ok() {
- // Re-register global hotkeys so new shortcuts take effect immediately — works even when app is backgrounded
+
let _ = desktop::hotkeys::reregister_hotkeys(&app);
}
result
}
-/// Re-register global hotkeys from current config (call after save_config or on demand)
#[tauri::command]
fn reregister_hotkeys(app: tauri::AppHandle) -> Result<(), String> {
desktop::hotkeys::reregister_hotkeys(&app)
}
-/// Load upload history from disk
+#[tauri::command]
+fn get_backend_logs() -> Vec {
+ common::logs::recent()
+}
+
+#[tauri::command]
+fn get_hotkey_status() -> std::collections::HashMap {
+ desktop::hotkeys::hotkey_failures()
+}
+
#[tauri::command]
fn load_history() -> Result, String> {
let history = common::load_history()?;
@@ -425,7 +402,6 @@ fn load_history() -> Result, String> {
.collect())
}
-/// Add item to upload history
#[tauri::command]
fn add_to_history(item: serde_json::Value) -> Result<(), String> {
let history_item: common::UploadHistoryItem = serde_json::from_value(item)
@@ -433,13 +409,11 @@ fn add_to_history(item: serde_json::Value) -> Result<(), String> {
common::add_to_history(history_item)
}
-/// Clear all upload history
#[tauri::command]
fn clear_history() -> Result<(), String> {
common::clear_history()
}
-/// Login to Emberly with email/username and password
#[tauri::command]
async fn emberly_login(
api_url: String,
@@ -451,12 +425,11 @@ async fn emberly_login(
let response = client
.login(email_or_username, password, two_factor_code)
.await?;
-
+
Ok(serde_json::to_value(response)
.map_err(|e| format!("Failed to serialize login response: {}", e))?)
}
-/// Get user profile from Emberly
#[tauri::command]
async fn emberly_get_profile(
api_url: String,
@@ -464,12 +437,11 @@ async fn emberly_get_profile(
) -> Result {
let client = common::EmberlyCient::new(api_url);
let profile = client.get_profile(&token).await?;
-
+
Ok(serde_json::to_value(profile)
.map_err(|e| format!("Failed to serialize profile: {}", e))?)
}
-/// Validate an Emberly upload token
#[tauri::command]
async fn emberly_validate_token(
api_url: String,
@@ -479,7 +451,6 @@ async fn emberly_validate_token(
client.validate_token(&token).await
}
-/// Upload a file to Emberly
#[tauri::command]
async fn emberly_upload_file(
api_url: String,
@@ -497,7 +468,6 @@ async fn emberly_upload_file(
.map_err(|e| format!("Failed to serialize upload response: {}", e))?)
}
-/// Get user statistics from Emberly
#[tauri::command]
async fn emberly_get_stats(
api_url: String,
@@ -510,7 +480,6 @@ async fn emberly_get_stats(
.map_err(|e| format!("Failed to serialize stats: {}", e))?)
}
-/// Delete a file from Emberly
#[tauri::command]
async fn emberly_delete_file(
api_url: String,
@@ -521,7 +490,6 @@ async fn emberly_delete_file(
client.delete_file(&token, &file_id).await
}
-/// Get the user's custom domains and domain-slot usage
#[tauri::command]
async fn emberly_get_domains(
api_url: String,
@@ -534,7 +502,46 @@ async fn emberly_get_domains(
.map_err(|e| format!("Failed to serialize domains: {}", e))?)
}
-/// Get the user's active perk bonuses
+fn device_name() -> String {
+ let from_env = std::env::var("COMPUTERNAME").or_else(|_| std::env::var("HOSTNAME")).ok();
+ let name = from_env.or_else(|| {
+ std::process::Command::new("hostname")
+ .output()
+ .ok()
+ .and_then(|o| String::from_utf8(o.stdout).ok())
+ });
+ name.map(|n| n.trim().trim_end_matches(".local").to_string())
+ .filter(|n| !n.is_empty())
+ .unwrap_or_else(|| "this computer".to_string())
+}
+
+#[tauri::command]
+async fn device_sign_in_start(api_url: String) -> Result {
+ common::EmberlyCient::new(api_url).start_device_sign_in(&device_name()).await
+}
+
+#[tauri::command]
+async fn device_sign_in_poll(api_url: String, device_code: String) -> Result {
+ common::EmberlyCient::new(api_url).poll_device_sign_in(&device_code).await
+}
+
+#[tauri::command]
+async fn emberly_get_instance(api_url: String) -> Result {
+ common::EmberlyCient::new(api_url).get_instance().await
+}
+
+#[tauri::command]
+async fn emberly_list_files(
+ api_url: String,
+ token: String,
+ page: Option,
+ limit: Option,
+) -> Result {
+ common::EmberlyCient::new(api_url)
+ .list_files(&token, page.unwrap_or(1), limit.unwrap_or(50).min(100))
+ .await
+}
+
#[tauri::command]
async fn emberly_get_perks(
api_url: String,
@@ -547,7 +554,6 @@ async fn emberly_get_perks(
.map_err(|e| format!("Failed to serialize perks: {}", e))?)
}
-/// Shorten a URL via the Emberly URL shortener
#[tauri::command]
async fn emberly_shorten_url(
api_url: String,
@@ -561,7 +567,6 @@ async fn emberly_shorten_url(
.map_err(|e| format!("Failed to serialize shortened url: {}", e))?)
}
-/// Update a file's visibility and/or password
#[tauri::command]
async fn emberly_update_file(
api_url: String,
@@ -574,37 +579,31 @@ async fn emberly_update_file(
client.update_file(&token, &file_id, visibility, password).await
}
-/// Get device information for support/diagnostics
#[tauri::command]
fn get_device_info() -> Result {
Ok(common::get_device_info())
}
-/// Get audit logs (optionally limited to last N entries)
#[tauri::command]
fn get_audit_logs(limit: Option) -> Result, String> {
common::get_audit_logs(limit)
}
-/// Get audit logs with device info appended for support export
#[tauri::command]
fn get_audit_logs_with_device() -> Result, String> {
common::get_audit_logs_with_device_info(None)
}
-/// Export audit logs as JSON string for user sharing
#[tauri::command]
fn export_audit_logs() -> Result {
common::export_audit_logs()
}
-/// Clear all audit logs
#[tauri::command]
fn clear_audit_logs() -> Result<(), String> {
common::clear_audit_logs()
}
-/// Log an event to the audit system (for frontend-initiated events)
#[tauri::command]
fn log_event(
event_type: String,
@@ -615,11 +614,6 @@ fn log_event(
common::log_event(&event_type, &message, &level, metadata)
}
-// ============================================================================
-// Notification Commands
-// ============================================================================
-
-/// Add a new notification
#[tauri::command]
fn notification_add(
priority: String,
@@ -650,71 +644,56 @@ fn notification_add(
common::add_notification(priority, category, title, message, persistent, action_label, action_id, metadata)
}
-/// Get all notifications
#[tauri::command]
fn notification_get_all(include_dismissed: bool) -> Result, String> {
common::get_notifications(None, include_dismissed)
}
-/// Get unread notification count
#[tauri::command]
fn notification_get_unread_count() -> Result {
common::get_unread_count()
}
-/// Mark a notification as read
#[tauri::command]
fn notification_mark_read(id: String) -> Result<(), String> {
common::mark_as_read(&id)
}
-/// Mark all notifications as read
#[tauri::command]
fn notification_mark_all_read() -> Result<(), String> {
common::mark_all_as_read()
}
-/// Dismiss a notification
#[tauri::command]
fn notification_dismiss(id: String) -> Result<(), String> {
common::dismiss_notification(&id)
}
-/// Delete a notification permanently
#[tauri::command]
fn notification_delete(id: String) -> Result<(), String> {
common::delete_notification(&id)
}
-/// Clear all notifications
#[tauri::command]
fn notification_clear_all(include_system: bool) -> Result<(), String> {
common::clear_notifications(include_system)
}
-/// Check for system notifications on startup
#[tauri::command]
fn notification_check_system() -> Vec {
common::check_system_notifications()
}
-// ============================================================================
-// Region Capture (Global Overlay) Commands
-// ============================================================================
-
-/// Start global region capture overlay (system-wide, works when main window is hidden)
#[tauri::command]
async fn start_region_capture(app: tauri::AppHandle) -> Result<(), String> {
desktop::region::start_region_capture(app).await
}
-/// Cancel / close the region overlay
#[tauri::command]
fn cancel_region_capture(app: tauri::AppHandle) -> Result<(), String> {
desktop::region::cancel_region_capture(&app)
}
-/// Confirm region capture from overlay window - captures region and returns file path
#[tauri::command]
async fn confirm_region_capture(
app: tauri::AppHandle,
@@ -728,7 +707,6 @@ async fn confirm_region_capture(
desktop::region::confirm_region_capture(app, monitor_index, x, y, width, height, scale_factor).await
}
-/// Capture region and upload in one call (used by overlay for full flow)
#[tauri::command]
async fn capture_region_and_upload(
app: tauri::AppHandle,
@@ -759,7 +737,6 @@ async fn capture_region_and_upload(
.await
}
-/// Check screen recording permission (macOS)
#[tauri::command]
fn check_screen_recording_permission() -> bool {
#[cfg(target_os = "macos")]
@@ -772,7 +749,6 @@ fn check_screen_recording_permission() -> bool {
}
}
-/// Request screen recording permission (macOS) and open settings if needed
#[tauri::command]
fn request_screen_recording_permission() -> Result {
#[cfg(target_os = "macos")]
@@ -782,7 +758,7 @@ fn request_screen_recording_permission() -> Result {
return Ok(true);
}
let _ = desktop::macos::request_screen_recording_permission();
- // Give system a moment then check again
+
let has_now = desktop::macos::has_screen_recording_permission();
if !has_now {
desktop::macos::open_screen_recording_settings();
@@ -796,7 +772,6 @@ fn request_screen_recording_permission() -> Result {
}
}
-/// Capture window under cursor (single-click without drag) and upload — fixes Helium tabs not captured
#[tauri::command]
async fn capture_window_and_upload(
app: tauri::AppHandle,
@@ -815,54 +790,67 @@ async fn capture_window_and_upload(
.await
}
-/// Check accessibility permission (macOS — needed for global shortcuts in background)
#[tauri::command]
fn check_accessibility_permission() -> bool {
- desktop::macos::has_accessibility_permission()
+ #[cfg(target_os = "macos")]
+ return desktop::macos::has_accessibility_permission();
+ #[cfg(not(target_os = "macos"))]
+ true
}
-/// Request accessibility permission (opens System Settings)
#[tauri::command]
fn request_accessibility_permission() -> Result {
- if desktop::macos::has_accessibility_permission() {
- return Ok(true);
+ #[cfg(target_os = "macos")]
+ {
+ if !desktop::macos::has_accessibility_permission() {
+ desktop::macos::open_accessibility_settings();
+ }
+ return Ok(desktop::macos::has_accessibility_permission());
}
- desktop::macos::open_accessibility_settings();
- // On macOS, AXIsProcessTrusted will be true only after user grants and restarts
- Ok(desktop::macos::has_accessibility_permission())
+ #[cfg(not(target_os = "macos"))]
+ Ok(true)
}
-/// Check if app is allowed to run in background (Login Item)
#[tauri::command]
fn check_background_permission(app: tauri::AppHandle) -> bool {
- desktop::macos::is_background_enabled(&app)
+ #[cfg(target_os = "macos")]
+ return desktop::macos::is_background_enabled(&app);
+ #[cfg(not(target_os = "macos"))]
+ {
+ let _ = app;
+ true
+ }
}
-/// Enable background execution (adds to Login Items)
#[tauri::command]
fn enable_background(app: tauri::AppHandle) -> Result {
- desktop::macos::enable_background(&app)
+ #[cfg(target_os = "macos")]
+ return desktop::macos::enable_background(&app);
+ #[cfg(not(target_os = "macos"))]
+ {
+ let _ = app;
+ Ok(true)
+ }
}
-/// Open background items settings
#[tauri::command]
fn open_background_settings() {
+ #[cfg(target_os = "macos")]
desktop::macos::open_background_settings();
}
-/// Open Screen Recording settings (macOS)
#[tauri::command]
fn open_screen_recording_settings() {
+ #[cfg(target_os = "macos")]
desktop::macos::open_screen_recording_settings();
}
-/// Open Accessibility settings (macOS)
#[tauri::command]
fn open_accessibility_settings() {
+ #[cfg(target_os = "macos")]
desktop::macos::open_accessibility_settings();
}
-/// Start native video recording (mp4, 10m max, no ffmpeg)
#[tauri::command]
async fn start_video_recording(
app: tauri::AppHandle,
@@ -871,7 +859,6 @@ async fn start_video_recording(
desktop::video::start_video_recording(&app, options).await
}
-/// Stop video recording and optionally upload
#[tauri::command]
async fn stop_video_recording(
app: tauri::AppHandle,
@@ -880,19 +867,16 @@ async fn stop_video_recording(
desktop::video::stop_video_recording(&app, auto_upload).await
}
-/// Cancel video recording
#[tauri::command]
async fn cancel_video_recording(app: tauri::AppHandle) -> Result<(), String> {
desktop::video::cancel_video_recording(&app).await
}
-/// Get video recording status
#[tauri::command]
fn get_recording_status() -> desktop::video::VideoRecordingStatus {
desktop::video::get_recording_status()
}
-/// Toggle video recording
#[tauri::command]
async fn toggle_video_recording(app: tauri::AppHandle) -> Result<(), String> {
desktop::video::toggle_video_recording(app).await
@@ -901,39 +885,29 @@ async fn toggle_video_recording(app: tauri::AppHandle) -> Result<(), String> {
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let mut builder = tauri::Builder::default();
-
- // Setup plugins
+
builder = desktop::app::setup_plugins(builder);
-
- // Setup the app
+
builder
.setup(|tauri_app| {
- // Open devtools in debug builds to help with debugging
+
#[cfg(debug_assertions)]
{
if let Some(window) = tauri_app.get_webview_window("main") {
window.open_devtools();
}
}
-
- // Setup system tray and window handlers (non-blocking)
+
#[cfg(not(mobile))]
{
- // Run as menu-bar (accessory) app on macOS so Flicker lives in the
- // menu bar / tray, not the Dock. LSUIElement in Info.plist covers
- // the bundled app; this covers `tauri dev` too.
- #[cfg(target_os = "macos")]
- {
- let _ = tauri_app.set_activation_policy(tauri::ActivationPolicy::Accessory);
- }
+
desktop::app::setup_system_tray(tauri_app)?;
desktop::app::setup_window_handlers(tauri_app)?;
- // Register global hotkeys in Rust so captures work even when main window is hidden/backgrounded
- // (fixes: “need to go back into app to upload”)
+
let app_handle = tauri_app.handle().clone();
let _ = desktop::hotkeys::reregister_hotkeys(&app_handle);
}
-
+
Ok(())
})
.invoke_handler(tauri::generate_handler![
@@ -962,6 +936,10 @@ pub fn run() {
emberly_get_stats,
emberly_delete_file,
emberly_get_domains,
+ emberly_list_files,
+ device_sign_in_start,
+ device_sign_in_poll,
+ emberly_get_instance,
emberly_get_perks,
emberly_shorten_url,
emberly_update_file,
@@ -1000,7 +978,16 @@ pub fn run() {
get_recording_status,
toggle_video_recording,
reregister_hotkeys,
+ get_hotkey_status,
+ get_backend_logs,
])
- .run(tauri::generate_context!())
- .expect("error while running tauri application");
+ .build(tauri::generate_context!())
+ .expect("error while building tauri application")
+ .run(|_app, _event| {
+ // Clicking Flicker in the Dock or Finder while it's already running.
+ #[cfg(target_os = "macos")]
+ if let tauri::RunEvent::Reopen { .. } = _event {
+ let _ = desktop::app::show_window(_app);
+ }
+ });
}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 7f5f807..e945abe 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -1,4 +1,3 @@
-// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
diff --git a/src-tauri/src/mobile/android.rs b/src-tauri/src/mobile/android.rs
index 63d980e..e93a78b 100644
--- a/src-tauri/src/mobile/android.rs
+++ b/src-tauri/src/mobile/android.rs
@@ -1,13 +1,9 @@
-/// Android-specific functionality
-
use tauri::Emitter;
-/// Android screenshot capture (not supported)
pub async fn capture_screenshot(_monitor_index: Option) -> Result {
Err("Native screenshot not supported on Android. Use photo library or MediaStore instead.".to_string())
}
-/// Android region capture (not supported)
pub async fn capture_region(
_x: i32,
_y: i32,
@@ -18,14 +14,11 @@ pub async fn capture_region(
Err("Region capture not supported on Android.".to_string())
}
-/// Check if running with necessary Android permissions
pub fn has_required_permissions() -> bool {
- // This would integrate with Android permission system
- // For now, return false to indicate permissions need to be requested
+
false
}
-/// Request necessary Android permissions
pub fn request_permissions(window: &tauri::WebviewWindow) {
let _ = window.emit(
"android_permissions_required",
diff --git a/src-tauri/src/mobile/ios.rs b/src-tauri/src/mobile/ios.rs
index fa732f6..6e13928 100644
--- a/src-tauri/src/mobile/ios.rs
+++ b/src-tauri/src/mobile/ios.rs
@@ -1,13 +1,9 @@
-/// iOS-specific functionality
-
use tauri::Emitter;
-/// iOS screenshot capture (not supported)
pub async fn capture_screenshot(_monitor_index: Option) -> Result {
Err("Native screenshot not supported on iOS. Use Photos app or UIImage APIs instead.".to_string())
}
-/// iOS region capture (not supported)
pub async fn capture_region(
_x: i32,
_y: i32,
@@ -18,14 +14,11 @@ pub async fn capture_region(
Err("Region capture not supported on iOS.".to_string())
}
-/// Check if running with necessary iOS permissions
pub fn has_required_permissions() -> bool {
- // This would integrate with iOS permission system
- // For now, return false to indicate permissions need to be requested
+
false
}
-/// Request necessary iOS permissions
pub fn request_permissions(window: &tauri::WebviewWindow) {
let _ = window.emit(
"ios_permissions_required",
diff --git a/src-tauri/src/mobile/mod.rs b/src-tauri/src/mobile/mod.rs
index 89787c4..83bcb1a 100644
--- a/src-tauri/src/mobile/mod.rs
+++ b/src-tauri/src/mobile/mod.rs
@@ -1,5 +1,3 @@
-/// Mobile platform module - Android and iOS specific code
-
pub mod screenshot;
pub mod android;
pub mod ios;
diff --git a/src-tauri/src/mobile/screenshot.rs b/src-tauri/src/mobile/screenshot.rs
index 7712922..6fd8dbc 100644
--- a/src-tauri/src/mobile/screenshot.rs
+++ b/src-tauri/src/mobile/screenshot.rs
@@ -1,12 +1,8 @@
-/// Mobile screenshot functionality stubs - not supported on Android/iOS
-
-/// Mobile: Capture screenshot (currently unsupported, returns error)
#[cfg(feature = "mobile")]
pub async fn capture_screenshot(_monitor_index: Option) -> Result {
Err("Native screenshot not supported on this platform. Use photo library instead.".to_string())
}
-/// Mobile: Capture region (currently unsupported, returns error)
#[cfg(feature = "mobile")]
pub async fn capture_region(
_x: i32,
@@ -18,20 +14,17 @@ pub async fn capture_region(
Err("Region capture not supported on this platform.".to_string())
}
-/// Mobile: Capture all monitors (currently unsupported)
#[cfg(feature = "mobile")]
pub async fn capture_all_monitors() -> Result {
Err("Multi-monitor capture not supported on this platform.".to_string())
}
-/// Mobile: Get monitors (returns empty list)
#[cfg(feature = "mobile")]
pub fn get_monitors() -> Result, String> {
- Ok(vec![]) // Mobile has no concept of multiple monitors
+ Ok(vec![])
}
-/// Mobile: Get monitor at point (returns None)
#[cfg(feature = "mobile")]
pub fn get_monitor_at_point(_x: i32, _y: i32) -> Result, String> {
- Ok(None) // Mobile has no monitors
+ Ok(None)
}
diff --git a/src-tauri/src/platform/desktop.rs b/src-tauri/src/platform/desktop.rs
index b83adb0..0419402 100644
--- a/src-tauri/src/platform/desktop.rs
+++ b/src-tauri/src/platform/desktop.rs
@@ -1,11 +1,3 @@
-/**
- * Desktop platform-specific capabilities and functions
- *
- * This module provides functions and structures to determine the capabilities of the desktop platform
- * on which the application is running. It includes information about native screenshot support, region capture,
- * and other platform-specific features.
- */
-
use super::detection::PlatformType;
pub struct DesktopCapabilities {
diff --git a/src-tauri/src/platform/detection.rs b/src-tauri/src/platform/detection.rs
index 7a164e7..5149932 100644
--- a/src-tauri/src/platform/detection.rs
+++ b/src-tauri/src/platform/detection.rs
@@ -1,8 +1,5 @@
-/// Platform detection module - identify OS and capabilities
-
use crate::common::types::SystemInfo;
-/// Supported platform types
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PlatformType {
Windows,
@@ -13,7 +10,6 @@ pub enum PlatformType {
Unknown,
}
-/// Get the current platform type
pub fn get_platform() -> PlatformType {
#[cfg(target_os = "windows")]
{
@@ -47,7 +43,6 @@ pub fn get_platform() -> PlatformType {
}
}
-/// Get OS version string
pub fn get_os_version() -> String {
#[cfg(target_os = "windows")]
{
@@ -81,7 +76,6 @@ pub fn get_os_version() -> String {
}
}
-/// Get system information for the current platform
pub fn get_system_info() -> SystemInfo {
SystemInfo {
platform: get_platform_name(),
@@ -92,7 +86,6 @@ pub fn get_system_info() -> SystemInfo {
}
}
-/// Get human-readable platform name
pub fn get_platform_name() -> String {
match get_platform() {
PlatformType::Windows => "Windows".to_string(),
@@ -104,7 +97,6 @@ pub fn get_platform_name() -> String {
}
}
-/// Check if platform is desktop
pub fn is_desktop() -> bool {
matches!(
get_platform(),
@@ -112,12 +104,10 @@ pub fn is_desktop() -> bool {
)
}
-/// Check if platform is mobile
pub fn is_mobile() -> bool {
matches!(get_platform(), PlatformType::Android | PlatformType::IOs)
}
-/// Check if the platform supports screenshots
pub fn supports_screenshots() -> bool {
#[cfg(feature = "desktop")]
{
@@ -129,17 +119,14 @@ pub fn supports_screenshots() -> bool {
}
}
-/// Check if the platform supports system tray
pub fn supports_system_tray() -> bool {
is_desktop()
}
-/// Check if the platform supports multiple monitors
pub fn supports_multiple_monitors() -> bool {
is_desktop()
}
-/// Check if the platform requires elevation
pub fn requires_elevation() -> bool {
#[cfg(target_os = "windows")]
{
@@ -169,7 +156,6 @@ pub fn requires_elevation() -> bool {
}
}
-/// Platform-specific capabilities
#[derive(Debug, Clone)]
pub struct Capabilities {
pub native_screenshot: bool,
@@ -177,14 +163,13 @@ pub struct Capabilities {
pub multi_monitor: bool,
pub system_tray: bool,
pub clipboard_access: bool,
- pub file_access: String, // "full" or "restricted"
+ pub file_access: String,
pub elevation_support: bool,
}
-/// Get platform capabilities
pub fn get_capabilities() -> Capabilities {
let is_desk = is_desktop();
-
+
Capabilities {
native_screenshot: is_desk && supports_screenshots(),
region_capture: is_desk,
@@ -196,27 +181,26 @@ pub fn get_capabilities() -> Capabilities {
}
}
-/// Get capability vector for API response
pub fn get_capabilities_vector() -> Vec {
let mut caps = vec![
"upload".to_string(),
"system_info".to_string(),
"clipboard".to_string(),
];
-
+
if supports_screenshots() {
caps.push("screenshot".to_string());
caps.push("region_capture".to_string());
}
-
+
if supports_multiple_monitors() {
caps.push("multiple_monitors".to_string());
}
-
+
if supports_system_tray() {
caps.push("system_tray".to_string());
}
-
+
caps
}
@@ -232,7 +216,7 @@ mod tests {
#[test]
fn test_supports_screenshots() {
- // On desktop, screenshots should be supported
+
#[cfg(not(mobile))]
assert!(supports_screenshots());
}
diff --git a/src-tauri/src/platform/mobile.rs b/src-tauri/src/platform/mobile.rs
index 46cabae..a97ba22 100644
--- a/src-tauri/src/platform/mobile.rs
+++ b/src-tauri/src/platform/mobile.rs
@@ -1,6 +1,3 @@
-/// Mobile platform abstraction - shared capabilities for Android, iOS
-
-/// Mobile-specific platform capabilities
pub struct MobileCapabilities {
pub native_screenshot: bool,
pub region_capture: bool,
@@ -10,7 +7,6 @@ pub struct MobileCapabilities {
pub file_access: String,
}
-/// Get mobile platform capabilities
pub fn get_mobile_capabilities() -> MobileCapabilities {
MobileCapabilities {
native_screenshot: false,
diff --git a/src-tauri/src/platform/mod.rs b/src-tauri/src/platform/mod.rs
index f32dafd..f061a58 100644
--- a/src-tauri/src/platform/mod.rs
+++ b/src-tauri/src/platform/mod.rs
@@ -1,5 +1,3 @@
-/// Platform detection and capability reporting
-
pub mod detection;
pub mod desktop;
pub mod mobile;
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index da9ce84..7a9fe6c 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Flicker",
- "version": "0.3.0",
+ "version": "0.4.0",
"identifier": "ca.embrly.flicker",
"build": {
"beforeDevCommand": "bun run dev",
@@ -33,6 +33,7 @@
},
"bundle": {
"active": true,
+ "createUpdaterArtifacts": true,
"targets": "all",
"icon": [
"icons/32x32.png",
@@ -55,7 +56,7 @@
"endpoints": [
"https://github.com/EmberlyOSS/Flicker/releases/latest/download/latest.json"
],
- "pubkey": ""
+ "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDc4Mzk5Njg1NzcwRTY0OTkKUldTWlpBNTNoWlk1ZUxDKy9pUkRMYzlIeVd2VDV5aGZaNFhRWUFieDdOUUJRUzJ4YUFsSDMvdE4K"
}
}
}
diff --git a/src/App.css b/src/App.css
index b1e90f7..c34b982 100644
--- a/src/App.css
+++ b/src/App.css
@@ -1,4 +1,3 @@
-/* Animation Utilities */
@keyframes fadeIn {
from {
opacity: 0;
@@ -55,39 +54,35 @@
animation: spin 1s linear infinite;
}
-/* Responsive Utilities */
* {
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
}
-/* Mobile-first base styles */
body {
- font-size: 16px; /* Prevents zoom on input focus on iOS */
+ font-size: 16px;
overflow-x: hidden;
}
-/* Touch-friendly button minimum sizes */
-button, a, [role="button"] {
- min-height: 44px;
- min-width: 44px;
+@media (pointer: coarse) {
+ button, a, [role="button"] {
+ min-height: 44px;
+ min-width: 44px;
+ }
}
-/* Tablet layout adjustments */
@media (min-width: 641px) and (max-width: 1024px) {
body {
font-size: 15px;
}
}
-/* Desktop layout */
@media (min-width: 1025px) {
body {
font-size: 16px;
}
}
-/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
body {
padding-left: max(0px, env(safe-area-inset-left));
@@ -95,24 +90,20 @@ button, a, [role="button"] {
}
}
-/* Prevent horizontal scroll on mobile */
html, body {
overflow-x: hidden;
width: 100%;
}
-/* Better scroll behavior */
html {
scroll-behavior: smooth;
}
-/* Improve legibility */
body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
-/* Custom Titlebar Styles */
.titlebar {
-webkit-app-region: drag;
user-select: none;
@@ -124,7 +115,6 @@ body {
-webkit-app-region: no-drag;
}
-/* Prevent titlebar buttons from having min-width */
.titlebar-button {
min-width: unset;
min-height: unset;
diff --git a/src/App.tsx b/src/App.tsx
index aebdfe0..2d9534b 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -10,13 +10,13 @@ function OverlayRouter() {
const [isOverlay, setIsOverlay] = useState(null);
useEffect(() => {
- // Fast path: query param
+
const params = new URLSearchParams(window.location.search);
if (params.get('overlay') === 'region') {
setIsOverlay(true);
return;
}
- // Fallback: check window label (Tauri)
+
const checkLabel = async () => {
try {
const { getCurrentWindow } = await import('@tauri-apps/api/window');
@@ -35,13 +35,12 @@ function OverlayRouter() {
}, []);
if (isOverlay === null) {
- // briefly show nothing while detecting
+
return
;
}
if (isOverlay) {
- // Transparent background for overlay window
- // Ensure body is transparent
+
document.documentElement.style.background = 'transparent';
document.body.style.background = 'transparent';
return ;
@@ -74,7 +73,7 @@ function AppContent() {
return (
{showSplash &&
setShowSplash(false)} />}
- {/* Soft-blocking permission onboarding — shows after splash if any macOS perm missing and not dismissed this session */}
+
{!showSplash && showPermissionsModal && }
@@ -84,7 +83,6 @@ function AppContent() {
- {/* Region selector fallback — in-app (kept for browser preview; global overlay is preferred) */}
{showRegionSelector && (
{
diff --git a/src/colors.ts b/src/colors.ts
index b4f880b..5caa066 100644
--- a/src/colors.ts
+++ b/src/colors.ts
@@ -1,9 +1,3 @@
-/**
- * Flicker Color System - Based on the main website theme system
- * Uses HSL format: "hue saturation% lightness%"
- * All colors are CSS variables that get injected into :root
- */
-
export interface ColorConfig {
background: string
foreground: string
@@ -26,9 +20,6 @@ export interface ColorConfig {
ring: string
}
-/**
- * Stranger Things Theme - Purple/Red/Cyan neon (DEFAULT)
- */
export const STRANGER_THINGS_THEME: ColorConfig = {
background: '232 36% 6%',
foreground: '210 40% 96%',
@@ -51,13 +42,31 @@ export const STRANGER_THINGS_THEME: ColorConfig = {
ring: '197 100% 60%',
}
-// Default colors are now the Stranger Things theme
-export const DEFAULT_COLORS: ColorConfig = STRANGER_THINGS_THEME
+export const EMBER_THEME: ColorConfig = {
+ background: '20 14% 4%',
+ foreground: '30 20% 96%',
+ card: '20 12% 6.5%',
+ cardForeground: '30 20% 96%',
+ popover: '20 12% 7%',
+ popoverForeground: '30 20% 96%',
+ primary: '24.6 95% 53.1%',
+ primaryForeground: '20 30% 8%',
+ secondary: '20 10% 13%',
+ secondaryForeground: '30 20% 96%',
+ muted: '20 10% 13%',
+ mutedForeground: '25 8% 64%',
+ accent: '20 10% 14%',
+ accentForeground: '30 20% 96%',
+ destructive: '0 72% 51%',
+ destructiveForeground: '0 0% 98%',
+ border: '20 9% 15%',
+ input: '20 9% 17%',
+ ring: '24.6 95% 53.1%',
+}
+
+export const DEFAULT_THEME_NAME = 'Ember'
+export const DEFAULT_COLORS: ColorConfig = EMBER_THEME
-/**
- * Emberly Classic Dark Theme
- * Dark midnight blue base with bright foregrounds
- */
export const EMBERLY_CLASSIC_THEME: ColorConfig = {
background: '222.2 84% 4.9%',
foreground: '210 40% 98%',
@@ -80,9 +89,6 @@ export const EMBERLY_CLASSIC_THEME: ColorConfig = {
ring: '212.7 26.8% 83.9%',
}
-/**
- * Christmas Theme - Red/Green/Gold
- */
export const CHRISTMAS_THEME: ColorConfig = {
background: '140 40% 6%',
foreground: '210 40% 98%',
@@ -105,9 +111,6 @@ export const CHRISTMAS_THEME: ColorConfig = {
ring: '45 90% 60%',
}
-/**
- * Pride Theme - Rainbow colors
- */
export const PRIDE_THEME: ColorConfig = {
background: '220 18% 10%',
foreground: '210 40% 98%',
@@ -130,9 +133,6 @@ export const PRIDE_THEME: ColorConfig = {
ring: '300 82% 60%',
}
-/**
- * Aurora Borealis Theme - Cyan/Green/Purple
- */
export const AURORA_BOREALIS_THEME: ColorConfig = {
background: '240 40% 6%',
foreground: '210 40% 98%',
@@ -155,9 +155,6 @@ export const AURORA_BOREALIS_THEME: ColorConfig = {
ring: '180 100% 55%',
}
-/**
- * Cyberpunk Neon Theme - Cyan/Magenta
- */
export const CYBERPUNK_NEON_THEME: ColorConfig = {
background: '270 20% 5%',
foreground: '210 40% 98%',
@@ -180,9 +177,6 @@ export const CYBERPUNK_NEON_THEME: ColorConfig = {
ring: '180 100% 60%',
}
-/**
- * Dark Matrix Theme - Green code theme
- */
export const DARK_MATRIX_THEME: ColorConfig = {
background: '120 40% 5%',
foreground: '120 100% 90%',
@@ -205,9 +199,6 @@ export const DARK_MATRIX_THEME: ColorConfig = {
ring: '120 100% 60%',
}
-/**
- * Vaporwave Theme - Purple/Pink/Cyan
- */
export const VAPORWAVE_THEME: ColorConfig = {
background: '300 40% 8%',
foreground: '210 40% 98%',
@@ -230,9 +221,6 @@ export const VAPORWAVE_THEME: ColorConfig = {
ring: '280 100% 60%',
}
-/**
- * Dracula Theme - Purple/Pink/Green
- */
export const DRACULA_THEME: ColorConfig = {
background: '231 15% 18%',
foreground: '60 30% 96%',
@@ -255,9 +243,6 @@ export const DRACULA_THEME: ColorConfig = {
ring: '265 89% 78%',
}
-/**
- * Tokyo Night Theme - Deep blue with purple accents
- */
export const TOKYO_NIGHT_THEME: ColorConfig = {
background: '235 21% 13%',
foreground: '220 13% 91%',
@@ -280,9 +265,6 @@ export const TOKYO_NIGHT_THEME: ColorConfig = {
ring: '252 87% 67%',
}
-/**
- * Nord Theme - Arctic, bluish-gray
- */
export const NORD_THEME: ColorConfig = {
background: '220 16% 22%',
foreground: '218 27% 92%',
@@ -305,9 +287,6 @@ export const NORD_THEME: ColorConfig = {
ring: '193 43% 67%',
}
-/**
- * Sunset Theme - Orange/Pink/Purple gradient feel
- */
export const SUNSET_THEME: ColorConfig = {
background: '260 30% 8%',
foreground: '30 100% 96%',
@@ -330,9 +309,6 @@ export const SUNSET_THEME: ColorConfig = {
ring: '25 95% 60%',
}
-/**
- * Ocean Deep Theme - Deep sea blues and teals
- */
export const OCEAN_DEEP_THEME: ColorConfig = {
background: '200 50% 6%',
foreground: '185 30% 94%',
@@ -355,9 +331,6 @@ export const OCEAN_DEEP_THEME: ColorConfig = {
ring: '185 80% 50%',
}
-/**
- * Rose Pine Theme - Soft, warm rose colors
- */
export const ROSE_PINE_THEME: ColorConfig = {
background: '249 22% 12%',
foreground: '245 50% 91%',
@@ -380,9 +353,6 @@ export const ROSE_PINE_THEME: ColorConfig = {
ring: '330 59% 69%',
}
-/**
- * Catppuccin Mocha Theme - Warm pastel colors
- */
export const CATPPUCCIN_MOCHA_THEME: ColorConfig = {
background: '240 21% 15%',
foreground: '226 64% 88%',
@@ -405,10 +375,8 @@ export const CATPPUCCIN_MOCHA_THEME: ColorConfig = {
ring: '267 84% 81%',
}
-/**
- * Theme presets for easy switching
- */
export const THEME_PRESETS = [
+ { name: 'Ember', colors: EMBER_THEME, description: 'The Emberly look' },
{ name: 'Stranger Things', colors: STRANGER_THINGS_THEME, description: 'Red neon - Hawkins vibes' },
{ name: 'Emberly Classic', colors: EMBERLY_CLASSIC_THEME, description: 'Original midnight blue' },
{ name: 'Dracula', colors: DRACULA_THEME, description: 'Classic purple vampire' },
@@ -426,10 +394,6 @@ export const THEME_PRESETS = [
{ name: 'Pride', colors: PRIDE_THEME, description: 'Rainbow colors' },
]
-/**
- * Convert HSL to Hex color
- * Used for color picker compatibility
- */
export function hslToHex(h: number, s: number, l: number): string {
l = l / 100
const a = (s * Math.min(l, 1 - l)) / 100
@@ -443,10 +407,6 @@ export function hslToHex(h: number, s: number, l: number): string {
return `#${f(0)}${f(8)}${f(4)}`.toUpperCase()
}
-/**
- * Convert Hex to HSL string
- * Used for color picker compatibility
- */
export function hexToHSL(hex: string): string {
const parts = hex.replace(/^#/, '').split('')
if (parts.length === 6) {
diff --git a/src/components/HotkeyInput.tsx b/src/components/HotkeyInput.tsx
index 12352ec..a602228 100644
--- a/src/components/HotkeyInput.tsx
+++ b/src/components/HotkeyInput.tsx
@@ -8,12 +8,8 @@ interface HotkeyInputProps {
disabled?: boolean
}
-// Platform detection for proper modifier display
const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.platform || (navigator as any).userAgent || '')
-// Map browser key codes to Tauri shortcut format
-// On macOS, Meta (Command) should be stored as "Super" which global_hotkey maps to Command,
-// but we display it as "⌘" for familiarity.
const KEY_MAP: Record = {
'Control': 'Control',
'Shift': 'Shift',
@@ -35,16 +31,14 @@ const KEY_MAP: Record = {
'End': 'End',
'PageUp': 'PageUp',
'PageDown': 'PageDown',
- // F keys
+
'F1': 'F1', 'F2': 'F2', 'F3': 'F3', 'F4': 'F4',
'F5': 'F5', 'F6': 'F6', 'F7': 'F7', 'F8': 'F8',
'F9': 'F9', 'F10': 'F10', 'F11': 'F11', 'F12': 'F12',
}
-// Modifiers in order they should appear — Super (Cmd) first on macOS for natural reading
const MODIFIER_ORDER = isMac ? ['Super', 'Control', 'Shift', 'Alt'] : ['Control', 'Shift', 'Alt', 'Super']
-// Display name for modifiers (macOS shows ⌘ instead of Super)
function displayModifier(mod: string): string {
if (isMac) {
if (mod === 'Super') return '⌘'
@@ -56,25 +50,21 @@ function displayModifier(mod: string): string {
}
function normalizeKey(key: string, code: string): string | null {
- // Handle modifiers - they shouldn't be standalone
+
if (['Control', 'Shift', 'Alt', 'Meta'].includes(key)) {
- return null // We handle modifiers separately
+ return null
}
-
- // Check key map
+
if (KEY_MAP[key]) return KEY_MAP[key]
-
- // Single letter/number keys
+
if (key.length === 1 && /[a-zA-Z0-9]/.test(key)) {
return key.toUpperCase()
}
-
- // Numpad keys
+
if (code.startsWith('Numpad')) {
return code.replace('Numpad', 'Num')
}
-
- // Special characters
+
const specialKeys: Record = {
';': 'Semicolon',
'=': 'Equal',
@@ -89,7 +79,7 @@ function normalizeKey(key: string, code: string): string | null {
"'": 'Quote',
}
if (specialKeys[key]) return specialKeys[key]
-
+
return null
}
@@ -99,7 +89,7 @@ export function HotkeyInput({ value, onChange, placeholder, disabled }: HotkeyIn
const inputRef = useRef(null)
const buildShortcut = useCallback((modifiers: string[], key: string | null): string => {
- // Sort modifiers in standard order
+
const sortedMods = MODIFIER_ORDER.filter(m => modifiers.includes(m))
if (key) {
return [...sortedMods, key].join('+')
@@ -109,7 +99,7 @@ export function HotkeyInput({ value, onChange, placeholder, disabled }: HotkeyIn
const handleKeyDown = useCallback((e: KeyboardEvent) => {
if (!isRecording) return
-
+
e.preventDefault()
e.stopPropagation()
@@ -120,13 +110,11 @@ export function HotkeyInput({ value, onChange, placeholder, disabled }: HotkeyIn
if (e.metaKey) modifiers.push('Super')
const mainKey = normalizeKey(e.key, e.code)
-
- // Update current keys display
+
const newKeys = new Set(modifiers)
if (mainKey) newKeys.add(mainKey)
setCurrentKeys(newKeys)
-
- // Only save if we have at least one modifier and a non-modifier key
+
if (modifiers.length > 0 && mainKey) {
const shortcut = buildShortcut(modifiers, mainKey)
onChange(shortcut)
@@ -137,8 +125,7 @@ export function HotkeyInput({ value, onChange, placeholder, disabled }: HotkeyIn
const handleKeyUp = useCallback(() => {
if (!isRecording) return
-
- // Clear keys on all key releases
+
setCurrentKeys(new Set())
}, [isRecording])
@@ -170,7 +157,6 @@ export function HotkeyInput({ value, onChange, placeholder, disabled }: HotkeyIn
setCurrentKeys(new Set())
}
- // Convert stored value to display-friendly (Super → ⌘ on mac)
const formatDisplayValue = (val: string) => {
if (!val) return ''
return val.split('+').map(p => displayModifier(p.trim())).join(' + ')
@@ -191,8 +177,8 @@ export function HotkeyInput({ value, onChange, placeholder, disabled }: HotkeyIn
w-full px-4 py-2.5 bg-background border rounded-lg text-sm
flex items-center justify-between gap-2 cursor-pointer
transition-all duration-200
- ${isRecording
- ? 'border-primary ring-2 ring-primary/30 bg-primary/5'
+ ${isRecording
+ ? 'border-primary ring-2 ring-primary/30 bg-primary/5'
: 'border-input hover:border-primary/50'
}
${disabled ? 'opacity-50 cursor-not-allowed' : ''}
@@ -206,7 +192,7 @@ export function HotkeyInput({ value, onChange, placeholder, disabled }: HotkeyIn
{displayValue}
-
+
{value && !isRecording && (
-
+
{isRecording && (
Press a key combination (e.g., {isMac ? '⌘+Shift+S' : 'Ctrl+Shift+S'})
@@ -244,12 +230,11 @@ export function HotkeyInput({ value, onChange, placeholder, disabled }: HotkeyIn
)
}
-// Display a hotkey in a nice badge format — shows ⌘ on macOS
export function HotkeyBadge({ shortcut, className }: { shortcut: string; className?: string }) {
if (!shortcut) return null
-
+
const keys = shortcut.split('+').map(k => displayModifier(k.trim()))
-
+
return (
{keys.map((key, i) => (
diff --git a/src/components/ScreenshotPreview.tsx b/src/components/ScreenshotPreview.tsx
index 28d8f0a..c329ff3 100644
--- a/src/components/ScreenshotPreview.tsx
+++ b/src/components/ScreenshotPreview.tsx
@@ -7,7 +7,6 @@ interface ScreenshotPreviewProps {
autoCloseMs?: number
}
-// This component is kept for compatibility but notifications are now handled in useHotkeys
export function ScreenshotPreview({
upload,
onClose,
@@ -16,7 +15,6 @@ export function ScreenshotPreview({
useEffect(() => {
if (!upload) return
- // Auto-close after delay
const timer = setTimeout(() => {
onClose()
}, autoCloseMs)
@@ -24,6 +22,5 @@ export function ScreenshotPreview({
return () => clearTimeout(timer)
}, [upload, autoCloseMs, onClose])
- // Notifications handled by useHotkeys, this just manages the state cleanup
return null
}
diff --git a/src/components/UpdateNotification.tsx b/src/components/UpdateNotification.tsx
index bc78df2..718845d 100644
--- a/src/components/UpdateNotification.tsx
+++ b/src/components/UpdateNotification.tsx
@@ -13,7 +13,7 @@ export function UpdateNotification({ updateInfo, onDownload, onDismiss }: Update
return (
- {/* Header */}
+
@@ -30,7 +30,6 @@ export function UpdateNotification({ updateInfo, onDownload, onDismiss }: Update
- {/* Content */}
@@ -43,11 +42,10 @@ export function UpdateNotification({ updateInfo, onDownload, onDismiss }: Update
)}
- {/* Progress bar when downloading */}
{updateInfo.downloading && (
-
@@ -58,14 +56,12 @@ export function UpdateNotification({ updateInfo, onDownload, onDismiss }: Update
)}
- {/* Error message */}
{updateInfo.error && (
{updateInfo.error}
)}
- {/* Actions */}
{!updateInfo.downloading && (
void
onSkip: () => void
+ server: string
+ onServerChange: (url: string) => void
}
-export function Login({ onLogin, onSkip }: LoginProps) {
+const hostOf = (url: string) => {
+ try {
+ return new URL(url).host
+ } catch {
+ return url
+ }
+}
+
+function normalizeServer(input: string) {
+ let value = input.trim().replace(/\/+$/, '')
+ if (!/^https?:\/\//i.test(value)) value = `https://${value}`
+ const url = new URL(value)
+ return `${url.protocol}//${url.host}${url.pathname.replace(/\/+$/, '')}`
+}
+
+function ServerPicker({ server, onChange, disabled }: { server: string; onChange: (url: string) => void; disabled?: boolean }) {
+ const [editing, setEditing] = useState(false)
+ const [value, setValue] = useState(server)
+ const [checking, setChecking] = useState(false)
+ const [error, setError] = useState(null)
+
+ const apply = async (input: string) => {
+ setError(null)
+ let url: string
+ try {
+ url = normalizeServer(input)
+ } catch {
+ setError('That doesn’t look like a web address.')
+ return
+ }
+ setChecking(true)
+ try {
+ const info = await invoke<{ name?: string }>('emberly_get_instance', { apiUrl: url })
+ if (!info || typeof info !== 'object') throw new Error()
+ onChange(url)
+ setEditing(false)
+ } catch {
+ setError(`Couldn’t find an Emberly server at ${hostOf(url)}.`)
+ } finally {
+ setChecking(false)
+ }
+ }
+
+ if (!editing) {
+ return (
+
+
+
+ Server: {hostOf(server)}
+
+ {
+ setValue(server)
+ setEditing(true)
+ }}
+ className="text-primary hover:underline disabled:opacity-50"
+ >
+ Change
+
+
+ )
+ }
+
+ return (
+
+ )
+}
+
+interface DeviceCode {
+ deviceCode: string
+ userCode: string
+ verificationUriComplete: string
+ interval: number
+ expiresIn: number
+}
+
+type PollResult =
+ | { status: 'pending' | 'denied' | 'expired' | 'invalid' }
+ | { status: 'approved'; key: string; user: Omit, 'uploadToken'> }
+
+const inputClass =
+ 'w-full px-3 py-2.5 bg-background border border-input rounded-lg text-sm text-foreground placeholder-muted-foreground focus:outline-none focus:border-ring focus:ring-2 focus:ring-ring/20 transition-colors'
+
+function ErrorNote({ message }: { message: string }) {
+ return (
+
+ )
+}
+
+function BrowserSignIn({ onLogin, server }: { onLogin: LoginProps['onLogin']; server: string }) {
+ const [device, setDevice] = useState(null)
+ const [starting, setStarting] = useState(false)
+ const [error, setError] = useState(null)
+ const cancelled = useRef(false)
+
+ useEffect(() => () => {
+ cancelled.current = true
+ }, [])
+
+ const start = async () => {
+ cancelled.current = false
+ setStarting(true)
+ setError(null)
+ try {
+ const code = await invoke('device_sign_in_start', { apiUrl: server })
+ setDevice(code)
+ openUrl(code.verificationUriComplete).catch(() => {})
+ poll(code)
+ } catch (e) {
+ setError(String(e))
+ } finally {
+ setStarting(false)
+ }
+ }
+
+ const poll = async (code: DeviceCode) => {
+ const deadline = Date.now() + code.expiresIn * 1000
+ while (!cancelled.current && Date.now() < deadline) {
+ await new Promise(r => setTimeout(r, code.interval * 1000))
+ if (cancelled.current) return
+ try {
+ const result = await invoke('device_sign_in_poll', { apiUrl: server, deviceCode: code.deviceCode })
+ if (result.status === 'pending') continue
+ if (result.status === 'approved') {
+ onLogin(result.key, { ...result.user, uploadToken: result.key })
+ return
+ }
+ setDevice(null)
+ setError(result.status === 'denied' ? 'Sign-in was denied in the browser.' : 'That sign-in expired. Start again.')
+ return
+ } catch (e) {
+ setDevice(null)
+ setError(String(e))
+ return
+ }
+ }
+ if (!cancelled.current) {
+ setDevice(null)
+ setError('That sign-in expired. Start again.')
+ }
+ }
+
+ const cancel = () => {
+ cancelled.current = true
+ setDevice(null)
+ }
+
+ if (device) {
+ return (
+
+
+
Approve Flicker in your browser
+
Check the code there matches this one.
+
+
+
+
+ Waiting for approval…
+
+
+
+ Cancel
+
+ openUrl(device.verificationUriComplete).catch(() => {})}
+ className="flex items-center justify-center gap-2 rounded-lg bg-primary px-4 py-2.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
+ >
+
+ Open browser
+
+
+
+ )
+ }
+
+ return (
+
+
+ {starting ? : }
+ Sign in with Emberly
+
+
+ Opens {hostOf(server)} in your browser. Works with every sign-in method, including two-factor, and Flicker gets its own key you can revoke anytime.
+
+ {error &&
}
+
+ )
+}
+
+function PasswordSignIn({ onLogin, server }: { onLogin: LoginProps['onLogin']; server: string }) {
const [emailOrUsername, setEmailOrUsername] = useState('')
const [password, setPassword] = useState('')
const [twoFactorCode, setTwoFactorCode] = useState('')
@@ -22,197 +270,167 @@ export function Login({ onLogin, onSkip }: LoginProps) {
e.preventDefault()
setIsLoading(true)
setError(null)
-
try {
- const payload: LoginRequest = {
- emailOrUsername,
- password,
- }
-
- if (requires2FA && twoFactorCode) {
- payload.twoFactorCode = twoFactorCode
- }
+ const payload: LoginRequest = { emailOrUsername, password }
+ if (requires2FA && twoFactorCode) payload.twoFactorCode = twoFactorCode
- const response = await fetch(`${API_URL}/api/auth/desktop`, {
+ const response = await fetch(`${server}/api/auth/desktop`, {
method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
+ headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
})
-
const data: LoginResponse = await response.json()
if (data.requires2FA) {
setRequires2FA(true)
- setError(null)
return
}
-
if (!data.success || !data.user) {
- setError(data.error || 'Login failed')
+ setError(data.error || 'Sign-in failed')
return
}
-
- // Success! Pass the token and user data back
onLogin(data.user.uploadToken, data.user)
} catch (err) {
console.error('Login error:', err)
- setError('Failed to connect to Emberly. Please check your internet connection.')
+ setError(`Couldn't reach ${hostOf(server)}. Check your internet connection.`)
} finally {
setIsLoading(false)
}
}
return (
-