Skip to content

Commit 14a5d3c

Browse files
committed
behaviors: only waiting for pending network requests, not internal async fetches (to lower wait time)
behaviors: fix start/pause button in electron app ui: fix page selection, fixes #25 ui: add message when finishing recording, wait for fetch requests but not more than 20 sec ui: replay: fix for location bar not always loading entered URL (from replayweb.page) ipfs: use trickle dag, ui default to replayweb.page link as gateway links not reliable for partial loading bump to browsertrix-behaviors 0.2.0 - experimental facebook behavior bump to latest electron (12.0.5), latest ruffle bump to 0.6.2
1 parent def0320 commit 14a5d3c

File tree

13 files changed

+227
-169
lines changed

13 files changed

+227
-169
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "ArchiveWeb.page",
3-
"version": "0.6.1",
3+
"version": "0.6.2",
44
"main": "index.js",
55
"description": "Create Web Archives directly in your browser",
66
"repository": "https://github.com/webrecorder/archiveweb.page",
77
"author": "Webrecorder Software",
88
"license": "AGPL-3.0-or-later",
99
"dependencies": {
1010
"@fortawesome/fontawesome-free": "^5.13.0",
11-
"@webrecorder/wabac": "github:webrecorder/wabac.js#multi-wacz",
12-
"browsertrix-behaviors": "0.1.1",
13-
"bulma": "^0.9.1",
11+
"@webrecorder/wabac": "2.7.0-beta.2",
12+
"browsertrix-behaviors": "^0.2.0",
13+
"bulma": "^0.9.2",
1414
"flexsearch": "^0.6.32",
1515
"hash-wasm": "^4.4.1",
1616
"http-status-codes": "^1.4.0",
@@ -21,13 +21,13 @@
2121
"lodash": "^4.17.20",
2222
"node-fetch": "^2.6.1",
2323
"pretty-bytes": "^5.3.0",
24-
"replaywebpage": "github:webrecorder/replayweb.page#1.4.0-work",
24+
"replaywebpage": "^1.4.0-beta.0",
2525
"warcio": "^1.4.3"
2626
},
2727
"devDependencies": {
2828
"copy-webpack-plugin": "^6.4.0",
2929
"css-loader": "^3.5.3",
30-
"electron": "12.0.2",
30+
"electron": "12.0.5",
3131
"electron-builder": "^22.9.1",
3232
"electron-notarize": "^1.0.0",
3333
"generate-json-webpack-plugin": "1.0.0",

src/electron/electron-recorder-app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ class ElectronRecorderApp extends ElectronReplayApp
181181
case "stopRecording":
182182
await recorder.detach();
183183
break;
184+
185+
case "toggleBehaviors":
186+
await recorder.toggleBehaviors();
187+
break;
184188
}
185189
});
186190

src/popup.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class RecPopup extends LitElement
5656
this.allowCreate = true;
5757

5858
this.waitingForStart = false;
59+
this.waitingForStop = false;
5960
this.behaviorState = BEHAVIOR_WAIT_LOAD;
6061
this.behaviorMsg = "";
6162
this.autorun = localStorage.getItem("autorunBehaviors") === "1";
@@ -87,7 +88,7 @@ class RecPopup extends LitElement
8788
}
8889

