diff --git a/.github/workflows/changesets.yml b/.github/workflows/changesets.yml index 12899d5..cce9a4a 100644 --- a/.github/workflows/changesets.yml +++ b/.github/workflows/changesets.yml @@ -17,15 +17,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - run: npm install + - uses: oven-sh/setup-bun@v2 + - run: bun install --frozen-lockfile - name: Create Version PR id: changesets uses: changesets/action@v1 with: - version: npm run version + version: bun run version commit: "chore: version packages" title: "chore: version packages" env: @@ -56,7 +54,7 @@ jobs: exit 0 fi - version=$(node -p "require('./package.json').version") + version=$(node -p "require('./apps/macos/package.json').version") if git ls-remote --exit-code --tags origin "refs/tags/v$version" >/dev/null 2>&1; then echo "v$version is already tagged — nothing to do." exit 0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a8b940..e21bc35 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,33 @@ concurrency: cancel-in-progress: true jobs: - build-and-test: + changes: + runs-on: ubuntu-latest + outputs: + macos: ${{ steps.filter.outputs.macos }} + web: ${{ steps.filter.outputs.web }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + macos: + - 'apps/macos/**' + - '.github/workflows/ci.yml' + web: + - 'apps/web/**' + - 'package.json' + - 'bun.lock' + - '.github/workflows/ci.yml' + + macos: + needs: changes + if: needs.changes.outputs.macos == 'true' runs-on: macos-15 + defaults: + run: + working-directory: apps/macos steps: - uses: actions/checkout@v4 @@ -24,3 +49,18 @@ jobs: - name: Test (unit + benchmarks) # GitHub's runners ship full Xcode, so scripts/test.sh runs plain `swift test`. run: ./scripts/test.sh + + web: + needs: changes + if: needs.changes.outputs.web == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: oven-sh/setup-bun@v2 + - run: bun install --frozen-lockfile + - name: Format check + run: bun run --filter @ewiz/web format:check + - name: Lint + run: bun run --filter @ewiz/web lint + - name: Build + run: bun run --filter @ewiz/web build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 140a385..7d30e45 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,9 @@ jobs: # (SDK 15) build silently fails to launch (exit 1) on macOS 26 — the Swift # concurrency runtime mismatch — so the release must be built on 26. runs-on: macos-26 + defaults: + run: + working-directory: apps/macos # secrets can't be used in step `if:` directly, so surface them as env flags. env: HAS_SIGNING: ${{ secrets.DEVELOPER_ID_CERT_P12_BASE64 != '' }} @@ -135,7 +138,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: eWiz-${{ steps.ver.outputs.version }} - path: dist/eWiz-${{ steps.ver.outputs.version }}.dmg + path: apps/macos/dist/eWiz-${{ steps.ver.outputs.version }}.dmg # The release notes are this version's CHANGELOG.md section, which the # Version PR wrote. ewiz.app's changelog and download pages read them from @@ -168,11 +171,11 @@ jobs: with: name: "eWiz ${{ steps.ver.outputs.version }}" tag_name: ${{ github.ref_name }} - body_path: dist/release-notes.md + body_path: apps/macos/dist/release-notes.md files: | - dist/eWiz-${{ steps.ver.outputs.version }}.dmg - dist/appcast.xml - dist/appcast.json + apps/macos/dist/eWiz-${{ steps.ver.outputs.version }}.dmg + apps/macos/dist/appcast.xml + apps/macos/dist/appcast.json draft: false make_latest: true diff --git a/.gitignore b/.gitignore index 34146ab..ca68e4b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ package-lock.json *.p12 *.p8 AuthKey_*.p8 +.turbo/ diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..ea5a55b --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +bunx lint-staged diff --git a/README.md b/README.md index b32e9f4..cea4537 100644 --- a/README.md +++ b/README.md @@ -238,12 +238,34 @@ your neck. with **Apple Pay** in a couple of taps, in-app or [on ewiz.app](https://ewiz.app/buy). +## Repository layout + +This is a monorepo ([Bun](https://bun.sh) workspaces + [Turborepo](https://turbo.build)): + +| Path | What | +| --- | --- | +| [`apps/macos`](apps/macos) | The menu-bar app, helper daemon, MCP server and release scripts (Swift) | +| [`apps/web`](apps/web) | [ewiz.app](https://ewiz.app): website, checkout and licensing (TanStack Start on Cloudflare) | +| `packages/` | Shared code (empty for now) | + +The in-app update feed (`appcast.xml` / `appcast.json`) and the Homebrew cask still +live in [`stroke-app/ewiz-releases`](https://github.com/stroke-app/ewiz-releases): +installed copies read the feed from that URL, and the release workflow publishes to it. + +```bash +bun install +bun run dev:web # the website +bun run build # build everything (turbo) +bun run test # Swift tests +``` + ## Build from source Requires the Swift toolchain (Xcode or the Command Line Tools), macOS 14+, and an -Apple Silicon Mac. +Apple Silicon Mac. From `apps/macos`: ```bash +cd apps/macos swift build swift run eWiz # run the menu-bar app sudo ./scripts/install-helper.sh # install the root helper daemon @@ -258,7 +280,7 @@ sudo ./scripts/install-helper.sh # install the root helper daemon it adds the swift-testing framework search paths automatically. CI runs it on every push and pull request. -See [`DISTRIBUTION.md`](DISTRIBUTION.md) for signing, notarization, the GitHub +See [`DISTRIBUTION.md`](apps/macos/DISTRIBUTION.md) for signing, notarization, the GitHub Actions release pipeline, licensing on ewiz.app, and the auto-update feed. ## Contributing & releases @@ -266,12 +288,12 @@ Actions release pipeline, licensing on ewiz.app, and the auto-update feed. This repo uses [Changesets](https://github.com/changesets/changesets): ```bash -npm install -npm run changeset # describe your change (patch / minor / major) +bun install +bun run changeset # describe your change (patch / minor / major) ``` Commit the generated `.changeset/*.md`. Merging the auto-opened "Version Packages" -PR bumps the version and `CHANGELOG.md`; pushing that version tag triggers the +PR bumps the version in `apps/macos/package.json` and [`CHANGELOG.md`](apps/macos/CHANGELOG.md); pushing that version tag triggers the release build. The app and helper speak a small versioned protocol over their socket. When you diff --git a/CHANGELOG.md b/apps/macos/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to apps/macos/CHANGELOG.md diff --git a/Casks/ewiz.rb b/apps/macos/Casks/ewiz.rb similarity index 100% rename from Casks/ewiz.rb rename to apps/macos/Casks/ewiz.rb diff --git a/DISTRIBUTION.md b/apps/macos/DISTRIBUTION.md similarity index 100% rename from DISTRIBUTION.md rename to apps/macos/DISTRIBUTION.md diff --git a/Package.resolved b/apps/macos/Package.resolved similarity index 100% rename from Package.resolved rename to apps/macos/Package.resolved diff --git a/Package.swift b/apps/macos/Package.swift similarity index 100% rename from Package.swift rename to apps/macos/Package.swift diff --git a/Sources/CPowerUI/include/powerui.h b/apps/macos/Sources/CPowerUI/include/powerui.h similarity index 100% rename from Sources/CPowerUI/include/powerui.h rename to apps/macos/Sources/CPowerUI/include/powerui.h diff --git a/Sources/CPowerUI/powerui.m b/apps/macos/Sources/CPowerUI/powerui.m similarity index 100% rename from Sources/CPowerUI/powerui.m rename to apps/macos/Sources/CPowerUI/powerui.m diff --git a/Sources/CSMC/csmc.c b/apps/macos/Sources/CSMC/csmc.c similarity index 100% rename from Sources/CSMC/csmc.c rename to apps/macos/Sources/CSMC/csmc.c diff --git a/Sources/CSMC/include/csmc.h b/apps/macos/Sources/CSMC/include/csmc.h similarity index 100% rename from Sources/CSMC/include/csmc.h rename to apps/macos/Sources/CSMC/include/csmc.h diff --git a/Sources/CTry/ctry.m b/apps/macos/Sources/CTry/ctry.m similarity index 100% rename from Sources/CTry/ctry.m rename to apps/macos/Sources/CTry/ctry.m diff --git a/Sources/CTry/include/ctry.h b/apps/macos/Sources/CTry/include/ctry.h similarity index 100% rename from Sources/CTry/include/ctry.h rename to apps/macos/Sources/CTry/include/ctry.h diff --git a/Sources/EWizKit/AgentAccess.swift b/apps/macos/Sources/EWizKit/AgentAccess.swift similarity index 100% rename from Sources/EWizKit/AgentAccess.swift rename to apps/macos/Sources/EWizKit/AgentAccess.swift diff --git a/Sources/EWizKit/AgentLidHold.swift b/apps/macos/Sources/EWizKit/AgentLidHold.swift similarity index 100% rename from Sources/EWizKit/AgentLidHold.swift rename to apps/macos/Sources/EWizKit/AgentLidHold.swift diff --git a/Sources/EWizKit/BatteryAlerts.swift b/apps/macos/Sources/EWizKit/BatteryAlerts.swift similarity index 100% rename from Sources/EWizKit/BatteryAlerts.swift rename to apps/macos/Sources/EWizKit/BatteryAlerts.swift diff --git a/Sources/EWizKit/BatteryMonitor.swift b/apps/macos/Sources/EWizKit/BatteryMonitor.swift similarity index 100% rename from Sources/EWizKit/BatteryMonitor.swift rename to apps/macos/Sources/EWizKit/BatteryMonitor.swift diff --git a/Sources/EWizKit/CaffeineManager.swift b/apps/macos/Sources/EWizKit/CaffeineManager.swift similarity index 100% rename from Sources/EWizKit/CaffeineManager.swift rename to apps/macos/Sources/EWizKit/CaffeineManager.swift diff --git a/Sources/EWizKit/ChargeController.swift b/apps/macos/Sources/EWizKit/ChargeController.swift similarity index 100% rename from Sources/EWizKit/ChargeController.swift rename to apps/macos/Sources/EWizKit/ChargeController.swift diff --git a/Sources/EWizKit/ChargeDisplay.swift b/apps/macos/Sources/EWizKit/ChargeDisplay.swift similarity index 100% rename from Sources/EWizKit/ChargeDisplay.swift rename to apps/macos/Sources/EWizKit/ChargeDisplay.swift diff --git a/Sources/EWizKit/Config.swift b/apps/macos/Sources/EWizKit/Config.swift similarity index 100% rename from Sources/EWizKit/Config.swift rename to apps/macos/Sources/EWizKit/Config.swift diff --git a/Sources/EWizKit/ConfigMerge.swift b/apps/macos/Sources/EWizKit/ConfigMerge.swift similarity index 100% rename from Sources/EWizKit/ConfigMerge.swift rename to apps/macos/Sources/EWizKit/ConfigMerge.swift diff --git a/Sources/EWizKit/Control.swift b/apps/macos/Sources/EWizKit/Control.swift similarity index 100% rename from Sources/EWizKit/Control.swift rename to apps/macos/Sources/EWizKit/Control.swift diff --git a/Sources/EWizKit/DeviceIdentity.swift b/apps/macos/Sources/EWizKit/DeviceIdentity.swift similarity index 100% rename from Sources/EWizKit/DeviceIdentity.swift rename to apps/macos/Sources/EWizKit/DeviceIdentity.swift diff --git a/Sources/EWizKit/EWizLinks.swift b/apps/macos/Sources/EWizKit/EWizLinks.swift similarity index 100% rename from Sources/EWizKit/EWizLinks.swift rename to apps/macos/Sources/EWizKit/EWizLinks.swift diff --git a/Sources/EWizKit/Easing.swift b/apps/macos/Sources/EWizKit/Easing.swift similarity index 100% rename from Sources/EWizKit/Easing.swift rename to apps/macos/Sources/EWizKit/Easing.swift diff --git a/Sources/EWizKit/History.swift b/apps/macos/Sources/EWizKit/History.swift similarity index 100% rename from Sources/EWizKit/History.swift rename to apps/macos/Sources/EWizKit/History.swift diff --git a/Sources/EWizKit/HistoryExport.swift b/apps/macos/Sources/EWizKit/HistoryExport.swift similarity index 100% rename from Sources/EWizKit/HistoryExport.swift rename to apps/macos/Sources/EWizKit/HistoryExport.swift diff --git a/Sources/EWizKit/Hotkey.swift b/apps/macos/Sources/EWizKit/Hotkey.swift similarity index 100% rename from Sources/EWizKit/Hotkey.swift rename to apps/macos/Sources/EWizKit/Hotkey.swift diff --git a/Sources/EWizKit/LegacyBattlify.swift b/apps/macos/Sources/EWizKit/LegacyBattlify.swift similarity index 100% rename from Sources/EWizKit/LegacyBattlify.swift rename to apps/macos/Sources/EWizKit/LegacyBattlify.swift diff --git a/Sources/EWizKit/License.swift b/apps/macos/Sources/EWizKit/License.swift similarity index 100% rename from Sources/EWizKit/License.swift rename to apps/macos/Sources/EWizKit/License.swift diff --git a/Sources/EWizKit/LidSession.swift b/apps/macos/Sources/EWizKit/LidSession.swift similarity index 100% rename from Sources/EWizKit/LidSession.swift rename to apps/macos/Sources/EWizKit/LidSession.swift diff --git a/Sources/EWizKit/Modes.swift b/apps/macos/Sources/EWizKit/Modes.swift similarity index 100% rename from Sources/EWizKit/Modes.swift rename to apps/macos/Sources/EWizKit/Modes.swift diff --git a/Sources/EWizKit/NativeChargeLimit.swift b/apps/macos/Sources/EWizKit/NativeChargeLimit.swift similarity index 100% rename from Sources/EWizKit/NativeChargeLimit.swift rename to apps/macos/Sources/EWizKit/NativeChargeLimit.swift diff --git a/Sources/EWizKit/OKLab.swift b/apps/macos/Sources/EWizKit/OKLab.swift similarity index 100% rename from Sources/EWizKit/OKLab.swift rename to apps/macos/Sources/EWizKit/OKLab.swift diff --git a/Sources/EWizKit/PathMorph.swift b/apps/macos/Sources/EWizKit/PathMorph.swift similarity index 100% rename from Sources/EWizKit/PathMorph.swift rename to apps/macos/Sources/EWizKit/PathMorph.swift diff --git a/Sources/EWizKit/PowerMonitor.swift b/apps/macos/Sources/EWizKit/PowerMonitor.swift similarity index 100% rename from Sources/EWizKit/PowerMonitor.swift rename to apps/macos/Sources/EWizKit/PowerMonitor.swift diff --git a/Sources/EWizKit/RestAdvisor.swift b/apps/macos/Sources/EWizKit/RestAdvisor.swift similarity index 100% rename from Sources/EWizKit/RestAdvisor.swift rename to apps/macos/Sources/EWizKit/RestAdvisor.swift diff --git a/Sources/EWizKit/SMC.swift b/apps/macos/Sources/EWizKit/SMC.swift similarity index 100% rename from Sources/EWizKit/SMC.swift rename to apps/macos/Sources/EWizKit/SMC.swift diff --git a/Sources/EWizKit/Schedule.swift b/apps/macos/Sources/EWizKit/Schedule.swift similarity index 100% rename from Sources/EWizKit/Schedule.swift rename to apps/macos/Sources/EWizKit/Schedule.swift diff --git a/Sources/EWizKit/SealedSleep.swift b/apps/macos/Sources/EWizKit/SealedSleep.swift similarity index 100% rename from Sources/EWizKit/SealedSleep.swift rename to apps/macos/Sources/EWizKit/SealedSleep.swift diff --git a/Sources/EWizKit/SensorReader.swift b/apps/macos/Sources/EWizKit/SensorReader.swift similarity index 100% rename from Sources/EWizKit/SensorReader.swift rename to apps/macos/Sources/EWizKit/SensorReader.swift diff --git a/Sources/EWizKit/SessionAnalysis.swift b/apps/macos/Sources/EWizKit/SessionAnalysis.swift similarity index 100% rename from Sources/EWizKit/SessionAnalysis.swift rename to apps/macos/Sources/EWizKit/SessionAnalysis.swift diff --git a/Sources/EWizKit/SystemPower.swift b/apps/macos/Sources/EWizKit/SystemPower.swift similarity index 100% rename from Sources/EWizKit/SystemPower.swift rename to apps/macos/Sources/EWizKit/SystemPower.swift diff --git a/Sources/EWizKit/SystemUptime.swift b/apps/macos/Sources/EWizKit/SystemUptime.swift similarity index 100% rename from Sources/EWizKit/SystemUptime.swift rename to apps/macos/Sources/EWizKit/SystemUptime.swift diff --git a/Sources/EWizKit/TickPolicy.swift b/apps/macos/Sources/EWizKit/TickPolicy.swift similarity index 100% rename from Sources/EWizKit/TickPolicy.swift rename to apps/macos/Sources/EWizKit/TickPolicy.swift diff --git a/Sources/EWizKit/Trigger.swift b/apps/macos/Sources/EWizKit/Trigger.swift similarity index 100% rename from Sources/EWizKit/Trigger.swift rename to apps/macos/Sources/EWizKit/Trigger.swift diff --git a/Sources/EWizKit/UpdateSignature.swift b/apps/macos/Sources/EWizKit/UpdateSignature.swift similarity index 100% rename from Sources/EWizKit/UpdateSignature.swift rename to apps/macos/Sources/EWizKit/UpdateSignature.swift diff --git a/Sources/EWizKit/WearAnalysis.swift b/apps/macos/Sources/EWizKit/WearAnalysis.swift similarity index 100% rename from Sources/EWizKit/WearAnalysis.swift rename to apps/macos/Sources/EWizKit/WearAnalysis.swift diff --git a/Sources/eWiz/AgentStore.swift b/apps/macos/Sources/eWiz/AgentStore.swift similarity index 100% rename from Sources/eWiz/AgentStore.swift rename to apps/macos/Sources/eWiz/AgentStore.swift diff --git a/Sources/eWiz/AppIconView.swift b/apps/macos/Sources/eWiz/AppIconView.swift similarity index 100% rename from Sources/eWiz/AppIconView.swift rename to apps/macos/Sources/eWiz/AppIconView.swift diff --git a/Sources/eWiz/AppSettings.swift b/apps/macos/Sources/eWiz/AppSettings.swift similarity index 100% rename from Sources/eWiz/AppSettings.swift rename to apps/macos/Sources/eWiz/AppSettings.swift diff --git a/Sources/eWiz/AutomationStore.swift b/apps/macos/Sources/eWiz/AutomationStore.swift similarity index 100% rename from Sources/eWiz/AutomationStore.swift rename to apps/macos/Sources/eWiz/AutomationStore.swift diff --git a/Sources/eWiz/BatteryIconStyle.swift b/apps/macos/Sources/eWiz/BatteryIconStyle.swift similarity index 100% rename from Sources/eWiz/BatteryIconStyle.swift rename to apps/macos/Sources/eWiz/BatteryIconStyle.swift diff --git a/Sources/eWiz/BatteryStore.swift b/apps/macos/Sources/eWiz/BatteryStore.swift similarity index 100% rename from Sources/eWiz/BatteryStore.swift rename to apps/macos/Sources/eWiz/BatteryStore.swift diff --git a/Sources/eWiz/BrightnessControl.swift b/apps/macos/Sources/eWiz/BrightnessControl.swift similarity index 100% rename from Sources/eWiz/BrightnessControl.swift rename to apps/macos/Sources/eWiz/BrightnessControl.swift diff --git a/Sources/eWiz/ChargeFrameSequence.swift b/apps/macos/Sources/eWiz/ChargeFrameSequence.swift similarity index 100% rename from Sources/eWiz/ChargeFrameSequence.swift rename to apps/macos/Sources/eWiz/ChargeFrameSequence.swift diff --git a/Sources/eWiz/ChargeLimitStore.swift b/apps/macos/Sources/eWiz/ChargeLimitStore.swift similarity index 100% rename from Sources/eWiz/ChargeLimitStore.swift rename to apps/macos/Sources/eWiz/ChargeLimitStore.swift diff --git a/Sources/eWiz/ChargeMatrix.swift b/apps/macos/Sources/eWiz/ChargeMatrix.swift similarity index 100% rename from Sources/eWiz/ChargeMatrix.swift rename to apps/macos/Sources/eWiz/ChargeMatrix.swift diff --git a/Sources/eWiz/ChargeOverlay.swift b/apps/macos/Sources/eWiz/ChargeOverlay.swift similarity index 100% rename from Sources/eWiz/ChargeOverlay.swift rename to apps/macos/Sources/eWiz/ChargeOverlay.swift diff --git a/Sources/eWiz/ChargeSound.swift b/apps/macos/Sources/eWiz/ChargeSound.swift similarity index 100% rename from Sources/eWiz/ChargeSound.swift rename to apps/macos/Sources/eWiz/ChargeSound.swift diff --git a/Sources/eWiz/ClamshellMode.swift b/apps/macos/Sources/eWiz/ClamshellMode.swift similarity index 100% rename from Sources/eWiz/ClamshellMode.swift rename to apps/macos/Sources/eWiz/ClamshellMode.swift diff --git a/Sources/eWiz/DesignSystem.swift b/apps/macos/Sources/eWiz/DesignSystem.swift similarity index 100% rename from Sources/eWiz/DesignSystem.swift rename to apps/macos/Sources/eWiz/DesignSystem.swift diff --git a/Sources/eWiz/DetailsView.swift b/apps/macos/Sources/eWiz/DetailsView.swift similarity index 100% rename from Sources/eWiz/DetailsView.swift rename to apps/macos/Sources/eWiz/DetailsView.swift diff --git a/Sources/eWiz/EWizApp.swift b/apps/macos/Sources/eWiz/EWizApp.swift similarity index 100% rename from Sources/eWiz/EWizApp.swift rename to apps/macos/Sources/eWiz/EWizApp.swift diff --git a/Sources/eWiz/HapticFeedback.swift b/apps/macos/Sources/eWiz/HapticFeedback.swift similarity index 100% rename from Sources/eWiz/HapticFeedback.swift rename to apps/macos/Sources/eWiz/HapticFeedback.swift diff --git a/Sources/eWiz/HelperInstaller.swift b/apps/macos/Sources/eWiz/HelperInstaller.swift similarity index 100% rename from Sources/eWiz/HelperInstaller.swift rename to apps/macos/Sources/eWiz/HelperInstaller.swift diff --git a/Sources/eWiz/HelperService.swift b/apps/macos/Sources/eWiz/HelperService.swift similarity index 100% rename from Sources/eWiz/HelperService.swift rename to apps/macos/Sources/eWiz/HelperService.swift diff --git a/Sources/eWiz/HistoryStoreGUI.swift b/apps/macos/Sources/eWiz/HistoryStoreGUI.swift similarity index 100% rename from Sources/eWiz/HistoryStoreGUI.swift rename to apps/macos/Sources/eWiz/HistoryStoreGUI.swift diff --git a/Sources/eWiz/HistoryView.swift b/apps/macos/Sources/eWiz/HistoryView.swift similarity index 100% rename from Sources/eWiz/HistoryView.swift rename to apps/macos/Sources/eWiz/HistoryView.swift diff --git a/Sources/eWiz/HotkeyHUD.swift b/apps/macos/Sources/eWiz/HotkeyHUD.swift similarity index 100% rename from Sources/eWiz/HotkeyHUD.swift rename to apps/macos/Sources/eWiz/HotkeyHUD.swift diff --git a/Sources/eWiz/HotkeyMonitor.swift b/apps/macos/Sources/eWiz/HotkeyMonitor.swift similarity index 100% rename from Sources/eWiz/HotkeyMonitor.swift rename to apps/macos/Sources/eWiz/HotkeyMonitor.swift diff --git a/Sources/eWiz/HotkeyRecorderField.swift b/apps/macos/Sources/eWiz/HotkeyRecorderField.swift similarity index 100% rename from Sources/eWiz/HotkeyRecorderField.swift rename to apps/macos/Sources/eWiz/HotkeyRecorderField.swift diff --git a/Sources/eWiz/HotkeyStore.swift b/apps/macos/Sources/eWiz/HotkeyStore.swift similarity index 100% rename from Sources/eWiz/HotkeyStore.swift rename to apps/macos/Sources/eWiz/HotkeyStore.swift diff --git a/Sources/eWiz/HugeIcon.swift b/apps/macos/Sources/eWiz/HugeIcon.swift similarity index 100% rename from Sources/eWiz/HugeIcon.swift rename to apps/macos/Sources/eWiz/HugeIcon.swift diff --git a/Sources/eWiz/HugeIconsData.swift b/apps/macos/Sources/eWiz/HugeIconsData.swift similarity index 100% rename from Sources/eWiz/HugeIconsData.swift rename to apps/macos/Sources/eWiz/HugeIconsData.swift diff --git a/Sources/eWiz/IdleSaverStore.swift b/apps/macos/Sources/eWiz/IdleSaverStore.swift similarity index 100% rename from Sources/eWiz/IdleSaverStore.swift rename to apps/macos/Sources/eWiz/IdleSaverStore.swift diff --git a/Sources/eWiz/LegacyMigration.swift b/apps/macos/Sources/eWiz/LegacyMigration.swift similarity index 100% rename from Sources/eWiz/LegacyMigration.swift rename to apps/macos/Sources/eWiz/LegacyMigration.swift diff --git a/Sources/eWiz/LicenseManager.swift b/apps/macos/Sources/eWiz/LicenseManager.swift similarity index 100% rename from Sources/eWiz/LicenseManager.swift rename to apps/macos/Sources/eWiz/LicenseManager.swift diff --git a/Sources/eWiz/LicenseView.swift b/apps/macos/Sources/eWiz/LicenseView.swift similarity index 100% rename from Sources/eWiz/LicenseView.swift rename to apps/macos/Sources/eWiz/LicenseView.swift diff --git a/Sources/eWiz/LidMonitor.swift b/apps/macos/Sources/eWiz/LidMonitor.swift similarity index 100% rename from Sources/eWiz/LidMonitor.swift rename to apps/macos/Sources/eWiz/LidMonitor.swift diff --git a/Sources/eWiz/MenuBarController.swift b/apps/macos/Sources/eWiz/MenuBarController.swift similarity index 100% rename from Sources/eWiz/MenuBarController.swift rename to apps/macos/Sources/eWiz/MenuBarController.swift diff --git a/Sources/eWiz/MenuContentView.swift b/apps/macos/Sources/eWiz/MenuContentView.swift similarity index 100% rename from Sources/eWiz/MenuContentView.swift rename to apps/macos/Sources/eWiz/MenuContentView.swift diff --git a/Sources/eWiz/NetworkProfileStore.swift b/apps/macos/Sources/eWiz/NetworkProfileStore.swift similarity index 100% rename from Sources/eWiz/NetworkProfileStore.swift rename to apps/macos/Sources/eWiz/NetworkProfileStore.swift diff --git a/Sources/eWiz/NotificationIcon.swift b/apps/macos/Sources/eWiz/NotificationIcon.swift similarity index 100% rename from Sources/eWiz/NotificationIcon.swift rename to apps/macos/Sources/eWiz/NotificationIcon.swift diff --git a/Sources/eWiz/NotificationManager.swift b/apps/macos/Sources/eWiz/NotificationManager.swift similarity index 100% rename from Sources/eWiz/NotificationManager.swift rename to apps/macos/Sources/eWiz/NotificationManager.swift diff --git a/Sources/eWiz/PerceptualColor.swift b/apps/macos/Sources/eWiz/PerceptualColor.swift similarity index 100% rename from Sources/eWiz/PerceptualColor.swift rename to apps/macos/Sources/eWiz/PerceptualColor.swift diff --git a/Sources/eWiz/ProcessMonitor.swift b/apps/macos/Sources/eWiz/ProcessMonitor.swift similarity index 100% rename from Sources/eWiz/ProcessMonitor.swift rename to apps/macos/Sources/eWiz/ProcessMonitor.swift diff --git a/Sources/eWiz/ProcessPickerView.swift b/apps/macos/Sources/eWiz/ProcessPickerView.swift similarity index 100% rename from Sources/eWiz/ProcessPickerView.swift rename to apps/macos/Sources/eWiz/ProcessPickerView.swift diff --git a/Sources/eWiz/RadioControl.swift b/apps/macos/Sources/eWiz/RadioControl.swift similarity index 100% rename from Sources/eWiz/RadioControl.swift rename to apps/macos/Sources/eWiz/RadioControl.swift diff --git a/Sources/eWiz/RestReminder.swift b/apps/macos/Sources/eWiz/RestReminder.swift similarity index 100% rename from Sources/eWiz/RestReminder.swift rename to apps/macos/Sources/eWiz/RestReminder.swift diff --git a/Sources/eWiz/ScheduleSettings.swift b/apps/macos/Sources/eWiz/ScheduleSettings.swift similarity index 100% rename from Sources/eWiz/ScheduleSettings.swift rename to apps/macos/Sources/eWiz/ScheduleSettings.swift diff --git a/Sources/eWiz/ScreenActivity.swift b/apps/macos/Sources/eWiz/ScreenActivity.swift similarity index 100% rename from Sources/eWiz/ScreenActivity.swift rename to apps/macos/Sources/eWiz/ScreenActivity.swift diff --git a/Sources/eWiz/SealedSleepView.swift b/apps/macos/Sources/eWiz/SealedSleepView.swift similarity index 100% rename from Sources/eWiz/SealedSleepView.swift rename to apps/macos/Sources/eWiz/SealedSleepView.swift diff --git a/Sources/eWiz/SettingsView.swift b/apps/macos/Sources/eWiz/SettingsView.swift similarity index 100% rename from Sources/eWiz/SettingsView.swift rename to apps/macos/Sources/eWiz/SettingsView.swift diff --git a/Sources/eWiz/StartupManager.swift b/apps/macos/Sources/eWiz/StartupManager.swift similarity index 100% rename from Sources/eWiz/StartupManager.swift rename to apps/macos/Sources/eWiz/StartupManager.swift diff --git a/Sources/eWiz/SupportInfo.swift b/apps/macos/Sources/eWiz/SupportInfo.swift similarity index 100% rename from Sources/eWiz/SupportInfo.swift rename to apps/macos/Sources/eWiz/SupportInfo.swift diff --git a/Sources/eWiz/SystemActions.swift b/apps/macos/Sources/eWiz/SystemActions.swift similarity index 100% rename from Sources/eWiz/SystemActions.swift rename to apps/macos/Sources/eWiz/SystemActions.swift diff --git a/Sources/eWiz/TriggerSensors.swift b/apps/macos/Sources/eWiz/TriggerSensors.swift similarity index 100% rename from Sources/eWiz/TriggerSensors.swift rename to apps/macos/Sources/eWiz/TriggerSensors.swift diff --git a/Sources/eWiz/TriggerSettings.swift b/apps/macos/Sources/eWiz/TriggerSettings.swift similarity index 100% rename from Sources/eWiz/TriggerSettings.swift rename to apps/macos/Sources/eWiz/TriggerSettings.swift diff --git a/Sources/eWiz/TriggerStore.swift b/apps/macos/Sources/eWiz/TriggerStore.swift similarity index 100% rename from Sources/eWiz/TriggerStore.swift rename to apps/macos/Sources/eWiz/TriggerStore.swift diff --git a/Sources/eWiz/UpdaterManager.swift b/apps/macos/Sources/eWiz/UpdaterManager.swift similarity index 100% rename from Sources/eWiz/UpdaterManager.swift rename to apps/macos/Sources/eWiz/UpdaterManager.swift diff --git a/Sources/ewiz-helper/ControlServer.swift b/apps/macos/Sources/ewiz-helper/ControlServer.swift similarity index 100% rename from Sources/ewiz-helper/ControlServer.swift rename to apps/macos/Sources/ewiz-helper/ControlServer.swift diff --git a/Sources/ewiz-helper/Daemon.swift b/apps/macos/Sources/ewiz-helper/Daemon.swift similarity index 100% rename from Sources/ewiz-helper/Daemon.swift rename to apps/macos/Sources/ewiz-helper/Daemon.swift diff --git a/Sources/ewiz-helper/DeferredHibernate.swift b/apps/macos/Sources/ewiz-helper/DeferredHibernate.swift similarity index 100% rename from Sources/ewiz-helper/DeferredHibernate.swift rename to apps/macos/Sources/ewiz-helper/DeferredHibernate.swift diff --git a/Sources/ewiz-helper/FanRelease.swift b/apps/macos/Sources/ewiz-helper/FanRelease.swift similarity index 100% rename from Sources/ewiz-helper/FanRelease.swift rename to apps/macos/Sources/ewiz-helper/FanRelease.swift diff --git a/Sources/ewiz-helper/HelperLog.swift b/apps/macos/Sources/ewiz-helper/HelperLog.swift similarity index 100% rename from Sources/ewiz-helper/HelperLog.swift rename to apps/macos/Sources/ewiz-helper/HelperLog.swift diff --git a/Sources/ewiz-helper/HelperUpdate.swift b/apps/macos/Sources/ewiz-helper/HelperUpdate.swift similarity index 100% rename from Sources/ewiz-helper/HelperUpdate.swift rename to apps/macos/Sources/ewiz-helper/HelperUpdate.swift diff --git a/Sources/ewiz-helper/HighPowerMode.swift b/apps/macos/Sources/ewiz-helper/HighPowerMode.swift similarity index 100% rename from Sources/ewiz-helper/HighPowerMode.swift rename to apps/macos/Sources/ewiz-helper/HighPowerMode.swift diff --git a/Sources/ewiz-helper/LegacyHelper.swift b/apps/macos/Sources/ewiz-helper/LegacyHelper.swift similarity index 100% rename from Sources/ewiz-helper/LegacyHelper.swift rename to apps/macos/Sources/ewiz-helper/LegacyHelper.swift diff --git a/Sources/ewiz-helper/LowPowerMode.swift b/apps/macos/Sources/ewiz-helper/LowPowerMode.swift similarity index 100% rename from Sources/ewiz-helper/LowPowerMode.swift rename to apps/macos/Sources/ewiz-helper/LowPowerMode.swift diff --git a/Sources/ewiz-helper/PowerSettings.swift b/apps/macos/Sources/ewiz-helper/PowerSettings.swift similarity index 100% rename from Sources/ewiz-helper/PowerSettings.swift rename to apps/macos/Sources/ewiz-helper/PowerSettings.swift diff --git a/Sources/ewiz-helper/ProcessScan.swift b/apps/macos/Sources/ewiz-helper/ProcessScan.swift similarity index 100% rename from Sources/ewiz-helper/ProcessScan.swift rename to apps/macos/Sources/ewiz-helper/ProcessScan.swift diff --git a/Sources/ewiz-helper/ScheduledWake.swift b/apps/macos/Sources/ewiz-helper/ScheduledWake.swift similarity index 100% rename from Sources/ewiz-helper/ScheduledWake.swift rename to apps/macos/Sources/ewiz-helper/ScheduledWake.swift diff --git a/Sources/ewiz-helper/SealedSleepController.swift b/apps/macos/Sources/ewiz-helper/SealedSleepController.swift similarity index 100% rename from Sources/ewiz-helper/SealedSleepController.swift rename to apps/macos/Sources/ewiz-helper/SealedSleepController.swift diff --git a/Sources/ewiz-helper/Shell.swift b/apps/macos/Sources/ewiz-helper/Shell.swift similarity index 100% rename from Sources/ewiz-helper/Shell.swift rename to apps/macos/Sources/ewiz-helper/Shell.swift diff --git a/Sources/ewiz-helper/SleepWatcher.swift b/apps/macos/Sources/ewiz-helper/SleepWatcher.swift similarity index 100% rename from Sources/ewiz-helper/SleepWatcher.swift rename to apps/macos/Sources/ewiz-helper/SleepWatcher.swift diff --git a/Sources/ewiz-helper/main.swift b/apps/macos/Sources/ewiz-helper/main.swift similarity index 100% rename from Sources/ewiz-helper/main.swift rename to apps/macos/Sources/ewiz-helper/main.swift diff --git a/Sources/ewiz-mcp/AgentAwake.swift b/apps/macos/Sources/ewiz-mcp/AgentAwake.swift similarity index 100% rename from Sources/ewiz-mcp/AgentAwake.swift rename to apps/macos/Sources/ewiz-mcp/AgentAwake.swift diff --git a/Sources/ewiz-mcp/BatteryChannel.swift b/apps/macos/Sources/ewiz-mcp/BatteryChannel.swift similarity index 100% rename from Sources/ewiz-mcp/BatteryChannel.swift rename to apps/macos/Sources/ewiz-mcp/BatteryChannel.swift diff --git a/Sources/ewiz-mcp/BatteryHook.swift b/apps/macos/Sources/ewiz-mcp/BatteryHook.swift similarity index 100% rename from Sources/ewiz-mcp/BatteryHook.swift rename to apps/macos/Sources/ewiz-mcp/BatteryHook.swift diff --git a/Sources/ewiz-mcp/MCPServer.swift b/apps/macos/Sources/ewiz-mcp/MCPServer.swift similarity index 100% rename from Sources/ewiz-mcp/MCPServer.swift rename to apps/macos/Sources/ewiz-mcp/MCPServer.swift diff --git a/Sources/ewiz-mcp/PowerTools.swift b/apps/macos/Sources/ewiz-mcp/PowerTools.swift similarity index 100% rename from Sources/ewiz-mcp/PowerTools.swift rename to apps/macos/Sources/ewiz-mcp/PowerTools.swift diff --git a/Sources/ewiz-mcp/main.swift b/apps/macos/Sources/ewiz-mcp/main.swift similarity index 100% rename from Sources/ewiz-mcp/main.swift rename to apps/macos/Sources/ewiz-mcp/main.swift diff --git a/Sources/licensetool/main.swift b/apps/macos/Sources/licensetool/main.swift similarity index 100% rename from Sources/licensetool/main.swift rename to apps/macos/Sources/licensetool/main.swift diff --git a/Tests/EWizKitTests/AgentLidHoldTests.swift b/apps/macos/Tests/EWizKitTests/AgentLidHoldTests.swift similarity index 100% rename from Tests/EWizKitTests/AgentLidHoldTests.swift rename to apps/macos/Tests/EWizKitTests/AgentLidHoldTests.swift diff --git a/Tests/EWizKitTests/AwakeScheduleTests.swift b/apps/macos/Tests/EWizKitTests/AwakeScheduleTests.swift similarity index 100% rename from Tests/EWizKitTests/AwakeScheduleTests.swift rename to apps/macos/Tests/EWizKitTests/AwakeScheduleTests.swift diff --git a/Tests/EWizKitTests/BatteryAlertsTests.swift b/apps/macos/Tests/EWizKitTests/BatteryAlertsTests.swift similarity index 100% rename from Tests/EWizKitTests/BatteryAlertsTests.swift rename to apps/macos/Tests/EWizKitTests/BatteryAlertsTests.swift diff --git a/Tests/EWizKitTests/CaffeineManagerTests.swift b/apps/macos/Tests/EWizKitTests/CaffeineManagerTests.swift similarity index 100% rename from Tests/EWizKitTests/CaffeineManagerTests.swift rename to apps/macos/Tests/EWizKitTests/CaffeineManagerTests.swift diff --git a/Tests/EWizKitTests/ChargeDisplayTests.swift b/apps/macos/Tests/EWizKitTests/ChargeDisplayTests.swift similarity index 100% rename from Tests/EWizKitTests/ChargeDisplayTests.swift rename to apps/macos/Tests/EWizKitTests/ChargeDisplayTests.swift diff --git a/Tests/EWizKitTests/ChargeHoldTests.swift b/apps/macos/Tests/EWizKitTests/ChargeHoldTests.swift similarity index 100% rename from Tests/EWizKitTests/ChargeHoldTests.swift rename to apps/macos/Tests/EWizKitTests/ChargeHoldTests.swift diff --git a/Tests/EWizKitTests/ChargePaletteTests.swift b/apps/macos/Tests/EWizKitTests/ChargePaletteTests.swift similarity index 100% rename from Tests/EWizKitTests/ChargePaletteTests.swift rename to apps/macos/Tests/EWizKitTests/ChargePaletteTests.swift diff --git a/Tests/EWizKitTests/ConfigCompatibilityTests.swift b/apps/macos/Tests/EWizKitTests/ConfigCompatibilityTests.swift similarity index 100% rename from Tests/EWizKitTests/ConfigCompatibilityTests.swift rename to apps/macos/Tests/EWizKitTests/ConfigCompatibilityTests.swift diff --git a/Tests/EWizKitTests/ConfigMergeTests.swift b/apps/macos/Tests/EWizKitTests/ConfigMergeTests.swift similarity index 100% rename from Tests/EWizKitTests/ConfigMergeTests.swift rename to apps/macos/Tests/EWizKitTests/ConfigMergeTests.swift diff --git a/Tests/EWizKitTests/EasingTests.swift b/apps/macos/Tests/EWizKitTests/EasingTests.swift similarity index 100% rename from Tests/EWizKitTests/EasingTests.swift rename to apps/macos/Tests/EWizKitTests/EasingTests.swift diff --git a/Tests/EWizKitTests/HotkeyTests.swift b/apps/macos/Tests/EWizKitTests/HotkeyTests.swift similarity index 100% rename from Tests/EWizKitTests/HotkeyTests.swift rename to apps/macos/Tests/EWizKitTests/HotkeyTests.swift diff --git a/Tests/EWizKitTests/LegacyBattlifyTests.swift b/apps/macos/Tests/EWizKitTests/LegacyBattlifyTests.swift similarity index 100% rename from Tests/EWizKitTests/LegacyBattlifyTests.swift rename to apps/macos/Tests/EWizKitTests/LegacyBattlifyTests.swift diff --git a/Tests/EWizKitTests/LicenseProductTests.swift b/apps/macos/Tests/EWizKitTests/LicenseProductTests.swift similarity index 100% rename from Tests/EWizKitTests/LicenseProductTests.swift rename to apps/macos/Tests/EWizKitTests/LicenseProductTests.swift diff --git a/Tests/EWizKitTests/LidHistoryTests.swift b/apps/macos/Tests/EWizKitTests/LidHistoryTests.swift similarity index 100% rename from Tests/EWizKitTests/LidHistoryTests.swift rename to apps/macos/Tests/EWizKitTests/LidHistoryTests.swift diff --git a/Tests/EWizKitTests/LongevityCareTests.swift b/apps/macos/Tests/EWizKitTests/LongevityCareTests.swift similarity index 100% rename from Tests/EWizKitTests/LongevityCareTests.swift rename to apps/macos/Tests/EWizKitTests/LongevityCareTests.swift diff --git a/Tests/EWizKitTests/MCPClientConfigTests.swift b/apps/macos/Tests/EWizKitTests/MCPClientConfigTests.swift similarity index 100% rename from Tests/EWizKitTests/MCPClientConfigTests.swift rename to apps/macos/Tests/EWizKitTests/MCPClientConfigTests.swift diff --git a/Tests/EWizKitTests/PathMorphTests.swift b/apps/macos/Tests/EWizKitTests/PathMorphTests.swift similarity index 100% rename from Tests/EWizKitTests/PathMorphTests.swift rename to apps/macos/Tests/EWizKitTests/PathMorphTests.swift diff --git a/Tests/EWizKitTests/PersistedLevelTests.swift b/apps/macos/Tests/EWizKitTests/PersistedLevelTests.swift similarity index 100% rename from Tests/EWizKitTests/PersistedLevelTests.swift rename to apps/macos/Tests/EWizKitTests/PersistedLevelTests.swift diff --git a/Tests/EWizKitTests/PowerFlowTests.swift b/apps/macos/Tests/EWizKitTests/PowerFlowTests.swift similarity index 100% rename from Tests/EWizKitTests/PowerFlowTests.swift rename to apps/macos/Tests/EWizKitTests/PowerFlowTests.swift diff --git a/Tests/EWizKitTests/RestAdvisorTests.swift b/apps/macos/Tests/EWizKitTests/RestAdvisorTests.swift similarity index 100% rename from Tests/EWizKitTests/RestAdvisorTests.swift rename to apps/macos/Tests/EWizKitTests/RestAdvisorTests.swift diff --git a/Tests/EWizKitTests/SaveModeTests.swift b/apps/macos/Tests/EWizKitTests/SaveModeTests.swift similarity index 100% rename from Tests/EWizKitTests/SaveModeTests.swift rename to apps/macos/Tests/EWizKitTests/SaveModeTests.swift diff --git a/Tests/EWizKitTests/ScheduledWakeRequestTests.swift b/apps/macos/Tests/EWizKitTests/ScheduledWakeRequestTests.swift similarity index 100% rename from Tests/EWizKitTests/ScheduledWakeRequestTests.swift rename to apps/macos/Tests/EWizKitTests/ScheduledWakeRequestTests.swift diff --git a/Tests/EWizKitTests/SealedSleepTests.swift b/apps/macos/Tests/EWizKitTests/SealedSleepTests.swift similarity index 100% rename from Tests/EWizKitTests/SealedSleepTests.swift rename to apps/macos/Tests/EWizKitTests/SealedSleepTests.swift diff --git a/Tests/EWizKitTests/TickPolicyTests.swift b/apps/macos/Tests/EWizKitTests/TickPolicyTests.swift similarity index 100% rename from Tests/EWizKitTests/TickPolicyTests.swift rename to apps/macos/Tests/EWizKitTests/TickPolicyTests.swift diff --git a/Tests/EWizKitTests/TriggerTests.swift b/apps/macos/Tests/EWizKitTests/TriggerTests.swift similarity index 100% rename from Tests/EWizKitTests/TriggerTests.swift rename to apps/macos/Tests/EWizKitTests/TriggerTests.swift diff --git a/Tests/EWizKitTests/UpdateSignatureTests.swift b/apps/macos/Tests/EWizKitTests/UpdateSignatureTests.swift similarity index 100% rename from Tests/EWizKitTests/UpdateSignatureTests.swift rename to apps/macos/Tests/EWizKitTests/UpdateSignatureTests.swift diff --git a/branding/AppIcon.icns b/apps/macos/branding/AppIcon.icns similarity index 100% rename from branding/AppIcon.icns rename to apps/macos/branding/AppIcon.icns diff --git a/branding/Assets.xcassets/AppIcon.appiconset/Contents.json b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/Contents.json rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_128x128.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_128x128.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_128x128.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_16x16.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_16x16.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_16x16.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_256x256.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_256x256.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_256x256.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_32x32.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_32x32.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_32x32.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_512x512.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_512x512.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_512x512.png diff --git a/branding/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png b/apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png similarity index 100% rename from branding/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png rename to apps/macos/branding/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png diff --git a/branding/Assets.xcassets/Contents.json b/apps/macos/branding/Assets.xcassets/Contents.json similarity index 100% rename from branding/Assets.xcassets/Contents.json rename to apps/macos/branding/Assets.xcassets/Contents.json diff --git a/branding/ewiz-icon.svg b/apps/macos/branding/ewiz-icon.svg similarity index 100% rename from branding/ewiz-icon.svg rename to apps/macos/branding/ewiz-icon.svg diff --git a/branding/ewiz-logo-showcase.html b/apps/macos/branding/ewiz-logo-showcase.html similarity index 100% rename from branding/ewiz-logo-showcase.html rename to apps/macos/branding/ewiz-logo-showcase.html diff --git a/apps/macos/package.json b/apps/macos/package.json new file mode 100644 index 0000000..8f5e376 --- /dev/null +++ b/apps/macos/package.json @@ -0,0 +1,11 @@ +{ + "name": "ewiz", + "version": "0.19.10", + "private": true, + "description": "Menu bar battery saver and charge limiter for Apple Silicon Macs", + "scripts": { + "build": "swift build", + "test": "./scripts/test.sh", + "package": "./scripts/package-app.sh" + } +} diff --git a/scripts/build-number.sh b/apps/macos/scripts/build-number.sh similarity index 100% rename from scripts/build-number.sh rename to apps/macos/scripts/build-number.sh diff --git a/scripts/com.ewiz.helper.daemon.plist b/apps/macos/scripts/com.ewiz.helper.daemon.plist similarity index 100% rename from scripts/com.ewiz.helper.daemon.plist rename to apps/macos/scripts/com.ewiz.helper.daemon.plist diff --git a/scripts/com.ewiz.helper.plist b/apps/macos/scripts/com.ewiz.helper.plist similarity index 100% rename from scripts/com.ewiz.helper.plist rename to apps/macos/scripts/com.ewiz.helper.plist diff --git a/scripts/install-helper-bundled.sh b/apps/macos/scripts/install-helper-bundled.sh similarity index 100% rename from scripts/install-helper-bundled.sh rename to apps/macos/scripts/install-helper-bundled.sh diff --git a/scripts/install-helper.sh b/apps/macos/scripts/install-helper.sh similarity index 100% rename from scripts/install-helper.sh rename to apps/macos/scripts/install-helper.sh diff --git a/scripts/license-mint.mjs b/apps/macos/scripts/license-mint.mjs similarity index 100% rename from scripts/license-mint.mjs rename to apps/macos/scripts/license-mint.mjs diff --git a/scripts/make-appcast.sh b/apps/macos/scripts/make-appcast.sh similarity index 100% rename from scripts/make-appcast.sh rename to apps/macos/scripts/make-appcast.sh diff --git a/scripts/make-cask.sh b/apps/macos/scripts/make-cask.sh similarity index 100% rename from scripts/make-cask.sh rename to apps/macos/scripts/make-cask.sh diff --git a/scripts/make-dmg.sh b/apps/macos/scripts/make-dmg.sh similarity index 100% rename from scripts/make-dmg.sh rename to apps/macos/scripts/make-dmg.sh diff --git a/scripts/make-icon.sh b/apps/macos/scripts/make-icon.sh similarity index 100% rename from scripts/make-icon.sh rename to apps/macos/scripts/make-icon.sh diff --git a/scripts/notarize.sh b/apps/macos/scripts/notarize.sh similarity index 100% rename from scripts/notarize.sh rename to apps/macos/scripts/notarize.sh diff --git a/scripts/package-app.sh b/apps/macos/scripts/package-app.sh similarity index 100% rename from scripts/package-app.sh rename to apps/macos/scripts/package-app.sh diff --git a/scripts/plug-trace.py b/apps/macos/scripts/plug-trace.py similarity index 100% rename from scripts/plug-trace.py rename to apps/macos/scripts/plug-trace.py diff --git a/scripts/release-notes.sh b/apps/macos/scripts/release-notes.sh similarity index 100% rename from scripts/release-notes.sh rename to apps/macos/scripts/release-notes.sh diff --git a/scripts/set-github-secrets.sh b/apps/macos/scripts/set-github-secrets.sh similarity index 100% rename from scripts/set-github-secrets.sh rename to apps/macos/scripts/set-github-secrets.sh diff --git a/scripts/test.sh b/apps/macos/scripts/test.sh similarity index 100% rename from scripts/test.sh rename to apps/macos/scripts/test.sh diff --git a/scripts/uninstall-helper.sh b/apps/macos/scripts/uninstall-helper.sh similarity index 100% rename from scripts/uninstall-helper.sh rename to apps/macos/scripts/uninstall-helper.sh diff --git a/apps/macos/turbo.json b/apps/macos/turbo.json new file mode 100644 index 0000000..342ae20 --- /dev/null +++ b/apps/macos/turbo.json @@ -0,0 +1,7 @@ +{ + "extends": ["//"], + "tasks": { + "build": { "cache": false }, + "test": { "cache": false } + } +} diff --git a/apps/web/.agents/auth.md b/apps/web/.agents/auth.md new file mode 100644 index 0000000..444618a --- /dev/null +++ b/apps/web/.agents/auth.md @@ -0,0 +1,26 @@ +# Auth Conventions + +## Auth Architecture + +- Better Auth config lives in `src/lib/auth/auth.ts`. +- Auth utilities are centralized in `src/lib/auth/*`. +- In components, prefer shared auth hooks (`useAuth`, `useAuthSuspense`) from `src/lib/auth/hooks.ts`. These reuse the same auth data as the route loader. +- For route loaders under `_auth`, prefer loader context user over duplicate auth fetches. + +## Route Guards + +- Protected route layout is `src/routes/_auth/route.tsx`. + - It enforces auth in `beforeLoad` using `ensureQueryData(authQueryOptions())`. + - It returns `{ user }`, which is available to all child route loaders via router context. +- Guest-only route layout is `src/routes/_guest/route.tsx`. + - It redirects authenticated users away from login/signup routes. + +## Server Functions and Mutations + +- Server functions can be called from both server and client code. + - Server call: executed directly on the server. + - Client call: treated as RPC and executed through an HTTP API request. +- Treat protected server functions like protected API routes from a security perspective. +- If a server function requires auth, always apply `authMiddleware` from `src/lib/auth/middleware.ts`. This applies even when called from an auth-protected route (`routes/_auth/**`). +- Route-level `beforeLoad` guards protect route navigation/rendering, but they do not replace server-function authorization. +- When auth is required, middleware-provided user context is the source of truth. diff --git a/apps/web/.agents/tanstack-patterns.md b/apps/web/.agents/tanstack-patterns.md new file mode 100644 index 0000000..9ad6e2c --- /dev/null +++ b/apps/web/.agents/tanstack-patterns.md @@ -0,0 +1,86 @@ + + +# TanStack Patterns + +## Route Group Conventions + +- Protected routes live under `src/routes/_auth/**`, enforced by `beforeLoad` in the `_auth` layout (`src/routes/_auth/route.tsx`). +- Guest-only routes live under `src/routes/_guest/**`, enforced by `beforeLoad` in the `_guest` layout (`src/routes/_guest/route.tsx`). +- Auth-specific route guard behavior and middleware rules are documented in `.agents/auth.md`. + +## Data Fetching + +Route loaders are isomorphic; they run on both server and client. They cannot directly access server-only APIs. + +```typescript +// Bad: direct server API access +loader: async () => { + const todos = await fs.readFile("todos.json"); + return { todos }; +}; +``` + +```typescript +// Good (minimal/valid): call a server function from the loader +loader: async () => { + const todos = await $getTodos({ data: {} }); + return { todos }; +}; +``` + +Instead of directly calling server functions in loaders, prefer wrapping in TanStack Query for better caching and reusability. + +```typescript +loader: async ({ context }) => { + // Best/Preferred: For read/data-fetching server functions, wrap in TanStack Query + const todos = await context.queryClient.ensureQueryData(todosQueryOptions()); + return { todos }; +}; + +// lib/todos/queries.ts +export const todosQueryOptions = () => + queryOptions({ + queryKey: ["todos"], + queryFn: ({ signal }) => $getTodos({ signal }), // TanStack Query calls the server function + }); +``` + +## Environment Shaking + +TanStack Start strips any code not referenced by a `createServerFn` handler from the client build. + +- Server-only code (database, fs) is automatically excluded from client bundles +- Only code inside `createServerFn` handlers goes to server bundles +- Code outside handlers is included in both bundles + +## Importing Server Functions + +Server functions wrapped in `createServerFn` can be imported statically. Never use dynamic imports for server-only code in components. Prefix server function names with `$` (e.g. `$getUser`) for easier identification. + +```typescript +// Bad: dynamic import causes bundler issues +const rolesQuery = useQuery({ + queryFn: async () => { + const { $listRoles } = await import("#/utils/roles.server"); + return $listRoles({ data: {} }); + }, +}); + +// Good: static import +import { $listRoles } from "#/utils/roles.server"; + +const rolesQuery = useQuery({ + queryFn: async () => $listRoles({ data: {} }), +}); +``` + +## Server-Only Import Rules + +1. `createServerFn` wrappers can be imported statically anywhere +2. Direct server-only code (database clients, fs) must only be imported: + - Inside `createServerFn` handlers + - In `*.server.ts` files + +## Auth-specific Patterns + +- See `.agents/auth.md` for auth middleware usage, route guards, and session/cookie patterns. diff --git a/apps/web/.agents/typescript.md b/apps/web/.agents/typescript.md new file mode 100644 index 0000000..c845615 --- /dev/null +++ b/apps/web/.agents/typescript.md @@ -0,0 +1,47 @@ + + +# TypeScript Conventions + +## Avoid Type Casting + +Never cast types unless absolutely necessary. This includes: + +- Manual generic type parameters (e.g., ``) +- Type assertions using `as` +- Type assertions using `satisfies` + +## Prefer Type Inference + +Infer types by going up the logical chain: + +1. **Schema validation** as source of truth (e.g. Zod) +2. **Type inference** from function return types, API responses +3. **Fix at source** (schema, API definition, function signature) rather than casting at point of use + +```typescript +// Bad +const result = api.getData() as MyType; +const value = getValue(); + +// Good +const result = api.getData(); // Type inferred from return type +const value = getValue(); // Type inferred from implementation +``` + +## Generic Type Parameter Naming + +All generic type parameters must be prefixed with `T`. + +```typescript +// Bad +function withCapability( + handler: (user: AuthUser, ...args: Args) => R, +) { ... } + +// Good +function withCapability( + handler: (user: AuthUser, ...args: TArgs) => TReturn, +) { ... } +``` + +Common names: `T`, `TArgs`, `TReturn`, `TData`, `TError`, `TKey`, `TValue` diff --git a/apps/web/.agents/workflow.md b/apps/web/.agents/workflow.md new file mode 100644 index 0000000..cca3a2c --- /dev/null +++ b/apps/web/.agents/workflow.md @@ -0,0 +1,18 @@ +# Workflow + +## Build Commands + +- `pnpm build`: Only for build/bundler issues or verifying production output +- `pnpm lint`: Type-checking & type-aware linting +- `pnpm dev` runs indefinitely in watch mode +- `pnpm db` for Drizzle Kit commands (e.g. `pnpm db generate` to generate a migration) + +Don't build after every change. If lint & type checks pass; assume changes work. + +## Testing + +No testing framework is currently set up. Prefer lint checks for now. + +## Formatting + +Oxfmt is configured for consistent code formatting via `pnpm format`. It runs automatically on commit via Husky pre-commit hooks, so manual formatting is not necessary. diff --git a/apps/web/.editorconfig b/apps/web/.editorconfig new file mode 100644 index 0000000..2b4ac33 --- /dev/null +++ b/apps/web/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +max_line_length = 100 \ No newline at end of file diff --git a/apps/web/.env.example b/apps/web/.env.example new file mode 100644 index 0000000..54f0d4e --- /dev/null +++ b/apps/web/.env.example @@ -0,0 +1,41 @@ +# Copy this file to `.env` and fill in the real values. +# `.env` is gitignored — never commit real secrets. + +# Base URL of the site (used by auth + links) +VITE_BASE_URL="http://localhost:3000" + +# Postgres connection string +DATABASE_URL="postgres://user:password@localhost:5432/battlify" + +# Better Auth — generate with: pnpm auth:secret +BETTER_AUTH_SECRET="replace-with-a-long-random-string" + +# GitHub OAuth (https://github.com/settings/developers) +GITHUB_CLIENT_ID="" +GITHUB_CLIENT_SECRET="" + +# Google OAuth (https://console.cloud.google.com/apis/credentials) +GOOGLE_CLIENT_ID="" +GOOGLE_CLIENT_SECRET="" + +# Dodo Payments (https://app.dodopayments.com) +DODO_PAYMENTS_API_KEY="" +DODO_PAYMENTS_WEBHOOK_SECRET="" +DODO_PAYMENTS_ENVIRONMENT="test_mode" +DODO_BATTLIFY_PRODUCT_ID="" + +# License signing key (Ed25519 private key, PEM/base64) +LICENSE_SIGNING_PRIVATE_KEY="" + +# Read-only GitHub token for the stroke-app/ewiz releases API (optional; +# raises the rate limit the changelog and download pages fetch under) +GITHUB_RELEASES_TOKEN="" + +# --- PostHog analytics --- +# Public project key: safe to expose in the client bundle, so it's fine to commit. +VITE_PUBLIC_POSTHOG_KEY="phc_vC3Zpv7J3G7QrrJaayAMmwYoABnC8KZ8URmxbmLrvaXa" +VITE_PUBLIC_POSTHOG_HOST="https://us.i.posthog.com" +# Personal API key is for local tooling only (PostHog CLI/wizard) — NOT read by +# the app at runtime. Keep it out of the client and out of production. Set it in +# your local .env only if a tool needs it: +# POSTHOG_PERSONAL_API_KEY="" diff --git a/apps/web/.gitattributes b/apps/web/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/apps/web/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/apps/web/.gitignore b/apps/web/.gitignore new file mode 100644 index 0000000..620de0d --- /dev/null +++ b/apps/web/.gitignore @@ -0,0 +1,28 @@ +node_modules + +# Ignore lockfiles we don't use +# package-lock.json +# yarn.lock +# pnpm-lock.yaml +# bun.lock + +.DS_Store +.cache +.env +.env.* + +.data +.vercel +.output +.wrangler +.netlify +dist +/build/ +/api/ +/server/build +/public/build + +.tanstack +# Local Claude Code tool state +.claude/phobos-state.md +.claude/phobos-activity.log diff --git a/apps/web/.oxfmtrc.json b/apps/web/.oxfmtrc.json new file mode 100644 index 0000000..0df327f --- /dev/null +++ b/apps/web/.oxfmtrc.json @@ -0,0 +1,36 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "tabWidth": 2, + "semi": true, + "printWidth": 100, + "singleQuote": false, + "endOfLine": "lf", + "trailingComma": "all", + "sortImports": {}, + "sortTailwindcss": { + "stylesheet": "./src/styles.css", + "attributes": ["class", "className"], + "functions": ["clsx", "cn", "cva", "tw"] + }, + "sortPackageJson": true, + "ignorePatterns": [ + "pnpm-lock.yaml", + "package-lock.json", + "yarn.lock", + "bun.lock", + "routeTree.gen.ts", + ".tanstack-start/", + ".tanstack/", + "drizzle/", + "migrations/", + ".drizzle/", + ".turbo", + ".cache", + "worker-configuration.d.ts", + ".vercel", + ".output", + ".wrangler", + ".netlify", + "dist" + ] +} diff --git a/apps/web/.oxlintrc.json b/apps/web/.oxlintrc.json new file mode 100644 index 0000000..307cc98 --- /dev/null +++ b/apps/web/.oxlintrc.json @@ -0,0 +1,73 @@ +{ + "$schema": "./node_modules/oxlint/configuration_schema.json", + "plugins": ["typescript", "react", "react-perf", "jsx-a11y"], + "env": { + "builtin": true, + "node": true, + "browser": true + }, + "options": { + "typeAware": true + }, + "jsPlugins": [ + { "name": "react-hooks-js", "specifier": "eslint-plugin-react-hooks" }, + // Plugins with "/" in name have to be aliased for now + // Issue: https://github.com/oxc-project/oxc/issues/14557 + { + "name": "eslint-tanstack-router", + "specifier": "@tanstack/eslint-plugin-router" + }, + { + "name": "eslint-tanstack-query", + "specifier": "@tanstack/eslint-plugin-query" + } + ], + "rules": { + "no-deprecated": "warn", + "typescript/no-floating-promises": "off", + "typescript/no-misused-spread": "off", + + "jsx-a11y/prefer-tag-over-role": "off", + + "eslint-tanstack-router/create-route-property-order": "warn", + + "eslint-tanstack-query/exhaustive-deps": "warn", + "eslint-tanstack-query/stable-query-client": "warn", + "eslint-tanstack-query/no-rest-destructuring": "warn", + "eslint-tanstack-query/no-unstable-deps": "warn", + "eslint-tanstack-query/infinite-query-property-order": "warn", + "eslint-tanstack-query/no-void-query-fn": "warn", + "eslint-tanstack-query/mutation-property-order": "warn", + + // ref: + // - https://github.com/TheAlexLichter/oxlint-react-compiler-rules/issues/1 + // - https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md#custom-configuration + // Recommended rules (from LintRulePreset.Recommended) + "react-hooks-js/config": "error", + "react-hooks-js/error-boundaries": "error", + "react-hooks-js/gating": "error", + "react-hooks-js/globals": "error", + "react-hooks-js/immutability": "error", + "react-hooks-js/incompatible-library": "warn", + "react-hooks-js/preserve-manual-memoization": "error", + "react-hooks-js/purity": "error", + "react-hooks-js/refs": "error", + "react-hooks-js/set-state-in-effect": "warn", + "react-hooks-js/set-state-in-render": "error", + "react-hooks-js/static-components": "error", + "react-hooks-js/unsupported-syntax": "warn", + "react-hooks-js/use-memo": "error", + // Recommended-latest rules (from LintRulePreset.RecommendedLatest) + "react-hooks-js/void-use-memo": "error" + }, + "ignorePatterns": [ + "dist", + ".wrangler", + ".vercel", + ".netlify", + ".output", + "build/", + "worker-configuration.d.ts", + "scripts/" + ] +} diff --git a/apps/web/.vscode/extensions.json b/apps/web/.vscode/extensions.json new file mode 100644 index 0000000..4ea727f --- /dev/null +++ b/apps/web/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["oxc.oxc-vscode", "bradlc.vscode-tailwindcss"] +} diff --git a/apps/web/.vscode/mcp.json b/apps/web/.vscode/mcp.json new file mode 100644 index 0000000..fd7d236 --- /dev/null +++ b/apps/web/.vscode/mcp.json @@ -0,0 +1,11 @@ +{ + "servers": { + "better-auth": { + "url": "https://mcp.inkeep.com/better-auth/mcp" + }, + "shadcn": { + "command": "npx", + "args": ["-y", "shadcn@latest", "mcp"] + } + } +} diff --git a/apps/web/.vscode/settings.json b/apps/web/.vscode/settings.json new file mode 100644 index 0000000..04d0dde --- /dev/null +++ b/apps/web/.vscode/settings.json @@ -0,0 +1,44 @@ +{ + "files.readonlyInclude": { + "**/routeTree.gen.ts": true, + "**/.tanstack/**/*": true, + "pnpm-lock.yaml": true, + "bun.lock": true + }, + "files.watcherExclude": { + "**/routeTree.gen.ts": true, + "**/.tanstack/**/*": true, + "pnpm-lock.yaml": true, + "bun.lock": true + }, + "search.exclude": { + "**/routeTree.gen.ts": true, + "**/.tanstack/**/*": true, + "pnpm-lock.yaml": true, + "bun.lock": true + }, + + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.patterns": { + "tsconfig.json": "tsconfig.*.json, env.d.ts", + "vite.config.*": "jsconfig*, vitest.config.*, cypress.config.*, playwright.config.*", + "package.json": "package-lock.json, pnpm*, .yarnrc*, yarn*, .editorconfig, .gitattributes, oxfmt*, oxlint*, .oxfmt*, .oxlint*, commitlint.config*, bun.lock" + }, + + // use LF line endings + "files.eol": "\n", + + // disable prettier, eslint, biome + "prettier.enable": false, + "eslint.enable": false, + "biome.enabled": false, + // enable oxlint + oxfmt + "oxc.enable": true, + + // format on save and paste + "editor.formatOnSave": true, + "editor.formatOnPaste": true, + + // set oxfmt as default formatter + "editor.defaultFormatter": "oxc.oxc-vscode" +} diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md new file mode 100644 index 0000000..a29c468 --- /dev/null +++ b/apps/web/AGENTS.md @@ -0,0 +1,43 @@ +# Agent Guidelines + +## Essentials + +- Stack: TypeScript + React (TanStack Start), with Drizzle ORM, shadcn/ui, and Better Auth. +- Use shadcn CLI (`bun run ui add `) for adding new UI components & primitives. +- Use `lucide-react` for UI icons (use `Icon` suffix, e.g. `import { Loader2Icon } from "lucide-react"`); for brand icons use `@icons-pack/react-simple-icons` (e.g. `SiGithub`). +- Don't build after every little change. If `bun run lint` passes; assume changes work. + +## Topic-specific Guidelines + +- [TanStack patterns](.agents/tanstack-patterns.md) - Routing, data fetching, loaders, server functions, environment shaking +- [Auth patterns](.agents/auth.md) - Route guards, middleware, auth utilities +- [TypeScript conventions](.agents/typescript.md) - Casting rules, prefer type inference +- [Workflow](.agents/workflow.md) - Workflow commands, validation approach + + + +## Skill Loading + +Before substantial work: + +- Skill check: run `bun run intent list`, or use skills already listed in context. +- Skill guidance: if one local skill clearly matches the task, run `bun run intent load #` and follow the returned `SKILL.md`. +- Multiple matches: prefer the most specific local skill for the package or concern you are changing; load additional skills only when the task spans multiple packages or concerns. + + +## TanStack Docs + +Use `bun run tanstack` (aliased to `bun run dlx @tanstack/cli@latest`) to look up TanStack documentation. Always pass `--json` for machine-readable output. + +```bash +# List TanStack libraries (optionally filter by --group state|headlessUI|performance|tooling) +bun run tanstack libraries --json + +# Fetch a specific doc page +bun run tanstack doc router framework/react/guide/data-loading --json +bun run tanstack doc query framework/react/overview --docs-version v5 --json + +# Search docs (optionally filter by --library, --framework, --limit) +bun run tanstack search-docs "server functions" --library start --json +bun run tanstack search-docs "loaders" --library router --framework react --json +``` diff --git a/apps/web/LICENSE b/apps/web/LICENSE new file mode 100644 index 0000000..ea0e0b7 --- /dev/null +++ b/apps/web/LICENSE @@ -0,0 +1,69 @@ +# eWiz License + +Copyright (c) 2026 Nischal Dahal + +You may do whatever you want with the eWiz source code and other source files +in this repository, which holds the eWiz website and the eWiz update feed (from +here on referred to as the "eWiz Source"), with the following restrictions: + +- If you publish any work derived from the eWiz Source, you must make it apparent + in some way that it is derived from the eWiz Source. + +- If you have created an executable program, website or online service (from + here on called "Your Program") built or compiled from some source code and/or + other source files (from here on called "Your Source"), and if Your Source + includes files or source code copied or derived from the eWiz Source, then you + may only publish Your Program under the following conditions. For a website or + online service, publishing means making it available to anyone other than + yourself. + + - Your Program does not contain any malware or hidden malicious content. + + - You may not charge users money for Your Program, and Your Source must + contain the monetization systems present in the eWiz Source, including the + license key, checkout and payment systems, without any alterations, and all + of these systems must be active and working as intended in Your Program, + paying the original author. That is unless Your Source features substantial + improvements or additions to the eWiz Source, such that Your Source should + be considered its own, derivative work, separate from the eWiz Source. + + - You may not publish Your Program under the name "eWiz", or under a name or + with an icon so similar that users could mistake it for eWiz. + +THE EWIZ SOURCE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE EWIZ SOURCE OR THE USE OR OTHER DEALINGS IN THE EWIZ SOURCE. + +--- + +# Notes on the eWiz License + +The eWiz License has two goals: + +1. To stop people with bad intentions, or people out for a quick buck, from + publishing sites or apps based on eWiz: a copy of the eWiz website that hands + out malware in place of the real download, or one that sells eWiz licenses + while someone other than the author gets paid. + +2. To let everyone else do anything they like with the eWiz source code: reuse it + in their own free or paid projects, write bug fixes and improvements to eWiz and + publish them, or make a substantial improvement to eWiz and charge for that + improved version or release it for free. + +The license is meant to be open source in spirit, with protections against bad +actors now that eWiz is a paid app. Note that there are no restrictions at all on +how you use the source code, only on publishing programs, websites or services +built from it. + +eWiz is "source-available", not open source by the OSI definition, because of the +publishing restrictions above. + +Buying eWiz buys a license key for the eWiz app; it does not change these terms, +which govern the source code. + +The eWiz app's own repository carries the same license, worded for the Mac app. +Files in this repository that carry their own license notice, such as the +generated Cloudflare type definitions, stay under that notice. diff --git a/apps/web/README.md b/apps/web/README.md new file mode 100644 index 0000000..1698631 --- /dev/null +++ b/apps/web/README.md @@ -0,0 +1,97 @@ +# [TanStarter](https://github.com/mugnavo/tanstarter) + + + +A minimal starter template for 🏝️ TanStack Start. [→ Preview here](https://tanstarter.mugnavo.com/) + +```bash +pnpm create mugnavo +``` + +- [React 19](https://react.dev) + [React Compiler](https://react.dev/learn/react-compiler) +- TanStack [Start](https://tanstack.com/start/latest) + [Router](https://tanstack.com/router/latest) + [Query](https://tanstack.com/query/latest) +- [Tailwind CSS](https://tailwindcss.com/) + [shadcn/ui](https://ui.shadcn.com/) + [Base UI](https://base-ui.com/) (base-rhea, [`--preset b1au68YWO`](https://ui.shadcn.com/create?preset=b1au68YWO&base=base&template=start&pointer=true)) +- [Vite 8](https://vite.dev) + [Nitro v3](https://nitro.build/) +- [Drizzle ORM](https://orm.drizzle.team/) + PostgreSQL +- [Better Auth](https://better-auth.com/) +- [Oxlint](https://oxc.rs/docs/guide/usage/linter.html) + [Oxfmt](https://oxc.rs/docs/guide/usage/formatter.html) + +> [!TIP] +> This template is also available as a monorepo, powered by [Vite+](https://viteplus.dev/) and pnpm. See [mugnavo/tanstarter-plus](https://github.com/mugnavo/tanstarter-plus). + +## Getting Started + +1. [Use this template](https://github.com/new?template_name=tanstarter&template_owner=mugnavo) or create a project using our CLI: + + ```bash + pnpm create mugnavo + ``` + +2. Create a `.env` file based on [`.env.example`](./.env.example). + +3. Generate the initial migration with drizzle-kit, then apply to your database: + + ```sh + pnpm db generate + pnpm db migrate + ``` + + https://orm.drizzle.team/docs/migrations + +4. Run the development server: + + ```bash + pnpm dev + ``` + + The development server should now be running at [http://localhost:3000](http://localhost:3000). + +## Deploying to production + +[![Netlify Status](https://api.netlify.com/api/v1/badges/66acdee6-8e42-436f-9943-a67cad998f63/deploy-status)](https://app.netlify.com/projects/mugnavo-tanstarter/deploys) + +The [vite config](./vite.config.ts#L19-L20) is configured to use Nitro by default, which supports many [deployment presets](https://nitro.build/deploy) like Netlify, Vercel, Node.js, and more. + +Refer to the [TanStack Start hosting docs](https://tanstack.com/start/latest/docs/framework/react/guide/hosting) for more information. + +## Issue watchlist + +- [Router/Start issues](https://github.com/TanStack/router/issues) - TanStack Start is in RC. +- [Devtools releases](https://github.com/TanStack/devtools/releases) - TanStack Devtools is in alpha and may still have breaking changes. +- [Nitro v3 beta](https://nitro.build/blog/v3-beta) - The template is configured with Nitro v3 beta by default. + +## Goodies + +#### Upgrading dependencies + +Dependency versions are pinned, so they may be slightly outdated when you create your project. To selectively upgrade packages, run `pnpm deps` or `pnx taze@latest -Ilw --maturity-period 3`. + +#### Scripts + +We use **pnpm** by default, but you can modify these scripts in [package.json](./package.json) to use your preferred package manager. + +- **`auth:generate`** - Regenerate the [auth db schema](./src/lib/db/schema/auth.schema.ts) if you've made changes to your Better Auth [config](./src/lib/auth/auth.ts). +- **`db`** - Run [drizzle-kit](https://orm.drizzle.team/docs/kit-overview) commands. (e.g. `pnpm db generate`, `pnpm db studio`) +- **`ui`** - The shadcn/ui CLI. (e.g. `pnpm ui add button`) +- **`format`**, **`lint`** - Run Oxfmt and Oxlint, or both via `pnpm check`. +- **`deps`** - Selectively upgrade dependencies via taze. + +#### Utilities + +- [`auth/middleware.ts`](./src/lib/auth/middleware.ts) - Sample middleware for enforcing authentication on server functions & API routes. +- [`theme-toggle.tsx`](./src/components/theme-toggle.tsx), [`theme-provider.tsx`](./src/components/theme-provider.tsx) - A theme toggle and provider for toggling between light and dark mode. + +## License + +This site is **source-available** under the [eWiz License](../LICENSE). It started from the TanStarter template, which is public domain via the [Unlicense](https://unlicense.org). + +## Ecosystem + +- [@tanstack/intent](https://tanstack.com/intent/latest/docs/getting-started/quick-start-consumers) - Up-to-date skills for your AI agents, auto-synchronized from your installed dependencies. +- [awesome-tanstack-start](https://github.com/Balastrong/awesome-tanstack-start) - A curated list of awesome resources for TanStack Start. +- [shadcn/ui Directory](https://ui.shadcn.com/docs/directory), [MCP](https://ui.shadcn.com/docs/mcp), [shoogle.dev](https://shoogle.dev/) - Component directories & registries for shadcn/ui. + +## Related templates + +- [mugnavo/tanstarter-plus](https://github.com/mugnavo/tanstarter-plus) - A minimal monorepo version of this template, powered by Vite+ and pnpm workspaces. +- [tsu-moe/tsu-stack](https://github.com/tsu-moe/tsu-stack) - An opinionated and batteries-included monorepo template from Luzefiru, built on tanstarter-plus, with Paraglide.js (i18n), Hono, oRPC, and more. diff --git a/apps/web/SEO-AUDIT.md b/apps/web/SEO-AUDIT.md new file mode 100644 index 0000000..e5cba49 --- /dev/null +++ b/apps/web/SEO-AUDIT.md @@ -0,0 +1,72 @@ +# Battlify SEO Audit + +Snapshot after the SEO pass. URLs are environment-driven via `VITE_BASE_URL` +(localhost in dev, `battlify.discerns.app` in prod), so nothing is hardcoded. + +## 1. Title & meta optimization + +| Area | Status | Notes | +| ------------ | ------ | --------------------------------------------------------------------------- | +| Titles | ✅ | Central `seo()` helper. Home: brand title; inner pages: `Page \| Battlify`. | +| Descriptions | ✅ | Unique, human, ~150 chars per page. | +| Open Graph | ✅ | `og:type/site_name/title/description/url/image(+w/h)/locale` on every page. | +| Twitter card | ✅ | `summary_large_image` with title/description/image + `@broisnischal`. | +| Canonical | ✅ | One per page from `seo()`; root emits none (avoids duplicates). | +| Keywords | ✅ | Targeted keywords on home + blog posts. | + +## 2. Heading structure + +- Exactly one `

` per page; `

`/`

` nest correctly in the blog article and legal pages. No skipped levels found. + +## 3. Internal linking + +- Nav links Pricing, Blog, **Changelog (now internal `/changelog`, was pointing at the external GitHub URL)**, Community. +- Footer links Product/Connect + legal. Blog posts cross-link to home CTA. Breadcrumb JSON-LD on blog. + +## 4. Canonicalization + +- `/privacy` and `/terms` (the older `.blf` duplicates) now carry `robots: noindex, follow` and `canonical → /legal/privacy` and `/legal/terms`. Only one legal set is indexed. **Action for you: eventually delete one legal set to remove the duplication entirely.** + +## 5. Image alt text + +- No `` tags on the marketing site (all icons/mockups are inline SVG), so no alt gaps. Decorative SVGs carry `aria-hidden`. +- Social share image added: `public/og.png` (1200×630). + +## 6. Page speed signals + +- SSR on Cloudflare Workers, hashed assets with 1-year immutable cache (`_headers`). +- Fonts and CSS inlined via the app bundle. No render-blocking third-party scripts (PostHog loads client-side, no-ops without a key). +- LCP element is text/SVG hero (no large image). CLS low (fixed layouts). Recommend a Lighthouse run post-deploy to confirm INP. + +## 7. Structured data (JSON-LD) + +| Schema | Where | Rich result | +| ------------------- | -------------------------- | --------------------------------------------- | +| Organization | Home | Brand/knowledge panel | +| WebSite | Home | Site name | +| SoftwareApplication | Home | App result (price $2.99, macOS 14+, download) | +| FAQPage | Home (visible FAQ section) | FAQ rich result | +| Article | Blog post | Article result | +| BreadcrumbList | Blog index + post | Breadcrumb trail | + +- All validated structurally against schema.org types; entities linked by `@id`. Validate live post-deploy with Google Rich Results Test. +- **Missing/optional to consider:** `aggregateRating` on SoftwareApplication (needs real review data), `VideoObject` if a demo video is added. + +## 8. Content quality + +- Removed every user-facing em dash (the "AI tell") across blog, landing, legal, changelog, and the app dashboard; replaced with natural punctuation. Voice preserved. +- Blog article is deep, interactive, and cites primary sources (Battery University). Search intent for "macbook charge limit / battery health" is well covered. +- Added a 6-question FAQ answering real pre-purchase questions. +- **Gaps to fill:** thin content on older changelog entries (fine); consider 1–2 more articles ("How Battlify's charge limit works", "macOS 26 Tahoe battery changes") to build topical depth. + +## 9. Crawlability + +- Dynamic `robots.txt`: allows all public pages, disallows `/app`, `/login`, `/signup`, `/buy`, `/api/`, links the sitemap. +- Dynamic `sitemap.xml`: indexable pages + all blog posts with `lastmod`, `changefreq`, `priority`. Excludes the noindex duplicates. + +## Open items for you + +1. Delete one legal set (`/legal/*` vs `/privacy`+`/terms`) to fully remove duplication. +2. Fill the `[JURISDICTION]` placeholder in `/legal/terms`. +3. Replace the placeholder roadmap items in the changelog with real plans. +4. Run Lighthouse + Google Rich Results Test against the deployed domain. diff --git a/apps/web/components.json b/apps/web/components.json new file mode 100644 index 0000000..6015cd5 --- /dev/null +++ b/apps/web/components.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "base-rhea", + "rsc": false, + "tsx": true, + "tailwind": { + "config": "", + "css": "src/styles.css", + "baseColor": "neutral", + "cssVariables": true, + "prefix": "" + }, + "iconLibrary": "lucide", + "rtl": false, + "aliases": { + "components": "#/components", + "utils": "#/lib/utils", + "ui": "#/components/ui", + "lib": "#/lib", + "hooks": "#/hooks" + }, + "menuColor": "default", + "menuAccent": "subtle", + "registries": {} +} diff --git a/apps/web/docker-compose.yml b/apps/web/docker-compose.yml new file mode 100644 index 0000000..33bac1a --- /dev/null +++ b/apps/web/docker-compose.yml @@ -0,0 +1,16 @@ +services: + db: + image: postgres:alpine + ports: + # Host 5433 -> container 5432, to avoid clashing with a native + # postgres already listening on the host's 5432. + - 5433:5432 + volumes: + - postgres_data_tanstarter:/var/lib/postgresql + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=password + - POSTGRES_DB=tanstarter + +volumes: + postgres_data_tanstarter: diff --git a/apps/web/drizzle.config.ts b/apps/web/drizzle.config.ts new file mode 100644 index 0000000..0bab106 --- /dev/null +++ b/apps/web/drizzle.config.ts @@ -0,0 +1,17 @@ +import type { Config } from "drizzle-kit"; + +export default { + out: "./drizzle", + schema: "./src/lib/db/schema/index.ts", + breakpoints: true, + verbose: true, + strict: true, + dialect: "sqlite", + driver: "d1-http", + casing: "snake_case", + dbCredentials: { + accountId: process.env.CLOUDFLARE_ACCOUNT_ID!, + databaseId: process.env.CLOUDFLARE_DATABASE_ID!, + token: process.env.CLOUDFLARE_D1_TOKEN!, + }, +} satisfies Config; diff --git a/apps/web/drizzle/0000_init.sql b/apps/web/drizzle/0000_init.sql new file mode 100644 index 0000000..bad43dd --- /dev/null +++ b/apps/web/drizzle/0000_init.sql @@ -0,0 +1,70 @@ +CREATE TABLE `account` ( + `id` text PRIMARY KEY NOT NULL, + `account_id` text NOT NULL, + `provider_id` text NOT NULL, + `user_id` text NOT NULL, + `access_token` text, + `refresh_token` text, + `id_token` text, + `access_token_expires_at` integer, + `refresh_token_expires_at` integer, + `scope` text, + `password` text, + `created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +CREATE INDEX `account_userId_idx` ON `account` (`user_id`);--> statement-breakpoint +CREATE TABLE `session` ( + `id` text PRIMARY KEY NOT NULL, + `expires_at` integer NOT NULL, + `token` text NOT NULL, + `created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `ip_address` text, + `user_agent` text, + `user_id` text NOT NULL, + FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +CREATE UNIQUE INDEX `session_token_unique` ON `session` (`token`);--> statement-breakpoint +CREATE INDEX `session_userId_idx` ON `session` (`user_id`);--> statement-breakpoint +CREATE TABLE `user` ( + `id` text PRIMARY KEY NOT NULL, + `name` text NOT NULL, + `email` text NOT NULL, + `email_verified` integer DEFAULT false NOT NULL, + `image` text, + `created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `dodo_customer_id` text +); +--> statement-breakpoint +CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint +CREATE TABLE `verification` ( + `id` text PRIMARY KEY NOT NULL, + `identifier` text NOT NULL, + `value` text NOT NULL, + `expires_at` integer NOT NULL, + `created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL +); +--> statement-breakpoint +CREATE INDEX `verification_identifier_idx` ON `verification` (`identifier`);--> statement-breakpoint +CREATE TABLE `license` ( + `id` text PRIMARY KEY NOT NULL, + `user_id` text NOT NULL, + `email` text NOT NULL, + `name` text NOT NULL, + `product` text DEFAULT 'battlify' NOT NULL, + `key` text NOT NULL, + `dodo_payment_id` text, + `dodo_customer_id` text, + `issued_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +CREATE UNIQUE INDEX `license_user_id_unique` ON `license` (`user_id`);--> statement-breakpoint +CREATE INDEX `license_userId_idx` ON `license` (`user_id`); \ No newline at end of file diff --git a/apps/web/drizzle/0001_license_device_binding.sql b/apps/web/drizzle/0001_license_device_binding.sql new file mode 100644 index 0000000..297f47a --- /dev/null +++ b/apps/web/drizzle/0001_license_device_binding.sql @@ -0,0 +1,24 @@ +PRAGMA foreign_keys=OFF;--> statement-breakpoint +CREATE TABLE `__new_license` ( + `id` text PRIMARY KEY NOT NULL, + `user_id` text NOT NULL, + `email` text NOT NULL, + `name` text NOT NULL, + `product` text DEFAULT 'battlify' NOT NULL, + `key` text, + `device_code` text, + `device_bound_at` integer, + `rebind_count` integer DEFAULT 0 NOT NULL, + `dodo_payment_id` text, + `dodo_customer_id` text, + `issued_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + `created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL, + FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +INSERT INTO `__new_license`("id", "user_id", "email", "name", "product", "key", "dodo_payment_id", "dodo_customer_id", "issued_at", "created_at") SELECT "id", "user_id", "email", "name", "product", "key", "dodo_payment_id", "dodo_customer_id", "issued_at", "created_at" FROM `license`;--> statement-breakpoint +DROP TABLE `license`;--> statement-breakpoint +ALTER TABLE `__new_license` RENAME TO `license`;--> statement-breakpoint +PRAGMA foreign_keys=ON;--> statement-breakpoint +CREATE UNIQUE INDEX `license_user_id_unique` ON `license` (`user_id`);--> statement-breakpoint +CREATE INDEX `license_userId_idx` ON `license` (`user_id`); \ No newline at end of file diff --git a/apps/web/drizzle/meta/0000_snapshot.json b/apps/web/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..6b46105 --- /dev/null +++ b/apps/web/drizzle/meta/0000_snapshot.json @@ -0,0 +1,491 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "2cc7bcf1-e081-4af2-87a5-6c52ff10dd0d", + "prevId": "00000000-0000-0000-0000-000000000000", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "account_userId_idx": { + "name": "account_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_token_unique": { + "name": "session_token_unique", + "columns": [ + "token" + ], + "isUnique": true + }, + "session_userId_idx": { + "name": "session_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "dodo_customer_id": { + "name": "dodo_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email_unique": { + "name": "user_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "verification": { + "name": "verification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + "identifier" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "license": { + "name": "license", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product": { + "name": "product", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'battlify'" + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dodo_payment_id": { + "name": "dodo_payment_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dodo_customer_id": { + "name": "dodo_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "issued_at": { + "name": "issued_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "license_user_id_unique": { + "name": "license_user_id_unique", + "columns": [ + "user_id" + ], + "isUnique": true + }, + "license_userId_idx": { + "name": "license_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "license_user_id_user_id_fk": { + "name": "license_user_id_user_id_fk", + "tableFrom": "license", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/apps/web/drizzle/meta/0001_snapshot.json b/apps/web/drizzle/meta/0001_snapshot.json new file mode 100644 index 0000000..dd4922b --- /dev/null +++ b/apps/web/drizzle/meta/0001_snapshot.json @@ -0,0 +1,513 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "7d667c0b-33f9-40e6-956b-dc854e76b213", + "prevId": "2cc7bcf1-e081-4af2-87a5-6c52ff10dd0d", + "tables": { + "account": { + "name": "account", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "account_userId_idx": { + "name": "account_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "session_token_unique": { + "name": "session_token_unique", + "columns": [ + "token" + ], + "isUnique": true + }, + "session_userId_idx": { + "name": "session_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "dodo_customer_id": { + "name": "dodo_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "user_email_unique": { + "name": "user_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "verification": { + "name": "verification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + "identifier" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "license": { + "name": "license", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product": { + "name": "product", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'battlify'" + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_code": { + "name": "device_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "device_bound_at": { + "name": "device_bound_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "rebind_count": { + "name": "rebind_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "dodo_payment_id": { + "name": "dodo_payment_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dodo_customer_id": { + "name": "dodo_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "issued_at": { + "name": "issued_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsecond') * 1000 as integer))" + } + }, + "indexes": { + "license_user_id_unique": { + "name": "license_user_id_unique", + "columns": [ + "user_id" + ], + "isUnique": true + }, + "license_userId_idx": { + "name": "license_userId_idx", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "license_user_id_user_id_fk": { + "name": "license_user_id_user_id_fk", + "tableFrom": "license", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/apps/web/drizzle/meta/_journal.json b/apps/web/drizzle/meta/_journal.json new file mode 100644 index 0000000..881b0af --- /dev/null +++ b/apps/web/drizzle/meta/_journal.json @@ -0,0 +1,20 @@ +{ + "version": "7", + "dialect": "sqlite", + "entries": [ + { + "idx": 0, + "version": "6", + "when": 1782983559897, + "tag": "0000_init", + "breakpoints": true + }, + { + "idx": 1, + "version": "6", + "when": 1783070108246, + "tag": "0001_license_device_binding", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/apps/web/package.json b/apps/web/package.json new file mode 100644 index 0000000..78dec2f --- /dev/null +++ b/apps/web/package.json @@ -0,0 +1,97 @@ +{ + "name": "@ewiz/web", + "version": "0.0.1", + "private": true, + "license": "SEE LICENSE IN LICENSE", + "type": "module", + "scripts": { + "dev": "CI=true wrangler d1 migrations apply battlify --local && vite dev", + "build": "vite build", + "preview": "vite preview", + "deploy": "VITE_BASE_URL=https://ewiz.app vite build && wrangler types && CLOUDFLARE_ACCOUNT_ID=16b2c363a412bfaaec2a5a2572964728 CI=true wrangler d1 migrations apply battlify --remote; wrangler deploy", + "migrate:local": "CI=true wrangler d1 migrations apply battlify --local", + "migrate:remote": "CI=true wrangler d1 migrations apply battlify --remote", + "cf-gen": "wrangler types", + "lint": "oxlint --type-aware --type-check", + "lint:fix": "oxlint --type-aware --type-check --fix", + "format": "oxfmt", + "format:check": "oxfmt --check", + "check": "bun run format && bun run lint", + "db": "drizzle-kit", + "deps": "bunx taze@latest -Ilw --maturity-period 3", + "tanstack": "bunx @tanstack/cli@latest", + "ui": "bunx shadcn@latest", + "auth": "bunx auth@latest", + "auth:secret": "bunx auth@latest secret", + "auth:generate": "bunx auth@latest generate --config ./src/lib/auth/auth.ts --y --output ./src/lib/db/schema/auth.schema.ts", + "auth:migrate": "bun run auth:generate && bun run db generate && bun run db migrate", + "skills": "bunx skills@latest", + "intent": "bunx @tanstack/intent@latest" + }, + "dependencies": { + "@base-ui/react": "1.6.0", + "@better-auth/drizzle-adapter": "1.6.23", + "@dodopayments/better-auth": "^1.6.3", + "@fontsource-variable/bricolage-grotesque": "^5.2.10", + "@fontsource-variable/dm-sans": "^5.2.8", + "@fontsource-variable/geist-mono": "^5.2.8", + "@fontsource-variable/inter": "5.2.8", + "@fontsource-variable/syne": "^5.2.7", + "@hugeicons/core-free-icons": "^4.2.2", + "@hugeicons/react": "^1.1.9", + "@icons-pack/react-simple-icons": "13.13.0", + "@t3-oss/env-core": "0.13.11", + "@tanstack/react-query": "5.101.2", + "@tanstack/react-router": "1.170.16", + "@tanstack/react-router-ssr-query": "1.167.1", + "@tanstack/react-start": "1.168.26", + "better-auth": "1.6.23", + "class-variance-authority": "0.7.1", + "cnfast": "0.0.8", + "dodopayments": "^2.40.1", + "drizzle-orm": "0.45.2", + "lucide-react": "1.22.0", + "motion": "^12.42.2", + "postgres": "3.4.9", + "posthog-js": "^1.400.0", + "react": "19.2.7", + "react-dom": "19.2.7", + "shadcn": "4.12.0", + "sonner": "2.0.7", + "zod": "4.4.3" + }, + "devDependencies": { + "@babel/core": "8.0.1", + "@cloudflare/vite-plugin": "latest", + "@cloudflare/workers-types": "latest", + "@rolldown/plugin-babel": "0.2.3", + "@tailwindcss/vite": "4.3.2", + "@tanstack/devtools-a11y": "0.1.6", + "@tanstack/devtools-vite": "0.8.1", + "@tanstack/eslint-plugin-query": "5.101.2", + "@tanstack/eslint-plugin-router": "1.162.0", + "@tanstack/react-devtools": "0.10.8", + "@tanstack/react-query-devtools": "5.101.2", + "@tanstack/react-router-devtools": "1.167.0", + "@types/babel__core": "7.20.5", + "@types/node": "26.0.1", + "@types/react": "19.2.17", + "@types/react-dom": "19.2.3", + "@vitejs/plugin-react": "6.0.3", + "babel-plugin-react-compiler": "1.0.0", + "drizzle-kit": "0.31.10", + "eslint-plugin-react-hooks": "7.1.1", + "oxfmt": "0.57.0", + "oxlint": "1.72.0", + "oxlint-tsgolint": "0.23.0", + "tailwindcss": "4.3.2", + "tw-animate-css": "1.4.0", + "typescript": "6.0.3", + "vite": "8.1.0", + "wrangler": "latest" + }, + "lint-staged": { + "*": "oxfmt --no-error-on-unmatched-pattern" + }, + "generator": "create-mugnavo" +} diff --git a/apps/web/public/_headers b/apps/web/public/_headers new file mode 100644 index 0000000..f84cc43 --- /dev/null +++ b/apps/web/public/_headers @@ -0,0 +1,5 @@ +# This _headers file works for Netlify and Cloudflare. For other providers, you may want to configure these headers yourself, depending on your setup. + +# TanStack Start generated assets (hash-based filenames) +/assets/* + Cache-Control: public, max-age=31536000, immutable diff --git a/apps/web/public/apple-touch-icon.png b/apps/web/public/apple-touch-icon.png new file mode 100644 index 0000000..16667cc Binary files /dev/null and b/apps/web/public/apple-touch-icon.png differ diff --git a/apps/web/public/brand/ewiz-icon-1024.png b/apps/web/public/brand/ewiz-icon-1024.png new file mode 100644 index 0000000..178b36b Binary files /dev/null and b/apps/web/public/brand/ewiz-icon-1024.png differ diff --git a/apps/web/public/brand/ewiz-icon.svg b/apps/web/public/brand/ewiz-icon.svg new file mode 100644 index 0000000..723a2f6 --- /dev/null +++ b/apps/web/public/brand/ewiz-icon.svg @@ -0,0 +1,67 @@ + + eWiz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/web/public/ewiz-icon.svg b/apps/web/public/ewiz-icon.svg new file mode 100644 index 0000000..723a2f6 --- /dev/null +++ b/apps/web/public/ewiz-icon.svg @@ -0,0 +1,67 @@ + + eWiz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/web/public/favicon-32.png b/apps/web/public/favicon-32.png new file mode 100644 index 0000000..7b8199c Binary files /dev/null and b/apps/web/public/favicon-32.png differ diff --git a/apps/web/public/favicon.ico b/apps/web/public/favicon.ico new file mode 100644 index 0000000..e5d3cc3 Binary files /dev/null and b/apps/web/public/favicon.ico differ diff --git a/apps/web/public/favicon.svg b/apps/web/public/favicon.svg new file mode 100644 index 0000000..723a2f6 --- /dev/null +++ b/apps/web/public/favicon.svg @@ -0,0 +1,67 @@ + + eWiz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/web/public/icon-192.png b/apps/web/public/icon-192.png new file mode 100644 index 0000000..34dc65a Binary files /dev/null and b/apps/web/public/icon-192.png differ diff --git a/apps/web/public/icon-512.png b/apps/web/public/icon-512.png new file mode 100644 index 0000000..5b74a31 Binary files /dev/null and b/apps/web/public/icon-512.png differ diff --git a/apps/web/public/og.png b/apps/web/public/og.png new file mode 100644 index 0000000..cb0a09f Binary files /dev/null and b/apps/web/public/og.png differ diff --git a/apps/web/public/site.webmanifest b/apps/web/public/site.webmanifest new file mode 100644 index 0000000..549ef57 --- /dev/null +++ b/apps/web/public/site.webmanifest @@ -0,0 +1,14 @@ +{ + "name": "eWiz", + "short_name": "eWiz", + "description": "Menu bar battery care for Apple Silicon Macs.", + "start_url": "/", + "display": "browser", + "background_color": "#161616", + "theme_color": "#161616", + "icons": [ + { "src": "/icon-192.png?v=8", "sizes": "192x192", "type": "image/png" }, + { "src": "/icon-512.png?v=8", "sizes": "512x512", "type": "image/png" }, + { "src": "/favicon.svg?v=8", "sizes": "any", "type": "image/svg+xml" } + ] +} diff --git a/apps/web/src/components/analytics/posthog.tsx b/apps/web/src/components/analytics/posthog.tsx new file mode 100644 index 0000000..9ba2cd8 --- /dev/null +++ b/apps/web/src/components/analytics/posthog.tsx @@ -0,0 +1,73 @@ +import { useRouterState } from "@tanstack/react-router"; +import posthog from "posthog-js"; +import { PostHogProvider, usePostHog } from "posthog-js/react"; +import { type ReactNode, useEffect, useRef } from "react"; + +import { env } from "#/env/client"; +import { useAuth } from "#/lib/auth/hooks"; + +const POSTHOG_KEY = env.VITE_PUBLIC_POSTHOG_KEY; + +/** + * Wraps the app in PostHog. We init inside an effect so it only ever runs in + * the browser (posthog-js touches window/localStorage and would blow up during + * SSR). If there's no key configured, we just render children untouched. + */ +export function Analytics({ children }: { children: ReactNode }) { + useEffect(() => { + if (!POSTHOG_KEY || posthog.__loaded) return; + posthog.init(POSTHOG_KEY, { + api_host: env.VITE_PUBLIC_POSTHOG_HOST, + // We fire pageviews ourselves off the router (see PageViewTracker), since + // a client-side router doesn't do full page loads for PostHog to catch. + capture_pageview: false, + capture_pageleave: true, + person_profiles: "identified_only", + }); + }, []); + + if (!POSTHOG_KEY) return <>{children}; + + return ( + + + {children} + + ); +} + +/** Sends a $pageview whenever the router lands on a new URL. */ +function PageViewTracker() { + const ph = usePostHog(); + const href = useRouterState({ select: (s) => s.location.href }); + + useEffect(() => { + if (!ph) return; + ph.capture("$pageview", { $current_url: window.location.origin + href }); + }, [ph, href]); + + return null; +} + +/** + * Ties the signed-in user to their PostHog profile, and resets it when they + * sign out so the next person on the machine starts fresh. Call this from the + * authenticated layout, where the user is already loaded. + */ +export function usePostHogIdentify() { + const ph = usePostHog(); + const { user } = useAuth(); + const wasIdentified = useRef(false); + + useEffect(() => { + if (!ph) return; + + if (user) { + ph.identify(user.id, { email: user.email, name: user.name }); + wasIdentified.current = true; + } else if (wasIdentified.current) { + ph.reset(); + wasIdentified.current = false; + } + }, [ph, user]); +} diff --git a/apps/web/src/components/auth/auth-field.tsx b/apps/web/src/components/auth/auth-field.tsx new file mode 100644 index 0000000..233a7bd --- /dev/null +++ b/apps/web/src/components/auth/auth-field.tsx @@ -0,0 +1,63 @@ +import { EyeIcon, EyeOffIcon } from "@hugeicons/core-free-icons"; +import * as React from "react"; + +import { Icon } from "#/components/icon"; +import { Input } from "#/components/ui/input"; +import { Label } from "#/components/ui/label"; + +/** + * Labeled input with a leading icon (and, for passwords, a trailing show/hide + * toggle). Matches the auth-screen field style: taller control, red required + * asterisk, muted inline icon. + */ +export function AuthField({ + id, + label, + icon, + type = "text", + required, + rightSlot, + ...props +}: React.ComponentProps<"input"> & { + label: string; + icon: React.ReactNode; + /** Optional element rendered to the right of the label (e.g. "Forgot password?"). */ + rightSlot?: React.ReactNode; +}) { + const [show, setShow] = React.useState(false); + const isPassword = type === "password"; + const inputType = isPassword ? (show ? "text" : "password") : type; + + return ( +
+
+ + {rightSlot} +
+
+ + {icon} + + + {isPassword ? ( + + ) : null} +
+
+ ); +} diff --git a/apps/web/src/components/auth/sign-in-methods.tsx b/apps/web/src/components/auth/sign-in-methods.tsx new file mode 100644 index 0000000..1db882e --- /dev/null +++ b/apps/web/src/components/auth/sign-in-methods.tsx @@ -0,0 +1,91 @@ +import { SiGithub, SiGoogle } from "@icons-pack/react-simple-icons"; +import { useMutation, useQuery } from "@tanstack/react-query"; +import { CheckIcon, MailIcon } from "lucide-react"; +import { toast } from "sonner"; + +import { Button } from "#/components/ui/button"; +import { authClient } from "#/lib/auth/auth-client"; +import { $getSocialProviders } from "#/lib/auth/functions"; + +const PROVIDERS = [ + { id: "github", label: "GitHub", icon: SiGithub }, + { id: "google", label: "Google", icon: SiGoogle }, +] as const; + +/** + * Lists how this account can sign in and lets the user connect the other + * provider, so GitHub and Google both open the same account and license. + */ +export function SignInMethods() { + const { data: accounts } = useQuery({ + queryKey: ["auth", "accounts"], + queryFn: async () => { + const { data, error } = await authClient.listAccounts(); + if (error) throw new Error(error.message); + return data; + }, + }); + const { data: configured } = useQuery({ + queryKey: ["auth", "providers"], + queryFn: () => $getSocialProviders(), + staleTime: Infinity, + }); + const linked = new Set(accounts?.map((a) => a.providerId)); + const providers = PROVIDERS.filter((p) => configured?.[p.id] || linked.has(p.id)); + + const { + mutate: connect, + isPending, + variables, + } = useMutation({ + mutationFn: async (provider: (typeof PROVIDERS)[number]["id"]) => { + const { error } = await authClient.linkSocial({ provider, callbackURL: "/app" }); + if (error) throw new Error(error.message); + }, + onError: (error) => toast.error(error.message || "Couldn't connect that account."), + }); + + return ( +
+

Sign-in methods

+

+ Connect both so either one opens this account and your license. +

+
    + {providers.map((p) => ( +
  • + + + {p.label} + + {linked.has(p.id) ? ( + + + Connected + + ) : ( + + )} +
  • + ))} +
  • + + + Email and password + + + {linked.has("credential") ? "Set" : "Not set"} + +
  • +
+
+ ); +} diff --git a/apps/web/src/components/blog/viz/aging-explorer.tsx b/apps/web/src/components/blog/viz/aging-explorer.tsx new file mode 100644 index 0000000..0001095 --- /dev/null +++ b/apps/web/src/components/blog/viz/aging-explorer.tsx @@ -0,0 +1,168 @@ +import { useEffect, useRef, useState } from "react"; + +import { fitCanvas, useThemeColors } from "./canvas-utils"; +import { Figure, Slider } from "./figure"; + +/** Illustrative aging model (directionally right, not a spec): + * voltage stress doubles ~every 12% of ceiling above 80%, and heat doubles + * reaction rate ~every 10 °C (Arrhenius). The two multiply. */ +function agingRate(ceiling: number, temp: number): number { + const fV = Math.pow(2, (ceiling - 80) / 12); + const fT = Math.pow(2, (temp - 25) / 10); + return fV * fT; +} + +const LAMBDA = 0.005325; // baseline (rate 1) → ~88% health after 24 months + +function healthAt(months: number, rate: number): number { + return 100 * Math.exp(-LAMBDA * rate * months); +} + +export function AgingExplorer() { + const canvasRef = useRef(null); + const [ceiling, setCeiling] = useState(100); + const [temp, setTemp] = useState(35); + const palette = useThemeColors(); + + const rate = agingRate(ceiling, temp); + const health2y = healthAt(24, rate); + const healthColor = + health2y >= 85 ? palette.green : health2y >= 70 ? palette.orange : palette.danger; + + useEffect(() => { + const canvas = canvasRef.current; + if (!canvas) return; + const p = palette; + + const render = () => { + const { ctx, w, h } = fitCanvas(canvas); + if (!ctx) return; + ctx.clearRect(0, 0, w, h); + + const ml = 42; + const mr = 14; + const mt = 16; + const mb = 26; + const plotW = w - ml - mr; + const plotH = h - mt - mb; + const months = 24; + + const xAt = (m: number) => ml + (m / months) * plotW; + const yAt = (pct: number) => mt + (1 - (pct - 60) / 40) * plotH; // show 60–100% + + // grid + labels + ctx.strokeStyle = p.grid; + ctx.fillStyle = p.muted; + ctx.lineWidth = 1; + ctx.font = "400 10px 'Geist Mono', ui-monospace, monospace"; + ctx.textAlign = "right"; + ctx.textBaseline = "middle"; + for (const pct of [100, 90, 80, 70, 60]) { + const y = yAt(pct); + ctx.beginPath(); + ctx.moveTo(ml, y); + ctx.lineTo(w - mr, y); + ctx.stroke(); + ctx.fillText(`${pct}%`, ml - 6, y); + } + ctx.textAlign = "center"; + ctx.textBaseline = "top"; + for (const m of [0, 12, 24]) { + ctx.fillText(m === 0 ? "now" : `${m}mo`, xAt(m), h - mb + 6); + } + + const plotCurve = (r: number, color: string, dashed: boolean) => { + ctx.strokeStyle = color; + ctx.lineWidth = dashed ? 1.5 : 2.5; + ctx.setLineDash(dashed ? [4, 4] : []); + ctx.beginPath(); + for (let m = 0; m <= months; m++) { + const x = xAt(m); + const y = yAt(Math.max(60, healthAt(m, r))); + if (m === 0) ctx.moveTo(x, y); + else ctx.lineTo(x, y); + } + ctx.stroke(); + ctx.setLineDash([]); + }; + + // ideal reference (80% / 25°C) then current + plotCurve(1, p.muted, true); + plotCurve(rate, healthColor, false); + + // endpoint dot on current curve + const ey = yAt(Math.max(60, health2y)); + ctx.fillStyle = healthColor; + ctx.beginPath(); + ctx.arc(xAt(24), ey, 4.5, 0, Math.PI * 2); + ctx.fill(); + + // legend + ctx.font = "500 10px Inter, system-ui, sans-serif"; + ctx.textAlign = "left"; + ctx.textBaseline = "top"; + ctx.fillStyle = p.muted; + ctx.fillText("– – ideal (80% · 25°C)", ml + 4, mt + 4); + }; + + render(); + const ro = new ResizeObserver(render); + ro.observe(canvas); + return () => ro.disconnect(); + }, [ceiling, temp, palette, rate, health2y, healthColor]); + + return ( +
+
+ + +
+
+
+

Aging rate

+

+ {rate < 1 ? rate.toFixed(2) : rate.toFixed(1)}× baseline +

+
+
+

Health after 2 years

+

+ {Math.round(health2y)}% +

+
+
+ + } + caption={ + <> + The two killers multiply. Push the ceiling to + 100% and let it run hot and the aging rate compounds: the curve nose-dives. Pull + both back toward the dashed ideal and the same battery is still near-full years later. + (Illustrative model, but the direction is real.) + + } + > + +
+ ); +} diff --git a/apps/web/src/components/blog/viz/canvas-utils.ts b/apps/web/src/components/blog/viz/canvas-utils.ts new file mode 100644 index 0000000..2f3ecbb --- /dev/null +++ b/apps/web/src/components/blog/viz/canvas-utils.ts @@ -0,0 +1,113 @@ +import { useEffect, useState } from "react"; + +/** Canvas-safe palettes (hex/rgba — no oklch, for cross-browser fillStyle). */ +export interface Palette { + ink: string; + muted: string; + grid: string; + track: string; + primary: string; + primaryDim: string; + green: string; + orange: string; + danger: string; + anode: string; + anodeFill: string; + cathode: string; + cathodeFill: string; + ion: string; + electron: string; +} + +const DARK: Palette = { + ink: "#e6e6e9", + muted: "#8b8b93", + grid: "rgba(255,255,255,0.07)", + track: "rgba(255,255,255,0.10)", + primary: "#3b82f6", + primaryDim: "rgba(59,130,246,0.16)", + green: "#34d399", + orange: "#fbbf24", + danger: "#f87171", + anode: "#3f3f46", + anodeFill: "#60a5fa", + cathode: "#4b5563", + cathodeFill: "#a78bfa", + ion: "#93c5fd", + electron: "#fcd34d", +}; + +const LIGHT: Palette = { + ink: "#1f2937", + muted: "#6b7280", + grid: "rgba(0,0,0,0.07)", + track: "rgba(0,0,0,0.09)", + primary: "#2563eb", + primaryDim: "rgba(37,99,235,0.12)", + green: "#059669", + orange: "#d97706", + danger: "#dc2626", + anode: "#d4d4d8", + anodeFill: "#3b82f6", + cathode: "#9ca3af", + cathodeFill: "#7c3aed", + ion: "#2563eb", + electron: "#b45309", +}; + +/** Tracks the app's light/dark class on and returns the matching palette. */ +export function useThemeColors(): Palette { + const [dark, setDark] = useState(true); + useEffect(() => { + const el = document.documentElement; + const update = () => setDark(el.classList.contains("dark")); + update(); + const obs = new MutationObserver(update); + obs.observe(el, { attributes: true, attributeFilter: ["class"] }); + return () => obs.disconnect(); + }, []); + return dark ? DARK : LIGHT; +} + +export function prefersReducedMotion(): boolean { + return ( + typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches + ); +} + +/** HiDPI-fit a canvas to its CSS box; returns the 2D context and CSS w/h. */ +export function fitCanvas(c: HTMLCanvasElement): { + ctx: CanvasRenderingContext2D | null; + w: number; + h: number; +} { + const ctx = c.getContext("2d"); + const dpr = Math.min(typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1, 2); + const r = c.getBoundingClientRect(); + const w = Math.max(1, Math.round(r.width)); + const h = Math.max(1, Math.round(r.height)); + c.width = w * dpr; + c.height = h * dpr; + if (ctx) ctx.setTransform(dpr, 0, 0, dpr, 0, 0); + return { ctx, w, h }; +} + +export function roundRect( + ctx: CanvasRenderingContext2D, + x: number, + y: number, + w: number, + h: number, + r: number, +): void { + const rr = Math.min(r, w / 2, h / 2); + ctx.beginPath(); + ctx.moveTo(x + rr, y); + ctx.arcTo(x + w, y, x + w, y + h, rr); + ctx.arcTo(x + w, y + h, x, y + h, rr); + ctx.arcTo(x, y + h, x, y, rr); + ctx.arcTo(x, y, x + w, y, rr); + ctx.closePath(); +} + +export const clamp = (v: number, lo: number, hi: number): number => Math.max(lo, Math.min(hi, v)); diff --git a/apps/web/src/components/blog/viz/cell-diagram.tsx b/apps/web/src/components/blog/viz/cell-diagram.tsx new file mode 100644 index 0000000..d14d338 --- /dev/null +++ b/apps/web/src/components/blog/viz/cell-diagram.tsx @@ -0,0 +1,242 @@ +import { useEffect, useRef, useState } from "react"; + +import { Button } from "#/components/ui/button"; + +import { + clamp, + fitCanvas, + type Palette, + prefersReducedMotion, + roundRect, + useThemeColors, +} from "./canvas-utils"; +import { Figure } from "./figure"; + +interface Ion { + x: number; // 0..1 across the electrolyte gap + lane: number; // 0..1 vertical position +} + +export function CellDiagram() { + const canvasRef = useRef(null); + const [charging, setCharging] = useState(true); + const chargingRef = useRef(true); + const palette = useThemeColors(); + const paletteRef = useRef(palette); + useEffect(() => { + paletteRef.current = palette; + }, [palette]); + + const setMode = (c: boolean) => { + chargingRef.current = c; + setCharging(c); + }; + + useEffect(() => { + const canvas = canvasRef.current; + if (!canvas) return; + const reduced = prefersReducedMotion(); + let dims = fitCanvas(canvas); + const ro = new ResizeObserver(() => { + dims = fitCanvas(canvas); + }); + ro.observe(canvas); + + const ions: Ion[] = Array.from({ length: 9 }, (_, i) => ({ + x: i / 9, + lane: 0.14 + 0.72 * ((i * 0.37) % 1), + })); + + let soc = 0.35; + let raf = 0; + let last = performance.now(); + + const draw = (dt: number) => { + const { ctx, w, h } = dims; + if (!ctx) return; + const p = paletteRef.current; + const target = chargingRef.current ? 1 : 0; + const rate = reduced ? 10 : 0.34; // per second + soc += clamp(target - soc, -rate * dt, rate * dt); + soc = clamp(soc, 0, 1); + const activity = clamp(Math.abs(target - soc) * 3.2, 0, 1); + const dir = chargingRef.current ? -1 : 1; // ions drift toward anode (left) when charging + + ctx.clearRect(0, 0, w, h); + + const pad = 18; + const wireY = 24; + const eTop = 50; + const eBot = h - 42; + const eH = eBot - eTop; + const ew = clamp(w * 0.2, 50, 84); + const anodeX = pad; + const cathodeX = w - pad - ew; + const gapL = anodeX + ew; + const gapR = cathodeX; + const anodeMid = anodeX + ew / 2; + const cathodeMid = cathodeX + ew / 2; + + // ---- external circuit (top wire + load) ---- + ctx.strokeStyle = p.track; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(anodeMid, eTop); + ctx.lineTo(anodeMid, wireY); + ctx.lineTo(cathodeMid, wireY); + ctx.lineTo(cathodeMid, eTop); + ctx.stroke(); + // load box + const boxW = 40; + const boxH = 18; + const boxX = (anodeMid + cathodeMid) / 2 - boxW / 2; + ctx.fillStyle = p.track; + roundRect(ctx, boxX, wireY - boxH / 2, boxW, boxH, 5); + ctx.fill(); + ctx.fillStyle = p.muted; + ctx.font = "500 10px Inter, system-ui, sans-serif"; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + ctx.fillText("your Mac", (anodeMid + cathodeMid) / 2, wireY); + + // electrons on the top run: discharge -> left→right, charge -> right→left + const eStart = anodeMid + 4; + const eEnd = cathodeMid - 4; + const eLen = eEnd - eStart; + const eDir = chargingRef.current ? -1 : 1; + ctx.fillStyle = p.electron; + for (let i = 0; i < 7; i++) { + const phase = (soc * 60 * eDir + i / 7) % 1; + const t = (phase + 1) % 1; + const x = eStart + t * eLen; + if (Math.abs(x - (anodeMid + cathodeMid) / 2) < boxW / 2 + 3) continue; + ctx.globalAlpha = 0.25 + 0.75 * activity; + ctx.beginPath(); + ctx.arc(x, wireY, 2.2, 0, Math.PI * 2); + ctx.fill(); + } + ctx.globalAlpha = 1; + + // ---- electrodes ---- + const layers = 8; + const layerGap = 3; + const layerH = (eH - layerGap * (layers - 1)) / layers; + + const drawElectrode = (x: number, filled: number, fill: string, outline: string) => { + ctx.strokeStyle = outline; + ctx.lineWidth = 1.5; + roundRect(ctx, x, eTop, ew, eH, 8); + ctx.stroke(); + for (let i = 0; i < layers; i++) { + const ly = eBot - (i + 1) * layerH - i * layerGap; + const on = i < filled; + if (on) { + ctx.fillStyle = fill; + roundRect(ctx, x + 6, ly, ew - 12, layerH, 2); + ctx.fill(); + } else { + ctx.strokeStyle = p.grid; + ctx.lineWidth = 1; + ctx.beginPath(); + ctx.moveTo(x + 6, ly + layerH / 2); + ctx.lineTo(x + ew - 6, ly + layerH / 2); + ctx.stroke(); + } + } + }; + + drawElectrode(anodeX, Math.round(layers * soc), p.anodeFill, p.anode); + drawElectrode(cathodeX, Math.round(layers * (1 - soc)), p.cathodeFill, p.cathode); + + // ---- lithium ions crossing the electrolyte ---- + const speed = (0.12 + activity * 0.9) * dt; + ctx.fillStyle = p.ion; + for (const ion of ions) { + ion.x += dir * speed; + if (ion.x > 1) ion.x -= 1; + if (ion.x < 0) ion.x += 1; + const x = gapL + 10 + ion.x * (gapR - gapL - 20); + const y = eTop + 10 + ion.lane * (eH - 20); + ctx.globalAlpha = 0.2 + 0.8 * activity; + ctx.beginPath(); + ctx.arc(x, y, 3.2, 0, Math.PI * 2); + ctx.fill(); + } + ctx.globalAlpha = 1; + + // ---- labels ---- + ctx.fillStyle = p.muted; + ctx.font = "600 11px Inter, system-ui, sans-serif"; + ctx.textAlign = "center"; + ctx.textBaseline = "top"; + ctx.fillText("Anode", anodeMid, eBot + 8); + ctx.fillText("Cathode", cathodeMid, eBot + 8); + ctx.font = "400 10px Inter, system-ui, sans-serif"; + ctx.fillText("graphite", anodeMid, eBot + 22); + ctx.fillText("metal oxide", cathodeMid, eBot + 22); + ctx.fillText("electrolyte", (gapL + gapR) / 2, eBot + 8); + + // ---- readout ---- + const voltage = 3.0 + 1.2 * soc; + ctx.textAlign = "left"; + ctx.textBaseline = "alphabetic"; + ctx.fillStyle = p.ink; + ctx.font = "700 24px 'Bricolage Grotesque', system-ui, sans-serif"; + ctx.fillText(`${Math.round(soc * 100)}%`, gapL + 8, eTop + 26); + ctx.fillStyle = p.muted; + ctx.font = "500 12px 'Geist Mono', ui-monospace, monospace"; + ctx.fillText(`≈ ${voltage.toFixed(2)} V`, gapL + 8, eTop + 44); + + if (!reduced) raf = requestAnimationFrame(step); + }; + + const step = (now: number) => { + const dt = Math.min(0.05, (now - last) / 1000); + last = now; + draw(dt); + }; + + raf = requestAnimationFrame(step); + return () => { + ro.disconnect(); + cancelAnimationFrame(raf); + }; + }, []); + + return ( +
+ Direction + + + + } + caption={ + <> + A lithium-ion cell, simplified. Hit Charge{" "} + and lithium ions drift left into the graphite anode; hit{" "} + Discharge and they flow back to the cathode, + pushing electrons through your Mac. The percentage is how full the anode is; the voltage + climbs as it fills. + + } + > + +
+ ); +} diff --git a/apps/web/src/components/blog/viz/charge-voltage.tsx b/apps/web/src/components/blog/viz/charge-voltage.tsx new file mode 100644 index 0000000..d080a6b --- /dev/null +++ b/apps/web/src/components/blog/viz/charge-voltage.tsx @@ -0,0 +1,148 @@ +import { useEffect, useRef, useState } from "react"; + +import { fitCanvas, useThemeColors } from "./canvas-utils"; +import { Figure, Slider } from "./figure"; + +/** Illustrative open-circuit voltage curve: steep at the ends, flatter in the middle. */ +function voltageAt(socFraction: number): number { + return 3.0 + 1.2 * Math.pow(socFraction, 0.55); +} + +function stressWord(soc: number): string { + if (soc <= 60) return "gentle"; + if (soc <= 80) return "easy"; + if (soc <= 90) return "stressful"; + return "hard on the cell"; +} + +export function ChargeVoltage() { + const canvasRef = useRef(null); + const [soc, setSoc] = useState(80); + const palette = useThemeColors(); + + useEffect(() => { + const canvas = canvasRef.current; + if (!canvas) return; + const p = palette; + + const render = () => { + const { ctx, w, h } = fitCanvas(canvas); + if (!ctx) return; + ctx.clearRect(0, 0, w, h); + + const ml = 46; + const mr = 14; + const mt = 40; + const mb = 26; + const plotW = w - ml - mr; + const plotH = h - mt - mb; + const vMin = 3.0; + const vMax = 4.2; + + const xAt = (pct: number) => ml + (pct / 100) * plotW; + const yAt = (v: number) => mt + (1 - (v - vMin) / (vMax - vMin)) * plotH; + + // high-stress zone (> 80%) + ctx.fillStyle = p.danger; + ctx.globalAlpha = 0.09; + ctx.fillRect(xAt(80), mt, xAt(100) - xAt(80), plotH); + ctx.globalAlpha = 1; + ctx.fillStyle = p.danger; + ctx.font = "600 10px Inter, system-ui, sans-serif"; + ctx.textAlign = "right"; + ctx.textBaseline = "top"; + ctx.globalAlpha = 0.8; + ctx.fillText("high-stress zone", xAt(100) - 6, mt + 6); + ctx.globalAlpha = 1; + + // grid + y labels (volts) + ctx.strokeStyle = p.grid; + ctx.fillStyle = p.muted; + ctx.lineWidth = 1; + ctx.font = "400 10px 'Geist Mono', ui-monospace, monospace"; + ctx.textAlign = "right"; + ctx.textBaseline = "middle"; + for (const v of [3.0, 3.6, 4.2]) { + const y = yAt(v); + ctx.beginPath(); + ctx.moveTo(ml, y); + ctx.lineTo(w - mr, y); + ctx.stroke(); + ctx.fillText(`${v.toFixed(1)}V`, ml - 6, y); + } + // x labels (%) + ctx.textAlign = "center"; + ctx.textBaseline = "top"; + for (const pct of [0, 50, 80, 100]) { + ctx.fillText(`${pct}%`, xAt(pct), h - mb + 6); + } + + // curve + ctx.strokeStyle = p.primary; + ctx.lineWidth = 2.5; + ctx.beginPath(); + for (let i = 0; i <= 100; i++) { + const x = xAt(i); + const y = yAt(voltageAt(i / 100)); + if (i === 0) ctx.moveTo(x, y); + else ctx.lineTo(x, y); + } + ctx.stroke(); + + // marker + const mx = xAt(soc); + const my = yAt(voltageAt(soc / 100)); + ctx.strokeStyle = p.track; + ctx.setLineDash([3, 3]); + ctx.beginPath(); + ctx.moveTo(mx, mt); + ctx.lineTo(mx, h - mb); + ctx.stroke(); + ctx.setLineDash([]); + ctx.fillStyle = soc > 80 ? p.danger : p.primary; + ctx.beginPath(); + ctx.arc(mx, my, 5, 0, Math.PI * 2); + ctx.fill(); + + // readout + ctx.textAlign = "left"; + ctx.textBaseline = "alphabetic"; + ctx.fillStyle = p.ink; + ctx.font = "700 20px 'Bricolage Grotesque', system-ui, sans-serif"; + ctx.fillText(`${voltageAt(soc / 100).toFixed(2)} V`, ml, 26); + ctx.fillStyle = soc > 80 ? p.danger : p.muted; + ctx.font = "500 12px Inter, system-ui, sans-serif"; + ctx.textAlign = "right"; + ctx.fillText(`${soc}% · ${stressWord(soc)}`, w - mr, 26); + }; + + render(); + const ro = new ResizeObserver(render); + ro.observe(canvas); + return () => ro.disconnect(); + }, [soc, palette]); + + return ( +
+ } + caption={ + <> + Voltage is the dial that matters. Dragging past ~80% pushes the cell into the red zone + above ~4.0 V, where the electrolyte oxidizes fastest. Capping the charge at 80% gives + up a sliver of runtime for a dramatically longer life. + + } + > + +
+ ); +} diff --git a/apps/web/src/components/blog/viz/figure.tsx b/apps/web/src/components/blog/viz/figure.tsx new file mode 100644 index 0000000..19159f7 --- /dev/null +++ b/apps/web/src/components/blog/viz/figure.tsx @@ -0,0 +1,63 @@ +/** Shared frame for an interactive visualization: canvas surface, an optional + * controls strip, and a caption. Keeps the article's figures visually uniform. */ +export function Figure({ + children, + controls, + caption, +}: { + children: React.ReactNode; + controls?: React.ReactNode; + caption?: React.ReactNode; +}) { + return ( +
+
{children}
+ {controls ? ( +
{controls}
+ ) : null} + {caption ? ( +
+ {caption} +
+ ) : null} +
+ ); +} + +/** A labeled range slider used across the visualizations. */ +export function Slider({ + label, + value, + display, + min, + max, + step = 1, + onChange, +}: { + label: string; + value: number; + display: string; + min: number; + max: number; + step?: number; + onChange: (v: number) => void; +}) { + return ( + + ); +} diff --git a/apps/web/src/components/buy-button.tsx b/apps/web/src/components/buy-button.tsx new file mode 100644 index 0000000..8ca2589 --- /dev/null +++ b/apps/web/src/components/buy-button.tsx @@ -0,0 +1,36 @@ +import { useNavigate } from "@tanstack/react-router"; +import { useState } from "react"; +import { toast } from "sonner"; + +import { startCheckout } from "#/lib/auth/auth-client"; +import { useAuth } from "#/lib/auth/hooks"; + +/** + * Shared Dodo Payments checkout action. Checkout is `authenticatedUsersOnly`, + * so signed-out visitors are sent to log in first, then can buy. + */ +export function useCheckout() { + const { user, isPending } = useAuth(); + const navigate = useNavigate(); + const [loading, setLoading] = useState(false); + + const buy = async () => { + if (isPending || loading) return; + + if (!user) { + toast.info("Sign in to buy eWiz. It only takes a second."); + navigate({ to: "/login" }); + return; + } + + setLoading(true); + try { + await startCheckout(`battlify-${user.id}-${Date.now()}`); + } catch (error) { + toast.error(error instanceof Error ? error.message : "Couldn't open checkout. Try again."); + setLoading(false); + } + }; + + return { buy, loading }; +} diff --git a/apps/web/src/components/default-catch-boundary.tsx b/apps/web/src/components/default-catch-boundary.tsx new file mode 100644 index 0000000..deb9b77 --- /dev/null +++ b/apps/web/src/components/default-catch-boundary.tsx @@ -0,0 +1,57 @@ +import { + ErrorComponent, + type ErrorComponentProps, + Link, + rootRouteId, + useMatch, + useRouter, +} from "@tanstack/react-router"; + +import { Button } from "./ui/button"; + +export function DefaultCatchBoundary({ error }: Readonly) { + const router = useRouter(); + const isRoot = useMatch({ + strict: false, + select: (state) => state.id === rootRouteId, + }); + + console.error(error); + + return ( +
+ +
+ + {isRoot ? ( + + ) : ( + + )} +
+
+ ); +} diff --git a/apps/web/src/components/default-not-found.tsx b/apps/web/src/components/default-not-found.tsx new file mode 100644 index 0000000..9ebcbfd --- /dev/null +++ b/apps/web/src/components/default-not-found.tsx @@ -0,0 +1,26 @@ +import { Link } from "@tanstack/react-router"; + +import { Container, SitePage } from "#/components/site/site-shell"; +import { Button } from "#/components/ui/button"; + +export function DefaultNotFound() { + return ( + + +

404

+

This page doesn't exist

+

+ It may have moved, or the link is wrong. +

+
+ + +
+
+
+ ); +} diff --git a/apps/web/src/components/download-button.tsx b/apps/web/src/components/download-button.tsx new file mode 100644 index 0000000..ca10e94 --- /dev/null +++ b/apps/web/src/components/download-button.tsx @@ -0,0 +1,25 @@ +import { Link } from "@tanstack/react-router"; +import { DownloadIcon } from "lucide-react"; + +import { Button } from "#/components/ui/button"; +import { cn } from "#/lib/utils"; + +export function DownloadButton({ + variant = "default", + className, +}: { + variant?: "default" | "outline"; + className?: string; +}) { + return ( + + ); +} diff --git a/apps/web/src/components/icon.tsx b/apps/web/src/components/icon.tsx new file mode 100644 index 0000000..bc46dd8 --- /dev/null +++ b/apps/web/src/components/icon.tsx @@ -0,0 +1,28 @@ +import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react"; + +import { cn } from "#/lib/utils"; + +/** + * Thin wrapper over Hugeicons so call sites read like the old lucide ones: + * ``. Defaults to a + * 16px stroke icon that inherits `currentColor`. + */ +export function Icon({ + icon, + className, + strokeWidth = 1.8, + ...props +}: { + icon: IconSvgElement; + className?: string; + strokeWidth?: number; +} & Omit, "icon" | "className" | "strokeWidth">) { + return ( + + ); +} diff --git a/apps/web/src/components/landing/landing-data.ts b/apps/web/src/components/landing/landing-data.ts new file mode 100644 index 0000000..8b627e6 --- /dev/null +++ b/apps/web/src/components/landing/landing-data.ts @@ -0,0 +1,83 @@ +export const LINKS = { + github: "https://github.com/stroke-app/ewiz", + /** This website's source. */ + siteSource: "https://github.com/stroke-app/ewiz-releases", + releases: "https://github.com/stroke-app/ewiz/releases", + feedback: "https://github.com/stroke-app/ewiz/issues", + x: "https://x.com/broisnischal", + stroke: "https://stroke.click", + site: "https://nischal-dahal.com.np", +} as const; + +/** + * The hero's headlines, each with the line under it. A random one leads on + * every visit, then they take turns. + */ +export const HEADLINES = [ + { + title: "Stop charging your MacBook to 100%.", + body: "Sitting full and running hot are what wear a battery out. eWiz holds the charge where you set it and pauses charging when the battery gets warm.", + }, + { + title: "Your Mac shouldn't drain in your bag.", + body: "A closed Mac still wakes itself for the network and for maintenance. Sealed Sleep switches every one of those wakes off and shows what the last close cost.", + }, + { + title: "Your earbuds shouldn't connect to a closed Mac.", + body: "With Sealed Sleep on, closing the lid turns Bluetooth and Wi-Fi off, so your earbuds stay with your phone. Open it and everything comes back.", + }, + { + title: "Play music with the lid closed.", + body: "Always Active keeps your Mac running with the lid shut, on the charger or, if you allow it, on battery. The screen and keyboard light go dark.", + }, + { + title: "Clamshell mode, without the charger.", + body: "Let Always Active run on battery, close the lid, and keep working on your external display. eWiz keeps the Mac awake and leaves the monitor alone.", + }, + { + title: "Let your AI agent keep the Mac awake.", + body: "Claude, Cursor and other MCP apps can switch keep-awake on for a long build or test run and off when they're done, on a timer that ends by itself.", + }, +] as const; + +/** Homebrew cask, published to the stroke-app/homebrew-ewiz tap on every release. */ +export const BREW_INSTALL = "brew install --cask stroke-app/ewiz/ewiz"; + +export const PRICE = "$2.99"; + +// Plain-language answers to the questions people actually ask before buying. +// Also serialized into FAQPage JSON-LD, so keep the answers self-contained. +export const FAQS = [ + { + q: "Which Macs does eWiz support?", + a: "Apple Silicon Macs (M1 and later) on macOS 14 Sonoma or newer, including macOS 26 Tahoe. Intel Macs aren't supported. It lives in the menu bar with no Dock icon, and at idle it uses close to 0% CPU.", + }, + { + q: "Does a charge limit really make my battery last longer?", + a: "It slows the wear. Lithium-ion batteries age fastest when they sit full and when they run hot, and a MacBook on a charger does both. Holding around 80% avoids the worst of it. It won't make an old battery new again.", + }, + { + q: "Does the limit hold while my Mac is asleep?", + a: "Yes, if you let it. A charge limiter can't check anything while the Mac sleeps, which is how macOS sneaks back to 100% overnight. eWiz either stops charging just before sleep or keeps the Mac awake on wall power. You pick which.", + }, + { + q: "How much does eWiz cost?", + a: "$2.99, once. There's no subscription, updates are free, and every feature is unlocked for the first 30 days so you can decide with the real thing.", + }, + { + q: "Can I move my license to another Mac?", + a: "Yes. A license works on one Mac at a time, and you can move it to a new one once every 30 days.", + }, + { + q: "Is my data private?", + a: "eWiz does its work on your Mac and doesn't send your usage anywhere. The website keeps only what it needs to sell you a license and support it: your account and your license.", + }, + { + q: "Why does it ask for my password?", + a: "Charge limiting, Low Power Mode and the sleep controls need a small helper that runs as root, because macOS only lets root change them. You install it once from the menu, and you can uninstall it from Settings › General.", + }, + { + q: "Why does macOS warn me the first time I open it?", + a: "eWiz isn't notarized by Apple yet. The first time, right-click the app in Applications and choose Open, or allow it in System Settings › Privacy & Security. After that it opens like any other app.", + }, +] as const; diff --git a/apps/web/src/components/landing/landing-page.tsx b/apps/web/src/components/landing/landing-page.tsx new file mode 100644 index 0000000..bf9f31d --- /dev/null +++ b/apps/web/src/components/landing/landing-page.tsx @@ -0,0 +1,757 @@ +import { Link } from "@tanstack/react-router"; +import { + BatteryChargingIcon, + CoffeeIcon, + CpuIcon, + LaptopIcon, + LayoutGridIcon, + MousePointerClickIcon, + MoonStarIcon, + PlugIcon, + ThermometerIcon, + XIcon, +} from "lucide-react"; +import type { LucideIcon } from "lucide-react"; +import { useEffect, useState } from "react"; + +import { useCheckout } from "#/components/buy-button"; +import { DownloadButton } from "#/components/download-button"; +import { AppIcon } from "#/components/logo"; +import { PricingPlans } from "#/components/pricing-plans"; +import { Container, SitePage } from "#/components/site/site-shell"; +import { Button } from "#/components/ui/button"; +import { cn } from "#/lib/utils"; + +import { FAQS, HEADLINES, PRICE } from "./landing-data"; +import { LightningField } from "./lightning-field"; +import { + DetailsWindow, + HistoryWindow, + MenuBarStrip, + MenuPopover, + SettingsWindow, + Stage, + Toggle, +} from "./mac-ui"; +import type { IconStyle, SettingsTab } from "./mac-ui"; + +const H2 = "text-3xl font-semibold tracking-tight text-balance sm:text-[2.25rem] sm:leading-[1.15]"; +const WIDE = "mx-auto w-full max-w-[68rem] px-4"; + +function BuyButton({ className, children }: { className?: string; children: React.ReactNode }) { + const { buy, loading } = useCheckout(); + return ( + + ); +} + +/* ========================================================================== + Hero: the eWiz panel, rebuilt for the web, dropping from the menu bar. + ========================================================================== */ +type DesktopView = "settings" | "details" | "history"; + +const HEADLINE_MS = 5000; + +/** + * The headline and the line under it, taking turns. Every headline sits in the + * same grid cell, so the block keeps the height of the longest one and nothing + * below it jumps when they change. Headlines sit at the bottom of that space, + * so a short one stays next to its line instead of leaving a gap between them. + */ +function RotatingHeadline({ start }: { start: number }) { + const [index, setIndex] = useState(start); + const [prev, setPrev] = useState(null); + + useEffect(() => { + if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return; + const id = window.setTimeout(() => { + setPrev(index); + setIndex((index + 1) % HEADLINES.length); + }, HEADLINE_MS); + return () => window.clearTimeout(id); + }, [index]); + + // The new line rises into place while the old one lifts away. + const item = (i: number) => + cn( + "transition-[opacity,translate,filter] duration-700 ease-[cubic-bezier(0.22,1,0.36,1)] [grid-area:1/1]", + i === index + ? "translate-y-0 opacity-100 blur-none" + : cn("opacity-0 blur-[4px]", i === prev ? "-translate-y-2" : "translate-y-2"), + ); + + return ( + <> +

+ {HEADLINES.map((h, i) => ( + + {h.title} + + ))} +

+

+ {HEADLINES.map((h, i) => ( + + {h.body} + + ))} +

+ + ); +} + +function Hero({ + headline, + iconStyle, + onIconStyle, +}: { + headline: number; + iconStyle: IconStyle; + onIconStyle: (s: IconStyle) => void; +}) { + const [view, setView] = useState("settings"); + const [tab, setTab] = useState("Charging"); + return ( +
+ + + +
+ + Buy · {PRICE} +
+

+ Free for 30 days · macOS 14+ · Apple Silicon +

+
+ +
+
+ {/* Desktop: the whole menu bar scene. */} + +
+
+ +
+
+ {view === "settings" ? ( + + ) : null} + {view === "details" ? : null} + {view === "history" ? : null} +
+ + + {/* Phone: just the panel, at a readable size. */} + +
+
+ +
+ + +
+

+ + This is the eWiz panel, rebuilt for the web. Drag the limit, flip a mode, open Settings. +

+
+
+ ); +} + +/* ========================================================================== + Feature switcher: pick a feature, see the real screen. Auto-advances until + the visitor takes over. + ========================================================================== */ +type FeatureView = + | { kind: "settings"; tab: SettingsTab; scroll?: number } + | { kind: "history" } + | { kind: "details" }; + +const FEATURES: Array<{ + id: string; + title: string; + body: string; + view: FeatureView; +}> = [ + { + id: "limit", + title: "A charge limit that holds", + body: "Pick a ceiling between 50 and 100% and eWiz holds it, with a small buffer so the charger isn't switching on and off all day. It keeps holding while the Mac sleeps, which is where a simple limiter lets macOS sneak back to 100%.", + view: { kind: "settings", tab: "Charging" }, + }, + { + id: "sealed", + title: "Sealed Sleep", + body: "A closed Mac isn't off: it keeps memory powered and wakes itself for maintenance and the network. One switch shuts all of that down and shows what the last close cost. The catch is honest: opening the lid then takes 15 to 30 seconds.", + view: { kind: "settings", tab: "Sleep & Power" }, + }, + { + id: "rules", + title: "Automation rules", + body: "\u201cWhile this is true, do that.\u201d Plug into your desk display and the limit drops to 80%; join the office Wi-Fi and the Mac stays awake. A rule puts things back when it stops matching.", + view: { kind: "settings", tab: "Automation" }, + }, + { + id: "agents", + title: "AI agents, kept in check", + body: "Claude, Cursor and other MCP apps can keep your Mac awake through a long build or test run, on a timer that ends by itself. You can see which agent is holding it, and for how long.", + view: { kind: "settings", tab: "Automation", scroll: 486 }, + }, + { + id: "schedule", + title: "Schedules and Ready By", + body: "Hold at your limit overnight and top up to full just before you leave. Or charge on a weekly timetable, and turn charge power down when you'd rather it ran cool.", + view: { kind: "settings", tab: "Schedule" }, + }, + { + id: "history", + title: "Every close, measured", + body: "Every charge and every lid-closed session, with how much it drained per hour. Export it all as CSV if you like a spreadsheet.", + view: { kind: "history" }, + }, + { + id: "details", + title: "The numbers that matter", + body: "Health, cycle count, temperature and capacity, where the power is going right now, and what your charger actually agreed to deliver.", + view: { kind: "details" }, + }, + { + id: "menubar", + title: "Your menu bar, your way", + body: "Twelve battery icons, from Bars to Dial. Pick one and the menu bar at the top of this page changes with it.", + view: { kind: "settings", tab: "General" }, + }, +]; + +const FEATURE_MS = 7000; + +/** The feature a Settings tab belongs to, so clicking around the window moves the list too. */ +function featureForTab(tab: SettingsTab) { + return FEATURES.findIndex( + (f) => f.view.kind === "settings" && f.view.tab === tab && !f.view.scroll, + ); +} + +/** Stage size and the windows inside it, with even margins all round. */ +const STAGE = { width: 760, height: 680, inset: 44 }; +const WINDOW_HEIGHT = STAGE.height - 2 * STAGE.inset; + +function Features({ + iconStyle, + onIconStyle, +}: { + iconStyle: IconStyle; + onIconStyle: (s: IconStyle) => void; +}) { + const [index, setIndex] = useState(0); + const [auto, setAuto] = useState(true); + const [paused, setPaused] = useState(false); + // A tab picked in the window that no feature covers (Shortcuts, About). + const [looseTab, setLooseTab] = useState(null); + + useEffect(() => { + if (!auto || paused || window.matchMedia("(prefers-reduced-motion: reduce)").matches) return; + const id = window.setTimeout(() => setIndex((i) => (i + 1) % FEATURES.length), FEATURE_MS); + return () => window.clearTimeout(id); + }, [auto, paused, index]); + + const feature = FEATURES[index]; + const view = feature.view; + const tab = looseTab ?? (view.kind === "settings" ? view.tab : "Charging"); + const select = (i: number) => { + setAuto(false); + setLooseTab(null); + setIndex(i); + }; + const selectTab = (t: SettingsTab) => { + const i = featureForTab(t); + if (i >= 0) select(i); + else { + setAuto(false); + setLooseTab(t); + } + }; + + return ( +
+
+

A closer look

+

+ Pick a feature to see where it lives in the app. The window is clickable: switch tabs, + flip a switch, try a menu bar style. +

+ +
+
    + {FEATURES.map((f, i) => { + const on = i === index && !looseTab; + return ( +
  1. + {on ? ( + + ) : null} + +
  2. + ); + })} +
+ +
+ +
+
+ {view.kind === "settings" || looseTab ? ( + { + setAuto(false); + onIconStyle(s); + }} + /> + ) : null} + {!looseTab && view.kind === "history" ? ( + + ) : null} + {!looseTab && view.kind === "details" ? ( + + ) : null} +
+ +
+
+
+
+ ); +} + +/* ========================================================================== + Bento: the smaller things, each with a sliver of the real UI. + ========================================================================== */ +const SAVE_MODES = { + Off: "No battery saving, standard macOS behavior.", + Normal: "Charge limit 80%, pause when warm, Power Nap off. Find My stays active.", + "Super Saver": + "Low Power Mode, charge limit 80%, pause when warm, all sleep wake-ups off, Wi-Fi & Bluetooth off when closed.", +} as const; + +function MiniPanel({ className, children }: { className?: string; children: React.ReactNode }) { + return ( +
+
{children}
+
+ ); +} + +function BentoCard({ + icon: Icon, + title, + body, + visual, +}: { + icon: LucideIcon; + title: string; + body: string; + visual: React.ReactNode; +}) { + return ( +
+
{visual}
+
+

+ + {title} +

+

{body}

+
+
+ ); +} + +const QUICK_TILES: Array<{ icon: LucideIcon; label: string; on: boolean }> = [ + { icon: LaptopIcon, label: "Lid", on: false }, + { icon: CoffeeIcon, label: "Awake", on: true }, + { icon: MoonStarIcon, label: "Rest", on: false }, +]; + +const TOP_UP_MENU = [ + "Pause 1 hour", + "Pause until I resume", + "Charge to 100% once", + "Park near 60% (long-term care)", +]; + +function Bento() { + const [mode, setMode] = useState("Normal"); + const [heat, setHeat] = useState(true); + return ( +
+
+

And the little things

+
+ +
+ {(Object.keys(SAVE_MODES) as Array).map((m) => ( + + ))} +
+

+ {SAVE_MODES[mode]} +

+ + } + /> + +
+ Pause charging when hot + setHeat((v) => !v)} /> +
+
+ Max temperature + 40 °C +
+

