Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/desktop-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: DroidUI Desktop Windows Installer

on:
workflow_dispatch:
pull_request:
paths:
- "desktop/**"
- ".github/workflows/desktop-windows.yml"
push:
branches:
- feat/desktop-foundation
paths:
- "desktop/**"
- ".github/workflows/desktop-windows.yml"

permissions:
contents: read

jobs:
windows-installer:
name: Build Windows NSIS installer
runs-on: windows-latest
defaults:
run:
working-directory: desktop
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-pc-windows-msvc
- name: Generate required Tauri icons
shell: pwsh
run: |
python -m pip install --disable-pip-version-check pillow
@'
from PIL import Image, ImageDraw
from pathlib import Path
p=Path("src-tauri/icons")
p.mkdir(parents=True, exist_ok=True)
im=Image.new("RGBA",(512,512),(21,29,42,255))
d=ImageDraw.Draw(im)
d.rounded_rectangle((65,65,447,447),radius=85,fill=(50,105,232,255))
d.polygon([(256,115),(390,256),(256,397),(122,256)],fill=(240,246,255,255))
im.save(p/"icon.png")
im.save(p/"icon.ico",sizes=[(16,16),(32,32),(48,48),(64,64),(128,128),(256,256)])
'@ | python -
- name: Install desktop dependencies
run: npm install --no-audit --no-fund
- name: Build desktop web frontend
run: npm run build
- name: Build Tauri Windows installer
id: installer
continue-on-error: true
run: npm run desktop:build
- name: Upload compiled portable executable
if: always()
uses: actions/upload-artifact@v4
with:
name: droidui-desktop-windows-portable
path: desktop/src-tauri/target/release/droidui-desktop.exe
if-no-files-found: error
retention-days: 14
- name: Retry installer packaging after transient network failure
if: steps.installer.outcome == 'failure'
run: npm run desktop:build
- name: Verify installer exists
shell: pwsh
run: |
$files = @(Get-ChildItem -Path src-tauri/target/release/bundle/nsis -Filter "*.exe" -File -ErrorAction SilentlyContinue)
if ($files.Count -eq 0) { throw "No Windows NSIS installer generated" }
$files | ForEach-Object { Write-Host "$($_.Name) $($_.Length) bytes" }
- uses: actions/upload-artifact@v4
with:
name: droidui-desktop-windows-installer
path: desktop/src-tauri/target/release/bundle/nsis/*.exe
if-no-files-found: error
retention-days: 14
19 changes: 19 additions & 0 deletions desktop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# DroidUI Desktop — Phase D1

Windows-first Tauri 2 + React/TypeScript desktop studio. This first scaffold supports a draggable canvas, layer selection, property editing, and saving/loading a **desktop prototype** project.

## Run

Prerequisites: Node 20+, Rust stable, Windows C++ build tools, WebView2.

```bash
cd desktop
npm install
npm run desktop
```

Build an installer with `npm run desktop:build`.

## Known limitations

The current desktop JSON document is a **prototype**, NOT the existing DroidUI mobile `.dui` schema. Loading a mobile project is intentionally rejected until the shared project adapter and schema validation are implemented. File dialogs and disk access require the Tauri runtime (not a plain browser). No Windows installer has been verified yet. Drag positions are not yet constrained to canvas bounds. Additional production features (undo/redo, device presets, export, shared compiler, icons, animation timeline) remain future phases.
1 change: 1 addition & 0 deletions desktop/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><title>DroidUI Desktop</title></head><body><div id="root"></div><script type="module" src="/src/main.tsx"></script></body></html>
26 changes: 26 additions & 0 deletions desktop/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "droidui-desktop",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"desktop": "tauri dev",
"desktop:build": "tauri build"
},
"dependencies": {
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@tauri-apps/cli": "^2.0.0",
"@types/react": "^18.3.0",
"@types/react-dom": "^18.3.0",
"typescript": "^5.6.0",
"vite": "^5.4.0"
}
}
12 changes: 12 additions & 0 deletions desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "droidui-desktop"
version = "0.1.0"
edition = "2021"

[build-dependencies]
tauri-build = { version = "2", features = [] }

[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-dialog = "2"
tauri-plugin-fs = "2"
1 change: 1 addition & 0 deletions desktop/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() { tauri_build::build() }
17 changes: 17 additions & 0 deletions desktop/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"identifier": "default",
"description": "Project file open and save",
"windows": [
"main"
],
"permissions": [
"core:default",
"dialog:allow-open",
"dialog:allow-save",
"fs:allow-read-text-file",
"fs:allow-write-text-file",
"fs:scope-home",
"fs:scope-document",
"fs:scope-download"
]
}
2 changes: 2 additions & 0 deletions desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() { tauri::Builder::default().plugin(tauri_plugin_dialog::init()).plugin(tauri_plugin_fs::init()).run(tauri::generate_context!()).expect("failed to run DroidUI Desktop"); }
32 changes: 32 additions & 0 deletions desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "DroidUI Desktop",
"version": "0.1.0",
"identifier": "com.codephrex.droidui.desktop",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "DroidUI Desktop",
"width": 1440,
"height": 900,
"minWidth": 1024,
"minHeight": 700
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": [
"nsis"
]
}
}
26 changes: 26 additions & 0 deletions desktop/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { useState } from "react";
import { createRoot } from "react-dom/client";
import { open, save } from "@tauri-apps/plugin-dialog";
import { readTextFile, writeTextFile } from "@tauri-apps/plugin-fs";
import "./style.css";

type Node = { id: string; type: "Text" | "Button" | "Card"; label: string; x: number; y: number };
type Document = { name: string; nodes: Node[] };
const initial: Document = { name: "Untitled Project", nodes: [{ id: "welcome", type: "Text", label: "Welcome to DroidUI", x: 64, y: 72 }] };
function App() {
const [doc, setDoc] = useState<Document>(initial);
const [selected, setSelected] = useState<string | null>("welcome");
const [path, setPath] = useState<string | null>(null);
const [message, setMessage] = useState("Ready");
const node = doc.nodes.find(n => n.id === selected);
function updateNode(id: string, patch: Partial<Node>) { setDoc(d => ({ ...d, nodes: d.nodes.map(n => n.id === id ? { ...n, ...patch } : n) })); }
function add(type: Node["type"]) { const id = crypto.randomUUID(); setDoc(d => ({ ...d, nodes: [...d.nodes, { id, type, label: type === "Text" ? "Text label" : type, x: 48, y: 48 }] })); setSelected(id); }
async function load() { try { const file = await open({ multiple: false, filters: [{ name: "DroidUI project", extensions: ["dui", "json"] }] }); if (typeof file !== "string") return; const raw = JSON.parse(await readTextFile(file)); if (!raw || typeof raw !== "object" || !Array.isArray(raw.nodes) || typeof raw.name !== "string") throw Error("Unsupported project format"); setDoc(raw as Document); setPath(file); setSelected(null); setMessage("Project opened"); } catch (e) { setMessage(String(e)); } }
async function persist() { try { const file = path ?? await save({ defaultPath: doc.name.replace(/[^a-z0-9-_]/gi, "_") + ".dui", filters: [{ name: "DroidUI project", extensions: ["dui"] }] }); if (!file) return; await writeTextFile(file, JSON.stringify(doc, null, 2)); setPath(file); setMessage("Project saved"); } catch (e) { setMessage(String(e)); } }
return <div className="shell">
<header><div className="brand"><span className="mark">◈</span> DroidUI <small>DESKTOP</small></div><div className="actions"><button onClick={() => { setDoc(initial); setSelected("welcome"); setPath(null); }}>New</button><button onClick={load}>Open</button><button onClick={persist}>Save</button></div></header>
<div className="workspace"><aside className="tools"><h3>Toolbox</h3>{(["Text","Button","Card"] as const).map(type => <button key={type} onClick={() => add(type)}>+ {type}</button>)}<h3>Layers</h3>{doc.nodes.map(n => <button className={n.id === selected ? "active" : ""} key={n.id} onClick={() => setSelected(n.id)}>{n.type} · {n.label}</button>)}</aside>
<main><div className="canvasbar"><strong>{doc.name}</strong><span>Canvas · 390 × 844</span></div><div className="canvas" onClick={() => setSelected(null)}>{doc.nodes.map(n => <div key={n.id} className={`element ${n.type.toLowerCase()} ${selected === n.id ? "selected" : ""}`} style={{ left:n.x,top:n.y }} onClick={e => {e.stopPropagation();setSelected(n.id);}} onPointerDown={e => { if(e.button!==0) return; const startX=e.clientX,startY=e.clientY,ox=n.x,oy=n.y; const move=(ev:PointerEvent)=>updateNode(n.id,{x:Math.max(0,ox+ev.clientX-startX),y:Math.max(0,oy+ev.clientY-startY)}); const stop=()=>{window.removeEventListener("pointermove",move);window.removeEventListener("pointerup",stop);};window.addEventListener("pointermove",move);window.addEventListener("pointerup",stop); }}>{n.label}</div>)}</div></main>
<aside className="inspector"><h3>Properties</h3>{node ? <><label>Label<input value={node.label} onChange={e=>updateNode(node.id,{label:e.target.value})}/></label><label>X<input type="number" value={node.x} onChange={e=>updateNode(node.id,{x:Number(e.target.value)})}/></label><label>Y<input type="number" value={node.y} onChange={e=>updateNode(node.id,{y:Number(e.target.value)})}/></label><button onClick={()=>{setDoc(d=>({...d,nodes:d.nodes.filter(n=>n.id!==node.id)}));setSelected(null);}}>Delete element</button></> : <p>Select an element to edit it.</p>}</aside></div><footer>{message}<span>Phase D1 · Desktop foundation</span></footer></div>;
}
createRoot(document.getElementById("root")!).render(<App/>);
1 change: 1 addition & 0 deletions desktop/src/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions desktop/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": [
"ES2022",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"noEmit": true,
"allowImportingTsExtensions": true
},
"include": [
"src"
]
}
2 changes: 2 additions & 0 deletions desktop/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { defineConfig } from "vite";
export default defineConfig({ server: { port: 1420, strictPort: true }, clearScreen: false });
37 changes: 37 additions & 0 deletions docs/DESKTOP_ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# DroidUI Desktop — Architecture

## Current implementation
- Desktop shell: Tauri 2 / Rust / WebView2 on Windows.
- UI: React 18 + TypeScript + Vite.
- File dialogs: `@tauri-apps/plugin-dialog`.
- Local persistence: `@tauri-apps/plugin-fs`.
- CI: GitHub Actions Windows NSIS packaging with a portable executable fallback.

## Target architecture
```text
desktop-ui (React)
├── editor shell (panels, commands, shortcuts)
├── canvas renderer (viewport, transforms, selection)
├── property inspector / component catalog
└── preview
│
shared-editor-core (framework-neutral TypeScript)
├── document schema and migrations
├── commands + undo/redo
├── selection, layout, snapping
├── validation and serializers
└── import/export adapters
│
Tauri desktop services (filesystem, dialogs, OS integration)
│
Android DroidUI app (existing Expo/React Native implementation)
```

## Compatibility contract
Do not treat the D1 prototype's `{name,nodes}` JSON as the production Android project schema. Introduce a shared versioned model with explicit adapters for Android signature `DROID_STUDIO_PROJECT_V30` and schema versions 29/30. Preserve unknown fields when practical; reject invalid or unsafe inputs. Test round trips with real sanitized Android fixtures before enabling cross-platform project open/save.

## Security
Limit filesystem scope to user-approved project paths; validate imported JSON; never execute project-authored scripts. Release builds should be signed before public distribution.

## Engineering workflow
Use feature branches, pull requests, required Windows build/typecheck/tests, release tags, changelogs, and reproducible dependency locks. Keep Android CI independent from desktop CI.
27 changes: 27 additions & 0 deletions docs/DESKTOP_CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contributing to DroidUI Desktop

## Local Windows setup
Install Node.js 20+, Rust stable, Microsoft C++ Build Tools and WebView2. From the repository root:

```powershell
cd desktop
npm install
npm run build
npm run desktop
```

Build a Windows installer with `npm run desktop:build`.

## Development conventions
- TypeScript strict mode; explicit types for document and command boundaries.
- Separate UI components from document mutations; commands must be undoable.
- Validate imported project files; use fixtures for migration tests.
- Keep each pull request focused, include screenshots for UI changes and explain manual tests.
- Do not merge failing Windows builds or claim a packaged installer exists without an uploaded artifact.
- Avoid breaking Android project compatibility; keep existing mobile application isolated.

## Proposed issue labels
`desktop`, `phase-d2`, `ux`, `interop`, `bug`, `testing`, `documentation`.

## Release checklist
Typecheck; tests; Windows installer and portable executable artifacts; smoke test on Windows 10/11; verify open/save; check antivirus false positives; version/changelog; code signing for public distribution.
24 changes: 24 additions & 0 deletions docs/DESKTOP_PRODUCT_SPEC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# DroidUI Desktop — Product Specification

**Status:** Phase D1 prototype complete; Phase D2 planned. **Target:** commercial-quality Windows-first visual UI studio.

## Product principles
- Desktop-first, keyboard-accessible professional workflow; Android project interoperability.
- Non-destructive editing, explicit save state, responsive inspector, predictable shortcuts.
- Offline-first project editing; no cloud account required for core features.

## Phase D2 acceptance criteria
1. **Canvas:** zoom 25–400%, pan, optional grid/snap, multi-select, drag, resize handles, alignment guides, visible device bounds.
2. **Workspace:** resizable/dockable toolbox, Layers, Properties, Assets and History panels; restore layout between sessions.
3. **Editing:** undo/redo for mutations, duplicate/delete, grouping, z-order, context menu, keyboard shortcuts.
4. **Components:** searchable categorized library with thumbnails and presets; editable text, layout, colors, spacing, typography, events.
5. **Preview:** interactive device-size preview with selectable device presets and clear edit/preview modes.
6. **Persistence:** atomic save, unsaved-change prompt, schema validation, safe error messages, backups, recent projects.
7. **Interoperability:** a versioned adapter that reads/writes the existing Android `.dui` schema without losing unsupported fields; round-trip regression fixtures.
8. **Quality:** Windows CI installer, UI regression tests, accessibility and keyboard checks, release notes, signed releases before commercial distribution.

## Non-goals for D2
Cloud collaboration, marketplace, and full cross-platform packaging are later phases.

## Current limitations
The Phase D1 desktop prototype uses a separate project JSON format and is **not yet interoperable** with Android `.dui` projects. Windows executable has been built in GitHub Actions; no code signing or commercial release readiness is claimed.
Loading