8990
firstUpdated() {
90-
document.addEventListener("click", (event) => {
91+
document.addEventListener("click", () => {
9192
if (this.collDrop === "show") {
9293
this.collDrop = "";
9394
}
@@ -127,6 +128,9 @@ class RecPopup extends LitElement
127128
if (this.waitingForStart && message.firstPageStarted) {
128129
this.waitingForStart = false;
129130
}
131+
if (this.waitingForStop && !message.recording && !message.stopping) {
132+
this.waitingForStop = false;
133+
}
130134
this.status = message;
131135
this.behaviorState = message.behaviorState;
132136
this.behaviorMsg = message.behaviorData && message.behaviorData.msg || "Starting...";
@@ -350,9 +354,9 @@ class RecPopup extends LitElement
350354
return html`<span class="status-autopilot">Auto Recording, ${this.behaviorMsg}</span>`;
351355
}
352356

353-
if (this.recording) {
354-
return html`<b>Recording:&nbsp;</b>${this.status && this.status.numPending ? html`
355-
<span class="status-pending">${this.status.numPending} URLs pending, please wait before loading a new page.</span>
357+
if (this.recording) {
358+
return html`<b>${this.waitingForStop ? "Finishing " : ""} Recording:&nbsp;</b>${this.status && this.status.numPending ? html`
359+
<span class="status-pending">${this.status.numPending} URLs pending${this.waitingForStop ? '.' : ', please wait before loading a new page.'}</span>
356360
` :
357361
html`
358362
<span class="status-ready">Idle, Continue Browsing</span>`}`;
@@ -485,7 +489,7 @@ class RecPopup extends LitElement
485489
${this.canRecord ? html`
486490
${this.renderCollDropdown()}
487491
<button
488-
?disabled=${this.collDrop === "create" || (!this.recording && this.waitingForStart)}
492+
?disabled=${this.actionButtonDisabled}
489493
@click="${!this.recording ? this.onStart : this.onStop}" class="button">
490494
<span class="icon">
491495
${!this.recording ? html`
@@ -542,6 +546,14 @@ class RecPopup extends LitElement
542546
`;
543547
}
544548

549+
get actionButtonDisabled() {
550+
if (this.collDrop === "create") {
551+
return true;
552+
}
553+
554+
return !this.recording ? this.waitingForStart : this.waitingForStop;
555+
}
556+
545557
get behaviorsButtonLabel() {
546558
switch (this.behaviorState) {
547559
case BEHAVIOR_WAIT_LOAD:
@@ -578,6 +590,7 @@ class RecPopup extends LitElement
578590
onStop() {
579591
this.sendMessage({type: "stopRecording"});
580592
this.waitingForStart = false;
593+
this.waitingForStop = true;
581594
}
582595

583596
onSelectColl(event) {

src/recorder.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Recorder {
3636
this.numPending = 0;
3737

3838
this.running = false;
39+
this.stopping = false;
3940

4041
this.frameId = null;
4142
this.pageInfo = {size: 0};
@@ -122,14 +123,19 @@ class Recorder {
122123
}
123124

124125
async detach() {
126+
this.stopping = true;
127+
125128
const domNodes = await this.getFullText();
126129

127130
if (this.behaviorState === BEHAVIOR_RUNNING) {
128131
this.toggleBehaviors();
129132
}
130133

131134
try {
132-
await Promise.all(this._fetchPending.values());
135+
await Promise.race([
136+
Promise.all(this._fetchPending.values()),
137+
sleep(15000)
138+
]);
133139
} catch(e) {
134140
console.log(e);
135141
}
@@ -164,6 +170,7 @@ class Recorder {
164170
await this._doAttach();
165171

166172
this.running = true;
173+
this.stopping = false;
167174

168175
this._updateId = setInterval(() => this.updateStatus(), 1000);
169176

@@ -187,9 +194,10 @@ class Recorder {
187194
}
188195

189196
updateStatus() {
190-
this.numPending = Object.keys(this.pendingRequests).length + this._fetchPending.size;
197+
const networkPending = Object.keys(this.pendingRequests).length;
198+
this.numPending = networkPending + this._fetchPending.size;
191199

192-
if (this.numPending === 0 && this._loadedDoneResolve) {
200+
if (networkPending === 0 && this._loadedDoneResolve) {
193201
this._loadedDoneResolve();
194202
}
195203

@@ -212,6 +220,7 @@ class Recorder {
212220
pageTs: this.pageInfo.ts,
213221
failureMsg: this.failureMsg,
214222
collId: this.collId,
223+
stopping: this.stopping,
215224
type: "status"
216225
}
217226
}
@@ -1091,7 +1100,7 @@ class Recorder {
10911100
}
10921101

10931102
async doBackgroundFetch() {
1094-
if (!this._fetchQueue.length || this._fetchPending.size >= MAX_CONCURRENT_FETCH) {
1103+
if (!this._fetchQueue.length || this._fetchPending.size >= MAX_CONCURRENT_FETCH || this.stopping) {
10951104
return;
10961105
}
10971106

@@ -1157,10 +1166,10 @@ class Recorder {
11571166
} catch(e) {
11581167
console.log(e);
11591168
this._fetchUrls.delete(request.url);
1169+
} finally {
1170+
doneResolve();
1171+
this._fetchPending.delete(fetchId);
11601172
}
1161-
1162-
doneResolve();
1163-
this._fetchPending.delete(fetchId);
11641173
}
11651174

11661175
async fetchPayloads(params, reqresp, sessions, method) {

src/ui.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,18 +668,12 @@ class WrRecCollInfo extends LitElement
668668
</span>
669669
Copy IPFS URL
670670
</a>
671-
<a @click="${this.onCopyRWPLink}" class="dropdown-item">
671+
<a @click="${this.onCopyRWPLink}" class="has-text-weight-bold dropdown-item">
672672
<span class="icon is-small">
673673
<fa-icon size="0.8em" .svg="${fasShare}"></fa-icon>
674674
</span>
675675
Copy Shareable ReplayWeb.page Link
676676
</a>
677-
<a @click="${this.onCopyGatewayLink}" class="has-text-weight-bold dropdown-item">
678-
<span class="icon is-small">
679-
<fa-icon size="0.8em" .svg="${fasShare}"></fa-icon>
680-
</span>
681-
Copy Shareable IPFS Gateway Link
682-
</a>
683677
</div>
684678
</div>
685679
</div>

src/utils.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ async function checkPins(ipfsClient, validPins) {
8787

8888
// ===========================================================================
8989
async function ipfsAddPin(ipfsClient, path, content) {
90-
const resp = await ipfsClient.ipfs.add({path, content}, {wrapWithDirectory: true});
90+
const resp = await ipfsClient.ipfs.add({path, content}, {
91+
wrapWithDirectory: true,
92+
trickle: true
93+
});
9194

9295
const hash = resp.cid.toString();
9396

@@ -133,7 +136,10 @@ async function ipfsAddWithReplay(ipfsClient, waczPath, waczContent, swContent, u
133136

134137
fileData.push({path: waczPath, content: waczContent});
135138

136-
const resp = await ipfsClient.ipfs.addAll(fileData, {wrapWithDirectory: true});
139+
const resp = await ipfsClient.ipfs.addAll(fileData, {
140+
wrapWithDirectory: true,
141+
trickle: true
142+
});
137143

138144
let hash;
139145
let size = 0;

wr-ext/bg.js

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

wr-ext/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Webrecorder ArchiveWeb.page",
33
"description": "Create high-fidelity web archives directly in your browser",
4-
"version": "0.6.1",
4+
"version": "0.6.2",
55
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
66
"permissions": [
77
"debugger",

wr-ext/popup.js

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

wr-ext/replay/sw.js

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

0 commit comments

Comments
 (0)