Skip to content

Commit 97598b1

Browse files
committed
additional fixes for wabac.js 2.20.0 with typescript!
1 parent b636237 commit 97598b1

10 files changed

+111
-99
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@fortawesome/fontawesome-free": "^5.13.0",
1212
"@ipld/car": "^5.3.1",
1313
"@webrecorder/awp-sw": "^0.4.4",
14-
"@webrecorder/wabac": "^2.19.7",
14+
"@webrecorder/wabac": "^2.20.0-beta.1",
1515
"auto-js-ipfs": "^2.3.0",
1616
"browsertrix-behaviors": "^0.6.4",
1717
"btoa": "^1.2.1",
@@ -23,12 +23,12 @@
2323
"node-fetch": "2.6.7",
2424
"pdfjs-dist": "2.2.228",
2525
"pretty-bytes": "^5.6.0",
26-
"replaywebpage": "^2.0.2",
26+
"replaywebpage": "^2.1.4",
2727
"stream-browserify": "^3.0.0",
2828
"tsconfig-paths-webpack-plugin": "^4.1.0",
2929
"unused-filename": "^4.0.1",
3030
"uuid": "^8.3.2",
31-
"warcio": "^2.2.1"
31+
"warcio": "^2.3.1"
3232
},
3333
"devDependencies": {
3434
"@typescript-eslint/eslint-plugin": "^6.15.0",

src/electron/app-popup.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//import { ipcRenderer } from "electron";
22
import { RecPopup } from "../popup";
33

4-
// @ts-expect-error - TS7016 - Could not find a declaration file for module '@webrecorder/wabac/src/loaders'. '/Users/emma/Work/Webrecorder/archiveweb.page/node_modules/@webrecorder/wabac/src/loaders.js' implicitly has an 'any' type.
5-
import { CollectionLoader } from "@webrecorder/wabac/src/loaders";
4+
import { CollectionLoader } from "@webrecorder/wabac/swlib";
65
import { listAllMsg } from "../utils";
76
import { setLocalOption } from "../localstorage";
87

src/electron/electron-recorder-app.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ class ElectronRecorderApp extends ElectronReplayApp {
4848
const { url, responseHeaders, method } = details;
4949

5050
// Allow access to Browsertrix APIs
51-
if (url.indexOf("/api") >= 0) {
51+
if (url.indexOf("/api") >= 0 && responseHeaders) {
5252
let { statusLine } = details;
5353

5454
if (method === "OPTIONS") {
5555
statusLine = "HTTP/1.1 200 OK";
56-
responseHeaders["Access-Control-Allow-Headers"] = "Authorization, Content-Type";
57-
responseHeaders["Access-Control-Allow-Methods"] = "GET, PUT, POST";
56+
responseHeaders["Access-Control-Allow-Headers"] = ["Authorization, Content-Type"];
57+
responseHeaders["Access-Control-Allow-Methods"] = ["GET, PUT, POST"];
5858
}
59-
responseHeaders["Access-Control-Allow-Origin"] = "*";
59+
responseHeaders["Access-Control-Allow-Origin"] = ["*"];
6060
callback({responseHeaders, statusLine});
6161
} else {
6262
callback({responseHeaders});

src/ext/bg.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { BrowserRecorder } from "./browser-recorder";
22

3-
// @ts-expect-error - TS7016 - Could not find a declaration file for module '@webrecorder/wabac/src/loaders'. '/Users/emma/Work/Webrecorder/archiveweb.page/node_modules/@webrecorder/wabac/src/loaders.js' implicitly has an 'any' type.
4-
import { CollectionLoader } from "@webrecorder/wabac/src/loaders";
3+
import { CollectionLoader } from "@webrecorder/wabac/swlib";
54

65
import { listAllMsg } from "../utils";
76

src/recorder.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { RequestResponseInfo } from "./requestresponseinfo";
22

3-
// @ts-expect-error - Missing types
4-
import { getCustomRewriter } from "@webrecorder/wabac/src/rewrite";
5-
import {
6-
rewriteDASH,
7-
rewriteHLS,
8-
// @ts-expect-error - Missing types
9-
} from "@webrecorder/wabac/src/rewrite/rewriteVideo";
3+
import { getCustomRewriter, rewriteDASH, rewriteHLS } from "@webrecorder/wabac";
4+
105
import { Buffer } from "buffer";
116

127
// @ts-expect-error - Missing types
@@ -1457,7 +1452,9 @@ class Recorder {
14571452
const data = reqresp.toDBRecord(reqresp.payload, this.pageInfo);
14581453

14591454
// top-level URL is a non-GET request
1460-
if (data && data.requestUrl && data.requestUrl === this.pageInfo.url && !sessions.length) {
1455+
// @ts-expect-error - TS2339 - Property 'pageInfo' does not exist on type 'Recorder'.
1456+
if (data?.requestUrl && data.requestUrl === this.pageInfo.url && !sessions.length) {
1457+
// @ts-expect-error - TS2339 - Property 'pageInfo' does not exist on type 'Recorder'.
14611458
this.pageInfo.url = data.url;
14621459
}
14631460

src/requestresponseinfo.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
"use strict";
2-
3-
// @ts-expect-error - Missing types
4-
import { getCustomRewriter } from "@webrecorder/wabac/src/rewrite";
5-
// @ts-expect-error - Missing types
6-
import { getStatusText } from "@webrecorder/wabac/src/utils";
1+
import { getCustomRewriter, getStatusText } from "@webrecorder/wabac";
72

83
import { postToGetUrl } from "warcio";
94

@@ -281,7 +276,9 @@ class RequestResponseInfo {
281276
};
282277
if (postToGetUrl(convData)) {
283278
// if URL for custom rewriting, keep as is, otherwise truncate to avoid extra long URLs
279+
// @ts-expect-error - TS2339 - Property 'url' does not exist on type 'RequestResponseInfo'.
284280
if (getCustomRewriter(this.url, mime === "text/html")) {
281+
// @ts-expect-error - TS2339 - Property 'url' does not exist on type 'RequestResponseInfo'.
285282
this.url = convData.url;
286283
} else {
287284
try {
@@ -295,6 +292,7 @@ class RequestResponseInfo {
295292
} catch (e) {
296293
//ignore
297294
}
295+
// @ts-expect-error - TS2339 - Property 'url' does not exist on type 'RequestResponseInfo'.
298296
this.url = convData.url.slice(0, MAX_URL_LENGTH);
299297
}
300298
}

src/sw/main.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
// @ts-expect-error - TS7016 - Could not find a declaration file for module '@webrecorder/wabac/src/swmain'. '/Users/emma/Work/Webrecorder/archiveweb.page/node_modules/@webrecorder/wabac/src/swmain.js' implicitly has an 'any' type.
2-
import { SWReplay } from "@webrecorder/wabac/src/swmain";
1+
import { SWReplay, WorkerLoader } from "@webrecorder/wabac/swlib";
32

43
// @ts-expect-error - TS2307 - Cannot find module '@webrecorder/awp-sw' or its corresponding type declarations.
54
import { ExtAPI, RecordingCollections } from "@webrecorder/awp-sw";
65

76
import REC_INDEX_HTML from "@/static/index.html";
87
import RWP_INDEX_HTML from "replaywebpage/index.html";
98

10-
// @ts-expect-error - TS7016 - Could not find a declaration file for module '@webrecorder/wabac/src/loaders'. '/Users/emma/Work/Webrecorder/archiveweb.page/node_modules/@webrecorder/wabac/src/loaders.js' implicitly has an 'any' type.
11-
import { WorkerLoader } from "@webrecorder/wabac/src/loaders";
12-
139
// @ts-expect-error - TS2339 - Property 'registration' does not exist on type 'Window & typeof globalThis'.
1410
if (self.registration) {
1511
const defaultConfig = {
@@ -38,13 +34,10 @@ if (self.registration) {
3834
const ApiClass = ExtAPI;
3935
const CollectionsClass = RecordingCollections;
4036

41-
const autoipfsOpts = {};
42-
4337
// @ts-expect-error - TS2339 - Property 'sw' does not exist on type 'Window & typeof globalThis'.
4438
self.sw = new SWReplay({
4539
ApiClass,
4640
staticData,
47-
autoipfsOpts,
4841
defaultConfig,
4942
CollectionsClass,
5043
});

src/ui/app.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { html, css, wrapCss, IS_APP, apiPrefix } from "replaywebpage/misc";
33
// replaywebpage imports
44
import { ReplayWebApp, Embed, Loader } from "replaywebpage";
55

6-
import { SWManager } from "replaywebpage/src/swmanager";
6+
import { SWManager } from "replaywebpage";
77

88
import fasHelp from "@fortawesome/fontawesome-free/svgs/solid/question-circle.svg";
99
import fasPlus from "@fortawesome/fontawesome-free/svgs/solid/plus.svg";
@@ -184,7 +184,7 @@ class ArchiveWebApp extends ReplayWebApp {
184184
.register()
185185
.catch(
186186
() =>
187-
(this.swErrorMsg = this.swmanager.renderErrorReport(this.mainLogo)),
187+
(this.swErrorMsg = this.swmanager?.renderErrorReport(this.mainLogo) || ""),
188188
);
189189
}
190190
}
@@ -1105,7 +1105,7 @@ class ArchiveWebApp extends ReplayWebApp {
11051105
type="text"
11061106
name="btrixOrgName"
11071107
id="btrixOrgName"
1108-
value="${this.btrixOpts?.orgName}"
1108+
value="${this.btrixOpts?.orgName || ""}"
11091109
placeholder="my-org"
11101110
/>
11111111
</p>
@@ -1188,7 +1188,7 @@ class ArchiveWebApp extends ReplayWebApp {
11881188
type="url"
11891189
name="btrixUrl"
11901190
id="btrixUrl"
1191-
value="${this.btrixOpts?.url}"
1191+
value="${this.btrixOpts?.url || ""}"
11921192
placeholder="https://..."
11931193
/>
11941194
</p>
@@ -1201,7 +1201,7 @@ class ArchiveWebApp extends ReplayWebApp {
12011201
type="text"
12021202
name="btrixUsername"
12031203
id="btrixUsername"
1204-
value="${this.btrixOpts?.username}"
1204+
value="${this.btrixOpts?.username || ""}"
12051205
placeholder="Username"
12061206
/>
12071207
</p>
@@ -1214,7 +1214,7 @@ class ArchiveWebApp extends ReplayWebApp {
12141214
type="password"
12151215
name="btrixPassword"
12161216
id="btrixPassword"
1217-
value="${this.btrixOpts?.password}"
1217+
value="${this.btrixOpts?.password || ""}"
12181218
placeholder="Password"
12191219
/>
12201220
</p>
@@ -1227,7 +1227,7 @@ class ArchiveWebApp extends ReplayWebApp {
12271227
type="text"
12281228
name="btrixOrgName"
12291229
id="btrixOrgName"
1230-
value="${this.btrixOpts?.orgName}"
1230+
value="${this.btrixOpts?.orgName || ""}"
12311231
placeholder="Organization (optional)"
12321232
/>
12331233
</p>

src/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// @ts-expect-error - TS7016 - Could not find a declaration file for module '@webrecorder/wabac/src/utils'. '/Users/emma/Work/Webrecorder/archiveweb.page/node_modules/@webrecorder/wabac/src/utils.js' implicitly has an 'any' type.
2-
import { getCollData } from "@webrecorder/wabac/src/utils";
1+
import { rewriteHLS as getCollData } from "@webrecorder/wabac";
32
import { getLocalOption, setLocalOption } from "./localstorage";
43

54
// ===========================================================================

0 commit comments

Comments
 (0)