Skip to content

Commit

Permalink
Merge pull request #1836 from holium/master
Browse files Browse the repository at this point in the history
release-v0.13.5
  • Loading branch information
drunkplato authored Jun 26, 2023
2 parents 43802e4 + d724126 commit 2baa3c2
Show file tree
Hide file tree
Showing 86 changed files with 4,507 additions and 1,274 deletions.
100 changes: 100 additions & 0 deletions app/src/main/helpers/cursorSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,106 @@ const hideSystemCursorCss = `
*:focus:not(:focus-visible) {
cursor: none !important;
}
.react-player-hide-cursor {
cursor: none !important;
}
video::-webkit-media-controls-panel {
cursor: none !important;
}
video::-webkit-media-controls-play-button {
cursor: none !important;
}
video::-webkit-media-controls-volume-slider-container {
cursor: none !important;
}
video::-webkit-media-controls-volume-slider {
cursor: none !important;
}
video::-webkit-media-controls-mute-button {
cursor: none !important;
}
video::-webkit-media-controls-timeline {
cursor: none !important;
}
video::-webkit-media-controls-current-time-display {
cursor: none !important;
}
video::-webkit-full-page-media::-webkit-media-controls-panel {
cursor: none !important;
}
video::-webkit-media-controls-panel {
cursor: none !important;
}
video::-webkit-media-controls-start-playback-button {
cursor: none !important;
}
video::-webkit-media-controls-overlay-play-button {
cursor: none !important;
}
video::-webkit-media-controls-toggle-closed-captions-button {
cursor: none !important;
}
video::-webkit-media-controls-status-display {
cursor: none !important;
}
video::-webkit-media-controls-mouse-display {
cursor: none !important;
}
video::-webkit-media-controls-timeline-container {
cursor: none !important;
}
video::-webkit-media-controls-time-remaining-display {
cursor: none !important;
}
video::-webkit-media-controls-seek-back-button {
cursor: none !important;
}
video {
cursor: none !important;
}
video::-webkit-media-controls-seek-forward-button {
cursor: none !important;
}
video::-webkit-media-controls-fullscreen-button {
cursor: none !important;
}
video::-webkit-media-controls-enclosure {
cursor: none !important;
}
video::-webkit-media-controls-rewind-button {
cursor: none !important;
}
video::-webkit-media-controls-return-to-realtime-button {
cursor: none !important;
}
video::-webkit-media-controls-toggle-closed-captions-button {
cursor: none !important;
}
`;

