mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Remove unnecessary docs
This commit is contained in:
3 files changed
-667
No files matched your search
@@ -1,166 +0,0 @@
|
||||
# Electron Features
|
||||
|
||||
Shakespeare's Electron desktop app provides several powerful features beyond the browser version.
|
||||
|
||||
## Real OS Filesystem
|
||||
|
||||
Projects are stored at `~/shakespeare` on your local filesystem instead of in the browser's IndexedDB.
|
||||
|
||||
**Benefits:**
|
||||
- Use any code editor (VS Code, Sublime, etc.)
|
||||
- Use any Git client
|
||||
- No storage limits (only disk space)
|
||||
- Easy backup and version control
|
||||
- Better performance for large projects
|
||||
- Direct file access with file manager
|
||||
|
||||
**Location:**
|
||||
```
|
||||
~/shakespeare/
|
||||
├── projects/
|
||||
│ ├── project-1/
|
||||
│ ├── project-2/
|
||||
│ └── ...
|
||||
└── ...
|
||||
```
|
||||
|
||||
See [FILESYSTEM.md](./FILESYSTEM.md) for details.
|
||||
|
||||
## Real OS Terminal
|
||||
|
||||
The terminal executes real shell commands on your operating system instead of using virtual commands.
|
||||
|
||||
**Benefits:**
|
||||
- **All OS commands available** - Not limited to ~30 built-in commands
|
||||
- **Package managers work** - `npm install`, `yarn add`, `pnpm install`
|
||||
- **Build tools available** - `vite`, `webpack`, `tsc`, `rollup`, etc.
|
||||
- **System utilities** - `grep`, `sed`, `awk`, `curl`, `wget`, etc.
|
||||
- **Native shell features** - Pipes, redirection, environment variables
|
||||
- **Python/Ruby/etc.** - Run scripts in any installed language
|
||||
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
$ npm install
|
||||
|
||||
# Run build scripts
|
||||
$ npm run build
|
||||
|
||||
# Use system commands
|
||||
$ curl https://api.example.com
|
||||
$ grep -r "TODO" src/
|
||||
$ python scripts/deploy.py
|
||||
|
||||
# Chain commands with pipes
|
||||
$ cat package.json | grep dependencies
|
||||
$ ls -la | wc -l
|
||||
```
|
||||
|
||||
**AI Integration:**
|
||||
AI assistants can also execute real OS commands through the ShellTool, making them much more powerful in Electron.
|
||||
|
||||
See [REAL_TERMINAL.md](./REAL_TERMINAL.md) for details.
|
||||
|
||||
## Native Window Management
|
||||
|
||||
- **Resizable windows** with native OS controls
|
||||
- **Clean interface** - No default menu bar (File/Edit/View/etc.)
|
||||
- **Frameless app** - Shakespeare UI fills the entire window
|
||||
- **Multiple windows** support (planned)
|
||||
- **System tray integration** (planned)
|
||||
- **OS notifications** (planned)
|
||||
|
||||
## Offline First
|
||||
|
||||
- **No internet required** for core functionality
|
||||
- **Local AI models** support (planned)
|
||||
- **Cached dependencies** for faster builds
|
||||
- **Git operations** work offline (local commits)
|
||||
|
||||
## Better Performance
|
||||
|
||||
- **Faster file operations** - Direct OS filesystem access
|
||||
- **Faster builds** - Native Node.js instead of browser environment
|
||||
- **Lower memory usage** - No browser overhead
|
||||
- **Faster Git operations** - Native Git commands (planned)
|
||||
|
||||
## Security & Privacy
|
||||
|
||||
- **No cloud storage** - Everything stays on your machine
|
||||
- **No telemetry** - No data sent to servers
|
||||
- **Local API keys** - Stored securely on your OS
|
||||
- **Full control** - You own your data and code
|
||||
|
||||
## Platform Support
|
||||
|
||||
- **macOS** - Native .app bundle
|
||||
- **Windows** - Native .exe installer
|
||||
- **Linux** - AppImage, .deb, .rpm packages
|
||||
|
||||
## Comparison: Browser vs Electron
|
||||
|
||||
| Feature | Browser | Electron |
|
||||
|---------|---------|----------|
|
||||
| **Filesystem** | Virtual (IndexedDB) | Real OS filesystem |
|
||||
| **Terminal** | ~30 built-in commands | All OS commands |
|
||||
| **Storage Limit** | Browser quota (~50GB) | Disk space |
|
||||
| **File Access** | Only in browser | Any editor/tool |
|
||||
| **Package Managers** | Not available | Full support |
|
||||
| **Build Tools** | Limited | Full support |
|
||||
| **Performance** | Good | Better |
|
||||
| **Git** | isomorphic-git | isomorphic-git* |
|
||||
| **Offline** | Yes | Yes |
|
||||
| **Updates** | Automatic | Manual/Auto-update |
|
||||
|
||||
\* Native Git CLI support planned
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Installation
|
||||
|
||||
Download the latest release for your platform:
|
||||
- **macOS**: `Shakespeare-{version}.dmg`
|
||||
- **Windows**: `Shakespeare-Setup-{version}.exe`
|
||||
- **Linux**: `Shakespeare-{version}.AppImage`
|
||||
|
||||
### Building from Source
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/yourusername/shakespeare.git
|
||||
cd shakespeare
|
||||
|
||||
# Install dependencies
|
||||
npm install
|
||||
|
||||
# Build for your platform
|
||||
npm run electron:build
|
||||
|
||||
# Or build for all platforms
|
||||
npm run electron:build:all
|
||||
```
|
||||
|
||||
See [QUICKSTART.md](./QUICKSTART.md) for detailed build instructions.
|
||||
|
||||
## Roadmap
|
||||
|
||||
Planned features for future releases:
|
||||
|
||||
- [ ] Native Git CLI integration
|
||||
- [ ] Multiple window support
|
||||
- [ ] System tray integration
|
||||
- [ ] Auto-update mechanism
|
||||
- [ ] Local AI model support
|
||||
- [ ] Enhanced terminal (tabs, splits)
|
||||
- [ ] File watcher integration
|
||||
- [ ] Native notifications
|
||||
- [ ] Keyboard shortcuts customization
|
||||
- [ ] Theme customization
|
||||
|
||||
## Support
|
||||
|
||||
For issues, questions, or feature requests:
|
||||
- GitHub Issues: [Create an issue](https://github.com/yourusername/shakespeare/issues)
|
||||
- Documentation: See other `.md` files in this directory
|
||||
- Community: Join our Discord/Matrix (links TBD)
|
||||
@@ -1,331 +0,0 @@
|
||||
# Integrating Electron Features into Shakespeare
|
||||
|
||||
This guide shows how to use Electron-specific features in your Shakespeare codebase.
|
||||
|
||||
## Detecting Electron Environment
|
||||
|
||||
The preload script exposes a minimal API at `window.electron`. You can use this to detect if the app is running in Electron:
|
||||
|
||||
```typescript
|
||||
// Check if running in Electron
|
||||
if (window.electron?.isElectron) {
|
||||
console.log('Running in Electron desktop app');
|
||||
} else {
|
||||
console.log('Running in web browser');
|
||||
}
|
||||
```
|
||||
|
||||
## Using Electron API
|
||||
|
||||
The exposed API includes:
|
||||
|
||||
### Platform Detection
|
||||
|
||||
```typescript
|
||||
// Get the platform
|
||||
const platform = await window.electron?.platform();
|
||||
// Returns: 'darwin' | 'win32' | 'linux'
|
||||
|
||||
// Platform-specific code
|
||||
if (platform === 'darwin') {
|
||||
console.log('Running on macOS');
|
||||
} else if (platform === 'win32') {
|
||||
console.log('Running on Windows');
|
||||
} else if (platform === 'linux') {
|
||||
console.log('Running on Linux');
|
||||
}
|
||||
```
|
||||
|
||||
### App Version
|
||||
|
||||
```typescript
|
||||
// Get the app version
|
||||
const version = await window.electron?.version();
|
||||
console.log('Shakespeare version:', version);
|
||||
```
|
||||
|
||||
## Example: Platform-Specific UI
|
||||
|
||||
```tsx
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function PlatformBadge() {
|
||||
const [platform, setPlatform] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (window.electron?.isElectron) {
|
||||
window.electron.platform().then(setPlatform);
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (!platform) return null;
|
||||
|
||||
const platformNames = {
|
||||
darwin: 'macOS',
|
||||
win32: 'Windows',
|
||||
linux: 'Linux',
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="platform-badge">
|
||||
Running on {platformNames[platform as keyof typeof platformNames] || platform}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## Example: Conditional Features
|
||||
|
||||
```tsx
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function useIsElectron() {
|
||||
const [isElectron, setIsElectron] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setIsElectron(window.electron?.isElectron ?? false);
|
||||
}, []);
|
||||
|
||||
return isElectron;
|
||||
}
|
||||
|
||||
// Usage in a component
|
||||
function MyComponent() {
|
||||
const isElectron = useIsElectron();
|
||||
|
||||
return (
|
||||
<div>
|
||||
{isElectron ? (
|
||||
<button onClick={handleElectronFeature}>
|
||||
Use Native Feature
|
||||
</button>
|
||||
) : (
|
||||
<button onClick={handleWebFeature}>
|
||||
Use Web Feature
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## Adding New Electron Features
|
||||
|
||||
To add new Electron-specific features:
|
||||
|
||||
### 1. Add IPC Handler in Main Process
|
||||
|
||||
Edit `electron/main.js` (ESM syntax):
|
||||
|
||||
```javascript
|
||||
// Add new IPC handler
|
||||
ipcMain.handle('my-new-feature', async (event, arg) => {
|
||||
// Implement your feature
|
||||
return result;
|
||||
});
|
||||
```
|
||||
|
||||
### 2. Expose in Preload Script
|
||||
|
||||
Edit `electron/preload.js` (ESM syntax):
|
||||
|
||||
```javascript
|
||||
import { contextBridge, ipcRenderer } from 'electron';
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
// Existing API
|
||||
isElectron: true,
|
||||
platform: () => ipcRenderer.invoke('get-platform'),
|
||||
version: () => ipcRenderer.invoke('get-app-version'),
|
||||
|
||||
// New feature
|
||||
myNewFeature: (arg) => ipcRenderer.invoke('my-new-feature', arg),
|
||||
});
|
||||
```
|
||||
|
||||
### 3. Update TypeScript Definitions
|
||||
|
||||
Edit `electron/electron.d.ts`:
|
||||
|
||||
```typescript
|
||||
interface ElectronAPI {
|
||||
isElectron: boolean;
|
||||
platform(): Promise<string>;
|
||||
version(): Promise<string>;
|
||||
|
||||
// Add your new feature
|
||||
myNewFeature(arg: string): Promise<ReturnType>;
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Use in React Components
|
||||
|
||||
```typescript
|
||||
// Now you can use it
|
||||
const result = await window.electron?.myNewFeature('argument');
|
||||
```
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
### File System Access
|
||||
|
||||
```javascript
|
||||
// In electron/main.js (ESM)
|
||||
import { dialog } from 'electron';
|
||||
|
||||
ipcMain.handle('select-directory', async () => {
|
||||
const result = await dialog.showOpenDialog(mainWindow, {
|
||||
properties: ['openDirectory']
|
||||
});
|
||||
return result.filePaths[0];
|
||||
});
|
||||
```
|
||||
|
||||
### Native Notifications
|
||||
|
||||
```javascript
|
||||
// In electron/main.js (ESM)
|
||||
import { Notification } from 'electron';
|
||||
|
||||
ipcMain.handle('show-notification', async (event, { title, body }) => {
|
||||
new Notification({ title, body }).show();
|
||||
});
|
||||
```
|
||||
|
||||
### Native Menus
|
||||
|
||||
```javascript
|
||||
// In electron/main.js (ESM)
|
||||
import { Menu } from 'electron';
|
||||
|
||||
function createMenu() {
|
||||
const template = [
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
{
|
||||
label: 'New Project',
|
||||
accelerator: 'CmdOrCtrl+N',
|
||||
click: () => mainWindow.webContents.send('new-project')
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{ role: 'quit' }
|
||||
]
|
||||
},
|
||||
// ... more menu items
|
||||
];
|
||||
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
createMenu();
|
||||
});
|
||||
```
|
||||
|
||||
### Auto-Updates
|
||||
|
||||
```javascript
|
||||
// In electron/main.js (ESM)
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
mainWindow.webContents.send('update-available');
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
mainWindow.webContents.send('update-downloaded');
|
||||
});
|
||||
|
||||
// In preload.js (ESM)
|
||||
import { contextBridge, ipcRenderer } from 'electron';
|
||||
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
// ...
|
||||
installUpdate: () => ipcRenderer.send('install-update'),
|
||||
onUpdateAvailable: (callback) => ipcRenderer.on('update-available', callback),
|
||||
onUpdateDownloaded: (callback) => ipcRenderer.on('update-downloaded', callback),
|
||||
});
|
||||
```
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### ⚠️ Important Security Rules
|
||||
|
||||
1. **Never expose the entire IPC module** to the renderer
|
||||
2. **Always validate input** in main process handlers
|
||||
3. **Use contextBridge** for all renderer-to-main communication
|
||||
4. **Keep nodeIntegration disabled** in BrowserWindow
|
||||
5. **Keep contextIsolation enabled** in BrowserWindow
|
||||
6. **Sanitize any data** before passing to main process
|
||||
|
||||
### Good Example
|
||||
|
||||
```javascript
|
||||
// ✅ Good: Specific, validated handler
|
||||
ipcMain.handle('save-file', async (event, { filename, content }) => {
|
||||
// Validate input
|
||||
if (typeof filename !== 'string' || typeof content !== 'string') {
|
||||
throw new Error('Invalid arguments');
|
||||
}
|
||||
|
||||
// Sanitize filename
|
||||
const safeName = path.basename(filename);
|
||||
|
||||
// Perform operation
|
||||
await fs.writeFile(safeName, content);
|
||||
});
|
||||
```
|
||||
|
||||
### Bad Example
|
||||
|
||||
```javascript
|
||||
// ❌ Bad: Exposes too much
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
ipcRenderer: ipcRenderer, // Never do this!
|
||||
require: require, // Never do this!
|
||||
});
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Keep the Electron API minimal** - Only expose what you need
|
||||
2. **Use TypeScript** - Type definitions prevent errors
|
||||
3. **Handle errors gracefully** - IPC calls can fail
|
||||
4. **Test in both environments** - Web and Electron should both work
|
||||
5. **Progressive enhancement** - Web features first, Electron enhancements second
|
||||
6. **Document new features** - Update this file when adding features
|
||||
|
||||
## Testing Electron Features
|
||||
|
||||
```typescript
|
||||
// Mock window.electron for tests
|
||||
beforeEach(() => {
|
||||
(window as any).electron = {
|
||||
isElectron: true,
|
||||
platform: jest.fn().mockResolvedValue('darwin'),
|
||||
version: jest.fn().mockResolvedValue('1.0.0'),
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete (window as any).electron;
|
||||
});
|
||||
|
||||
test('component uses Electron API', async () => {
|
||||
render(<MyComponent />);
|
||||
|
||||
expect(window.electron?.platform).toHaveBeenCalled();
|
||||
});
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
- [Electron IPC Tutorial](https://www.electronjs.org/docs/latest/tutorial/ipc)
|
||||
- [Context Isolation](https://www.electronjs.org/docs/latest/tutorial/context-isolation)
|
||||
- [Security Best Practices](https://www.electronjs.org/docs/latest/tutorial/security)
|
||||
- [Process Model](https://www.electronjs.org/docs/latest/tutorial/process-model)
|
||||
@@ -1,170 +0,0 @@
|
||||
# Quick Start: Filesystem Access
|
||||
|
||||
## Where Are My Files?
|
||||
|
||||
When running Shakespeare as an Electron desktop app, all your projects are stored at:
|
||||
|
||||
```
|
||||
~/shakespeare/
|
||||
```
|
||||
|
||||
This expands to:
|
||||
- **macOS/Linux**: `/Users/yourname/shakespeare/` or `/home/yourname/shakespeare/`
|
||||
- **Windows**: `C:\Users\yourname\shakespeare\`
|
||||
|
||||
## Opening the Directory
|
||||
|
||||
### macOS
|
||||
```bash
|
||||
open ~/shakespeare
|
||||
```
|
||||
|
||||
### Linux
|
||||
```bash
|
||||
xdg-open ~/shakespeare
|
||||
# or
|
||||
nautilus ~/shakespeare
|
||||
```
|
||||
|
||||
### Windows
|
||||
```cmd
|
||||
explorer %USERPROFILE%\shakespeare
|
||||
```
|
||||
|
||||
## What's Inside?
|
||||
|
||||
```
|
||||
~/shakespeare/
|
||||
├── projects/ ← Your Shakespeare projects
|
||||
│ ├── my-react-app/
|
||||
│ ├── todo-app/
|
||||
│ └── ...
|
||||
├── config/ ← Settings (AI keys, Git credentials)
|
||||
│ ├── ai.json
|
||||
│ └── git.json
|
||||
└── tmp/ ← Temporary files
|
||||
```
|
||||
|
||||
## Working with Your Files
|
||||
|
||||
### Use Any Editor
|
||||
|
||||
Open your projects in VS Code, Sublime, or any code editor:
|
||||
|
||||
```bash
|
||||
code ~/shakespeare/projects/my-react-app
|
||||
```
|
||||
|
||||
### Use Git Clients
|
||||
|
||||
Use GitHub Desktop, GitKraken, or command-line Git:
|
||||
|
||||
```bash
|
||||
cd ~/shakespeare/projects/my-react-app
|
||||
git status
|
||||
git commit -am "Update homepage"
|
||||
```
|
||||
|
||||
### Backup Your Work
|
||||
|
||||
Use Time Machine, rsync, Dropbox, iCloud, or any backup tool:
|
||||
|
||||
```bash
|
||||
# Example: Backup to external drive
|
||||
rsync -av ~/shakespeare /Volumes/Backup/
|
||||
|
||||
# Example: Create archive
|
||||
tar -czf shakespeare-backup.tar.gz ~/shakespeare
|
||||
```
|
||||
|
||||
### Share Projects
|
||||
|
||||
Copy project folders to share with others:
|
||||
|
||||
```bash
|
||||
# Create shareable archive
|
||||
cd ~/shakespeare/projects
|
||||
tar -czf my-react-app.tar.gz my-react-app/
|
||||
|
||||
# Or use zip
|
||||
zip -r my-react-app.zip my-react-app/
|
||||
```
|
||||
|
||||
## Tips
|
||||
|
||||
### 1. Keep It Synced
|
||||
|
||||
Use cloud sync services to sync `~/shakespeare` across devices:
|
||||
- Dropbox
|
||||
- Google Drive
|
||||
- iCloud Drive
|
||||
- OneDrive
|
||||
|
||||
Just move or symlink the directory to your sync folder.
|
||||
|
||||
### 2. Use .gitignore
|
||||
|
||||
Each project has a `.gitignore` file. Add files you don't want to commit:
|
||||
|
||||
```
|
||||
node_modules/
|
||||
dist/
|
||||
.env
|
||||
```
|
||||
|
||||
### 3. External Tools
|
||||
|
||||
Since files are on your real filesystem, you can use:
|
||||
- File search tools (Spotlight, Everything, etc.)
|
||||
- Diff tools (Beyond Compare, Meld, etc.)
|
||||
- Backup software
|
||||
- Antivirus scanning
|
||||
- File recovery tools
|
||||
|
||||
### 4. Performance
|
||||
|
||||
Large projects perform better on the local filesystem than in IndexedDB:
|
||||
- Faster file operations
|
||||
- Better for thousands of files
|
||||
- No browser storage quota limits
|
||||
|
||||
## Migrating from Browser Version
|
||||
|
||||
If you were using Shakespeare in the browser before:
|
||||
|
||||
1. **Export** your projects as ZIP files in the browser version
|
||||
2. **Import** the ZIP files in the Electron version
|
||||
3. Your projects will be extracted to `~/shakespeare/projects/`
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Can't Find Directory
|
||||
|
||||
The directory is created automatically when you first run the Electron app. If it's missing:
|
||||
|
||||
```bash
|
||||
mkdir -p ~/shakespeare
|
||||
```
|
||||
|
||||
### Permission Denied
|
||||
|
||||
Ensure you have read/write permissions:
|
||||
|
||||
```bash
|
||||
ls -la ~/shakespeare
|
||||
chmod -R u+rw ~/shakespeare
|
||||
```
|
||||
|
||||
### Deleted Files
|
||||
|
||||
Files deleted in Shakespeare are permanently removed (not moved to Trash). Use:
|
||||
- Version control (Git) to recover committed files
|
||||
- Backup software to restore from backups
|
||||
- File recovery tools for recently deleted files
|
||||
|
||||
## Questions?
|
||||
|
||||
See the full documentation:
|
||||
- [FILESYSTEM.md](./FILESYSTEM.md) - Complete technical details
|
||||
- [README.md](./README.md) - Electron build overview
|
||||
- [QUICKSTART.md](./QUICKSTART.md) - Building and running Shakespeare
|
||||
Reference in new issue
Block a user