Skip to content

Commit 8f33d54

Browse files
authored
Electron app cleanup + dependency update (#122)
* 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
1 parent 0dc0358 commit 8f33d54

File tree

7 files changed

+328
-309
lines changed

7 files changed

+328
-309
lines changed

.github/workflows/buildext.yaml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
- name: Yarn Install
2323
run: yarn install --frozen-lockfile
2424

25+
- name: Yarn Lint
26+
run: yarn run lint
27+
2528
- name: Yarn Build
2629
run: yarn run build
2730

@@ -34,10 +37,21 @@ jobs:
3437
cd dist/ext
3538
zip ../../ArchiveWeb.page-${{ steps.package-version.outputs.current-version }}-extension.zip -r ./
3639
37-
- name: Upload Extension ZIP
40+
- name: Upload Extension ZIP to GitHub
3841
uses: softprops/action-gh-release@v1
3942
with:
4043
files: ArchiveWeb.page-${{ steps.package-version.outputs.current-version }}-extension.zip
4144
tag_name: v${{ steps.package-version.outputs.current-version }}
4245
fail_on_unmatched_files: true
4346
draft: true
47+
48+
- name: Upload Extension ZIP to Chrome Web Store
49+
uses: mnao305/[email protected]
50+
with:
51+
file-path: ArchiveWeb.page-${{ steps.package-version.outputs.current-version }}-extension.zip
52+
extension-id: fpeoodllldobpkbkabpblcfaogecpndd
53+
client-id: ${{ secrets.CHROME_WEBSTORE_CLIENT_ID }}
54+
client-secret: ${{ secrets.CHROME_WEBSTORE_CLIENT_SECRET }}
55+
refresh-token: ${{ secrets.CHROME_WEBSTORE_REFRESH_TOKEN }}
56+
publish: false
57+
glob: false

dist/embed/replay/sw.js

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/embed/ui.js

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@webrecorder/archivewebpage",
33
"productName": "ArchiveWeb.page",
4-
"version": "0.9.2",
4+
"version": "0.9.3",
55
"main": "index.js",
66
"description": "Create Web Archives directly in your browser",
77
"repository": "https://github.com/webrecorder/archiveweb.page",
@@ -11,9 +11,9 @@
1111
"@fortawesome/fontawesome-free": "^5.13.0",
1212
"@ipld/car": "^5.0.1",
1313
"@ipld/unixfs": "^2.0.0",
14-
"@webrecorder/awp-sw": "^0.1.7",
15-
"@webrecorder/wabac": "^2.13.14",
16-
"auto-js-ipfs": "^2.0.0",
14+
"@webrecorder/awp-sw": "^0.1.8",
15+
"@webrecorder/wabac": "^2.13.15",
16+
"auto-js-ipfs": "^2.1.0",
1717
"browsertrix-behaviors": "^0.3.4",
1818
"btoa": "^1.2.1",
1919
"bulma": "^0.9.3",
@@ -26,7 +26,7 @@
2626
"p-queue": "^7.3.0",
2727
"pretty-bytes": "^5.6.0",
2828
"querystring-es3": "^0.2.1",
29-
"replaywebpage": "^1.7.7",
29+
"replaywebpage": "^1.7.8",
3030
"stream-browserify": "^3.0.0",
3131
"unused-filename": "^4.0.1",
3232
"url": "^0.11.0",
@@ -36,7 +36,7 @@
3636
"devDependencies": {
3737
"copy-webpack-plugin": "^9.0.1",
3838
"css-loader": "^6.2.0",
39-
"electron": "^21.3.1",
39+
"electron": "^22.0.0",
4040
"electron-builder": "^23.0.3",
4141
"electron-notarize": "^1.0.0",
4242
"eslint": "^8.28.0",

src/electron/electron-recorder-app.js

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*eslint-env node */
22

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

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

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

15-
const IPFS_API_ORIGINS = ["http://localhost:5001", "http://127.0.0.1"];
16-
1714

1815
// ===========================================================================
1916
class ElectronRecorderApp extends ElectronReplayApp
@@ -38,14 +35,6 @@ class ElectronRecorderApp extends ElectronReplayApp
3835
onAppReady() {
3936
const sesh = session.defaultSession;
4037

41-
const ua = sesh.getUserAgent();
42-
const desktopUA = ua.replace(/ Electron[^\s]+/, "");
43-
44-
sesh.setUserAgent(desktopUA);
45-
46-
app.userAgentFallback = desktopUA;
47-
this.userAgent = desktopUA;
48-
4938
ipcMain.on("start-rec", (event, opts) => {
5039
this.createRecordWindow(opts);
5140
});
@@ -96,6 +85,10 @@ class ElectronRecorderApp extends ElectronReplayApp
9685
});
9786

9887
super.onAppReady();
88+
89+
this.userAgent = this.origUA.replace(/ Electron[^\s]+/, "");
90+
91+
app.userAgentFallback = this.userAgent;
9992
}
10093

