Skip to content

Commit

Permalink
Merge pull request #1932 from holium/master
Browse files Browse the repository at this point in the history
release-v0.16.0
  • Loading branch information
gdbroman authored Jul 24, 2023
2 parents 6a36c84 + 4213a54 commit cc01b2e
Show file tree
Hide file tree
Showing 76 changed files with 1,774 additions and 601 deletions.
23 changes: 23 additions & 0 deletions .docs/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,26 @@
The hosting website (hosting.holium.com) involves Stripe payments and is thus tested E2E with Cypress.

The Realm client itself is changed at a fast pace, so automated testing is not worth the cost at the time of writing.

## Test Distribution Moon

Moon: `~nimwyd-ramwyl-dozzod-hostyv`

`~nimwyd-ramwyl-dozzod-hostyv` runs on a Digital Ocean droplet:

Digital Ocean Team: `Holium - Moons only`
Projects: `Realm`
Droplet: `app-host-staging`

For access to the Digital Ocean team and project, please contact cody@holium.com.

### Test Moon App Deployment Steps

Staging builds deploy Urbit agent changes to the staging app host: `~nimwyd-ramwyl-dozzod-hostyv`:

1. The following files on the `%realm` desk are updated:

- desk.docket-0 - the version string is updated to reflect the version of the current build
- desk.ship - contents of this file are changed to `~nimwyd-ramwyl-dozzod-hostyv`