+ + {heat ? "Charging paused, battery is warm" : "Heat cap off"} +

+ + } + /> + + {[ + ["#f5a524", "Charging"], + ["#3fc24b", "Holding"], + ].map(([c, l]) => ( +
+
+ +
+ {l} +
+ ))} + + } + /> + +
+ {QUICK_TILES.map((t) => ( + + + {t.label} + + ))} +
+

+ Keeping awake · screen stays on · 45m left +

+ + } + /> + +
+ {[ + ["Adapter", "70W USB-C"], + ["Negotiated", "20.0 V · 3.4 A"], + ["Adapter maximum", "68 W"], + ].map(([k, v]) => ( +
+ {k} + {v} +
+ ))} +
+ + } + /> + +
+ {TOP_UP_MENU.map((item, i) => ( +

+ {item} +

+ ))} +
+ + } + /> +
+
+
+ ); +} + +/* ========================================================================== */ + +function Supported() { + const items: Array<{ icon: LucideIcon; title: string; status: string; ok: boolean }> = [ + { icon: CpuIcon, title: "Apple Silicon", status: "Supported", ok: true }, + { icon: LaptopIcon, title: "macOS 14 to 26", status: "Supported", ok: true }, + { icon: XIcon, title: "Intel Macs", status: "Not supported", ok: false }, + ]; + return ( +
+
+

Will it run on your Mac?

+

+ eWiz is built for Apple Silicon MacBooks on macOS 14 Sonoma or newer, and speaks both of + Apple's charging schemes, including the new one in macOS 26 Tahoe. +

+
+ {items.map((it) => ( +
+ +

{it.title}

+ + {it.status} + +
+ ))} +
+
+
+ ); +} + +function Pricing() { + return ( +
+
+
+

Free for 30 days, then {PRICE} once

+
+
+ +
+

+ + How the license works + +

+
+
+ ); +} + +function Faq() { + return ( +
+
+

Questions people ask

+
+ {FAQS.map((item) => ( +
+
{item.q}
+
{item.a}
+
+ ))} +
+
+
+ ); +} + +function ClosingCta() { + return ( +
+ + +

Try it for 30 days

+

+ Download it, set a limit, and forget about it. If it isn't for you, delete it. There + is no account and nothing to cancel. +

+
+ + Buy · {PRICE} +
+

+ Already using it and want to help?{" "} + + Donate + +

+
+
+ ); +} + +/** `headline` is the index of the hero headline to lead with. */ +export function LandingPage({ headline }: { headline: number }) { + const [iconStyle, setIconStyle] = useState("Bars"); + return ( + + } + > + + + + + + + + + ); +} diff --git a/apps/web/src/components/landing/lightning-field.tsx b/apps/web/src/components/landing/lightning-field.tsx new file mode 100644 index 0000000..05a133f --- /dev/null +++ b/apps/web/src/components/landing/lightning-field.tsx @@ -0,0 +1,144 @@ +import { useEffect, useRef } from "react"; + +type Pt = { x: number; y: number }; +type Seg = { a: Pt; b: Pt; w: number }; + +/** + * Midpoint-displacement lightning: split every segment, nudge its midpoint + * sideways, halve the nudge, repeat. Some midpoints sprout a thinner branch. + */ +function makeBolt(from: Pt, to: Pt, rand: () => number): Seg[] { + let segs: Seg[] = [{ a: from, b: to, w: 1 }]; + let offset = Math.hypot(to.x - from.x, to.y - from.y) * 0.22; + for (let gen = 0; gen < 6; gen++) { + const next: Seg[] = []; + for (const s of segs) { + const dx = s.b.x - s.a.x; + const dy = s.b.y - s.a.y; + const len = Math.hypot(dx, dy) || 1; + const k = (rand() * 2 - 1) * offset; + const mid = { + x: (s.a.x + s.b.x) / 2 - (dy / len) * k, + y: (s.a.y + s.b.y) / 2 + (dx / len) * k, + }; + next.push({ a: s.a, b: mid, w: s.w }, { a: mid, b: s.b, w: s.w }); + if (gen < 4 && s.w > 0.45 && rand() < 0.28) { + const turn = (rand() < 0.5 ? -1 : 1) * (0.35 + rand() * 0.4); + const bx = mid.x - s.a.x; + const by = mid.y - s.a.y; + const reach = 0.7 + rand() * 0.5; + next.push({ + a: mid, + b: { + x: mid.x + (bx * Math.cos(turn) - by * Math.sin(turn)) * reach, + y: mid.y + (bx * Math.sin(turn) + by * Math.cos(turn)) * reach, + }, + w: s.w * 0.5, + }); + } + } + segs = next; + offset /= 2; + } + return segs; +} + +// Bright hit, a dip, a second flicker, then a long fade. Runs on the compositor. +const FLASH: Keyframe[] = [ + { opacity: 0 }, + { opacity: 1, offset: 0.06 }, + { opacity: 0.3, offset: 0.13 }, + { opacity: 0.9, offset: 0.21 }, + { opacity: 0 }, +]; + +/** + * Hero backdrop: an occasional branching lightning strike along the edges of + * the hero. Each bolt is drawn once (no canvas blur), then flashed with a CSS + * opacity animation, so a strike costs one cheap draw and no per-frame work. + * Idle between strikes, paused off-screen or in a hidden tab, and off for + * prefers-reduced-motion. + */ +export function LightningField({ className }: { className?: string }) { + const ref = useRef(null); + + useEffect(() => { + const canvas = ref.current; + if (!canvas) return; + if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return; + const ctx = canvas.getContext("2d"); + if (!ctx) return; + + let visible = true; + const io = new IntersectionObserver(([e]) => { + visible = e.isIntersecting; + }); + io.observe(canvas); + + const rand = Math.random; + let side = rand() < 0.5 ? -1 : 1; + let timer = 0; + let flash: Animation | undefined; + + const strike = () => { + timer = window.setTimeout(strike, 3200 + rand() * 3800); + const width = canvas.clientWidth; + const height = canvas.clientHeight; + if (!visible || document.hidden || width === 0) return; + + // Size the backing store only when a strike is drawn; DPR capped for cost. + const dpr = Math.min(window.devicePixelRatio || 1, 1.5); + if (canvas.width !== Math.round(width * dpr)) canvas.width = Math.round(width * dpr); + if (canvas.height !== Math.round(height * dpr)) canvas.height = Math.round(height * dpr); + ctx.setTransform(dpr, 0, 0, dpr, 0, 0); + ctx.clearRect(0, 0, width, height); + + // Alternate sides so strikes frame the headline instead of crossing it. + side = -side; + const edge = side < 0 ? 0.06 + rand() * 0.2 : 0.74 + rand() * 0.2; + const from = { x: width * edge, y: -10 }; + const to = { x: from.x - side * (40 + rand() * 120), y: height * (0.55 + rand() * 0.3) }; + const segs = makeBolt(from, to, rand); + const dark = document.documentElement.classList.contains("dark"); + const glow = dark ? "76, 195, 255" : "0, 132, 209"; + const core = dark ? "235, 250, 255" : "30, 110, 200"; + + const wash = ctx.createRadialGradient(from.x, 0, 0, from.x, 0, height * 0.9); + wash.addColorStop(0, `rgba(${glow}, ${dark ? 0.12 : 0.08})`); + wash.addColorStop(1, `rgba(${glow}, 0)`); + ctx.fillStyle = wash; + ctx.fillRect(0, 0, width, height); + + // Glow from stacked translucent strokes instead of shadowBlur. + ctx.lineCap = "round"; + ctx.lineJoin = "round"; + for (const [lw, rgb, alpha] of [ + [12, glow, 0.05], + [6, glow, 0.12], + [2.6, glow, 0.5], + [1.1, core, 0.95], + ] as const) { + for (const s of segs) { + ctx.strokeStyle = `rgba(${rgb}, ${alpha * s.w})`; + ctx.lineWidth = lw * Math.max(0.35, s.w); + ctx.beginPath(); + ctx.moveTo(s.a.x, s.a.y); + ctx.lineTo(s.b.x, s.b.y); + ctx.stroke(); + } + } + + flash?.cancel(); + flash = canvas.animate(FLASH, { duration: 950, easing: "ease-out", fill: "forwards" }); + }; + timer = window.setTimeout(strike, 900); + + return () => { + window.clearTimeout(timer); + flash?.cancel(); + io.disconnect(); + }; + }, []); + + return ; +} diff --git a/apps/web/src/components/landing/mac-ui.tsx b/apps/web/src/components/landing/mac-ui.tsx new file mode 100644 index 0000000..5e43958 --- /dev/null +++ b/apps/web/src/components/landing/mac-ui.tsx @@ -0,0 +1,1535 @@ +/** + * Faithful HTML replicas of the eWiz macOS app (dark appearance), built from + * the SwiftUI sources: the menu bar panel, the Settings window and its tabs, + * Battery History and Battery Details. Everything is laid out in macOS points + * at 1x and scaled to fit by . + */ +import { SiApple } from "@icons-pack/react-simple-icons"; +import { useQuery } from "@tanstack/react-query"; +import { + ActivityIcon, + BatteryChargingIcon, + BatteryIcon, + CheckIcon, + ChevronRightIcon, + ClockIcon, + CoffeeIcon, + CpuIcon, + EllipsisIcon, + EyeIcon, + InfoIcon, + KeyRoundIcon, + LaptopIcon, + LogOutIcon, + MonitorIcon, + MoonIcon, + MoonStarIcon, + PauseIcon, + PlugIcon, + PlusIcon, + RotateCwIcon, + SearchIcon, + SettingsIcon, + SlidersHorizontalIcon, + SunDimIcon, + SunIcon, + WandSparklesIcon, + WifiIcon, + ZapIcon, +} from "lucide-react"; +import type { LucideIcon } from "lucide-react"; +import { useEffect, useLayoutEffect, useRef, useState } from "react"; + +import { AppIcon } from "#/components/logo"; +import { latestReleaseQueryOptions } from "#/lib/releases/queries"; +import { cn } from "#/lib/utils"; + +const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect; + +/* ========================================================================== + Stage: renders a fixed-size design and scales it to the container width, + like a screenshot, so the replicas keep their exact macOS proportions. + ========================================================================== */ +export function Stage({ + width, + height, + className, + children, +}: { + width: number; + height: number; + className?: string; + children: React.ReactNode; +}) { + const ref = useRef(null); + const [scale, setScale] = useState(null); + useIsoLayoutEffect(() => { + const el = ref.current; + if (!el) return; + const measure = () => setScale(el.clientWidth / width); + measure(); + const ro = new ResizeObserver(measure); + ro.observe(el); + return () => ro.disconnect(); + }, [width]); + return ( +
+
+ {children} +
+
+ ); +} + +/* ========================================================================== + Controls + ========================================================================== */ +export function Toggle({ + on, + onClick, + label = "Toggle", +}: { + on: boolean; + onClick?: () => void; + label?: string; +}) { + return ( + + ); +} + +function TickSlider({ + value, + min, + max, + step, + onChange, +}: { + value: number; + min: number; + max: number; + step: number; + onChange?: (v: number) => void; +}) { + const ticks = Math.round((max - min) / step) + 1; + const pos = ((value - min) / (max - min)) * 100; + return ( +
+
+
+ {Array.from({ length: ticks }, (_, i) => ( + + ))} +
+ + {onChange ? ( + onChange(Number(e.target.value))} + aria-label="Stop at" + tabIndex={-1} + className="absolute inset-0 w-full cursor-pointer opacity-0" + /> + ) : null} +
+ ); +} + +function Segmented({ + options, + value, + onChange, + className, +}: { + options: readonly T[]; + value: T; + onChange?: (v: T) => void; + className?: string; +}) { + return ( +
+ {options.map((o) => ( + + ))} +
+ ); +} + +function TrafficLights() { + return ( + + + + + + ); +} + +const WINDOW_SHADOW = + "shadow-[0_0_0_0.5px_rgb(0_0_0/0.9),inset_0_0.5px_0_rgb(255_255_255/0.14),0_24px_70px_-12px_rgb(0_0_0/0.65),0_8px_20px_-6px_rgb(0_0_0/0.4)]"; + +export function MacWindow({ + title, + width, + height, + className, + style, + children, +}: { + title: string; + width: number; + height: number; + className?: string; + style?: React.CSSProperties; + children: React.ReactNode; +}) { + return ( +
+
+ + + {title} + +
+ {children} +
+ ); +} + +/* ========================================================================== + Menu bar icon styles (BatteryIconStyle.swift), drawn at 24pt. + ========================================================================== */ +export const ICON_STYLES = [ + "Rounded", + "Bars", + "Classic", + "Minimal", + "Pixel", + "Upright", + "Ring", + "Meter", + "Dot", + "Wave", + "Bolt", + "Dial", +] as const; +export type IconStyle = (typeof ICON_STYLES)[number]; + +const BODY = + "M2 12C2 9.17 2 7.76 2.88 6.88C3.76 6 5.17 6 8 6H13C15.83 6 17.24 6 18.12 6.88C19 7.76 19 9.17 19 12C19 14.83 19 16.24 18.12 17.12C17.24 18 15.83 18 13 18H8C5.17 18 3.76 18 2.88 17.12C2 16.24 2 14.83 2 12Z"; +const NUB = "M19.6 9.6 20.6 9.8C21.6 10 22 10.6 22 12C22 13.4 21.6 14 20.6 14.2L19.6 14.4"; + +export function BatteryGlyph({ + style, + level = 0.8, + className, +}: { + style: IconStyle; + level?: number; + className?: string; +}) { + const s = { stroke: "currentColor", strokeWidth: 1.6, fill: "none" } as const; + const f = { fill: "currentColor" } as const; + const inner = (x: number, w: number, y = 8.6, h = 6.8, r = 1.6) => ( + + ); + let body: React.ReactNode; + switch (style) { + case "Rounded": + body = ( + <> + + + {inner(4.6, 11.8)} + + ); + break; + case "Bars": + body = ( + <> + + + {[5, 9, 13].map((x, i) => ( + i ? 1 : 0.25} + /> + ))} + + ); + break; + case "Classic": + body = ( + <> + + + {inner(4, 13, 8.5, 7, 0.8)} + + ); + break; + case "Minimal": + body = ( + <> + + {inner(4, 16, 9, 6, 3)} + + ); + break; + case "Pixel": + body = ( + <> + + {[4.5, 7.5, 10.5, 13.5].map((x, i) => ( + i ? 1 : 0.2} + /> + ))} + + ); + break; + case "Upright": + body = ( + <> + + + + + ); + break; + case "Ring": { + const c = 2 * Math.PI * 8; + body = ( + <> + + + + ); + break; + } + case "Meter": + body = ( + <> + {[0, 1, 2, 3].map((i) => ( + i ? 1 : 0.25} + /> + ))} + + ); + break; + case "Dot": + body = ( + <> + + + + + + + + + ); + break; + case "Wave": + body = ( + <> + + + + + ); + break; + case "Bolt": + body = ( + <> + + + + ); + break; + case "Dial": { + const r = 8.5; + const a = Math.PI * (1 - level); + const hx = 12 + r * Math.cos(a); + const hy = 16 - r * Math.sin(a); + body = ( + <> + + + + + ); + break; + } + } + return ( + + ); +} + +/* ========================================================================== + macOS menu bar strip + ========================================================================== */ +export function MenuBarStrip({ + iconStyle, + compact = false, +}: { + iconStyle: IconStyle; + compact?: boolean; +}) { + return ( +
+
+ + {compact ? null : ( + <> + Finder + File + Edit + View + Go + Window + Help + + )} +
+
+ {compact ? null : } + {compact ? null : } + + + + + {compact ? "9:41" : "Mon Oct 6 9:41 PM"} +
+
+ ); +} + +/* ========================================================================== + Menu bar panel (MenuContentView.swift), 320pt wide. + ========================================================================== */ +const MODES = ["Extreme", "Off", "Normal", "Super Saver"] as const; +type Mode = (typeof MODES)[number]; + +type Quick = "dim" | "off" | "rest" | "lid" | "awake"; + +export function MenuPopover({ + onOpen, + className, + style, +}: { + onOpen?: (view: "settings" | "details" | "history") => void; + className?: string; + style?: React.CSSProperties; +}) { + const level = 80; + const [mode, setMode] = useState("Normal"); + const [limitOn, setLimitOn] = useState(true); + const [stopAt, setStopAt] = useState(80); + const [dontCharge, setDontCharge] = useState(false); + const [sealed, setSealed] = useState(true); + const [wakeInstantly, setWakeInstantly] = useState(true); + const [quick, setQuick] = useState(null); + + const charging = limitOn ? stopAt > level && !dontCharge : !dontCharge && level < 100; + const caption = charging ? "Charging · 1h 12m · 32.2 W" : "Plugged in, not charging"; + const note = dontCharge + ? "Holding the level" + : !limitOn + ? "Charging to 100%" + : charging + ? `Charging to ${stopAt}%` + : stopAt < level + ? `Draining to ${stopAt}%` + : `Holding at ${stopAt}%`; + const status = + quick === "awake" + ? "Keeping awake · screen stays on · 45m left" + : quick === "lid" + ? "Lid mode · runs with the lid shut on power" + : quick === "rest" + ? "Resting · screen off, settings held" + : "Sleeps as usual"; + + const tiles: Array<{ id: Quick; label: string; icon: LucideIcon; alt?: [string, LucideIcon] }> = [ + { id: "dim", label: "Dim", icon: SunDimIcon, alt: ["Brighten", SunIcon] }, + { id: "off", label: "Off", icon: MonitorIcon }, + { id: "rest", label: "Rest", icon: MoonIcon, alt: ["Wake", SunIcon] }, + { id: "lid", label: "Lid", icon: LaptopIcon }, + { id: "awake", label: "Awake", icon: CoffeeIcon }, + ]; + + const hair =
; + + return ( +
+ {/* Header */} +
+ + {level} + % + + {caption} +
+
+
+ {limitOn ? ( + + ) : null} +
+

{note}

+ + {hair} + + {mode === "Extreme" ? ( +

+ Low Power Mode off, charging to 100%, no idle sleep, High Power Mode. +

+ ) : null} + + {hair} +
+ Limit charging + + + setLimitOn((v) => !v)} /> + +
+
+
+ Stop at + {stopAt}% +
+
+ +
+
+
+ + Don't charge + {dontCharge ? ( + Holding the level + ) : null} + + setDontCharge((v) => !v)} /> +
+ + {hair} +
+ Sealed Sleep + setSealed((v) => !v)} /> +
+
+ Wake instantly + setWakeInstantly((v) => !v)} /> +
+

