Skip to content

Commit 7e1ad12

Browse files
committed
embed mode:
- additional fixes for embed mode size updates - 'archivePrefix' and 'proxyPrefix' in <record-web-page> now configurable - dependency: update to replayweb.page 1.6.2
1 parent 6b5cfe2 commit 7e1ad12

File tree

7 files changed

+81
-34
lines changed

7 files changed

+81
-34
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"node-fetch": "2.6.7",
2323
"pretty-bytes": "^5.6.0",
2424
"querystring-es3": "^0.2.1",
25-
"replaywebpage": "^1.6.1",
25+
"replaywebpage": "^1.6.2",
2626
"stream-browserify": "^3.0.0",
2727
"unused-filename": "^4.0.1",
2828
"url": "^0.11.0",

src/electron/electron-recorder-app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { PassThrough } from "stream";
1010

1111
import fs from "fs";
1212
import util from "util";
13-
import { unusedFilenameSync } from 'unused-filename';
13+
import { unusedFilenameSync } from "unused-filename";
1414

1515
import { checkPins, ipfsAddWithReplay, ipfsUnpinAll } from "../utils";
1616

src/sw/main.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,9 @@ import { ExtAPI } from "./api";
55
import { RecordingCollections } from "./recproxy";
66

77
import REC_INDEX_HTML from "../static/replay/index.html";
8-
import { WorkerLoader } from "@webrecorder/wabac/src/loaders";
8+
import RWP_INDEX_HTML from "replaywebpage/index.html";
99

10-
const RWP_INDEX_HTML = `
11-
<!doctype html>
12-
<html class="no-overflow">
13-
<head><title>ReplayWeb.page</title>
14-
<meta name="viewport" content="width=device-width, initial-scale=1">
15-
<script src="./ui.js"></script>
16-
</head>
17-
<body>
18-
<replay-app-main></replay-app-main>
19-
</body>
20-
</html>
21-
`;
10+
import { WorkerLoader } from "@webrecorder/wabac/src/loaders";
2211

