Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for import as module, wabac.js 2.20 #364

Merged
merged 28 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c32a567
deps: update to wabac.js 2.19.7, fidelity improvements to FB rewritin…
ikreymer Aug 13, 2024
fc06689
wabac ts work
ikreymer Sep 6, 2024
7d17e78
update
ikreymer Sep 6, 2024
4a63589
fix for AWP imports, add types to swmanager, reformat
ikreymer Sep 7, 2024
224f126
add ui.js for testing
ikreymer Sep 7, 2024
8d5a90c
add misc
ikreymer Sep 7, 2024
3526fb2
add dist for testing
ikreymer Sep 7, 2024
2c46fe4
add types
ikreymer Sep 7, 2024
2c0a908
Merge branch 'main' into wabac-ts-work, update to latest wabac.js beta
ikreymer Sep 19, 2024
f6f4427
update CHANGES
ikreymer Sep 19, 2024
a6e9f28
remove separate misc export
ikreymer Sep 19, 2024
59d8240
use latest wabac beta, set version to 2.1.6-beta.0 for beta release
ikreymer Oct 9, 2024
6f00730
bump version to 2.2.0-beta.0
ikreymer Oct 9, 2024
fd803d7
webpack: fix include for dev build to ensure full rebuild for awp w/o…
ikreymer Oct 9, 2024
7ba5764
fix extending embed mode
ikreymer Oct 10, 2024
3fb1079
ui: make left and right side of toolbar customizable
ikreymer Oct 11, 2024
59b107d
allow passing postMessages from iframe or sw to parent
ikreymer Oct 11, 2024
ea47e78
switch back to unified ui.js as module
ikreymer Oct 12, 2024
a252dd5
bump to 2.2.0-beta.3
ikreymer Oct 12, 2024
f64a6c8
fix typo in filter
ikreymer Oct 14, 2024
224a4d0
update to wabac.js 2.20.0-beta.4
ikreymer Oct 14, 2024
d6fb4c2
lint fix
ikreymer Oct 14, 2024
fbd8827
fix build?
ikreymer Oct 14, 2024
7ee28eb
fix typo, remove libraryTarget
ikreymer Oct 15, 2024
a2edc75
back to separate lib index.js build to avoid difficulity with convert…
ikreymer Oct 15, 2024
04b4946
lint fix
ikreymer Oct 15, 2024
92d5d7b
update CHANGES
ikreymer Oct 17, 2024
e71e229
bump to 2.2.0 + wabac 2.20.0
ikreymer Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,53 @@

## CHANGES

v2.2.0
- Extensability: additional override options for AWP, make location toolbar more extensible
- Extensability: support importing as module via dist/index.js, separate from ui.js
- Deps: update to wabac.js 2.20.0, typescript support

v2.1.5

- Fidelity: updated rewriting rules for instagram
- Fidelity: disable window online/offline events in replay (via wabac.js)
- Dependencies: update to wabac.js 2.19.9 + wombat 3.8.2, electron 32.1.0

v2.1.4

- Fidelity: improvements to FB rewriting, eval() rewriting, 'object' tag rewriting (via wabac.js 2.19.7, wombat 3.7.14)

v2.1.3

- Fidelity: edge-case rewriting improvements, avoid rewriting inside of strings, detect old-html framesets (via wabac.js 2.19.5, wombat 3.7.12)

v2.1.2

- Fidelity: Video replay improvements, fix rewriting of DASH manifests (via wabac.js 2.19.4, wombat 3.7.11)

v2.1.1

- Fidelity: fixes to Sharepoint site replay (via wabac.js 2.19.2, wombat 3.7.10)
- UI: default URL resources search to 'prefix' as contains only works after prefix search

v2.1.0

- More fidelity fixes (via wabac.js 2.19.1, wombat 3.7.8)
- Improved messaging: embed tag emits @rwp-page-loading and @rwp-url-change events
- Remove multiTs from hashtag, avoid double history nav as it was being set

v2.0.2

- Fidelity improvements (via wabac.js 2.18.4 and wombat 3.7.7), including improved encoding detection
- Upgrade Shoelace & Lit by @SuaYoo in https://github.com/webrecorder/replayweb.page/pull/329
- Adds multi-resolution ICO file for Windows by @Shrinks99 in https://github.com/webrecorder/replayweb.page/pull/325
- Resource search remove auto-added http prefix by @ikreymer in https://github.com/webrecorder/replayweb.page/pull/334
- Configure package exports explicitly by @emma-sg in https://github.com/webrecorder/replayweb.page/pull/336

v2.0.1