2. The `%usher` desk's `%marshal` agent is poked during deployments to `|commit` changes to the realm hoon sources to this moon
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
globals: {
self: 'readonly',
},
extends: [
'react-app',
'eslint:recommended',
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ In the debug build you can bypass the invite code and email with `~admins-admins

`~hostyv` hosts several of the desks needed for Realm, you may have to manually install them for now.

### Urbit pre-release / development moon
To get the cutting edge `%base` desk to test and develop against, set your OTA source to `~binnec-dozzod-marzod`

### Linux Installation Notes

- Realm is distributed as an AppImage file. AppImages require FUSE version 2 to run. If you are running Ubuntu (>= 22.04), you will need to install fuse version 2. More information here:
Expand Down
13 changes: 12 additions & 1 deletion app/.holium/configs/webpack.config.renderer.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const configuration: webpack.Configuration = {
mouse: {
import: path.join(webpackPaths.srcRendererPath, 'mouse.tsx'),
},
reactRefreshSetup: '@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js',
updater: {
import: path.join(
webpackPaths.srcRendererPath,
Expand Down Expand Up @@ -202,7 +203,17 @@ const configuration: webpack.Configuration = {
__dirname: true,
__filename: false,
},

optimization: {
runtimeChunk: 'single',
// Ensure `react-refresh/runtime` is hoisted and shared
// Could be replicated via a vendors chunk
splitChunks: {
chunks: 'all',
name(_, __, cacheGroupKey) {
return cacheGroupKey;
},
},
},
devServer: {
port,
compress: true,
Expand Down
14 changes: 11 additions & 3 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
"devDependencies": {
"@electron/rebuild": "^3.2.10",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.0.0",
"@types/bcryptjs": "^2.4.2",
Expand Down Expand Up @@ -170,7 +170,15 @@
"entitlements": "assets/entitlements.mac.plist",
"entitlementsInherit": "assets/entitlements.mac.plist",
"gatekeeperAssess": false,
"timestamp": ""
"timestamp": "",
"extendInfo": {
"NSMicrophoneUsageDescription": "Please give us access to your microphone",
"NSCameraUsageDescription": "Please give us access to your camera",
"com.apple.security.device.audio-input": true,
"com.apple.security.device.camera": true,
"com.apple.security.cs.allow-jit": true,
"com.apple.security.cs.allow-unsigned-executable-memory": true
}
},
"dmg": {
"contents": [
Expand Down Expand Up @@ -234,4 +242,4 @@
"url": "https://github.com/holium/realm/issues"
},
"homepage": "https://github.com/holium/realm#readme"
}
}
38 changes: 36 additions & 2 deletions app/src/main/helpers/media.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { BrowserWindow, ipcMain, systemPreferences } from 'electron';
import {
BrowserWindow,
desktopCapturer,
ipcMain,
Menu,
systemPreferences,
} from 'electron';
import { download } from 'electron-dl';

import { MediaAccess, MediaAccessStatus } from '../../os/types';
import { isMac, isWindows } from './env';

const registerListeners = () => {
const registerListeners = (mainWindow: BrowserWindow) => {
ipcMain.removeHandler('ask-for-mic');
ipcMain.removeHandler('ask-for-camera');
ipcMain.removeHandler('ask-for-screen');
ipcMain.removeHandler('get-media-status');
ipcMain.removeHandler('download-url-as-file');

Expand All @@ -19,20 +26,47 @@ const registerListeners = () => {
return systemPreferences.getMediaAccessStatus('camera');
});

ipcMain.handle('ask-for-screen', async (): Promise<void | boolean> => {
const sources = await desktopCapturer.getSources({
types: ['screen', 'window'],
});

if (systemPreferences.getMediaAccessStatus('screen') !== 'granted') {
return false;
}
const videoOptionsMenu = Menu.buildFromTemplate(
sources
.filter((source) => source.name !== 'Mouse Overlay')
.map((source) => {
return {
label: source.name,
icon: source.thumbnail,
click: () =>
mainWindow.webContents.send('set-screenshare-source', source),
};
})
);

videoOptionsMenu.popup();
});

ipcMain.handle('get-media-status', (_event): MediaAccess => {
if (!isMac && !isWindows) {
return {
camera: 'unknown',
mic: 'unknown',
screen: 'unknown',
};
}

const camera = systemPreferences.getMediaAccessStatus('camera');
const mic = systemPreferences.getMediaAccessStatus('microphone');
const screen = systemPreferences.getMediaAccessStatus('screen');

return {
camera,
mic,
screen,
};
});

Expand Down
20 changes: 16 additions & 4 deletions app/src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { MouseState } from '@holium/realm-presence';

import { ConduitState } from 'os/services/api';
import { migrationPreload } from 'os/services/migration/migration.service';
import { lexiconPreload } from 'os/services/ship/lexicon.service';
import { settingsPreload } from 'os/services/ship/settings.service';
import { lexiconPreload } from 'os/services/ship/lexicon/lexicon.service';
import { settingsPreload } from 'os/services/ship/settings/settings.service';
import { bazaarPreload } from 'os/services/ship/spaces/bazaar.service';
import { spacesPreload } from 'os/services/ship/spaces/spaces.service';
import { trovePreload } from 'os/services/ship/trove.service';
import { trovePreload } from 'os/services/ship/trove/trove.service';

import { realmPreload } from '../os/realm.service';
import { authPreload } from '../os/services/auth/auth.service';
import { onboardingPreload } from '../os/services/auth/onboarding.service';
import { chatPreload } from '../os/services/ship/chat/chat.service';
import { friendsPreload } from '../os/services/ship/friends.service';
import { friendsPreload } from '../os/services/ship/friends/friends.service';
import { notifPreload } from '../os/services/ship/notifications/notifications.service';
import { shipPreload } from '../os/services/ship/ship.service';
import { appPublishersDBPreload } from '../os/services/ship/spaces/tables/appPublishers.table';
Expand Down Expand Up @@ -46,6 +46,9 @@ const appPreload = {
askForCamera: (): Promise<MediaAccessStatus> => {
return ipcRenderer.invoke('ask-for-camera');
},
askForScreen: (): Promise<MediaAccessStatus> => {
return ipcRenderer.invoke('ask-for-screen');
},
getMediaStatus: (): Promise<MediaAccess> => {
return ipcRenderer.invoke('get-media-status');
},
Expand Down Expand Up @@ -92,6 +95,15 @@ const appPreload = {
ipcRenderer.invoke('realm-to-app.ephemeral-chat', patp, message);
},
/* Receivers */
onScreenshareSource(
callback: (
source: Electron.DesktopCapturerSource
) => Promise<MediaStream | undefined>
) {
ipcRenderer.on('set-screenshare-source', (_, sourceId) => {
callback(sourceId);
});
},
onSetFullScreen(callback: (isFullscreen: boolean) => void) {
ipcRenderer.on('set-fullscreen', (_, isFullscreen) => {
callback(isFullscreen);
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const getDefaultRealmWindowOptions = (
simpleFullscreen: false,
acceptFirstMouse: true,
webPreferences: {
nodeIntegration: false,
nodeIntegration: true,
webviewTag: true,
sandbox: false,
contextIsolation: true,
Expand All @@ -52,7 +52,7 @@ export const createRealmWindow = () => {

WebViewHelper.registerListeners(newRealmWindow);
DevHelper.registerListeners(newRealmWindow);
MediaHelper.registerListeners();
MediaHelper.registerListeners(newRealmWindow);
BrowserHelper.registerListeners(newRealmWindow);
PowerHelper.registerListeners(newRealmWindow);
KeyHelper.registerListeners(newRealmWindow);
Expand Down Expand Up @@ -173,7 +173,7 @@ export const createStandaloneChatWindow = () => {

WebViewHelper.registerListeners(newStandaloneChatWindow);
DevHelper.registerListeners(newStandaloneChatWindow);
MediaHelper.registerListeners();
MediaHelper.registerListeners(newStandaloneChatWindow);
BrowserHelper.registerListeners(newStandaloneChatWindow);
PowerHelper.registerListeners(newStandaloneChatWindow);
KeyHelper.registerListeners(newStandaloneChatWindow);
Expand Down
30 changes: 12 additions & 18 deletions app/src/os/realm.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,15 @@ export class RealmService extends AbstractService<RealmUpdateTypes> {
this.onWebViewAttached = this.onWebViewAttached.bind(this);
this.onWillRedirect = this.onWillRedirect.bind(this);

app.on('quit', () => {
// do other cleanup here
});

app.on(
'web-contents-created',
async (_: Event, webContents: WebContents) => {
webContents.on('will-redirect', (e: Event, url: string) => {
e.preventDefault();
this.onWillRedirect(url, webContents);
});
}
);
// app.on(
// 'web-contents-created',
// async (_: Event, webContents: WebContents) => {
// webContents.on('will-redirect', (e: Event, url: string) => {
// e.preventDefault();
// this.onWillRedirect(url, webContents);
// });
// }
// );

const windows = BrowserWindow.getAllWindows();
windows.forEach(({ webContents }) => {
Expand Down Expand Up @@ -148,8 +144,6 @@ export class RealmService extends AbstractService<RealmUpdateTypes> {
}

await setSessionCookie({ ...credentials, cookie });
// return new Promise(async (resolve) => {
// APIConnection.getInstance().conduit.once('connected', () => {
log.info('realm.service.ts, login: conduit connected');
if (!this.services) return isAuthenticated;
this.services.auth._setLockfile({
Expand All @@ -159,10 +153,10 @@ export class RealmService extends AbstractService<RealmUpdateTypes> {
});
await this.services.ship?.init(this.services.auth);
this.services.ship?.updateCookie(cookie);

this._sendAuthenticated(patp, credentials.url, credentials.cookie ?? '');
// resolve(true);
// });
// });
const updatedPassport = await this.services.ship?.getOurPassport();
this.services.auth.setPassport(patp, updatedPassport);
}
return isAuthenticated;
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/os/services/api/api-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class APIConnection {
log.error('Conduit initialization failed', e);
});

app.on('quit', () => {
this.closeChannel();
app.once('quit', () => {
APIConnection.getInstance().conduit.closeChannel();
APIConnection.getInstance().conduit.removeAllListeners();
});
}
Expand Down Expand Up @@ -70,7 +70,7 @@ export class APIConnection {
this.isReconnecting = false;
}

public async closeChannel(): Promise<boolean> {
public async closeChannel() {
return await this.conduitInstance.closeChannel();
}
/**
Expand Down
Loading

0 comments on commit cc01b2e

Please sign in to comment.