Skip to content

Commit fa11c8a

Browse files
committed
update, various fixes for TS + embed
1 parent d72ae80 commit fa11c8a

12 files changed

+248
-203
lines changed

index.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

package.json

Lines changed: 5 additions & 5 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.12.8",
4+
"version": "0.13.0",
55
"main": "index.js",
66
"description": "Create Web Archives directly in your browser",
77
"repository": "https://github.com/webrecorder/archiveweb.page",
@@ -10,8 +10,8 @@
1010
"dependencies": {
1111
"@fortawesome/fontawesome-free": "^5.13.0",
1212
"@ipld/car": "^5.3.1",
13-
"@webrecorder/awp-sw": "^0.5.0-beta.2",
14-
"@webrecorder/wabac": "^2.20.0-beta.2",
13+
"@webrecorder/awp-sw": "^0.5.0-beta.4",
14+
"@webrecorder/wabac": "^2.20.0-beta.4",
1515
"auto-js-ipfs": "^2.3.0",
1616
"browsertrix-behaviors": "^0.6.4",
1717
"btoa": "^1.2.1",
@@ -23,7 +23,7 @@
2323
"node-fetch": "2.6.7",
2424
"pdfjs-dist": "2.2.228",
2525
"pretty-bytes": "^5.6.0",
26-
"replaywebpage": "github:webrecorder/replayweb.page#wabac-ts-work",
26+
"replaywebpage": "^2.2.0-beta.4",
2727
"stream-browserify": "^3.0.0",
2828
"tsconfig-paths-webpack-plugin": "^4.1.0",
2929
"unused-filename": "^4.0.1",
@@ -35,7 +35,7 @@
3535
"@typescript-eslint/parser": "^6.15.0",
3636
"copy-webpack-plugin": "^9.0.1",
3737
"css-loader": "^6.2.0",
38-
"electron": "^30.0.9",
38+
"electron": "^32.2.0",
3939
"electron-builder": "^24.13.3",
4040
"electron-notarize": "^1.2.2",
4141
"eslint": "^8.28.0",

src/embed.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
</head>
2323

2424
<body>
25-
<record-web-page url="https://example.com/"></record-web-page>
25+
<archive-web-page
26+
deepLink="true"
27+
url="https://example.com/"
28+
></archive-web-page>
2629
</body>
2730
</html>

src/sw/main.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@ import { ExtAPI, RecordingCollections } from "@webrecorder/awp-sw";
55
import REC_INDEX_HTML from "@/static/index.html";
66
import RWP_INDEX_HTML from "replaywebpage/index.html";
77

8-
// @ts-expect-error - TS2339 - Property 'registration' does not exist on type 'Window & typeof globalThis'.
8+
declare let self: ServiceWorkerGlobalScope;
9+
910
if (self.registration) {
10-
const defaultConfig = {
11-
injectScripts: ["/ruffle/ruffle.js"],
11+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
12+
const defaultConfig : Record<string, any> = {
1213
baseUrlSourcePrefix: "/replay/index.html",
1314
convertPostToGet: false,
1415
};
1516

17+
if (self.location.origin.startsWith("chrome-extension://")) {
18+
defaultConfig["injectScripts"] = ["/ruffle/ruffle.js"];
19+
}
20+
1621
const staticData = new Map();
1722

18-
// @ts-expect-error - TS2339 - Property 'registration' does not exist on type 'Window & typeof globalThis'.
1923
const prefix = self.registration.scope;
2024

2125
// for backwards compatibility to support <replay-web-page> tag
@@ -33,8 +37,7 @@ if (self.registration) {
3337
const ApiClass = ExtAPI;
3438
const CollectionsClass = RecordingCollections;
3539

36-
// @ts-expect-error - TS2339 - Property 'sw' does not exist on type 'Window & typeof globalThis'.
37-
self.sw = new SWReplay({
40+
(self as any).sw = new SWReplay({
3841
ApiClass,
3942
staticData,
4043
defaultConfig,

src/ui/app.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from "auto-js-ipfs";
3232
import { getLocalOption, setLocalOption } from "../localstorage";
3333
import { type BtrixOpts } from "../types";
34+
import { WrRecCollIndex } from "./coll-index";
3435

3536
const VERSION = __AWP_VERSION__;
3637

@@ -180,8 +181,11 @@ class ArchiveWebApp extends ReplayWebApp {
180181

181182
// For App: If no SW, register here
182183
if (IS_APP && !regs.length) {
184+
const qp = new URLSearchParams();
185+
qp.set("injectScripts", "ruffle/ruffle.js");
186+
183187
this.swmanager = new SWManager({
184-
name: this.swName,
188+
name: this.swName + "?" + qp.toString(),
185189
appName: this.appName,
186190
});
187191
this.swmanager
@@ -277,8 +281,7 @@ class ArchiveWebApp extends ReplayWebApp {
277281
}
278282
}
279283

280-
// @ts-expect-error - TS7006 - Parameter 'sourceUrl' implicitly has an 'any' type.
281-
getLoadInfo(sourceUrl) {
284+
getLoadInfo(sourceUrl: string) {
282285
this.disableCSP();
283286

284287
if (this.loadInfo) {
@@ -551,9 +554,9 @@ class ArchiveWebApp extends ReplayWebApp {
551554
renderColl() {
552555
return html` <wr-rec-coll
553556
.editable="${true}"
554-
.clearable="${Boolean(this.embed)}"
557+
.clearable="${false}"
555558
.browsable="${!this.embed}"
556-
.loadInfo="${this.getLoadInfo(this.sourceUrl)}"
559+
.loadInfo="${this.getLoadInfo(this.sourceUrl || "")}"
557560
.appLogo="${this.mainLogo}"
558561
.autoUpdateInterval=${
559562
// @ts-expect-error - TS2339 - Property 'embed' does not exist on type 'ArchiveWebApp'. | TS2551 - Property 'showDownloadProgress' does not exist on type 'ArchiveWebApp'. Did you mean 'onDownloadProgress'?
@@ -1271,10 +1274,9 @@ class ArchiveWebApp extends ReplayWebApp {
12711274
const resp = await fetch(`${apiPrefix}/c/create`, { method, body });
12721275
await resp.json();
12731276

1274-
const index = this.renderRoot.querySelector("wr-rec-coll-index");
1277+
const index = this.renderRoot.querySelector("wr-rec-coll-index") as WrRecCollIndex;
12751278
if (index) {
1276-
// @ts-expect-error - TS2339 - Property 'loadColls' does not exist on type 'Element'.
1277-
index.loadColls();
1279+
index.loadItems();
12781280
}
12791281
// @ts-expect-error - TS2339 - Property 'showNew' does not exist on type 'ArchiveWebApp'.
12801282
this.showNew = null;

src/ui/coll-index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { type WrRecCollInfo } from "./coll-info";
77
import { type WrRecItem } from "../types";
88

99
//============================================================================
10-
class WrRecCollIndex extends ItemIndex {
10+
export class WrRecCollIndex extends ItemIndex {
1111
@property({ type: Object })
1212
deleteConfirm: WrRecItem | null = null;
1313
ipfsSharePending = 0;

src/ui/coll-info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class WrRecCollInfo extends ItemInfo {
123123
}
124124

125125
// @ts-expect-error - TS7006 - Parameter 'changedProps' implicitly has an 'any' type.
126-
updated(changedProps) {
126+
updated(changedProps: Property) {
127127
if (changedProps.has("shareOpts") && this.shareOpts) {
128128
const { ipfsOpts, btrixOpts } = this.shareOpts;
129129
this.ipfsOpts = ipfsOpts;

0 commit comments

Comments
 (0)