- Fidelity improvements (via wabac.js and wombat), including fixes ebay carousel #326 (via wombat)
- partial fix to error page escaping #323 (via wabac)
fixes to reddit pages #317
- fixes to reddit pages #317
- Fixes to twitter/x replay (via wabac / wombat)
- Build improvements: run mkdocs gh-deploy --force in gh action, instead of publish-docs to avoid accidental updates
- Auto install ruffle from download script, remove from git, add 'update-ruffle' script
Expand Down Expand Up @@ -69,7 +82,6 @@ v2.0.0
- build(deps): bump loader-utils from 2.0.0 to 2.0.4 by @dependabot in https://github.com/webrecorder/replayweb.page/pull/316
- 2.0.0 Release by @SuaYoo in https://github.com/webrecorder/replayweb.page/pull/269


v1.8.17

- Dependencies: update to wabac.js 2.17.3, wombat 3.7.3
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ The static assets are placed in the root `index.html`, `sw.js`, and `ui.js`, and

The full site with docs is built using MkDocs. Using the `yarn build-docs` command, the static assets are copied into `mkdocs/site/` and using Markdown in `mkdocs/site/docs`, the final static site is built to `mkdocs/_genhtml`. This is what is published to https://replayweb.page/ via CI.


### Service Worker Requirements

