Skip to content

Commit 0e38bfa

Browse files
committed
fix: vue structure for replay
1 parent f3348a0 commit 0e38bfa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+9324
-2930
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"remote-interfaces",
8787
"replay",
8888
"replay-app",
89+
"replay-app/frontend",
8990
"replay-api",
9091
"session-state",
9192
"testing",

replay-app/backend/Application.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import * as Path from 'path';
2-
import { app, dialog, ipcMain, Menu } from 'electron';
2+
import { app, dialog, ipcMain, Menu, protocol } from 'electron';
33
import * as Fs from 'fs';
4-
import { app, protocol, dialog, ipcMain, Menu } from 'electron';
5-
import WindowManager from './managers/WindowManager';
64
import OverlayManager from './managers/OverlayManager';
75
import generateAppMenu from './menus/generateAppMenu';
86
import ReplayApi from './ReplayApi';
97
import storage from './storage';
108
import Window from './models/Window';
119
import { ChildProcess } from 'child_process';
12-
import InternalServer from '~shared/constants/files';
13-
import * as Fs from 'fs';
1410
import IReplayMeta from '../shared/interfaces/IReplayMeta';
1511

1612
protocol.registerSchemesAsPrivileged([
@@ -59,7 +55,6 @@ export default class Application {
5955

6056
public getPageUrl(page: string) {
6157
if (Application.devServerUrl) {
62-
console.log('returining page url', new URL(page, Application.devServerUrl).href);
6358
return new URL(page, Application.devServerUrl).href;
6459
}
6560
return `app://./${page}.html`;
@@ -319,9 +314,7 @@ export default class Application {
319314
protocol.registerBufferProtocol('app', async (request, respond) => {
320315
let pathName = new URL(request.url).pathname;
321316
pathName = decodeURI(pathName); // Needed in case URL contains spaces
322-
const filePath = Path.join(app.getAppPath(), 'pages', pathName);
323-
324-
console.log('getting protocol', request.url, filePath);
317+
const filePath = Path.join(app.getAppPath(), 'frontend', pathName);
325318

326319
try {
327320
const data = await Fs.promises.readFile(filePath);

replay-app/backend/models/AppView.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Window from './Window';
22
import TabBackend from './TabBackend';
33
import ITabLocation, { InternalLocations } from '~shared/interfaces/ITabLocation';
4-
import InternalServer from '~shared/constants/files';
4+
import Application from '~backend/Application';
55

66
export default class AppView extends TabBackend {
77
public location: InternalLocations;
@@ -20,9 +20,10 @@ export default class AppView extends TabBackend {
2020

2121
const page = location === InternalLocations.NewTab ? 'home' : location.toLowerCase();
2222

23-
console.log('Loading app page', `${InternalServer.url}/${page}`);
23+
const url = Application.instance.getPageUrl(page);
24+
console.log('Loading app page', url);
2425

25-
this.webContents.loadURL(`${InternalServer.url}/${page}`);
26+
this.webContents.loadURL(url);
2627

2728
this.window.sendToRenderer('tab:updated', { id: this.id, location, replaceTabId });
2829
}

replay-app/backend/models/ReplayView.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ReplayApi from '~backend/ReplayApi';
44
import IRectangle from '~shared/interfaces/IRectangle';
55
import Application from '~backend/Application';
66
import TabBackend from './TabBackend';
7+
import { v1 as uuidv1 } from 'uuid';
78

89
const domReplayerScript = require.resolve('../../injected-scripts/domReplayer');
910

@@ -14,6 +15,7 @@ export default class ReplayView extends TabBackend {
1415
super(window, {
1516
preload: domReplayerScript,
1617
nodeIntegration: true,
18+
partition: uuidv1(),
1719
contextIsolation: true,
1820
javascript: false,
1921
});

replay-app/backend/models/TabBackend.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import { BrowserView, app } from 'electron';
2-
import { URL } from 'url';
3-
import { v1 as uuidv1 } from 'uuid';
1+
import { BrowserView } from 'electron';
42
import Window from './Window';
53
import generateContextMenu from '../menus/generateContextMenu';
6-
import ITabLocation, { InternalLocations } from '~shared/interfaces/ITabLocation';
7-
import ReplayApi from '~backend/ReplayApi';
8-
import IRectangle from '~shared/interfaces/IRectangle';
9-
import Application from '~backend/Application';
104
import Rectangle = Electron.Rectangle;
115

126
export default abstract class TabBackend {
@@ -23,7 +17,6 @@ export default abstract class TabBackend {
2317
contextIsolation: false,
2418
javascript: true,
2519
enableRemoteModule: true,
26-
partition: uuidv1(),
2720
nativeWindowOpen: true,
2821
webSecurity: true,
2922
sandbox: false,

replay-app/backend/models/Window.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { resolve } from 'path';
33
import Application from '../Application';
44
import ReplayApi from '~backend/ReplayApi';
55
import storage from '../storage';
6-
import InternalServer from '~shared/constants/files';
76
import ICreateTabOptions from '~shared/interfaces/ICreateTabOptions';
87
import { defaultTabOptions } from '~shared/constants/tabs';
98
import ITabMeta from '~shared/interfaces/ITabMeta';
@@ -189,7 +188,7 @@ export default class Window {
189188

190189
const { width, height } = this.browserWindow.getContentBounds();
191190
const toolbarContentHeight = await this.webContents.executeJavaScript(
192-
`document.body.offsetHeight`,
191+
`document.querySelector('.AppPage').offsetHeight`,
193192
);
194193

195194
const newBounds = {
@@ -280,7 +279,8 @@ export default class Window {
280279
const resizeObserver = new ResizeObserver(() => {
281280
ipcRenderer.send('resize-height');
282281
});
283-
resizeObserver.observe(document.body);
282+
const elem = document.querySelector('.AppPage');
283+
resizeObserver.observe(elem);
284284
`);
285285

286286
this.webContents.on('ipc-message', (e, message) => {

replay-app/backend/overlays/BaseOverlay.ts

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BrowserView, BrowserWindow } from 'electron';
22
import IRectangle from '~shared/interfaces/IRectangle';
3-
import Application from '../Application';
43
import Rectangle = Electron.Rectangle;
4+
import Application from '~backend/Application';
55

66
interface IOptions {
77
name: string;
@@ -26,12 +26,8 @@ export default class BaseOverlay {
2626
height: 0,
2727
};
2828
private readonly calcBounds: (bounds: IRectangle) => IRectangle;
29+
private readonly hideTimeout: number;
2930
private timeout: any;
30-
private hideTimeout: number;
31-
32-
private isLoaded = false;
33-
private isInitialized = false;
34-
private showCallback: any = null;
3531

3632
public constructor({
3733
name,
@@ -55,16 +51,7 @@ export default class BaseOverlay {
5551
this.hideTimeout = hideTimeout;
5652
this.name = name;
5753

58-
const { webContents } = this.browserView;
59-
60-
webContents.once('dom-ready', () => {
61-
this.isLoaded = true;
62-
if (this.showCallback) {
63-
this.showCallback();
64-
this.showCallback = null;
65-
}
66-
});
67-
54+
this.webContents.loadURL(Application.instance.getPageUrl(this.name));
6855
if (devtools) {
6956
this.webContents.openDevTools({ mode: 'detach' });
7057
}
@@ -99,9 +86,6 @@ export default class BaseOverlay {
9986
options: { focus?: boolean; waitForLoad?: boolean; rect?: IRectangle },
10087
...args: any[]
10188
) {
102-
if (!this.isInitialized) {
103-
this.initialize();
104-
}
10589
const { focus = true, waitForLoad = true, rect } = options;
10690
return new Promise(resolve => {
10791
this.browserWindow = browserWindow;
@@ -131,11 +115,6 @@ export default class BaseOverlay {
131115
resolve();
132116
};
133117

134-
if (!this.isLoaded && waitForLoad) {
135-
this.showCallback = callback;
136-
return;
137-
}
138-
139118
callback();
140119
});
141120
}
@@ -166,11 +145,6 @@ export default class BaseOverlay {
166145
this.browserView.destroy();
167146
this.browserView = null;
168147
}
169-
170-
private initialize() {
171-
this.isInitialized = true;
172-
this.webContents.loadURL(Application.instance.getPageUrl(this.name));
173-
}
174148
}
175149

176150
export const roundifyRectangle = (rect: IRectangle): IRectangle => {

replay-app/frontend/package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@secret-agent/replay-app-frontend",
3+
"private": true,
4+
"scripts": {
5+
"build": "vue-cli-service build",
6+
"clean": "vue-cli-service clean",
7+
"start": "vue-cli-service serve",
8+
"dev": "vue-cli-service serve --mode=development"
9+
},
10+
"dependencies": {
11+
"@babel/runtime-corejs3": "^7.11.2",
12+
"animejs": "^3.2.0",
13+
"core-js": "^3.6.5",
14+
"mobx": "^5.15.4",
15+
"mobx-vue": "^2.0.10",
16+
"source-map-support": "^0.5.19",
17+
"uuid": "^8.1.0",
18+
"vue": "^2.6.11",
19+
"vue-class-component": "^7.2.4",
20+
"vue-property-decorator": "^9.0.0",
21+
"vue-slider-component": "^3.2.2",
22+
"vue-styled-components": "^1.5.1"
23+
},
24+
"devDependencies": {
25+
"@vue/cli-plugin-babel": "^4.2.3",
26+
"@vue/cli-plugin-typescript": "^4.2.3",
27+
"@vue/cli-service": "^4.2.3",
28+
"concurrently": "^5.2.0",
29+
"cross-env": "^7.0.2",
30+
"css-loader": "~3.5.3",
31+
"node-sass": "^4.14.1",
32+
"pug": "^2.0.4",
33+
"pug-plain-loader": "^1.0.0",
34+
"sass-loader": "^8.0.2",
35+
"shx": "^0.3.2",
36+
"typescript": "~3.8.3"
37+
}
38+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<html>
22
<head>
33
<title>SecretAgent</title>
4-
<body id="app">
4+
<body>
5+
<div id="app"></div>
56
</body>
67
</html>

replay-app/frontend/src/components/Icon.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<script lang="ts">
66
import Vue from 'vue';
77
import Component from 'vue-class-component';
8-
import { transparency } from '@/constants/transparency';
8+
import { transparency } from '~frontend/constants/transparency';
99
import { TOOLBAR_BUTTON_HEIGHT } from '~shared/constants/design';
1010
import store from '../models/BaseStore';
11-
import NoCache from '@/lib/NoCache';
11+
import NoCache from '~frontend/lib/NoCache';
1212
1313
const IconProps = Vue.extend({
1414
props: {

0 commit comments

Comments
 (0)