Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
emma-sg committed Jan 8, 2024
1 parent b60d0af commit 51575b6
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 328 deletions.
2 changes: 1 addition & 1 deletion src/electron/electron-rec-preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { ensureDefaultColl } from "../utils";

import { loader, getDB } from "replaywebpage/src/electron-preload";
import { loader, getDB } from "replaywebpage/dist/electron-preload";

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { ipcRenderer, contextBridge } = require("electron");
Expand Down
52 changes: 26 additions & 26 deletions src/electron/electron-recorder-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ElectronRecorder } from "./electron-recorder";
import {
ElectronReplayApp,
STATIC_PREFIX,
} from "replaywebpage/src/electron-replay-app";
} from "replaywebpage/dist/electron-replay-app";

import path from "path";

Expand All @@ -19,14 +19,14 @@ class ElectronRecorderApp extends ElectronReplayApp {
constructor(opts) {
super(opts);

// @ts-expect-error - TS2339 - Property 'userAgent' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'userAgent' does not exist on type 'ElectronRecorderApp'.
this.userAgent = null;

// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
this.recorders = new Map();
}

// @ts-expect-error - TS2416 - Property 'mainWindowWebPreferences' in type 'ElectronRecorderApp' is not assignable to the same property in base type 'ElectronReplayApp'.
// @ts-expect-error - TS2416 - Property 'mainWindowWebPreferences' in type 'ElectronRecorderApp' is not assignable to the same property in base type 'ElectronReplayApp'.
get mainWindowWebPreferences() {
return {
plugins: true,
Expand All @@ -49,12 +49,12 @@ class ElectronRecorderApp extends ElectronReplayApp {
console.log(`will-download: ${origFilename}`);

item.setSavePath(
unusedFilenameSync(path.join(app.getPath("downloads"), origFilename)),
unusedFilenameSync(path.join(app.getPath("downloads"), origFilename))
);

ipcMain.on("dlcancel:" + origFilename, () => {
console.log(
`Canceled download for ${origFilename} to ${item.getSavePath()}`,
`Canceled download for ${origFilename} to ${item.getSavePath()}`
);
item.cancel();
});
Expand Down Expand Up @@ -93,10 +93,10 @@ class ElectronRecorderApp extends ElectronReplayApp {

super.onAppReady();

// @ts-expect-error - TS2339 - Property 'userAgent' does not exist on type 'ElectronRecorderApp'. | TS2531 - Object is possibly 'null'.
// @ts-expect-error - TS2339 - Property 'userAgent' does not exist on type 'ElectronRecorderApp'. | TS2531 - Object is possibly 'null'.
this.userAgent = this.origUA.replace(/ Electron[^\s]+/, "");

// @ts-expect-error - TS2339 - Property 'userAgent' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'userAgent' does not exist on type 'ElectronRecorderApp'.
app.userAgentFallback = this.userAgent;
}

Expand All @@ -108,7 +108,7 @@ class ElectronRecorderApp extends ElectronReplayApp {
const theWindow = super.createMainWindow(argv);

theWindow.on("close", async (event) => {
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
if (this.recorders.size) {
event.preventDefault();
event.returnValue = false;
Expand All @@ -127,7 +127,7 @@ class ElectronRecorderApp extends ElectronReplayApp {
defaultId: 1,
cancelId: 0,
title: "Stop Archiving and Quit",
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
message: `There are still ${this.recorders.size} active archiving sessions. Stop all and quit?`,
});

Expand All @@ -138,9 +138,9 @@ class ElectronRecorderApp extends ElectronReplayApp {

const promises = [];

// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
for (const rec of this.recorders.values()) {
// @ts-expect-error - TS2345 - Argument of type 'any' is not assignable to parameter of type 'never'.
// @ts-expect-error - TS2345 - Argument of type 'any' is not assignable to parameter of type 'never'.
promises.push(rec.shutdownPromise);
//rec.detach();
rec.recWindow.close();
Expand All @@ -152,7 +152,7 @@ class ElectronRecorderApp extends ElectronReplayApp {
}

createRecordWindow({
// @ts-expect-error - TS2525 - Initializer provides no value for this binding element and the binding element has no default value.
// @ts-expect-error - TS2525 - Initializer provides no value for this binding element and the binding element has no default value.
url,
collId = "",
startRec = true,
Expand Down Expand Up @@ -188,43 +188,43 @@ class ElectronRecorderApp extends ElectronReplayApp {
collId,
startRec,
autorun,
popupView = null,
popupView = null
) {
const id = recWebContents.id;

const recorder = new ElectronRecorder({
recWC: recWebContents,
// @ts-expect-error - TS2531 - Object is possibly 'null'.
// @ts-expect-error - TS2531 - Object is possibly 'null'.
appWC: this.mainWindow.webContents,
recWindow,
collId,
autorun,
popup: popupView,
staticPrefix: this.staticContentPath,
// @ts-expect-error - TS2339 - Property 'userAgent' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'userAgent' does not exist on type 'ElectronRecorderApp'.
userAgent: this.userAgent,
});

recWindow.on("close", (event) => {
console.log("closing...");
event.preventDefault();
recorder.shutdown().then(() => {
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
this.recorders.delete(id);
});
});

const newWinContents = popupView
// @ts-expect-error - TS2339 - Property 'webContents' does not exist on type 'never'.
? popupView.webContents
? // @ts-expect-error - TS2339 - Property 'webContents' does not exist on type 'never'.
popupView.webContents
: recWindow.webContents;

newWinContents.on("new-window", (event, url) => {
event.preventDefault();
if (url.startsWith(STATIC_PREFIX)) {
// @ts-expect-error - TS2531 - Object is possibly 'null'.
// @ts-expect-error - TS2531 - Object is possibly 'null'.
this.mainWindow.loadURL(url);
// @ts-expect-error - TS2531 - Object is possibly 'null'.
// @ts-expect-error - TS2531 - Object is possibly 'null'.
this.mainWindow.show();
}
});
Expand Down Expand Up @@ -255,7 +255,7 @@ class ElectronRecorderApp extends ElectronReplayApp {
disposition,
options,
additionalFeatures,
referrer,
referrer
) => {
event.preventDefault();
event.newGuest = this.createRecordWindow({ url, collId, startRec });
Expand All @@ -266,21 +266,21 @@ class ElectronRecorderApp extends ElectronReplayApp {
disposition,
options,
additionalFeatures,
referrer,
referrer
);
},
}
);

recWebContents.on("destroyed", () => {
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
this.recorders.delete(id);
});

//await recWebContents.loadURL("about:blank");

recWebContents.clearHistory();

// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
// @ts-expect-error - TS2339 - Property 'recorders' does not exist on type 'ElectronRecorderApp'.
this.recorders.set(id, recorder);
if (startRec) {
await recorder.attach();
Expand Down
2 changes: 1 addition & 1 deletion src/electron/rec-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
css,
wrapCss,
clickOnSpacebarPress,
} from "replaywebpage/src/misc";
} from "replaywebpage/dist/misc";

import fasRefresh from "@fortawesome/fontawesome-free/svgs/solid/redo-alt.svg";
//import fasFullscreen from '@fortawesome/fontawesome-free/svgs/solid/desktop.svg';
Expand Down
9 changes: 9 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { type ItemType } from "replaywebpage";

export type WrRecItem = ItemType & {
uploadTime?: number;
mtime: number;
sourceUrl?: string;
ipfsPins?: { url: string }[];
uploadId: string;
};
17 changes: 9 additions & 8 deletions src/ui/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { html, css, wrapCss, IS_APP, apiPrefix } from "replaywebpage/src/misc";
import { ifDefined } from "lit/directives/if-defined.js";

import { html, css, wrapCss, IS_APP, apiPrefix } from "replaywebpage/dist/misc";

// replaywebpage imports
import { ReplayWebApp, Embed, Loader } from "replaywebpage";
Expand Down Expand Up @@ -505,7 +507,7 @@ class ArchiveWebApp extends ReplayWebApp {
renderColl() {
return html` <wr-rec-coll
.editable="${true}"
.clearable="${this.embed}"
.clearable="${Boolean(this.embed)}"
.browsable="${!this.embed}"
.loadInfo="${this.getLoadInfo(this.sourceUrl)}"
.appLogo="${this.mainLogo}"
Expand All @@ -517,12 +519,11 @@ class ArchiveWebApp extends ReplayWebApp {
// @ts-expect-error - TS2339 - Property 'ipfsOpts' does not exist on type 'ArchiveWebApp'. | TS2339 - Property 'btrixOpts' does not exist on type 'ArchiveWebApp'.
{ ipfsOpts: this.ipfsOpts, btrixOpts: this.btrixOpts }
}
swName=${
// @ts-expect-error - TS2339 - Property 'swName' does not exist on type 'ArchiveWebApp'.
this.swName
}
embed="${this.embed}"
sourceUrl="${this.sourceUrl}"
swName=${ifDefined(this.swName)}
embed="${ifDefined(this.embed === null ? undefined : this.embed)}"
sourceUrl="${ifDefined(
this.sourceUrl === null ? undefined : this.sourceUrl
)}"
appName="${this.appName}"
appVersion=${VERSION}
@replay-favicons=${this.onFavIcons}
Expand Down
Loading

0 comments on commit 51575b6

Please sign in to comment.