const showSystemCursorCss = `
Expand Down
10 changes: 7 additions & 3 deletions app/src/main/helpers/power.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { BrowserWindow, powerMonitor } from 'electron';

import { getRealmService } from '../main';

const registerListeners = (mainWindow: BrowserWindow) => {
powerMonitor.on('suspend', () => {
if (mainWindow.isDestroyed()) return;

mainWindow.webContents.send('realm.sys.sleep');
mainWindow.webContents.send('realm.sys.suspend');
});
powerMonitor.on('resume', () => {
powerMonitor.on('resume', async () => {
if (mainWindow.isDestroyed()) return;

const realmService = getRealmService();
if (realmService) {
realmService.reconnectConduit();
}
mainWindow.webContents.send('realm.sys.wake');
mainWindow.webContents.send('realm.sys.resume');
});
Expand Down
1 change: 1 addition & 0 deletions app/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const store = new Store();
let updater: AppUpdater;
let menuBuilder: MenuBuilder | null;
let realmService: RealmService | null;
export const getRealmService = () => realmService;

// The realm window has a mouse overlay window associated with it.
// The standalone chat window is for booting Realm in a standalone mode
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { contextBridge, ipcRenderer } from 'electron';
import { Position } from '@holium/design-system';
import { MouseState } from '@holium/realm-presence';

import { ConduitState } from 'os/services/api';
import { settingsPreload } from 'os/services/ship/settings.service';
import { bazaarPreload } from 'os/services/ship/spaces/bazaar.service';
import { spacesPreload } from 'os/services/ship/spaces/spaces.service';
Expand Down Expand Up @@ -93,6 +94,11 @@ const appPreload = {
callback(isFullscreen);
});
},
onConnectionStatus(callback: (status: ConduitState) => void) {
ipcRenderer.on('realm.sendConnectionStatus', (_, status) => {
callback(status);
});
},
onBrowserOpen(callback: any) {
ipcRenderer.on('realm.browser.open', callback);
},
Expand Down
20 changes: 16 additions & 4 deletions app/src/main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,20 @@ export const createMouseOverlayWindow = (parentWindow: BrowserWindow) => {
const newBounds = parentWindow.getBounds();

newMouseWindow.setBounds(newBounds);
parentWindow.webContents.send('set-dimensions', newBounds);
parentWindow.webContents.send('set-dimensions', {
width: newBounds.width,
height: newBounds.height - (isArm64Mac ? 40 : 0),
});
});

parentWindow.on('move', () => {
const newDimension = parentWindow.getBounds();
const newBounds = parentWindow.getBounds();

newMouseWindow.setBounds(newDimension);
parentWindow.webContents.send('set-dimensions', newDimension);
newMouseWindow.setBounds(newBounds);
parentWindow.webContents.send('set-dimensions', {
width: newBounds.width,
height: newBounds.height - (isArm64Mac ? 40 : 0),
});
});

return newMouseWindow;
Expand Down Expand Up @@ -181,5 +187,11 @@ export const createStandaloneChatWindow = () => {
newStandaloneChatWindow.show();
});

// Open standalone URLs in the user's default browser.
newStandaloneChatWindow.webContents.setWindowOpenHandler((edata) => {
shell.openExternal(edata.url);
return { action: 'deny' };
});

return newStandaloneChatWindow;
};
53 changes: 50 additions & 3 deletions app/src/os/lib/shipHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { session } from 'electron';
import log from 'electron-log';
import dns from 'dns';

import { Credentials } from '../services/ship/ship.types.ts';

dns.setDefaultResultOrder('ipv4first');

type ServerConnectionData = {
Expand All @@ -25,16 +28,60 @@ export async function getCookie({
headers: {
'Content-Type': 'text/plain',
},
// credentials: 'include', // TODO test this
credentials: 'include', // TODO test this
signal: controller.signal,
});
if (!response.ok) {
throw new Error(`Bad response from server: ${response.status}`);
}
cookie = response.headers.get('set-cookie');
log.info(`Got cookie for ${serverUrl}`);
const ship = cookie?.split('; ')[0].split('=')[0].replace('urbauth-', '');
const path = cookie?.split('; ')[1].split('=')[1];
// const maxAge = cookie?.split('; ')[2].split('=')[1];
const value = cookie?.split('=')[1].split('; ')[0];

// const expiresAt = parseInt(maxAge ?? '0') * 1000;

await session.defaultSession.cookies.remove(serverUrl, `urbauth-${ship}`);
await session.defaultSession.cookies.set({
url: serverUrl,
name: `urbauth-${ship}`,
value,
path: path,
});

return cookie;
} catch (e) {
log.error(`Error getting cookie for ${serverUrl}`, e);
return Promise.reject(e);
} finally {
clearTimeout(timeout);
}
return cookie;
}

export async function setSessionCookie(credentials: Credentials) {
const path = credentials.cookie?.split('; ')[1].split('=')[1];
// const maxAge = credentials.cookie?.split('; ')[2].split('=')[1];
const value = credentials.cookie?.split('=')[1].split('; ')[0];

try {
// remove current cookie
await session.defaultSession.cookies.remove(
`${credentials.url}`,
`urbauth-${credentials.ship}`
);

// set new cookie
return await session.defaultSession.cookies.set({
url: `${credentials.url}`,
name: `urbauth-${credentials.ship}`,
value,
// expirationDate: new Date(
// Date.now() + parseInt(maxAge ?? '0') * 1000
// ).getTime(),
path: path,
});
} catch (e) {
log.error('setSessionCookie error:', e);
}
}
Loading

0 comments on commit 2baa3c2

Please sign in to comment.