@gphone/sdk
    Preparing search index...

    @gphone/sdk

    gPhone Web Interface

    This directory contains the Svelte 5 frontend application and NUI bridge for gPhone, a custom smartphone resource for FiveM.


    • Framework: Svelte 5 โ€” runes ($state, $derived, $effect) for component-local state only. Global state is writable/derived stores in src/services/ and src/shell/state/, one file per domain. This split is a policy rather than a leftover: see AGENTS.md ยง4, which is the authority, and do not introduce .svelte.ts rune-based state modules or convert existing stores.
    • Build Tool: Vite
    • Styling: Hand-written CSS โ€” Material 3 design tokens in src/app.css, a flat utility layer in src/app-utilities.css
    • Language: TypeScript
    • Testing: Playwright (E2E) & Vitest (Unit)

    web/
    โ”œโ”€โ”€ e2e/                # Playwright End-to-End test suites
    โ”‚   โ”œโ”€โ”€ apps/           # Individual app E2E tests (Admin, Bank, Blabber, Bluetooth Share, Calculator, Camera,
    โ”‚   โ”‚                   # Contacts, Mail, Media, Messages, Notes, Phone, Settings, Sound, Store)
    โ”‚   โ”œโ”€โ”€ app-residency.spec.ts
    โ”‚   โ”œโ”€โ”€ deep-link.spec.ts        # the dev `?app=` deep link
    โ”‚   โ”œโ”€โ”€ deep-links.spec.ts       # notification deep-link routing
    โ”‚   โ”œโ”€โ”€ display.spec.ts
    โ”‚   โ”œโ”€โ”€ defects.spec.ts
    โ”‚   โ”œโ”€โ”€ error_boundary.spec.ts
    โ”‚   โ”œโ”€โ”€ home-grid.spec.ts        # icon drag/drop, dock, drawer
    โ”‚   โ”œโ”€โ”€ home-search.spec.ts
    โ”‚   โ”œโ”€โ”€ keybinds.spec.ts
    โ”‚   โ”œโ”€โ”€ navigation.spec.ts
    โ”‚   โ”œโ”€โ”€ notifications.spec.ts
    โ”‚   โ”œโ”€โ”€ nui.spec.ts
    โ”‚   โ”œโ”€โ”€ settings-persistence.spec.ts
    โ”‚   โ””โ”€โ”€ theme-modes.spec.ts
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ apps/           # One directory per app (admin, bank, blabber, calculator, camera, contacts, hodlr, mail,
    โ”‚   โ”‚                   # marketplace, media, messages, notes, phone, settings, snek, store)
    โ”‚   โ”œโ”€โ”€ shell/          # The OS itself: Shell.svelte, PhoneFrame, Launcher, ToastHost, VolumeHud, ErrorBoundary
    โ”‚   โ”‚   โ””โ”€โ”€ state/      # State the phone owns (appDrawer, appEvents, audio, bluetooth, bootstrap, catalog, charge,
    โ”‚   โ”‚                   # devtools, display, dock, homeGrid, homeGridSettings, iconDrag, keybinds, navigation,
    โ”‚   โ”‚                   # notificationSettings, onboarding, registry, remoteAppSecurity, search, searchResults,
    โ”‚   โ”‚                   # seedFromImage, shade, signal, theme, time, toast, wallpaper)
    โ”‚   โ”œโ”€โ”€ services/       # Client-side cache of each core service (account, admin, call, camera, contacts,
    โ”‚   โ”‚                   # conversations, highscores, mail, marketplace, media, notifications, reports, settings)
    โ”‚   โ”‚                   # plus the two factories they are built from: createCrudStore, createPagedStore. An
    โ”‚   โ”‚                   # add-on's store โ€” Notes, Blabber, Hodlr โ€” lives beside its app in src/apps/ instead;
    โ”‚   โ”‚                   # see AGENTS.md ยง8/ยง11.
    โ”‚   โ”œโ”€โ”€ sdk/            # @gphone/sdk โ€” the only thing apps may import
    โ”‚   โ”‚   โ””โ”€โ”€ ui/         # UI primitives and icons apps build with
    โ”‚   โ”œโ”€โ”€ nui/            # The bridge: transport adapters, fetchNui, useNuiEvent, browser mocks
    โ”‚   โ”œโ”€โ”€ lib/            # Helpers with no gPhone state and no I/O (debug, dragRatio, dragScroll, errors,
    โ”‚   โ”‚                   # filterByQuery, formatters, isBrowser, longPressDrag, m3, markdown, pointerDrag,
    โ”‚   โ”‚                   # useScrollDetect)
    โ”‚   โ””โ”€โ”€ main.ts         # Mounts shell/Shell.svelte
    โ”œโ”€โ”€ package.json
    โ””โ”€โ”€ playwright.config.ts
    

    gPhone includes a full suite of automated unit (Vitest) and Playwright End-to-End (E2E) tests.

    Run unit test suites covering the core service caches (account, admin, call, camera, contacts, conversations, highscores, mail, marketplace, media, notifications, reports, settings) and the createCrudStore/createPagedStore factories behind them, shell state (appDrawer, appEvents, audio, bluetooth, bootstrap, catalog, charge, display, dock, homeGrid, homeGridSettings, iconDrag, keybinds, navigation, onboarding, registry, remoteAppSecurity, searchResults, shade, signal, theme, time, toast, wallpaper), transport adapters, SDK helpers and boundaries, and the pure helpers in lib/:

    pnpm test:unit
    

    The Playwright test suite covers full application flows, NUI events, app error boundaries, interactive notification deep-linking, and form validation across all phone apps:

    # Run full headless E2E test suite
    pnpm test:e2e

    # Visually observe tests running in a single-worker headed Chrome window
    pnpm test:e2e:headed

    # Serve the HTML Web View Report at http://localhost:9323
    pnpm test:e2e:report

    gPhone uses a pluggable ITransportAdapter abstraction layer to handle event communication across runtime environments:

    • Standalone Browser Mode (MockTransportAdapter): Running pnpm dev launches the web app on http://localhost:5173. Callbacks dynamically resolve from MockRegistry data fixtures.
    • FiveM CEF NUI Mode (NuiTransportAdapter): Inside FiveM, callbacks issue fetch('https://<resource>/<event>') requests and handle incoming NUI window.message events seamlessly.
    • Remote Device & External Sync (WebSocketTransportAdapter): Connects gPhone to external WebSockets with automatic reconnection, timeouts, and transparent NUI event broadcasting for remote control and external browser sync.