Skip to content

Commit

Permalink
Electron app cleanup + dependency update (#122)
Browse files Browse the repository at this point in the history
* electron app: cleanup based on updates to replayweb.page 1.7.8
- remove proxyLive overrides (now handled in rwp)
- remove origin overrides (no longer needed with default UA)

* ci:
- add link check on build
- add extension upload on release

* deps: update to latest replaywebpage 1.7.8, awp-sw 0.1.8, webrecorder/wabac.js 2.13.15, auto-js-ipfs 2.1.0, electron 22.0

bump to 0.9.3
  • Loading branch information
ikreymer authored Dec 8, 2022
1 parent 0dc0358 commit 8f33d54
Show file tree
Hide file tree
Showing 7 changed files with 328 additions and 309 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/buildext.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: Yarn Install
run: yarn install --frozen-lockfile

- name: Yarn Lint
run: yarn run lint

- name: Yarn Build
run: yarn run build

Expand All @@ -34,10 +37,21 @@ jobs:
cd dist/ext
zip ../../ArchiveWeb.page-${{ steps.package-version.outputs.current-version }}-extension.zip -r ./
- name: Upload Extension ZIP
- name: Upload Extension ZIP to GitHub
uses: softprops/action-gh-release@v1
with:
files: ArchiveWeb.page-${{ steps.package-version.outputs.current-version }}-extension.zip
tag_name: v${{ steps.package-version.outputs.current-version }}
fail_on_unmatched_files: true
draft: true

- name: Upload Extension ZIP to Chrome Web Store
uses: mnao305/chrome-extension-upload@3.0.0
with:
file-path: ArchiveWeb.page-${{ steps.package-version.outputs.current-version }}-extension.zip
extension-id: fpeoodllldobpkbkabpblcfaogecpndd
client-id: ${{ secrets.CHROME_WEBSTORE_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_WEBSTORE_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_WEBSTORE_REFRESH_TOKEN }}
publish: false
glob: false
20 changes: 10 additions & 10 deletions dist/embed/replay/sw.js

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions dist/embed/ui.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@webrecorder/archivewebpage",
"productName": "ArchiveWeb.page",
"version": "0.9.2",
"version": "0.9.3",
"main": "index.js",
"description": "Create Web Archives directly in your browser",
"repository": "https://github.com/webrecorder/archiveweb.page",
Expand All @@ -11,9 +11,9 @@
"@fortawesome/fontawesome-free": "^5.13.0",
"@ipld/car": "^5.0.1",
"@ipld/unixfs": "^2.0.0",
"@webrecorder/awp-sw": "^0.1.7",
"@webrecorder/wabac": "^2.13.14",
"auto-js-ipfs": "^2.0.0",
"@webrecorder/awp-sw": "^0.1.8",
"@webrecorder/wabac": "^2.13.15",
"auto-js-ipfs": "^2.1.0",
"browsertrix-behaviors": "^0.3.4",
"btoa": "^1.2.1",
"bulma": "^0.9.3",
Expand All @@ -26,7 +26,7 @@
"p-queue": "^7.3.0",
"pretty-bytes": "^5.6.0",
"querystring-es3": "^0.2.1",
"replaywebpage": "^1.7.7",
"replaywebpage": "^1.7.8",
"stream-browserify": "^3.0.0",
"unused-filename": "^4.0.1",
"url": "^0.11.0",
Expand All @@ -36,7 +36,7 @@
"devDependencies": {
"copy-webpack-plugin": "^9.0.1",
"css-loader": "^6.2.0",
"electron": "^21.3.1",
"electron": "^22.0.0",
"electron-builder": "^23.0.3",
"electron-notarize": "^1.0.0",
"eslint": "^8.28.0",
Expand Down
61 changes: 4 additions & 57 deletions src/electron/electron-recorder-app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*eslint-env node */

import {Readable} from "stream";
import {app, session, BrowserWindow, ipcMain, dialog } from "electron";
import { ElectronRecorder } from "./electron-recorder";

Expand All @@ -12,8 +11,6 @@ import { unusedFilenameSync } from "unused-filename";

app.commandLine.appendSwitch("disable-features", "CrossOriginOpenerPolicy");

const IPFS_API_ORIGINS = ["http://localhost:5001", "http://127.0.0.1"];


// ===========================================================================
class ElectronRecorderApp extends ElectronReplayApp
Expand All @@ -38,14 +35,6 @@ class ElectronRecorderApp extends ElectronReplayApp
onAppReady() {
const sesh = session.defaultSession;

const ua = sesh.getUserAgent();
const desktopUA = ua.replace(/ Electron[^\s]+/, "");

sesh.setUserAgent(desktopUA);

app.userAgentFallback = desktopUA;
this.userAgent = desktopUA;

ipcMain.on("start-rec", (event, opts) => {
this.createRecordWindow(opts);
});
Expand Down Expand Up @@ -96,6 +85,10 @@ class ElectronRecorderApp extends ElectronReplayApp
});

super.onAppReady();

this.userAgent = this.origUA.replace(/ Electron[^\s]+/, "");

app.userAgentFallback = this.userAgent;
}

get mainWindowUrl() {
Expand Down Expand Up @@ -254,52 +247,6 @@ class ElectronRecorderApp extends ElectronReplayApp
console.warn("Load Failed", e);
}
}

async doIntercept(request, callback) {
const {url, headers} = request;
const origin = new URL(url).origin;

if (IPFS_API_ORIGINS.includes(origin)) {
delete headers.Referrer;
headers.Origin = new URL(url).origin;
}

return super.doIntercept(request, callback);
}

async proxyLive(request, callback) {
let headers = request.headers;
const {method, url, uploadData} = request;

const body = uploadData ? Readable.from(readBody(uploadData, session.defaultSession)) : null;

let response;
try {
respose = await fetch(url, {method, headers, body});
} catch (e) {
console.warn("fetch failed for: " + url);
callback({statusCode: 502, headers: {}, data: null});
return;
}
const data = method === "HEAD" ? null : response.body;
const statusCode = response.status;

headers = Object.fromEntries(response.headers.entries());
callback({statusCode, headers, data});
}
}

async function * readBody (body, session) {
for (const chunk of body) {
if (chunk.bytes) {
yield await Promise.resolve(chunk.bytes);
} else if (chunk.blobUUID) {
yield await session.getBlobData(chunk.blobUUID);
}
// } else if (chunk.file) {
// yield * Readable.from(fs.createReadStream(chunk.file));
// }
}
}


Expand Down
3 changes: 0 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const GenerateJsonPlugin = require("generate-json-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");

const APP_FILE_SERVE_PREFIX = "http://files.archiveweb.page/";

const AWP_PACKAGE = require("./package.json");
const RWP_PACKAGE = require("./node_modules/replaywebpage/package.json");
const WARCIO_PACKAGE = require("./node_modules/warcio/package.json");
Expand All @@ -22,7 +20,6 @@ const defaultDefines = {
__VERSION__: JSON.stringify(RWP_PACKAGE.version),
__WARCIO_VERSION__: JSON.stringify(WARCIO_PACKAGE.version),
__SW_NAME__: JSON.stringify("sw.js"),
__APP_FILE_SERVE_PREFIX__ : JSON.stringify(APP_FILE_SERVE_PREFIX),
__WEB3_STORAGE_TOKEN__: JSON.stringify(""),
};

Expand Down
Loading

0 comments on commit 8f33d54

Please sign in to comment.