10194
get mainWindowUrl() {
@@ -254,52 +247,6 @@ class ElectronRecorderApp extends ElectronReplayApp
254247
console.warn("Load Failed", e);
255248
}
256249
}
257-
258-
async doIntercept(request, callback) {
259-
const {url, headers} = request;
260-
const origin = new URL(url).origin;
261-
262-
if (IPFS_API_ORIGINS.includes(origin)) {
263-
delete headers.Referrer;
264-
headers.Origin = new URL(url).origin;
265-
}
266-
267-
return super.doIntercept(request, callback);
268-
}
269-
270-
async proxyLive(request, callback) {
271-
let headers = request.headers;
272-
const {method, url, uploadData} = request;
273-
274-
const body = uploadData ? Readable.from(readBody(uploadData, session.defaultSession)) : null;
275-
276-
let response;
277-
try {
278-
respose = await fetch(url, {method, headers, body});
279-
} catch (e) {
280-
console.warn("fetch failed for: " + url);
281-
callback({statusCode: 502, headers: {}, data: null});
282-
return;
283-
}
284-
const data = method === "HEAD" ? null : response.body;
285-
const statusCode = response.status;
286-
287-
headers = Object.fromEntries(response.headers.entries());
288-
callback({statusCode, headers, data});
289-
}
290-
}
291-
292-
async function * readBody (body, session) {
293-
for (const chunk of body) {
294-
if (chunk.bytes) {
295-
yield await Promise.resolve(chunk.bytes);
296-
} else if (chunk.blobUUID) {
297-
yield await session.getBlobData(chunk.blobUUID);
298-
}
299-
// } else if (chunk.file) {
300-
// yield * Readable.from(fs.createReadStream(chunk.file));
301-
// }
302-
}
303250
}
304251

305252

webpack.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ const GenerateJsonPlugin = require("generate-json-webpack-plugin");
77
const CopyPlugin = require("copy-webpack-plugin");
88
const TerserPlugin = require("terser-webpack-plugin");
99

10-
const APP_FILE_SERVE_PREFIX = "http://files.archiveweb.page/";
11-
1210
const AWP_PACKAGE = require("./package.json");
1311
const RWP_PACKAGE = require("./node_modules/replaywebpage/package.json");
1412
const WARCIO_PACKAGE = require("./node_modules/warcio/package.json");
@@ -22,7 +20,6 @@ const defaultDefines = {
2220
__VERSION__: JSON.stringify(RWP_PACKAGE.version),
2321
__WARCIO_VERSION__: JSON.stringify(WARCIO_PACKAGE.version),
2422
__SW_NAME__: JSON.stringify("sw.js"),
25-
__APP_FILE_SERVE_PREFIX__ : JSON.stringify(APP_FILE_SERVE_PREFIX),
2623
__WEB3_STORAGE_TOKEN__: JSON.stringify(""),
2724
};
2825

0 commit comments

Comments
 (0)