Skip to content

Commit

Permalink
fix typo in downloader
Browse files Browse the repository at this point in the history
bump to wabac.js 2.20.0-beta.3
  • Loading branch information
ikreymer committed Oct 11, 2024
1 parent db83f7d commit d80464f
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 75 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ module.exports = {
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/await-thenable": "error",
},
reportUnusedDisableDirectives: true,
ignorePatterns: ["__generated__", "__mocks__", "dist", "static"],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@webrecorder/awp-sw",
"browser": "dist/index.js",
"version": "0.5.0-beta.2",
"version": "0.5.0-beta.3",
"type": "module",
"repository": {
"type": "git",
Expand All @@ -21,7 +21,7 @@
"dependencies": {
"@ipld/car": "^5.3.2",
"@ipld/unixfs": "^3.0.0",
"@webrecorder/wabac": "^2.20.0-beta.2",
"@webrecorder/wabac": "^2.20.0-beta.3",
"auto-js-ipfs": "^2.3.0",
"client-zip": "^2.3.0",
"hash-wasm": "^4.9.0",
Expand Down
12 changes: 6 additions & 6 deletions src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { type DataSignature, type Signer } from "./keystore";

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

type ResponseWithFilename = Response & {
export type ResponseWithFilename = Response & {
filename?: string;
};

Expand Down Expand Up @@ -266,7 +266,7 @@ class Downloader {
markers,
}: DownloaderOpts) {
this.db = coll.store;
this.pageList = pageList || [];
this.pageList = pageList || null;
this.collId = coll.name;
this.metadata = coll.config.metadata || {};
this.gzip = gzip;
Expand Down Expand Up @@ -865,7 +865,7 @@ class Downloader {

const date = this.createdDate;

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

const record = await WARCRecord.create(
const record = WARCRecord.create(
{
url,
date,
Expand Down Expand Up @@ -1069,7 +1069,7 @@ class Downloader {
const urlParsed = new URL(url);
const statusline = `${method} ${url.slice(urlParsed.origin.length)} HTTP/1.1`;

const reqRecord = await WARCRecord.create(
const reqRecord = WARCRecord.create(
{
url,
date,
Expand Down Expand Up @@ -1102,7 +1102,7 @@ class Downloader {

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

const record = await WARCRecord.create(
const record = WARCRecord.create(
{ url, date, warcHeaders, warcVersion, type },
payload,
);
Expand Down
14 changes: 7 additions & 7 deletions src/ipfsutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type ReplayOpts = {
};

type MetadataWithIPFS = CollMetadata & {
ipfsPins?: {url: string, cid: string}[] | null;
}
ipfsPins?: { url: string; cid: string }[] | null;
};

export async function setAutoIPFSUrl(url: string) {
if (autoipfsOpts.daemonURL !== url) {
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function ipfsAdd(
throw new Error(dlResponse.error);
}

const metadata : MetadataWithIPFS = coll.config.metadata || {};
const metadata: MetadataWithIPFS = coll.config.metadata || {};

if (!metadata.ipfsPins) {
metadata.ipfsPins = [];
Expand Down Expand Up @@ -138,7 +138,7 @@ export async function ipfsAdd(
.pipeThrough(new ShardStoringStream(autoipfs, concur, reject!))
.pipeTo(
new WritableStream({
write: (res: {url: string, cid: string, size: number}) => {
write: (res: { url: string; cid: string; size: number }) => {
if (res.url && res.cid) {
url = res.url;
cid = res.cid;
Expand Down Expand Up @@ -178,7 +178,7 @@ export async function ipfsRemove(coll: Collection) {
autoipfs = await createAutoIPFS(autoipfsOpts);
}

const metadata : MetadataWithIPFS = coll.config.metadata || {};
const metadata: MetadataWithIPFS = coll.config.metadata || {};

if (metadata.ipfsPins) {
for (const { url } of metadata.ipfsPins) {
Expand Down Expand Up @@ -213,7 +213,7 @@ async function ipfsWriteBuff(
const file = UnixFS.createFileWriter(writer);
if (content instanceof Uint8Array) {
await file.write(content);
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
} else if (content[Symbol.asyncIterator]) {
for await (const chunk of content) {
await file.write(chunk);
Expand Down Expand Up @@ -247,7 +247,7 @@ export async function ipfsGenerateCar(
if (replayOpts.showEmbed) {
const replayDir = UnixFS.createDirectoryWriter(writer);
await ipfsWriteBuff(writer, "sw.js", swContent, replayDir);
await rootDir.set("replay", await replayDir.close());
rootDir.set("replay", await replayDir.close());
} else {
await ipfsWriteBuff(writer, "sw.js", swContent, rootDir);
}
Expand Down
116 changes: 60 additions & 56 deletions webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,70 @@ const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
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.'`;


module.exports = {
target: "web",
entry: {
"main": "./src/index.ts",
},
output: {
filename: "index.js",
globalObject: "self",
library: {
type: "module"
}
},
experiments: {
outputModule: true
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
]
},
module.exports = (env, argv) => {
return {
target: "web",
entry: {
"main": "./src/index.ts",
},
output: {
filename: "index.js",
globalObject: "self",
library: {
type: "module"
}
},
experiments: {
outputModule: true
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
]
},

resolve: {
extensions: [".ts", ".js"],
plugins: [new TsconfigPathsPlugin()],
},
resolve: {
extensions: [".ts", ".js"],
plugins: [new TsconfigPathsPlugin()],
},

plugins: [
new webpack.NormalModuleReplacementPlugin(
/^node:*/,
(resource) => {
switch (resource.request) {
case "node:stream":
resource.request = "stream-browserify";
break;
}
},
),
devtool: argv.mode === "production" ? undefined : "source-map",

new webpack.BannerPlugin(BANNER_TEXT),
],

module: {
rules: [
{
test: /wombat.js|wombatWorkers.js|index.html$/i,
use: ["raw-loader"],
},
{
test: /\.tsx?$/,
loader: "ts-loader",
include: path.resolve(__dirname, "src"),
options: {
onlyCompileBundledFiles: false,
plugins: [
new webpack.NormalModuleReplacementPlugin(
/^node:*/,
(resource) => {
switch (resource.request) {
case "node:stream":
resource.request = "stream-browserify";
break;
}
},
},
),

new webpack.BannerPlugin(BANNER_TEXT),
],
},
};

module: {
rules: [
{
test: /wombat.js|wombatWorkers.js|index.html$/i,
use: ["raw-loader"],
},
{
test: /\.tsx?$/,
loader: "ts-loader",
include: path.resolve(__dirname, "src"),
options: {
onlyCompileBundledFiles: false,
},
},
],
},
};
}


8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,10 @@
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.5.tgz#325db42395cd49fe6c14057f9a900e427df8810e"
integrity sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==

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

0 comments on commit d80464f

Please sign in to comment.