### Install, Start, Build, Lint, and Generate Icons (Bash) Source: https://context7.com/laplace-live/chat-overlay/llms.txt This snippet provides essential bash commands for managing the project. It includes commands for installing dependencies with pnpm, starting the development server, building for production, running the linter, and generating application icons. These commands facilitate the development lifecycle of the LAPLACE Chat Overlay. ```bash # Install dependencies pnpm install # Start development server pnpm start # Build for production (creates packages in out/ directory) pnpm make # Run linter pnpm lint # Generate application icons pnpm generate-icons ``` -------------------------------- ### Verify macOS Code Signing Identity Source: https://github.com/laplace-live/chat-overlay/blob/master/docs/macos-notarization-setup.md This command verifies that your code signing identity is correctly set up and accessible in your macOS Keychain. It lists all identities available for code signing, allowing you to confirm the exact name required for configuration, such as in GitHub repository secrets. ```bash security find-identity -v -p codesigning ``` -------------------------------- ### Run Development Mode with pnpm Source: https://github.com/laplace-live/chat-overlay/blob/master/README.md Starts the LAPLACE Chat Overlay application in development mode using the pnpm package manager. This command is essential for developers to test changes and debug the application. ```bash pnpm start ``` -------------------------------- ### Verify Application Code Signature Source: https://github.com/laplace-live/chat-overlay/blob/master/docs/macos-notarization-setup.md This command checks the code signature of a macOS application. It's crucial for verifying that your application has been correctly signed, which is a prerequisite for notarization and for the auto-update mechanism to function properly on macOS. The verbose output provides detailed information about the signature. ```bash codesign -dv --verbose=4 /path/to/app ``` -------------------------------- ### Export macOS Developer ID Certificate to PKCS12 Source: https://github.com/laplace-live/chat-overlay/blob/master/docs/macos-notarization-setup.md This script exports your macOS Developer ID certificate from the Keychain to a PKCS12 file. This file is then converted to a base64 encoded string, which is necessary for storing as a secret in CI/CD platforms like GitHub Actions. Ensure you replace 'YOUR_PASSWORD' with a strong password and delete the .p12 file after successful conversion for security. ```bash security export -t identities -f pkcs12 -k ~/Library/Keychains/login.keychain-db \ -P YOUR_PASSWORD -o ~/Desktop/Certificates.p12 base64 -i ~/Desktop/Certificates.p12 | pbcopy rm ~/Desktop/Certificates.p12 ``` -------------------------------- ### Setup Custom Context Menu for Editable Elements (TypeScript) Source: https://context7.com/laplace-live/chat-overlay/llms.txt This utility function sets up a global event listener for the 'contextmenu' event to display a custom context menu. It identifies if the target element is an input or textarea, captures selected text and input type, and then invokes Electron's `showContextMenu` API. Dependencies include the `electronAPI` exposed in the preload script. The function should be called once during application initialization in the renderer process. ```typescript // utils/context-menu.ts export function setupContextMenu() { document.addEventListener('contextmenu', e => { e.preventDefault() const target = e.target if (!(target instanceof Element)) return const isEditable = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' if (!isEditable && !window.getSelection()?.toString()) { return // Don't show menu if not on editable element and no text selected } let selectionText = '' let inputType = '' if (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement) { selectionText = target.value.substring( target.selectionStart || 0, target.selectionEnd || 0 ) inputType = target instanceof HTMLInputElement ? target.type : 'textarea' } else { selectionText = window.getSelection()?.toString() || '' } window.electronAPI.showContextMenu({ selectionText, isEditable, inputType, }) }) } // Initialize in renderer.tsx setupContextMenu() ``` -------------------------------- ### Create Production Build with pnpm Source: https://github.com/laplace-live/chat-overlay/blob/master/README.md Packages the LAPLACE Chat Overlay application for distribution on the target platform. This command generates the final build files, typically found in the 'out' directory, ready for deployment. ```bash pnpm make ``` -------------------------------- ### Git Workflow for Contributions Source: https://github.com/laplace-live/chat-overlay/blob/master/README.md A standard Git workflow for contributing to the LAPLACE Chat Overlay project. It outlines the steps for forking the repository, creating a feature branch, committing changes, and submitting a pull request. ```git git checkout -b feature/amazing-feature git commit -m 'Add some amazing feature' git push origin feature/amazing-feature ``` -------------------------------- ### Electron Main Process IPC Handlers for Window Control and Communication Source: https://context7.com/laplace-live/chat-overlay/llms.txt This code sets up various Inter-Process Communication (IPC) handlers in the Electron main process. It manages window opacity, always-on-top status, click-through mode, mouse event forwarding, retrieves the app version, synchronizes custom CSS changes between windows, and broadcasts connection states. It also includes logic for displaying a context menu based on the editability of the target element. ```typescript // Main process (main.ts) import { ipcMain, BrowserWindow } from 'electron' const registerIpcHandlers = () => { // Opacity control ipcMain.on('set-window-opacity', (_event, opacity) => { mainWindow.setOpacity(opacity) }) // Always on top toggle ipcMain.on('set-always-on-top', (_event, enabled) => { mainWindow.setAlwaysOnTop(enabled) }) // Click-through mode ipcMain.on('set-click-through', (_event, enabled) => { if (enabled) { mainWindow.webContents.send('click-through-enabled', true) } else { mainWindow.setIgnoreMouseEvents(false) mainWindow.webContents.send('click-through-enabled', false) } }) // Mouse events control ipcMain.on('set-ignore-mouse-events', (_event, ignore) => { mainWindow.setIgnoreMouseEvents(ignore, { forward: true }) }) // Get app version ipcMain.handle('get-app-version', () => { return app.getVersion() }) // CSS synchronization between windows ipcMain.on('update-custom-css', (_event, css) => { if (mainWindow && !mainWindow.isDestroyed()) { mainWindow.webContents.send('custom-css-updated', css) } }) // Connection state broadcasting ipcMain.on('broadcast-connection-state', (_event, state) => { if (mainWindow && !mainWindow.isDestroyed()) { mainWindow.webContents.send('connection-state-updated', state) } if (preferencesWindow && !preferencesWindow.isDestroyed()) { preferencesWindow.webContents.send('connection-state-updated', state) } }) ipcMain.handle('request-connection-state', () => { return currentConnectionState }) // Context menu ipcMain.on('show-context-menu', (_event, { isEditable, selectionText }) => { const template = [] const hasSelection = selectionText && selectionText.length > 0 if (isEditable) { template.push( { role: 'undo' }, { role: 'redo' }, { type: 'separator' }, { role: 'cut', enabled: hasSelection }, { role: 'copy', enabled: hasSelection }, { role: 'paste' }, { type: 'separator' }, { role: 'selectAll' } ) } else { template.push({ role: 'copy', enabled: hasSelection }) } const menu = Menu.buildFromTemplate(template) menu.popup() }) } // Register handlers on app ready app.whenReady().then(() => { registerIpcHandlers() createWindow() }) ``` -------------------------------- ### Manage Persistent Settings with Settings Store (TypeScript) Source: https://context7.com/laplace-live/chat-overlay/llms.txt This snippet demonstrates a persistent settings store using Zustand with localStorage synchronization. It allows managing UI and server settings, persisting them across sessions and synchronizing them across multiple browser windows. Settings include opacity, font size, window behavior, event visibility, custom CSS, server connection details, and origin filtering. ```typescript import { useSettingsStore } from './store/useSettingsStore' // In a React component function PreferencesPanel() { const { // UI Settings opacity, setOpacity, baseFontSize, setBaseFontSize, alwaysOnTop, setAlwaysOnTop, clickThrough, setClickThrough, showInteractionEvents, setShowInteractionEvents, showGiftFree, setShowGiftFree, showEntryEffect, setShowEntryEffect, customCSS, setCustomCSS, // Server Settings serverHost, setServerHost, serverPort, setServerPort, serverPassword, setServerPassword, allowedOrigins, setAllowedOrigins, } = useSettingsStore() return (
setOpacity(Number(e.target.value))} min={15} max={100} /> setServerHost(e.target.value)} placeholder="localhost" /> setServerPassword(e.target.value)} placeholder="Server password" /> setAllowedOrigins(e.target.value)} placeholder="origin1, origin2, origin3" />