+ + {sealed + ? "Last close: 5h shut · 0% lost · hibernated" + : "Last close: 5h shut · 3% lost · 0.6%/h"} +

+ + {hair} +
+ {tiles.map((t) => { + const on = quick === t.id; + const [label, Icon] = on && t.alt ? t.alt : [t.label, t.icon]; + const tint = t.id === "awake" ? "#f5c542" : t.id === "lid" ? "var(--m-blue-text)" : null; + return ( + + ); + })} +
+

+ + {status} +

+ + {hair} +
+ + {(["settings", "details", "history"] as const).map((v) => ( + + ))} + + + + + +
+
+ ); +} + +/* ========================================================================== + Settings window (SettingsView.swift), 580pt wide. + ========================================================================== */ +export type SettingsTab = + | "Charging" + | "Schedule" + | "Automation" + | "Sleep & Power" + | "Shortcuts" + | "General" + | "About"; + +const TABS: Array<{ id: SettingsTab; icon: LucideIcon }> = [ + { id: "Charging", icon: BatteryChargingIcon }, + { id: "Schedule", icon: ClockIcon }, + { id: "Automation", icon: WandSparklesIcon }, + { id: "Sleep & Power", icon: MoonStarIcon }, + { id: "Shortcuts", icon: KeyRoundIcon }, + { id: "General", icon: SettingsIcon }, + { id: "About", icon: InfoIcon }, +]; + +function SectionHeader({ children }: { children: React.ReactNode }) { + return ( +

+ {children} +

+ ); +} + +function Row({ + title, + subtitle, + right, + icon, +}: { + title: React.ReactNode; + subtitle?: React.ReactNode; + right?: React.ReactNode; + icon?: React.ReactNode; +}) { + return ( +
+ {icon} +
+

{title}

+ {subtitle ? ( +

{subtitle}

+ ) : null} +
+ {right} +
+ ); +} + +function Note({ icon: Icon, children }: { icon: LucideIcon; children: React.ReactNode }) { + return ( +
+ + {children} +
+ ); +} + +function useToggles(initial: Record) { + const [state, setState] = useState(initial); + const t = (k: string) => ( + setState((s) => ({ ...s, [k]: !s[k] }))} /> + ); + return [state, t] as const; +} + +function ChargingTab() { + const [s, t] = useToggles({ + park: false, + hold: true, + beforeSleep: false, + idle: true, + active: false, + heat: true, + discharge: false, + }); + return ( + <> + Long-term care + + {s.park ? ( + + On. You give up the top 40% day to day, so turn it off before a trip. + + ) : null} + Hold + + {s.hold ? ( + + Held. The battery stays around the level it was at when you switched this on, instead of + climbing to full. + + ) : null} + Enforcement + + + + Heat + + {s.heat ? ( + + 40 °C + + ▲ + ▼ + + + } + /> + ) : null} + Discharge + + + ); +} + +function ScheduleTab() { + const [s, t] = useToggles({ overnight: true, commute: false, ready: true }); + const days = ["S", "M", "T", "W", "T", "F", "S"]; + return ( + <> + Charging schedules + } + title="Overnight hold" + subtitle="22:00–06:00 · Weekdays" + right={ + + {t("overnight")} + + + } + /> + } + title="Top up before work" + subtitle="07:00–08:30 · Weekdays" + right={ + + {t("commute")} + + + } + /> +
+ + + Add Schedule + +
+ Ready by + + {s.ready ? ( + <> + + 8:00 AM + + } + /> + 90%} /> + + {days.map((d, i) => ( + 0 && i < 6 + ? "bg-(--m-blue) text-white" + : "bg-white/[0.08] text-(--m-text-2)", + )} + > + {d} + + ))} + + } + /> + + ) : null} + Charge power +
+
+ Power to the battery + 60% +
+
+ +
+

