Skip to content

Commit 1fe9fd6

Browse files
authored
Improved proxy recording mode + typescript conversion with wabac.js 2.20 (#11)
Proxy record mode: - better page detection, ignore iframes - better error reporting (via wabac.js 2.20) - support for adding favicons to pages Full typescript conversion to match wabac.js 2.20 export as module bump to 0.5.0
1 parent 5082ccb commit 1fe9fd6

17 files changed

+2463
-1334
lines changed

.eslintrc.cjs

Lines changed: 110 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,113 @@
1+
/* eslint-env node */
2+
/** @type {import('eslint').Linter.Config} */
13
module.exports = {
2-
"env": {
3-
"browser": true,
4-
"es6": true,
5-
"webextensions": true
4+
parser: "@typescript-eslint/parser",
5+
env: {
6+
browser: true,
7+
commonjs: true,
8+
es2017: true,
9+
},
10+
extends: [
11+
"eslint:recommended",
12+
"plugin:@typescript-eslint/eslint-recommended",
13+
"prettier"
14+
],
15+
plugins: ["@typescript-eslint"],
16+
parserOptions: {
17+
project: ["./tsconfig.eslint.json"],
18+
tsconfigRootDir: __dirname,
19+
},
20+
root: true,
21+
rules: {
22+
/* start stylistic rules */
23+
"@typescript-eslint/adjacent-overload-signatures": "error",
24+
"@typescript-eslint/array-type": "error",
25+
"@typescript-eslint/consistent-type-imports": [
26+
"error",
27+
{
28+
fixStyle: "inline-type-imports",
29+
},
30+
],
31+
"@typescript-eslint/consistent-type-exports": "error",
32+
"@typescript-eslint/prefer-readonly": "warn",
33+
"@typescript-eslint/class-literal-property-style": ["warn", "getters"],
34+
"@typescript-eslint/consistent-generic-constructors": "error",
35+
"@typescript-eslint/consistent-type-assertions": "error",
36+
"@typescript-eslint/no-confusing-non-null-assertion": "warn",
37+
"@typescript-eslint/no-inferrable-types": "warn",
38+
"@typescript-eslint/non-nullable-type-assertion-style": "warn",
39+
"@typescript-eslint/prefer-for-of": "warn",
40+
// "@typescript-eslint/prefer-nullish-coalescing": "warn",
41+
"@typescript-eslint/prefer-optional-chain": "warn",
42+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
43+
"@typescript-eslint/no-meaningless-void-operator": "error",
44+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
45+
"@typescript-eslint/no-unnecessary-condition": "warn",
46+
"@typescript-eslint/no-unnecessary-qualifier": "warn",
47+
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
48+
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
49+
"@typescript-eslint/promise-function-async": "warn",
50+
/* end stylistic rules */
51+
52+
/* start recommended rules */
53+
"no-restricted-globals": [2, "event", "error"],
54+
"@typescript-eslint/no-base-to-string": "warn",
55+
"@typescript-eslint/no-duplicate-enum-values": "error",
56+
"@typescript-eslint/no-duplicate-type-constituents": "warn",
57+
"@typescript-eslint/no-explicit-any": "error",
58+
"@typescript-eslint/no-extra-non-null-assertion": "error",
59+
"@typescript-eslint/no-floating-promises": "warn",
60+
"@typescript-eslint/no-for-in-array": "warn",
61+
"no-unused-vars": "off",
62+
"@typescript-eslint/no-unused-vars": [
63+
"error",
64+
{
65+
argsIgnorePattern: "^_",
66+
varsIgnorePattern: "^_",
67+
destructuredArrayIgnorePattern: "^_",
68+
caughtErrorsIgnorePattern: "^_",
69+
},
70+
],
71+
"no-implied-eval": "off",
72+
"@typescript-eslint/no-implied-eval": "error",
73+
"no-loss-of-precision": "off",
74+
"@typescript-eslint/no-loss-of-precision": "warn",
75+
"@typescript-eslint/no-misused-new": "error",
76+
"@typescript-eslint/no-misused-promises": [
77+
"error",
78+
{ checksVoidReturn: false },
79+
],
80+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
81+
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
82+
"@typescript-eslint/no-redundant-type-constituents": "warn",
83+
"@typescript-eslint/no-this-alias": "warn",
84+
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
85+
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
86+
/* TODO eventually turn all these on */
87+
"@typescript-eslint/no-unsafe-argument": "warn",
88+
// "@typescript-eslint/no-unsafe-assignment": "warn",
89+
// "@typescript-eslint/no-unsafe-call": "warn",
90+
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
91+
"@typescript-eslint/no-unsafe-enum-comparison": "warn",
92+
// "@typescript-eslint/no-unsafe-member-access": "warn",
93+
"@typescript-eslint/no-unsafe-return": "warn",
94+
"@typescript-eslint/prefer-as-const": "warn",
95+
"require-await": "off",
96+
// "@typescript-eslint/require-await": "warn",
97+
"@typescript-eslint/restrict-template-expressions": "warn",
98+
"@typescript-eslint/unbound-method": "off",
99+
"@typescript-eslint/method-signature-style": "error",
100+
"@typescript-eslint/await-thenable": "error",
101+
},
102+
reportUnusedDisableDirectives: true,
103+
ignorePatterns: ["__generated__", "__mocks__", "dist", "static"],
104+
overrides: [
105+
{
106+
extends: ["plugin:@typescript-eslint/disable-type-checked"],
107+
files: ["webpack.*.js", ".*.cjs"],
108+
rules: {
109+
"@typescript-eslint/no-var-requires": "off",
110+
},
6111
},
7-
"extends": "eslint:recommended",
8-
"parserOptions": {
9-
"ecmaVersion": 2018,
10-
"sourceType": "module"
11-
},
12-
"rules": {
13-
"no-restricted-globals": [
14-
2,
15-
"event", "error"
16-
],
17-
"indent": [
18-
"error",
19-
2
20-
],
21-
"linebreak-style": [
22-
"error",
23-
"unix"
24-
],
25-
"quotes": [
26-
"error",
27-
"double"
28-
],
29-
"semi": [
30-
"error",
31-
"always"
32-
]
33-
}
112+
],
34113
};

package.json

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,55 @@
11
{
22
"name": "@webrecorder/awp-sw",
3-
"browser": "dist/sw.js",
4-
"version": "0.4.4",
5-
"main": "index.js",
3+
"browser": "dist/index.js",
4+
"version": "0.5.0",
65
"type": "module",
76
"repository": {
87
"type": "git",
98
"url": "git+https://github.com/webrecorder/awp-sw.git"
109
},
1110
"license": "AGPL-3.0-or-later",
1211
"exports": {
13-
".": "./src/index.js"
12+
".": {
13+
"types": "./dist/types/index.d.ts",
14+
"default": "./dist/index.js"
15+
}
1416
},
1517
"files": [
16-
"src/*"
18+
"src/*",
19+
"dist/*"
1720
],
1821
"dependencies": {
19-
"@ipld/car": "^5.3.1",
22+
"@ipld/car": "^5.3.2",
2023
"@ipld/unixfs": "^3.0.0",
21-
"@webrecorder/wabac": "^2.18.1",
24+
"@webrecorder/wabac": "^2.20.0",
2225
"auto-js-ipfs": "^2.3.0",
2326
"client-zip": "^2.3.0",
2427
"hash-wasm": "^4.9.0",
2528
"idb": "^7.1.1",
26-
"p-queue": "^7.3.4",
29+
"p-queue": "^8.0.1",
2730
"uuid": "^9.0.0",
28-
"warcio": "^2.2.1"
31+
"warcio": "^2.3.1"
2932
},
3033
"scripts": {
3134
"build": "webpack --mode production",
3235
"build-dev": "webpack --mode development",
3336
"start-dev": "webpack serve --mode development --port 10001 --output-path ./dist --static ${PWD}",
34-
"lint": "eslint ./src webpack.config.cjs"
37+
"lint": "eslint ./src",
38+
"format:check": "prettier --check ./src/",
39+
"format": "prettier --write ./src/"
3540
},
3641
"devDependencies": {
37-
"eslint": "^8.28.0",
42+
"@types/uuid": "^10.0.0",
43+
"@typescript-eslint/eslint-plugin": "^8.4.0",
44+
"@typescript-eslint/parser": "^8.4.0",
45+
"eslint": "^8.56.1",
46+
"eslint-config-prettier": "^9.1.0",
47+
"prettier": "^3.3.3",
3848
"raw-loader": "^4.0.2",
39-
"webpack": "^5.91.0",
49+
"ts-loader": "^9.5.1",
50+
"tsconfig-paths-webpack-plugin": "^4.1.0",
51+
"typescript": "^5.5.4",
52+
"webpack": "^5.94.0",
4053
"webpack-cli": "^5.1.4"
4154
},
4255
"description": "This library has been factored out of [ArchiveWeb.page](https://webrecorder/archiveweb.page) and represents the core service worker implementation necessarily for high-fidelity web archiving.",

0 commit comments

Comments
 (0)