Skip to content

Commit d80464f

Browse files
committed
fix typo in downloader
bump to wabac.js 2.20.0-beta.3
1 parent db83f7d commit d80464f

File tree

6 files changed

+80
-75
lines changed

6 files changed

+80
-75
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ module.exports = {
9797
"@typescript-eslint/restrict-template-expressions": "warn",
9898
"@typescript-eslint/unbound-method": "off",
9999
"@typescript-eslint/method-signature-style": "error",
100+
"@typescript-eslint/await-thenable": "error",
100101
},
101102
reportUnusedDisableDirectives: true,
102103
ignorePatterns: ["__generated__", "__mocks__", "dist", "static"],

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@webrecorder/awp-sw",
33
"browser": "dist/index.js",
4-
"version": "0.5.0-beta.2",
4+
"version": "0.5.0-beta.3",
55
"type": "module",
66
"repository": {
77
"type": "git",
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@ipld/car": "^5.3.2",
2323
"@ipld/unixfs": "^3.0.0",
24-
"@webrecorder/wabac": "^2.20.0-beta.2",
24+
"@webrecorder/wabac": "^2.20.0-beta.3",
2525
"auto-js-ipfs": "^2.3.0",
2626
"client-zip": "^2.3.0",
2727
"hash-wasm": "^4.9.0",

src/downloader.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { type DataSignature, type Signer } from "./keystore";
2222

2323
export type SizeCallback = (size: number) => void;
2424

25-
type ResponseWithFilename = Response & {
25+
export type ResponseWithFilename = Response & {
2626
filename?: string;
2727
};
2828

@@ -266,7 +266,7 @@ class Downloader {
266266
markers,
267267
}: DownloaderOpts) {
268268
this.db = coll.store;
269-
this.pageList = pageList || [];
269+
this.pageList = pageList || null;
270270
this.collId = coll.name;
271271
this.metadata = coll.config.metadata || {};
272272
this.gzip = gzip;
@@ -865,7 +865,7 @@ class Downloader {
865865

866866
const date = this.createdDate;
867867

868-
const record = await WARCRecord.createWARCInfo(
868+
const record = WARCRecord.createWARCInfo(
869869
{ filename, type, date, warcHeaders, warcVersion },
870870
info,
871871
);
@@ -1028,7 +1028,7 @@ class Downloader {
10281028
// remove encoding, set content-length as encoding never preserved in browser-based capture
10291029
this.fixupHttpHeaders(httpHeaders, payload.length);
10301030

1031-
const record = await WARCRecord.create(
1031+
const record = WARCRecord.create(
10321032
{
10331033
url,
10341034
date,
@@ -1069,7 +1069,7 @@ class Downloader {
10691069
const urlParsed = new URL(url);
10701070
const statusline = `${method} ${url.slice(urlParsed.origin.length)} HTTP/1.1`;
10711071

1072-
const reqRecord = await WARCRecord.create(
1072+
const reqRecord = WARCRecord.create(
10731073
{
10741074
url,
10751075
date,
@@ -1102,7 +1102,7 @@ class Downloader {
11021102

11031103
const payload = getPayload(encoder.encode(resource.text));
11041104

1105-
const record = await WARCRecord.create(
1105+
const record = WARCRecord.create(
11061106
{ url, date, warcHeaders, warcVersion, type },
11071107
payload,
11081108
);

src/ipfsutils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ type ReplayOpts = {
3232
};
3333

3434
type MetadataWithIPFS = CollMetadata & {
35-
ipfsPins?: {url: string, cid: string}[] | null;
36-
}
35+
ipfsPins?: { url: string; cid: string }[] | null;
36+
};
3737

3838
export async function setAutoIPFSUrl(url: string) {
3939
if (autoipfsOpts.daemonURL !== url) {
@@ -70,7 +70,7 @@ export async function ipfsAdd(
7070
throw new Error(dlResponse.error);
7171
}
7272

73-
const metadata : MetadataWithIPFS = coll.config.metadata || {};
73+
const metadata: MetadataWithIPFS = coll.config.metadata || {};
7474

7575
if (!metadata.ipfsPins) {
7676
metadata.ipfsPins = [];
@@ -138,7 +138,7 @@ export async function ipfsAdd(
138138
.pipeThrough(new ShardStoringStream(autoipfs, concur, reject!))
139139
.pipeTo(
140140
new WritableStream({
141-
write: (res: {url: string, cid: string, size: number}) => {
141+
write: (res: { url: string; cid: string; size: number }) => {
142142
if (res.url && res.cid) {
143143
url = res.url;
144144
cid = res.cid;
@@ -178,7 +178,7 @@ export async function ipfsRemove(coll: Collection) {
178178
autoipfs = await createAutoIPFS(autoipfsOpts);
179179
}
180180

181-
const metadata : MetadataWithIPFS = coll.config.metadata || {};
181+
const metadata: MetadataWithIPFS = coll.config.metadata || {};
182182

183183
if (metadata.ipfsPins) {
184184
for (const { url } of metadata.ipfsPins) {
@@ -213,7 +213,7 @@ async function ipfsWriteBuff(
213213
const file = UnixFS.createFileWriter(writer);
214214
if (content instanceof Uint8Array) {
215215
await file.write(content);
216-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
216+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
217217
} else if (content[Symbol.asyncIterator]) {
218218
for await (const chunk of content) {
219219
await file.write(chunk);
@@ -247,7 +247,7 @@ export async function ipfsGenerateCar(
247247
if (replayOpts.showEmbed) {
248248
const replayDir = UnixFS.createDirectoryWriter(writer);
249249
await ipfsWriteBuff(writer, "sw.js", swContent, replayDir);
250-
await rootDir.set("replay", await replayDir.close());
250+
rootDir.set("replay", await replayDir.close());
251251
} else {
252252
await ipfsWriteBuff(writer, "sw.js", swContent, rootDir);
253253
}

webpack.config.cjs

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,70 @@ const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
77
const BANNER_TEXT = `'[name].js is part of the ArchiveWeb.page system (https://archiveweb.page) Copyright (C) 2020-${new Date().getFullYear()}, Webrecorder Software. Licensed under the Affero General Public License v3.'`;
88

99

10-
module.exports = {
11-
target: "web",
12-
entry: {
13-
"main": "./src/index.ts",
14-
},
15-
output: {
16-
filename: "index.js",
17-
globalObject: "self",
18-
library: {
19-
type: "module"
20-
}
21-
},
22-
experiments: {
23-
outputModule: true
24-
},
25-
optimization: {
26-
minimize: true,
27-
minimizer: [
28-
new TerserPlugin({
29-
extractComments: false,
30-
}),
31-
]
32-
},
10+
module.exports = (env, argv) => {
11+
return {
12+
target: "web",
13+
entry: {
14+
"main": "./src/index.ts",
15+
},
16+
output: {
17+
filename: "index.js",
18+
globalObject: "self",
19+
library: {
20+
type: "module"
21+
}
22+
},
23+
experiments: {
24+
outputModule: true
25+
},
26+
optimization: {
27+
minimize: true,
28+
minimizer: [
29+
new TerserPlugin({
30+
extractComments: false,
31+
}),
32+
]
33+
},
3334

34-
resolve: {
35-
extensions: [".ts", ".js"],
36-
plugins: [new TsconfigPathsPlugin()],
37-
},
35+
resolve: {
36+
extensions: [".ts", ".js"],
37+
plugins: [new TsconfigPathsPlugin()],
38+
},
3839

39-
plugins: [
40-
new webpack.NormalModuleReplacementPlugin(
41-
/^node:*/,
42-
(resource) => {
43-
switch (resource.request) {
44-
case "node:stream":
45-
resource.request = "stream-browserify";
46-
break;
47-
}
48-
},
49-
),
40+
devtool: argv.mode === "production" ? undefined : "source-map",
5041

51-
new webpack.BannerPlugin(BANNER_TEXT),
52-
],
53-
54-
module: {
55-
rules: [
56-
{
57-
test: /wombat.js|wombatWorkers.js|index.html$/i,
58-
use: ["raw-loader"],
59-
},
60-
{
61-
test: /\.tsx?$/,
62-
loader: "ts-loader",
63-
include: path.resolve(__dirname, "src"),
64-
options: {
65-
onlyCompileBundledFiles: false,
42+
plugins: [
43+
new webpack.NormalModuleReplacementPlugin(
44+
/^node:*/,
45+
(resource) => {
46+
switch (resource.request) {
47+
case "node:stream":
48+
resource.request = "stream-browserify";
49+
break;
50+
}
6651
},
67-
},
52+
),
53+
54+
new webpack.BannerPlugin(BANNER_TEXT),
6855
],
69-
},
70-
};
56+
57+
module: {
58+
rules: [
59+
{
60+
test: /wombat.js|wombatWorkers.js|index.html$/i,
61+
use: ["raw-loader"],
62+
},
63+
{
64+
test: /\.tsx?$/,
65+
loader: "ts-loader",
66+
include: path.resolve(__dirname, "src"),
67+
options: {
68+
onlyCompileBundledFiles: false,
69+
},
70+
},
71+
],
72+
},
73+
};
74+
}
7175

7276

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,10 @@
621621
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.5.tgz#325db42395cd49fe6c14057f9a900e427df8810e"
622622
integrity sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==
623623

624-
"@webrecorder/wabac@^2.20.0-beta.2":
625-
version "2.20.0-beta.2"
626-
resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.20.0-beta.2.tgz#532b6457cb970039812e3b1470134725d7e72ca5"
627-
integrity sha512-ENVlZOvnFpQO/iMDQX9IZzXrStqlKbDrXe5Tl1aEq0Diun+HI7RKZPF3jJjYEZr0GCON4yY8FNEZhodJCI7dGA==
624+
"@webrecorder/wabac@^2.20.0-beta.3":
625+
version "2.20.0-beta.3"
626+
resolved "https://registry.yarnpkg.com/@webrecorder/wabac/-/wabac-2.20.0-beta.3.tgz#034cd07078270537028104ba407ae5b7baa2dd20"
627+
integrity sha512-/s98zVZFn8+0btTwsb2kRiwyfLZxPyWwKclsrpFQvyUCsvrQsTTKVbHTpictAlmyknOIdkrLqqWK4ScYTs39Xg==
628628
dependencies:
629629
"@peculiar/asn1-ecc" "^2.3.4"
630630
"@peculiar/asn1-schema" "^2.3.3"

0 commit comments

Comments
 (0)