2312
if (self.registration) {
2413
const defaultConfig = {

src/ui/app.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,12 @@ class ArchiveWebApp extends ReplayWebApp
311311
renderColl() {
312312
return html`
313313
<wr-rec-coll
314-
.editable="${!this.embed}"
314+
.editable="${true}"
315+
.clearable="${this.embed}"
316+
.nonlocalDate="${this.embed}"
315317
.loadInfo="${this.getLoadInfo(this.sourceUrl)}"
316318
.appLogo="${this.mainLogo}"
317-
.autoUpdateInterval=${this.showDownloadProgress ? 0 : 10}
319+
.autoUpdateInterval=${this.embed || this.showDownloadProgress ? 0 : 10}
318320
embed="${this.embed}"
319321
sourceUrl="${this.sourceUrl}"
320322
appName="${this.appName}"
@@ -418,28 +420,28 @@ class ArchiveWebApp extends ReplayWebApp
418420
renderDownloadModal() {
419421
const renderDLStatus = () => {
420422
switch (this.download.state) {
421-
case "progressing":
422-
return html`
423+
case "progressing":
424+
return html`
423425
<button @click="${this.onDownloadCancel}" class="button is-danger">Cancel Download</button>
424426
`;
425427

426-
case "interrupted":
427-
return html`
428+
case "interrupted":
429+
return html`
428430
<p class="has-text-weight-bold has-text-danger">The download was interrupted</p>
429431
<button @click="${this.onDownloadCancel}" class="button">Close</button>
430-
`
432+
`;
431433

432-
case "cancelled":
433-
return html`
434+
case "cancelled":
435+
return html`
434436
<p class="has-text-weight-bold has-text-danger">The download was canceled</p>
435437
<button @click="${this.onDownloadCancel}" class="button">Close</button>
436438
`;
437439

438-
case "completed":
439-
return html`
440+
case "completed":
441+
return html`
440442
<p class="has-text-weight-bold has-text-primary">Download Completed!</p>
441443
<button @click="${this.onDownloadCancel}" class="button">Close</button>
442-
`
444+
`;
443445
}
444446
};
445447

src/ui/coll-info.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ class WrRecColl extends Coll
2323
constructor() {
2424
super();
2525
this.browsable = false;
26+
this._sizeUpdater = null;
27+
this.totalSize = 0;
28+
}
29+
30+
static get properties() {
31+
return {
32+
...Coll.properties,
33+
34+
totalSize: { type: Number }
35+
};
2636
}
2737

2838
static get styles() {
@@ -51,6 +61,31 @@ class WrRecColl extends Coll
5161
`;
5262
}
5363

64+
updated(changedProperties) {
65+
if (changedProperties.has("embed")) {
66+
if (this.embed && !this._sizeUpdater) {
67+
this._sizeUpdater = this.runSizeUpdater();
68+
}
69+
}
70+
71+
super.updated(changedProperties);
72+
}
73+
74+
async runSizeUpdater() {
75+
try {
76+
while (this.embed) {
77+
if (this.coll) {
78+
const resp = await fetch(`${apiPrefix}/c/${this.coll}`);
79+
const json = await resp.json();
80+
this.totalSize = json.size || 0;
81+
}
82+
await new Promise(resolve => setTimeout(resolve, 3000));
83+
}
84+
} finally {
85+
this._sizeUpdater = null;
86+
}
87+
}
88+
5489
renderExtraToolbar(isDropdown = false) {
5590
if (this.embed) {
5691
if (!isDropdown) {
@@ -59,7 +94,7 @@ class WrRecColl extends Coll
5994
<span class="icon is-small" title="Recording">
6095
<fa-icon size="1.2em" aria-hidden="true" .svg="${wrRec}"></fa-icon>
6196
</span>
62-
<span class="size-label">${prettyBytes(this.collInfo && this.collInfo.size)}</span>
97+
<span class="size-label">${prettyBytes(this.totalSize)}</span>
6398
</span>
6499
`;
65100
} else {

src/ui/recordembed.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class RecordEmbed extends Embed
2222
this.noWebWorker = true;
2323

2424
this.proxyPrefix = "https://wabac-cors-proxy.webrecorder.workers.dev/proxy/";
25+
this.archivePrefix = "";
2526

2627
const baseUrl = new URL(window.location);
2728
baseUrl.hash = "";
@@ -30,8 +31,8 @@ class RecordEmbed extends Embed
3031

3132
this.customConfig = {
3233
"prefix": this.proxyPrefix,
33-
"isLive": true,
34-
//"archivePrefix": this.archivePrefix,
34+
"isLive": false,
35+
"archivePrefix": this.archivePrefix,
3536
"baseUrl": baseUrl.href,
3637
"baseUrlHashReplay": false,
3738
"recording": true,
@@ -43,6 +44,26 @@ class RecordEmbed extends Embed
4344
this.source = "proxy://" + this.proxyPrefix;
4445
}
4546

47+
static get properties() {
48+
return {
49+
...Embed.properties,
50+
51+
archivePrefix: { type: String },
52+
proxyPrefix: { type: String }
53+
};
54+
}
55+
56+
updated(changedProperties) {
57+
if (changedProperties.has("proxyPrefix")) {
58+
this.customConfig.proxyPrefix = this.proxyPrefix;
59+
}
60+
if (changedProperties.has("archivePrefix")) {
61+
this.customConfig.archivePrefix = this.archivePrefix;
62+
this.customConfig.isLive = !this.archivePrefix;
63+
}
64+
super.updated(changedProperties);
65+
}
66+
4667
handleMessage(event) {
4768
if (this.downloaded && typeof(event.data) === "object" && event.data.msg_type === "downloadedBlob") {
4869
this.downloaded(event.data.url);

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6798,10 +6798,10 @@ registry-url@^5.0.0:
67986798
dependencies:
67996799
rc "^1.2.8"
68006800

6801-
replaywebpage@^1.6.1:
6802-
version "1.6.1"
6803-
resolved "https://registry.yarnpkg.com/replaywebpage/-/replaywebpage-1.6.1.tgz#7167f8650b717c24948f80ea1c9f1142663b9a49"
6804-
integrity sha512-iK3yw132w5nt4Y6hiaG7gJ2Sb30HD7Hi0wD3GroBapbfYck51Sdn5d++tsHeMhZN49Dz95YAEwmpDQmfrOWBIw==
6801+
replaywebpage@^1.6.2:
6802+
version "1.6.2"
6803+
resolved "https://registry.yarnpkg.com/replaywebpage/-/replaywebpage-1.6.2.tgz#1289a2cf788a55299f62e67aa1596768da896578"
6804+
integrity sha512-ZNIst15zaeej5CdHhQ1/QXLlA0mqALhGw3KJVlGoSZtM8HvX8Gv3YNS9k1w+TQpAecv9VCo6So8BLEE4XLGV7w==
68056805
dependencies:
68066806
"@fortawesome/fontawesome-free" "^5.15.4"
68076807
"@webrecorder/wabac" "^2.12.0"

0 commit comments

Comments
 (0)