Note that for the 'backend' service worker to work, the static site must be served from either localhost or an HTTPS endpoint.
Expand Down
13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "replaywebpage",
"productName": "ReplayWeb.page",
"version": "2.1.5",
"version": "2.2.0",
"description": "Serverless Web Archive Replay",
"repository": "https://github.com/webrecorder/replayweb.page",
"homepage": "https://replayweb.page/",
Expand All @@ -10,19 +10,15 @@
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"default": "./ui.js"
},
"./misc": {
"types": "./dist/types/misc.d.ts",
"default": "./dist/misc.js"
"default": "./dist/index.js"
},
"./src/electron-*": "./src/electron-*.ts",
"./index.html": "./index.html"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.4",
"@shoelace-style/shoelace": "~2.15.1",
"@webrecorder/wabac": "^2.19.9",
"@webrecorder/wabac": "^2.20.0",
"bulma": "^0.9.3",
"electron-log": "^4.4.1",
"electron-updater": "^6.3.2",
Expand Down Expand Up @@ -75,8 +71,7 @@
"webpack-merge": "^5.10.0"
},
"resolutions": {
"**/lit": "3.1.1",
"@webrecorder/wabac": "^2.19.9"
"**/lit": "3.1.1"
},
"files": [
"/dist",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-if-not-git-repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
* @param {string[]} args
* @returns {cp.SpawnSyncReturns<Buffer>}
*/
const git = (args) => cp.spawnSync("git", args, { stdio: "inherit" });

Check warning on line 23 in scripts/build-if-not-git-repo.js

View workflow job for this annotation

GitHub Actions / lint

Unsafe return of an `any` typed value

// Ensure that we're inside a Git repository
// If git command is not found, status is null and we should return
// That's why status value needs to be checked explicitly
if (git(["rev-parse"]).status !== 0 || process.argv.includes("--force")) {
l(`git command not found, running build`);
const compiler = webpack(config.map((c) => c()));
const compiler = webpack(config.map((c) => c(process.env, process.argv)));

Check warning on line 30 in scripts/build-if-not-git-repo.js

View workflow job for this annotation

GitHub Actions / lint

Unsafe return of an `any` typed value

compiler.run((err) => {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/appmain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class ReplayWebApp extends LitElement {
swErrorMsg: TemplateResult<1> | string | null = null;

protected swName?: string;
private swmanager: SWManager | null;
protected swmanager: SWManager | null;
private useRuffle = false;

private droppedFile: File | null = null;
Expand Down
12 changes: 11 additions & 1 deletion src/chooser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import fasUpload from "@fortawesome/fontawesome-free/svgs/solid/upload.svg";
import { customElement, property } from "lit/decorators.js";

export interface FileWithPath extends File {
readonly path: string;
path: string;
}

declare let window: Window & {
electron?: {
getPath: (file: File) => string;
};
};

// ===========================================================================
@customElement("wr-chooser")
export class Chooser extends LitElement {
Expand Down Expand Up @@ -89,6 +95,10 @@ export class Chooser extends LitElement {
setFile(file: FileWithPath) {
this.file = file;
// file.path only available in electron app
if (IS_APP && window.electron?.getPath) {
this.file.path = window.electron.getPath(this.file);
}

this.fileDisplayName = "file://" + (file.path || file.name);
}

Expand Down
12 changes: 8 additions & 4 deletions src/electron-preload.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/*eslint-env node */

// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7016 - Could not find a declaration file for module '@webrecorder/wabac/src/loaders'. 'node_modules/@webrecorder/wabac/src/loaders.js' implicitly has an 'any' type.
import { CollectionLoader } from "@webrecorder/wabac/src/loaders";
import { CollectionLoader } from "@webrecorder/wabac/swlib";
import { type IpcRendererEvent } from "electron";

const { ipcRenderer, contextBridge } = require("electron");
const { ipcRenderer, contextBridge, webUtils } = require("electron");

contextBridge.exposeInMainWorld("electron", { IS_APP: true });
contextBridge.exposeInMainWorld("electron", {
IS_APP: true,
getPath(file: File) {
return webUtils.getPathForFile(file);
},
});

const dbs = {};

Expand Down
12 changes: 7 additions & 5 deletions src/electron-replay-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
import path from "path";
import fs from "fs";

// @ts-expect-error [// TODO: Fix this the next time the file is edited.] - TS7016 - Could not find a declaration file for module '@webrecorder/wabac/src/rewrite'. 'node_modules/@webrecorder/wabac/src/rewrite/index.js' implicitly has an 'any' type.
import { ArchiveResponse, Rewriter } from "@webrecorder/wabac/src/rewrite";
import { ArchiveResponse, Rewriter } from "@webrecorder/wabac";

import { PassThrough, Readable } from "stream";

Expand Down Expand Up @@ -414,7 +413,7 @@
headers = new Headers(headers);
const date = new Date();

let response = new ArchiveResponse({
let response: ArchiveResponse = new ArchiveResponse({
payload,
headers,
status,
Expand All @@ -436,13 +435,16 @@
request.headers = new Headers(request.headers);

try {
response = await rewriter.rewrite(response, request);

Check warning on line 438 in src/electron-replay-app.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe argument of type `any` assigned to a parameter of type `ArchiveRequest`

// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
headers = Object.fromEntries(response.headers.entries());

let data = await response.getBuffer();
if (!data) {
data = new Uint8Array();
}

if (status === 206 || status === 200) {
const { statusCode, start, end } = this.parseRange(
Expand All @@ -456,9 +458,9 @@
status = statusCode;
}

data = this._bufferToStream(data);
const result = this._bufferToStream(data);

callback({ statusCode: status, headers, data });
callback({ statusCode: status, headers, data: result });
} catch (e) {
console.warn(e);
}
Expand Down
5 changes: 1 addition & 4 deletions src/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Embed extends LitElement {
replayfile = defaultReplayFile;
mainElementName = "replay-app-main";
appName = "ReplayWeb.page";
customConfig = null;
customConfig: Record<string, string | boolean> | null = null;
reloadCount = 0;

isCrossOrigin: boolean | undefined;
Expand Down Expand Up @@ -255,14 +255,11 @@ class Embed extends LitElement {
}

mergeConfigs() {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!this.customConfig) {
return this.config;
}

if (this.config) {
// @ts-expect-error - TS2339 - Property 'customConfig' does not exist on type 'Embed'. | TS2339 - Property 'config' does not exist on type 'Embed'.
const config = { ...this.customConfig, ...JSON.parse(this.config) };
return JSON.stringify(config);
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Pages } from "./pages";
import { PageEntry } from "./pageentry";
import { Replay } from "./replay";
import { Sorter } from "./sorter";
import { SWManager } from "./swmanager";
import { URLResources } from "./url-resources";
import { Embed } from "./embed";
import "./shoelace";
Expand Down Expand Up @@ -41,6 +42,9 @@ export {
Sorter,
URLResources,
Embed,
SWManager,
};

export type { ItemType, URLResource } from "./types";

export * from "./misc";
8 changes: 5 additions & 3 deletions src/item-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ItemIndex extends LitElement {
for (const item of this.items) {
if (
item.sourceUrl.indexOf(this.query) >= 0 ||
item.filename.indexOf(this.query) >= 0 ||
(item.filename && item.filename.indexOf(this.query) >= 0) ||
Boolean(item.loadUrl && item.loadUrl.indexOf(this.query) >= 0) ||
(item.title && item.title.indexOf(this.query) >= 0)
) {
Expand Down Expand Up @@ -383,8 +383,10 @@ class ItemIndex extends LitElement {
>ArchiveWeb.page</a
>
to save pages as you browse the web, or
<a href="https://browsertrix.com" target="_blank">sign up for Browsertrix</a> to archive
entire websites with automated crawling!
<a href="https://browsertrix.com" target="_blank"
>sign up for Browsertrix</a
>
to archive entire websites with automated crawling!
</p>
`;
}
Expand Down
Loading
Loading