release: bump version to 0.78.0
This commit is contained in:
1 parent
e6aa8c539b
commit
5fc698d738
96 files changed
+10214
-747
No files matched your search
@@ -45,9 +45,9 @@ export function normalizeSplashTheme(
|
||||
return VALID_SPLASH_THEMES.has(normalized) ? normalized : fallback
|
||||
}
|
||||
|
||||
const DEFAULT_ENDPOINTS: ServerEndpoints = {
|
||||
backendUrl: 'http://127.0.0.1:8000',
|
||||
adminUrl: 'http://127.0.0.1:3000',
|
||||
export const DEFAULT_ENDPOINTS: Readonly<ServerEndpoints> = {
|
||||
backendUrl: 'https://rclaw.top',
|
||||
adminUrl: 'https://admin.rclaw.top',
|
||||
motionWsUrl: 'ws://127.0.0.1:8765/ws/gestures',
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import { execFile } from 'node:child_process'
|
||||
import { mkdir, writeFile } from 'node:fs/promises'
|
||||
import { homedir } from 'node:os'
|
||||
import path from 'node:path'
|
||||
import { promisify } from 'node:util'
|
||||
|
||||
import { app } from 'electron'
|
||||
|
||||
const run = promisify(execFile)
|
||||
export const DESKTOP_SCHEME = 'planet-earth'
|
||||
|
||||
export async function registerDesktopLink(): Promise<void> {
|
||||
if (!app.isPackaged) return
|
||||
|
||||
if (process.platform === 'linux') {
|
||||
let desktopId = 'planet-client.desktop'
|
||||
if (process.env.APPIMAGE) {
|
||||
desktopId = 'planet-earth-appimage.desktop'
|
||||
const applications = path.join(
|
||||
process.env.XDG_DATA_HOME || path.join(homedir(), '.local', 'share'),
|
||||
'applications',
|
||||
)
|
||||
const executable = process.env.APPIMAGE
|
||||
if (!path.isAbsolute(executable) || /[\r\n]/.test(executable)) {
|
||||
throw new Error('Invalid AppImage path')
|
||||
}
|
||||
// Escape the Exec argument, then the backslashes in the desktop-entry value.
|
||||
const escaped = executable.replace(/%/g, '%%').replace(/["$\x60\\]/g, '\\$&').replace(/\\/g, '\\\\')
|
||||
await mkdir(applications, { recursive: true })
|
||||
await writeFile(path.join(applications, desktopId), [
|
||||
'[Desktop Entry]',
|
||||
'Type=Application',
|
||||
'Name=Planet Earth',
|
||||
'NoDisplay=true',
|
||||
'Exec="' + escaped + '" %u',
|
||||
'MimeType=x-scheme-handler/' + DESKTOP_SCHEME + ';',
|
||||
'',
|
||||
].join('\n'))
|
||||
}
|
||||
const mimeType = 'x-scheme-handler/' + DESKTOP_SCHEME
|
||||
try {
|
||||
await run('xdg-mime', ['default', desktopId, mimeType], { timeout: 8000 })
|
||||
} catch (error) {
|
||||
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error
|
||||
await run('gio', ['mime', mimeType, desktopId], { timeout: 8000 })
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const executable = process.platform === 'win32'
|
||||
? process.env.PORTABLE_EXECUTABLE_FILE || process.execPath
|
||||
: undefined
|
||||
if (!app.isDefaultProtocolClient(DESKTOP_SCHEME, executable)
|
||||
&& !app.setAsDefaultProtocolClient(DESKTOP_SCHEME, executable)) {
|
||||
throw new Error('Could not register the Planet Earth URL handler')
|
||||
}
|
||||
}
|
||||
+22
-14
@@ -4,6 +4,7 @@ import path from 'node:path'
|
||||
import { app, BrowserWindow, ipcMain, Menu, session, shell } from 'electron'
|
||||
|
||||
import { DesktopConfigStore, normalizeSplashTheme, type ServerEndpoints } from './config'
|
||||
import { DESKTOP_SCHEME, registerDesktopLink } from './desktop-link'
|
||||
import { buildApplicationMenu } from './menu'
|
||||
import { EARTH_ORIGIN, installEarthSessionHandlers, registerEarthScheme } from './protocol'
|
||||
import { createMainWindow, dismissMenuBarOnPointerDown, toggleWindowOrientation } from './window'
|
||||
@@ -63,24 +64,28 @@ function resolvePreloadPath(): string {
|
||||
}
|
||||
|
||||
let mainWindow: BrowserWindow | null = null
|
||||
let launchWindow: (() => void) | undefined
|
||||
|
||||
function showEarthWindow() {
|
||||
if (!mainWindow || mainWindow.isDestroyed()) {
|
||||
launchWindow?.()
|
||||
return
|
||||
}
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.show()
|
||||
mainWindow.focus()
|
||||
}
|
||||
|
||||
const singleInstanceLock = isHeadlessSmoke ? true : app.requestSingleInstanceLock()
|
||||
if (!singleInstanceLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
if (!isHeadlessSmoke && typeof app.setAsDefaultProtocolClient === 'function') {
|
||||
try {
|
||||
app.setAsDefaultProtocolClient('planet-earth')
|
||||
} catch {
|
||||
// Non-fatal in unpackaged dev sessions.
|
||||
}
|
||||
}
|
||||
|
||||
app.on('second-instance', () => {
|
||||
if (!mainWindow || mainWindow.isDestroyed()) return
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
app.on('open-url', (event, url) => {
|
||||
if (url !== `${DESKTOP_SCHEME}://open` && url !== `${DESKTOP_SCHEME}://open/`) return
|
||||
event.preventDefault()
|
||||
showEarthWindow()
|
||||
})
|
||||
app.on('second-instance', showEarthWindow)
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
@@ -89,6 +94,9 @@ if (!singleInstanceLock) {
|
||||
})
|
||||
|
||||
void app.whenReady().then(async () => {
|
||||
if (!isHeadlessSmoke) {
|
||||
void registerDesktopLink().catch(error => console.warn('Planet Earth protocol registration failed', error))
|
||||
}
|
||||
const configStore = new DesktopConfigStore({
|
||||
userDataDir: app.getPath('userData'),
|
||||
exeDir: path.dirname(app.getPath('exe')),
|
||||
@@ -180,7 +188,7 @@ if (!singleInstanceLock) {
|
||||
dismissMenuBarOnPointerDown(mainWindow)
|
||||
})
|
||||
|
||||
const launchWindow = () => {
|
||||
launchWindow = () => {
|
||||
const preloadPath = resolvePreloadPath()
|
||||
mainWindow = createMainWindow({
|
||||
preloadPath,
|
||||
@@ -321,7 +329,7 @@ if (!singleInstanceLock) {
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
launchWindow()
|
||||
launchWindow?.()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -4,7 +4,7 @@ import path from 'node:path'
|
||||
import { BrowserWindow, ipcMain, nativeTheme, screen, shell, type Display } from 'electron'
|
||||
|
||||
import { createSoloAltMenuTracker } from './alt-menu'
|
||||
import type { DesktopConfigStore, DesktopRuntimeConfig } from './config'
|
||||
import { DEFAULT_ENDPOINTS, type DesktopConfigStore, type DesktopRuntimeConfig } from './config'
|
||||
import { resolveExternalTargetUrl } from './external-links'
|
||||
import { createWindowShowGate } from './show-gate'
|
||||
import {
|
||||
@@ -489,9 +489,9 @@ export function openServerSettingsDialog(
|
||||
}
|
||||
};
|
||||
document.getElementById('defaults').addEventListener('click', () => {
|
||||
form.elements.backendUrl.value = 'http://127.0.0.1:8000';
|
||||
form.elements.adminUrl.value = 'http://127.0.0.1:3000';
|
||||
form.elements.motionWsUrl.value = 'ws://127.0.0.1:8765/ws/gestures';
|
||||
form.elements.backendUrl.value = ${JSON.stringify(DEFAULT_ENDPOINTS.backendUrl)};
|
||||
form.elements.adminUrl.value = ${JSON.stringify(DEFAULT_ENDPOINTS.adminUrl)};
|
||||
form.elements.motionWsUrl.value = ${JSON.stringify(DEFAULT_ENDPOINTS.motionWsUrl)};
|
||||
errEl.textContent = '';
|
||||
});
|
||||
document.getElementById('cancel').addEventListener('click', () => {
|
||||
|
||||
Reference in new issue
Block a user