+ How much of the charger goes to the battery rather than to your Mac. Lower is cooler and + slower; 0% holds the battery entirely. +

+
+ + ); +} + +function SmallButton({ children }: { children: React.ReactNode }) { + return ( + + {children} + + ); +} + +function AutomationTab() { + const [, t] = useToggles({ dock: true, build: true, heavy: false }); + const rule = (key: string, icon: LucideIcon, title: string, caption: string, active: boolean) => { + const Icon = icon; + return ( + } + title={ + + {title} + {active ? ( + + ACTIVE + + ) : null} + + } + subtitle={caption} + right={ + + {t(key)} + + + } + /> + ); + }; + return ( + <> + Rules + {rule( + "dock", + BatteryIcon, + "Docked at a display", + "While external display connected 1 → Charge limit 80%", + true, + )} + {rule( + "build", + EyeIcon, + "Long build: stay awake", + "While Xcode is running → Keep the Mac awake", + true, + )} + {rule( + "heavy", + ZapIcon, + "Heavy app: charge to full", + "While Final Cut Pro is running → Charge limit 100%", + false, + )} +
+ + + Add Rule + + Start from an example ⌄ +
+ Right now + {[ + ["Power", "Charging · 82%"], + ["External displays", "Studio Display"], + ["Wi-Fi", "Home"], + ["IP address", "192.168.1.24"], + ["VPN", "Not connected"], + ["Bluetooth", "AirPods Pro"], + ["CPU", "12%"], + ].map(([k, v]) => ( + {v}} /> + ))} + + + ); +} + +function AgentsSection() { + const [s, t] = useToggles({ agents: true, lid: false }); + const [copied, setCopied] = useState(false); + return ( + <> + AI Agents + + {s.agents ? ( + <> + + Keeping awake: Running the test suite · 42m left + } + /> + Connect} + /> + setCopied(true)}> + {copied ? "Copied" : "Copy Command"} + + } + /> + + ) : null} + + ); +} + +const LEAKS = [ + "Memory stays powered", + "Deep sleep is switched off", + "Terminal sessions block sleep", + "Always Active holds on battery", + "Network kept alive in sleep", + "Power Nap", + "Wake for network access", + "Bluetooth stays on", + "Wi-Fi stays on", +]; + +function SleepTab() { + const [s, t] = useToggles({ sealed: true, instant: true, wifi: true, bt: true }); + return ( + <> +
+
+ + Sealed Sleep + + {s.sealed ? "Nothing can wake it" : "Ordinary macOS sleep"} + + + {t("sealed")} +
+

+ A closed Mac isn't off. macOS keeps waking it on a timer for maintenance, the network + and Find My. Sealed Sleep switches all of that off, so nothing brings it up until you open + the lid. +

+
+ Wake instantly + {t("instant")} +
+
    + {LEAKS.map((l) => ( +
  • + {s.sealed ? ( + <> + + {l} + + ) : ( + <> + + {l} + + )} +
  • + ))} +
+

+ + Last close: 34h shut · 0% lost +

+
+ When the lid closes +
+ + +
+ Wake while closed + } + /> + } + /> + + ); +} + +function GeneralTab({ + iconStyle, + onIconStyle, +}: { + iconStyle: IconStyle; + onIconStyle: (s: IconStyle) => void; +}) { + const [, t] = useToggles({ color: false }); + return ( + <> + Helper +
+

+ + + + Installed and running +

+

+ Enforcing your charge policy in the background. It re-enables charging if ever stopped. +

+
+ Reinstall Helper… + Uninstall… +
+
+ Menu bar +
+ {ICON_STYLES.map((st) => { + const on = st === iconStyle; + return ( + + ); + })} +
+

+ Pick how the battery looks in the menu bar. The fill tracks your exact charge. +

+
+ + Icon only + + ⇕ + + + } + /> + +
+ + ); +} + +function AboutTab() { + const { data: latest } = useQuery(latestReleaseQueryOptions()); + return ( +
+ +

eWiz

+

+ {latest ? `Version ${latest.version}` : null} +

+

+ Charge limiting, heat-aware charging, sleep-safe enforcement, and one-tap save modes. +

+
+ Check for Updates… + Send Feedback +
+
+ ); +} + +export function SettingsWindow({ + tab, + onTab, + iconStyle, + onIconStyle, + height = 600, + scroll = 0, + className, + style, +}: { + scroll?: number; + tab: SettingsTab; + onTab: (t: SettingsTab) => void; + iconStyle: IconStyle; + onIconStyle: (s: IconStyle) => void; + height?: number; + className?: string; + style?: React.CSSProperties; +}) { + const clickable = (id: SettingsTab) => id !== "Shortcuts"; + return ( + +
+ {TABS.map(({ id, icon: Icon }) => { + const on = id === tab; + return ( + + ); + })} +
+
+
+ {tab === "Charging" ? : null} + {tab === "Schedule" ? : null} + {tab === "Automation" ? : null} + {tab === "Sleep & Power" ? : null} + {tab === "General" ? ( + + ) : null} + {tab === "About" ? : null} +
+
+
+ ); +} + +/* ========================================================================== + Battery History and Battery Details + ========================================================================== */ +function GroupCard({ children }: { children: React.ReactNode }) { + return
{children}
; +} + +function H({ children, right }: { children: React.ReactNode; right?: string }) { + return ( +
+

{children}

+ {right ? {right} : null} +
+ ); +} + +function HistoryRow({ + icon, + title, + sub, + value, + rate, + good, +}: { + icon?: boolean; + title: string; + sub: string; + value: string; + rate: string; + good?: boolean; +}) { + return ( +
+ {icon ? : null} +
+

{title}

+

{sub}

+
+
+

+ {value} +

+

{rate}

+
+
+ ); +} + +export function HistoryWindow({ + height = 560, + className, +}: { + height?: number; + className?: string; +}) { + const bars = [38, 52, 45, 70, 64, 80, 76, 80, 80, 72, 66, 80, 84, 80]; + return ( + +
+ Charge level + +
+ {bars.map((b, i) => ( + + ))} +
+
+ Charging + + + + + While Lid Was Closed + + + + + + +
+
+ ); +} + +function KV({ k, v, icon }: { k: string; v: string; icon?: React.ReactNode }) { + return ( +
+ {icon} + {k} + {v} +
+ ); +} + +export function DetailsWindow({ + height = 600, + className, +}: { + height?: number; + className?: string; +}) { + return ( + +
+ Battery + + + + + + + + + Power Flow +
+
+
+

+ + + System 18.6 W · 100% + + + + Into battery 0.0 W · 0% + +

+ + } + /> + } + /> + } + /> + + Power Adapter + + } + /> + + + +
+ + ); +} diff --git a/apps/web/src/components/legal/legal-layout.tsx b/apps/web/src/components/legal/legal-layout.tsx new file mode 100644 index 0000000..28e0e49 --- /dev/null +++ b/apps/web/src/components/legal/legal-layout.tsx @@ -0,0 +1,50 @@ +import type { ReactNode } from "react"; + +import { Container, Eyebrow, SitePage } from "#/components/site/site-shell"; + +/** Shared chrome for the short-form legal pages (/terms, /privacy). */ +export function LegalLayout({ + eyebrow, + title, + updated, + intro, + children, +}: { + eyebrow: string; + title: string; + updated?: string; + intro?: ReactNode; + children: ReactNode; +}) { + return ( + + + {eyebrow} +

{title}

+ {updated ? ( +

+ Last updated:{" "} + {updated} +

+ ) : null} + {intro ?
{intro}
: null} +
{children}
+
+
+ ); +} + +/** A numbered section within a legal document. */ +export function Section({ n, title, children }: { n: string; title: string; children: ReactNode }) { + return ( +
+

+ {n} + {title} +

+
+ {children} +
+
+ ); +} diff --git a/apps/web/src/components/logo.tsx b/apps/web/src/components/logo.tsx new file mode 100644 index 0000000..c8e4b2c --- /dev/null +++ b/apps/web/src/components/logo.tsx @@ -0,0 +1,27 @@ +import { cn } from "#/lib/utils"; + +/** Bump when the icon files in /public change so browsers and the CDN fetch the new art. */ +export const ICON_VERSION = "8"; + +/** The eWiz app icon: the silver volt wizard hat on a graphite squircle (public/ewiz-icon.svg). */ +export function AppIcon({ className }: { className?: string }) { + return ( + + ); +} + +export function Logo({ className }: { className?: string }) { + return ( + + + eWiz + + ); +} diff --git a/apps/web/src/components/pricing-plans.tsx b/apps/web/src/components/pricing-plans.tsx new file mode 100644 index 0000000..5b722c1 --- /dev/null +++ b/apps/web/src/components/pricing-plans.tsx @@ -0,0 +1,68 @@ +import { ArrowUpRightIcon, CheckIcon } from "lucide-react"; + +import { useCheckout } from "#/components/buy-button"; +import { DownloadButton } from "#/components/download-button"; +import { PRICE } from "#/components/landing/landing-data"; +import { Button } from "#/components/ui/button"; + +function Included({ items }: { items: string[] }) { + return ( +
+

What's included

+
    + {items.map((f) => ( +
  • + + {f} +
  • + ))} +
+
+ ); +} + +/** The free trial and the license, side by side. Shown on the home page and /pricing. */ +export function PricingPlans() { + const { buy, loading } = useCheckout(); + return ( + <> +
+
+

Free trial

+

+ $ + 0 + for 30 days +

+ + +
+ +
+

License - Single Mac

+

+ $ + {PRICE.slice(1)} + one-time +

+

+ Pay once and keep it forever. A replacement MacBook battery runs about $199. +

+ + +
+
+

+ Secure checkout via Dodo Payments. Taxes are handled at checkout. +

+ + ); +} diff --git a/apps/web/src/components/prose.tsx b/apps/web/src/components/prose.tsx new file mode 100644 index 0000000..79bd440 --- /dev/null +++ b/apps/web/src/components/prose.tsx @@ -0,0 +1,23 @@ +/** + * Long-form article styling without a typography plugin: descendant selectors + * style plain

/

/

    // written naturally inside . + */ +export function Prose({ children }: { children: React.ReactNode }) { + return ( +
    + {children} +
    + ); +} + +/** Pull-quote / key-insight box used to spotlight the crux of an article. */ +export function Callout({ title, children }: { title: string; children: React.ReactNode }) { + return ( + + ); +} diff --git a/apps/web/src/components/seo/json-ld.tsx b/apps/web/src/components/seo/json-ld.tsx new file mode 100644 index 0000000..1275966 --- /dev/null +++ b/apps/web/src/components/seo/json-ld.tsx @@ -0,0 +1,163 @@ +import { LINKS } from "#/components/landing/landing-data"; +import type { LatestReleaseDTO } from "#/lib/releases/functions"; +import { absoluteUrl, SITE } from "#/lib/seo"; + +/** The publisher/brand. Referenced by other schemas via @id. */ +export function organizationSchema() { + return { + "@context": "https://schema.org", + "@type": "Organization", + "@id": `${absoluteUrl("/")}#organization`, + name: SITE.name, + alternateName: ["eWiz app", "eWiz for Mac", "Battlify"], + url: absoluteUrl("/"), + logo: absoluteUrl("/brand/ewiz-icon-1024.png"), + sameAs: [LINKS.github, LINKS.x], + }; +} + +/** The site itself, so search engines can show a sitelinks/name box. */ +export function websiteSchema() { + return { + "@context": "https://schema.org", + "@type": "WebSite", + "@id": `${absoluteUrl("/")}#website`, + name: SITE.name, + alternateName: "eWiz app", + url: absoluteUrl("/"), + description: SITE.description, + publisher: { "@id": `${absoluteUrl("/")}#organization` }, + inLanguage: "en", + }; +} + +/** The product. Powers the app rich result (price, platform, rating). */ +export function softwareApplicationSchema(latest?: LatestReleaseDTO | null) { + return { + "@context": "https://schema.org", + "@type": "SoftwareApplication", + name: SITE.name, + alternateName: ["eWiz app", "eWiz for Mac", "Download eWiz", "Battlify"], + applicationCategory: "UtilitiesApplication", + operatingSystem: "macOS 14+", + description: SITE.description, + url: absoluteUrl("/"), + image: absoluteUrl("/og.png"), + downloadUrl: latest?.dmg ?? `${LINKS.releases}/latest`, + installUrl: absoluteUrl("/download"), + releaseNotes: absoluteUrl("/changelog"), + screenshot: absoluteUrl("/og.png"), + softwareRequirements: "macOS 14 Sonoma or later on Apple Silicon (M1 or newer)", + featureList: [ + "Charge limit from 50 to 100 percent that holds while the Mac sleeps", + "Heat-aware charging that pauses when the battery runs warm", + "Sealed Sleep: a closed lid that loses no charge", + "Automation rules and charging schedules", + "AI agents (MCP) can keep the Mac awake on a timer", + "One-tap save modes", + "MagSafe LED that shows the real charge state", + "Battery health, history and power adapter details", + ], + ...(latest ? { softwareVersion: latest.version } : {}), + offers: { + "@type": "Offer", + price: "2.99", + priceCurrency: "USD", + availability: "https://schema.org/InStock", + }, + publisher: { "@id": `${absoluteUrl("/")}#organization` }, + }; +} + +export interface ArticleSchemaInput { + title: string; + description: string; + slug: string; + /** ISO publish date. */ + datePublished: string; + /** ISO modified date; falls back to datePublished. */ + dateModified?: string; +} + +/** A blog article, for the Article rich result. */ +export function articleSchema(post: ArticleSchemaInput) { + const url = absoluteUrl(`/blog/${post.slug}`); + return { + "@context": "https://schema.org", + "@type": "Article", + "@id": `${url}#article`, + headline: post.title, + description: post.description, + image: absoluteUrl("/og.png"), + datePublished: post.datePublished, + dateModified: post.dateModified ?? post.datePublished, + author: { + "@type": "Person", + name: "Nischal Dahal", + url: LINKS.site, + }, + publisher: { "@id": `${absoluteUrl("/")}#organization` }, + mainEntityOfPage: { "@type": "WebPage", "@id": url }, + inLanguage: "en", + }; +} + +/** A breadcrumb trail, for the breadcrumb rich result. */ +export function breadcrumbSchema(crumbs: Array<{ name: string; path: string }>) { + return { + "@context": "https://schema.org", + "@type": "BreadcrumbList", + itemListElement: crumbs.map((c, i) => ({ + "@type": "ListItem", + position: i + 1, + name: c.name, + item: absoluteUrl(c.path), + })), + }; +} + +/** + * Hints the primary navigation to search engines. Does not force sitelinks + * (those are automatic), but names the pages Google is most likely to surface + * under the main result and gives it their preferred labels. + */ +export function siteNavigationSchema() { + const items = [ + { name: "Download", path: "/download" }, + { name: "Pricing", path: "/pricing" }, + { name: "Blog", path: "/blog" }, + { name: "Changelog", path: "/changelog" }, + { name: "Privacy Policy", path: "/legal/privacy" }, + { name: "Terms of Service", path: "/legal/terms" }, + { name: "eWiz License", path: "/legal/license" }, + ]; + return { + "@context": "https://schema.org", + "@type": "ItemList", + "@id": `${absoluteUrl("/")}#nav`, + itemListElement: items.map((it, i) => ({ + "@type": "SiteNavigationElement", + position: i + 1, + name: it.name, + url: absoluteUrl(it.path), + })), + }; +} + +export interface FaqItem { + question: string; + answer: string; +} + +/** A FAQ list, for the FAQ rich result. */ +export function faqSchema(items: FaqItem[]) { + return { + "@context": "https://schema.org", + "@type": "FAQPage", + mainEntity: items.map((it) => ({ + "@type": "Question", + name: it.question, + acceptedAnswer: { "@type": "Answer", text: it.answer }, + })), + }; +} diff --git a/apps/web/src/components/sign-in-social-button.tsx b/apps/web/src/components/sign-in-social-button.tsx new file mode 100644 index 0000000..87f892a --- /dev/null +++ b/apps/web/src/components/sign-in-social-button.tsx @@ -0,0 +1,47 @@ +import { useMutation } from "@tanstack/react-query"; +import { toast } from "sonner"; + +import { Button } from "#/components/ui/button"; +import { authClient } from "#/lib/auth/auth-client"; + +interface SocialLoginButtonProps { + provider: string; + icon: React.ReactNode; + disabled?: boolean; + callbackURL: string; +} + +export function SignInSocialButton(props: SocialLoginButtonProps) { + const providerLabel = + props.provider === "github" + ? "GitHub" + : props.provider.charAt(0).toUpperCase() + props.provider.slice(1); + + const mutation = useMutation({ + mutationFn: async () => + await authClient.signIn.social( + { + provider: props.provider, + callbackURL: props.callbackURL, + }, + { + onError: ({ error }) => { + toast.error(error.message || `An error occurred during ${providerLabel} sign-in.`); + }, + }, + ), + }); + + return ( + + ); +} diff --git a/apps/web/src/components/sign-out-button.tsx b/apps/web/src/components/sign-out-button.tsx new file mode 100644 index 0000000..cba5f67 --- /dev/null +++ b/apps/web/src/components/sign-out-button.tsx @@ -0,0 +1,32 @@ +import { useQueryClient } from "@tanstack/react-query"; +import { useRouter } from "@tanstack/react-router"; + +import { Button } from "#/components/ui/button"; +import { authClient } from "#/lib/auth/auth-client"; +import { authQueryOptions } from "#/lib/auth/queries"; + +export function SignOutButton() { + const queryClient = useQueryClient(); + const router = useRouter(); + return ( + + ); +} diff --git a/apps/web/src/components/site/site-shell.tsx b/apps/web/src/components/site/site-shell.tsx new file mode 100644 index 0000000..d7e2e5e --- /dev/null +++ b/apps/web/src/components/site/site-shell.tsx @@ -0,0 +1,181 @@ +import { Link } from "@tanstack/react-router"; + +import { LINKS } from "#/components/landing/landing-data"; +import { AppIcon, Logo } from "#/components/logo"; +import { ThemeToggle } from "#/components/theme-toggle"; +import { useAuth } from "#/lib/auth/hooks"; +import { cn } from "#/lib/utils"; + +/** The single 736px reading column every marketing page is laid out on. */ +export function Container({ className, ...props }: React.ComponentProps<"div">) { + return
    ; +} + +const EYEBROW_TONE = { + brand: "text-primary", + rose: "text-rose", + success: "text-success", + warning: "text-warning", +} as const; + +/** Small uppercase label above a heading. Each section picks its own color. */ +export function Eyebrow({ + tone = "brand", + className, + ...props +}: React.ComponentProps<"p"> & { tone?: keyof typeof EYEBROW_TONE }) { + return ( +

    + ); +} + +const NAV_LINK = "transition-colors hover:text-foreground"; + +export function SiteHeader() { + const { user } = useAuth(); + return ( +

    + + + + + + + {user ? "Dashboard" : "Sign in"} + + +
    + ); +} + +type FooterLink = { label: string } & ( + | { + to: + | "/" + | "/pricing" + | "/download" + | "/changelog" + | "/blog" + | "/donate" + | "/legal/privacy" + | "/legal/terms" + | "/legal/license"; + hash?: string; + } + | { href: string } +); + +const FOOTER_COLUMNS: Array<{ title: string; links: FooterLink[] }> = [ + { + title: "Product", + links: [ + { label: "Pricing", to: "/pricing" }, + { label: "Download", to: "/download" }, + { label: "Changelog", to: "/changelog" }, + { label: "Blog", to: "/blog" }, + { label: "Donate", to: "/donate" }, + ], + }, + { + title: "Connect", + links: [ + { label: "X / Twitter", href: LINKS.x }, + { label: "GitHub", href: LINKS.github }, + { label: "Report an issue", href: LINKS.feedback }, + ], + }, + { + title: "More", + links: [ + { label: "Stroke", href: LINKS.stroke }, + { label: "nischal-dahal.com.np", href: LINKS.site }, + ], + }, + { + title: "Legal", + links: [ + { label: "Privacy policy", to: "/legal/privacy" }, + { label: "Terms of service", to: "/legal/terms" }, + { label: "Source license", to: "/legal/license" }, + ], + }, +]; + +export function SiteFooter() { + return ( +
    + +
    +
    + +

    + Battery care for your Mac. +

    +
    + {FOOTER_COLUMNS.map((col) => ( +
    +

    {col.title}

    +
      + {col.links.map((l) => ( +
    • + {"href" in l ? ( + + {l.label} + + ) : ( + + {l.label} + + )} +
    • + ))} +
    +
    + ))} +
    +
    +

    © 2026 eWiz

    + +
    +
    +
    + ); +} + +/** Header + footer around a marketing page. `backdrop` paints behind the header and content. */ +export function SitePage({ + children, + backdrop, +}: { + children: React.ReactNode; + backdrop?: React.ReactNode; +}) { + return ( +
    + {backdrop} + +
    {children}
    + +
    + ); +} diff --git a/apps/web/src/components/theme-provider.tsx b/apps/web/src/components/theme-provider.tsx new file mode 100644 index 0000000..0723248 --- /dev/null +++ b/apps/web/src/components/theme-provider.tsx @@ -0,0 +1,95 @@ +// https://ui.shadcn.com/docs/dark-mode/tanstack-start +import { ScriptOnce } from "@tanstack/react-router"; +import { createContext, use, useEffect, useState } from "react"; + +type Theme = "dark" | "light" | "system"; + +type ThemeProviderProps = { + children: React.ReactNode; + defaultTheme?: Theme; + storageKey?: string; +}; + +type ThemeProviderState = { + theme: Theme; + setTheme: (theme: Theme) => void; +}; + +function getThemeScript(storageKey: string, defaultTheme: Theme) { + const key = JSON.stringify(storageKey); + const fallback = JSON.stringify(defaultTheme); + + return `(function(){try{var t=localStorage.getItem(${key});if(t!=='light'&&t!=='dark'&&t!=='system'){t=${fallback}}var d=matchMedia('(prefers-color-scheme: dark)').matches;var r=t==='system'?(d?'dark':'light'):t;var e=document.documentElement;e.classList.add(r);e.style.colorScheme=r}catch(e){}})();`; +} + +const ThemeProviderContext = createContext({ + theme: "system", + setTheme: () => {}, +}); + +function applyTheme(theme: Theme) { + const root = document.documentElement; + root.classList.remove("light", "dark"); + + const resolved = + theme === "system" + ? window.matchMedia("(prefers-color-scheme: dark)").matches + ? "dark" + : "light" + : theme; + + root.classList.add(resolved); + root.style.colorScheme = resolved; +} + +export function ThemeProvider({ + children, + defaultTheme = "system", + storageKey = "theme", +}: ThemeProviderProps) { + const [theme, setThemeState] = useState(defaultTheme); + const [mounted, setMounted] = useState(false); + + useEffect(() => { + const stored = localStorage.getItem(storageKey); + // oxlint-disable-next-line react-hooks-js/set-state-in-effect + setThemeState( + stored === "light" || stored === "dark" || stored === "system" ? stored : defaultTheme, + ); + setMounted(true); + }, [defaultTheme, storageKey]); + + useEffect(() => { + if (!mounted) return; + applyTheme(theme); + }, [theme, mounted]); + + useEffect(() => { + if (!mounted || theme !== "system") return; + + const media = window.matchMedia("(prefers-color-scheme: dark)"); + const onChange = () => applyTheme("system"); + media.addEventListener("change", onChange); + return () => media.removeEventListener("change", onChange); + }, [theme, mounted]); + + const setTheme = (next: Theme) => { + localStorage.setItem(storageKey, next); + setThemeState(next); + }; + + return ( + + {getThemeScript(storageKey, defaultTheme)} + {children} + + ); +} + +export function useTheme() { + const context = use(ThemeProviderContext); + + if (context === undefined) throw new Error("useTheme must be used within a ThemeProvider"); + + return context; +} diff --git a/apps/web/src/components/theme-toggle.tsx b/apps/web/src/components/theme-toggle.tsx new file mode 100644 index 0000000..aa3203f --- /dev/null +++ b/apps/web/src/components/theme-toggle.tsx @@ -0,0 +1,29 @@ +import { ContrastIcon } from "@hugeicons/core-free-icons"; + +import { Icon } from "#/components/icon"; +import { useTheme } from "#/components/theme-provider"; +import { Button } from "#/components/ui/button"; + +/** + * One-tap light/dark toggle. Reads the class the ThemeProvider applied to + * so it flips relative to what's actually on screen (even under + * `system`). Deliberately a plain button — no dropdown/menu dependency. + */ +export function ThemeToggle() { + const { setTheme } = useTheme(); + + return ( + + ); +} diff --git a/apps/web/src/components/ui/button.tsx b/apps/web/src/components/ui/button.tsx new file mode 100644 index 0000000..edd842b --- /dev/null +++ b/apps/web/src/components/ui/button.tsx @@ -0,0 +1,56 @@ +import { Button as ButtonPrimitive } from "@base-ui/react/button"; +import { cva, type VariantProps } from "class-variance-authority"; + +import { cn } from "#/lib/utils"; + +const buttonVariants = cva( + "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", + { + variants: { + variant: { + default: "bg-primary text-primary-foreground hover:bg-primary/90", + outline: + "border-border bg-surface-1 hover:bg-surface-2 hover:text-foreground aria-expanded:bg-surface-2 aria-expanded:text-foreground", + secondary: + "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground", + ghost: + "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50", + destructive: + "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40", + link: "text-primary underline-offset-4 hover:underline", + }, + size: { + default: + "h-8 gap-1.5 px-3 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5", + xs: "h-6 gap-1 px-2.5 text-xs has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3", + sm: "h-7 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2", + lg: "h-9 gap-1.5 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3", + icon: "size-8", + "icon-xs": "size-6 [&_svg:not([class*='size-'])]:size-3", + "icon-sm": "size-7", + "icon-lg": "size-9", + }, + }, + defaultVariants: { + variant: "default", + size: "default", + }, + }, +); + +function Button({ + className, + variant = "default", + size = "default", + ...props +}: ButtonPrimitive.Props & VariantProps) { + return ( + + ); +} + +export { Button, buttonVariants }; diff --git a/apps/web/src/components/ui/dropdown-menu.tsx b/apps/web/src/components/ui/dropdown-menu.tsx new file mode 100644 index 0000000..a0a9aca --- /dev/null +++ b/apps/web/src/components/ui/dropdown-menu.tsx @@ -0,0 +1,253 @@ +import { Menu as MenuPrimitive } from "@base-ui/react/menu"; +import { ChevronRightIcon, CheckIcon } from "lucide-react"; +import * as React from "react"; + +import { cn } from "#/lib/utils"; + +function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) { + return ; +} + +function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) { + return ; +} + +function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) { + return ; +} + +function DropdownMenuContent({ + align = "start", + alignOffset = 0, + side = "bottom", + sideOffset = 4, + className, + ...props +}: MenuPrimitive.Popup.Props & + Pick) { + return ( + + + + + + ); +} + +function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) { + return ; +} + +function DropdownMenuLabel({ + className, + inset, + ...props +}: MenuPrimitive.GroupLabel.Props & { + inset?: boolean; +}) { + return ( + + ); +} + +function DropdownMenuItem({ + className, + inset, + variant = "default", + ...props +}: MenuPrimitive.Item.Props & { + inset?: boolean; + variant?: "default" | "destructive"; +}) { + return ( + + ); +} + +function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) { + return ; +} + +function DropdownMenuSubTrigger({ + className, + inset, + children, + ...props +}: MenuPrimitive.SubmenuTrigger.Props & { + inset?: boolean; +}) { + return ( + + {children} + + + ); +} + +function DropdownMenuSubContent({ + align = "start", + alignOffset = -3, + side = "right", + sideOffset = 0, + className, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +function DropdownMenuCheckboxItem({ + className, + children, + checked, + inset, + ...props +}: MenuPrimitive.CheckboxItem.Props & { + inset?: boolean; +}) { + return ( + + + + + + + {children} + + ); +} + +function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) { + return ; +} + +function DropdownMenuRadioItem({ + className, + children, + inset, + ...props +}: MenuPrimitive.RadioItem.Props & { + inset?: boolean; +}) { + return ( + + + + + + + {children} + + ); +} + +function DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props) { + return ( + + ); +} + +function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<"span">) { + return ( + + ); +} + +export { + DropdownMenu, + DropdownMenuPortal, + DropdownMenuTrigger, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuLabel, + DropdownMenuItem, + DropdownMenuCheckboxItem, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuSub, + DropdownMenuSubTrigger, + DropdownMenuSubContent, +}; diff --git a/apps/web/src/components/ui/input.tsx b/apps/web/src/components/ui/input.tsx new file mode 100644 index 0000000..f6e18e1 --- /dev/null +++ b/apps/web/src/components/ui/input.tsx @@ -0,0 +1,20 @@ +import { Input as InputPrimitive } from "@base-ui/react/input"; +import * as React from "react"; + +import { cn } from "#/lib/utils"; + +function Input({ className, type, ...props }: React.ComponentProps<"input">) { + return ( + + ); +} + +export { Input }; diff --git a/apps/web/src/components/ui/label.tsx b/apps/web/src/components/ui/label.tsx new file mode 100644 index 0000000..2f878ec --- /dev/null +++ b/apps/web/src/components/ui/label.tsx @@ -0,0 +1,19 @@ +import * as React from "react"; + +import { cn } from "#/lib/utils"; + +function Label({ className, ...props }: React.ComponentProps<"label">) { + return ( + // oxlint-disable-next-line jsx-a11y/label-has-associated-control +