Skip to content

Commit

Permalink
TypeScript Conversion! (#257)
Browse files Browse the repository at this point in the history
- Update all of archiveweb.page to use TypeScript
* Convert entire project to TS using some tools from
https://github.com/stripe-archive/flow-to-typescript-codemod
* Set up ESLint with rules from replaywebpage, and autofix a bunch of
things
* Run format + lint on all files
* Remove checked-in built files
* Replaces outdated node-sass with sass

- Update dependencies to wabac.js 2.20.0 and awp-sw 0.5.0, also updated
to TS
- App: fixes for opening links in new window
- Some improvements to embed viewer, additional customizations,
additional event messages passed from iframe
- Supersedes PR #228

---------
Co-authored-by: emma <[email protected]>
Co-authored-by: Henry Wilkinson <[email protected]>
  • Loading branch information
ikreymer authored Oct 17, 2024
1 parent 3e714ac commit 793476a
Show file tree
Hide file tree
Showing 76 changed files with 12,829 additions and 7,617 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
src/static/*
static/*
130 changes: 98 additions & 32 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,100 @@
/* eslint-env node */
/** @type { import("eslint").Linter.Config } */
module.exports = {
"env": {
"browser": true,
"es6": true,
"webextensions": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-restricted-globals": [
2,
"event", "error"
],
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
]
}
env: {
browser: true,
es6: true,
webextensions: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:wc/recommended",
"plugin:lit/recommended",
"prettier",
],
plugins: ["@typescript-eslint", "lit"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: ["./tsconfig.eslint.json"],
tsconfigRootDir: __dirname,
},
root: true,
rules: {
/* start stylistic rules */
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/consistent-type-imports": [
"error",
{
fixStyle: "inline-type-imports",
},
],
"@typescript-eslint/prefer-readonly": "warn",
"@typescript-eslint/class-literal-property-style": ["warn", "getters"],
"@typescript-eslint/consistent-generic-constructors": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "warn",
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/non-nullable-type-assertion-style": "warn",
"@typescript-eslint/prefer-for-of": "warn",
// "@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
/* end stylistic rules */

/* start recommended rules */
"no-restricted-globals": [2, "event", "error"],
"@typescript-eslint/no-base-to-string": "warn",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-duplicate-type-constituents": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-extra-non-null-assertion": "error",
// "@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-for-in-array": "warn",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
},
],
"no-implied-eval": "off",
"@typescript-eslint/no-implied-eval": "error",
"no-loss-of-precision": "off",
"@typescript-eslint/no-loss-of-precision": "warn",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{ checksVoidReturn: { arguments: false } },
],
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
"@typescript-eslint/no-redundant-type-constituents": "warn",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
// "@typescript-eslint/no-unsafe-argument": "warn",
// "@typescript-eslint/no-unsafe-assignment": "warn",
// "@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "warn",
"@typescript-eslint/no-unsafe-enum-comparison": "warn",
// "@typescript-eslint/no-unsafe-member-access": "warn",
// "@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/prefer-as-const": "warn",
"require-await": "off",
"@typescript-eslint/require-await": "warn",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/unbound-method": "off",
},
ignorePatterns: [
"ruffle/**/*",
"build/**/*",
"/sw.js",
"/ui.js",
"dist/**/*",
],
reportUnusedDisableDirectives: true,
};
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
id: version
attributes:
label: ArchiveWeb.page Version
description: "This can be found on the app home page under \"About\""
description: 'This can be found on the app home page under "About"'
placeholder: "v0.11.3"
validations:
required: true
Expand All @@ -20,7 +20,7 @@ body:
"I was trying to archive a page however..."
Please submit any screenshots/videos that can be used to understand how to reproduce the issue. You can attach images by clicking this area to highlight it and then dragging files into the browser window.
If something wasn't captured in the way you expect please include a link to the archived item if possible.
validations:
required: true
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ body:
label: Requirements
description: |
Intended primarily for use by Webrecorder team, leave blank if unknown.
List the outcomes of the feature being implemented without design or implementation details.
placeholder: |
1. Item metadata should show links to the collections that the item belongs to.
Expand All @@ -43,6 +43,6 @@ body:
placeholder: |
- [ ] Mockups:
- [ ] Design:
- [ ] UI:
- [ ] UI:
validations:
required: false
93 changes: 46 additions & 47 deletions .github/workflows/buildapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,53 +48,52 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run: |
if [ "$GITHUB_REF" == "refs/heads/main" ] || [ -f ./force_release ]; then
export YARN_BUILD_CMD="release"
else
export YARN_BUILD_CMD="dist"
fi
if [ "$GITHUB_REF" == "refs/heads/main" ] || [ -f ./force_release ]; then
export YARN_BUILD_CMD="release"
else
export YARN_BUILD_CMD="dist"
fi
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$PLATFORM" == "linux" ]; then
#mkdir -p plugins-linux;
#pushd plugins-linux;
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/libpepflashplayer.so";
#popd;
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$PLATFORM" == "linux" ]; then
#mkdir -p plugins-linux;
#pushd plugins-linux;
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/libpepflashplayer.so";
#popd;
docker run --rm \
-e GH_TOKEN=${GH_TOKEN} \
-e YARN_BUILD_CMD=${YARN_BUILD_CMD} \
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:16-wine \
/bin/bash -c "yarn --link-duplicates --pure-lockfile --ignore-engines install && yarn run $YARN_BUILD_CMD --linux --x64"
else
#mkdir -p plugins-win;
#pushd plugins-win;
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/pepflashplayer-x86_64.dll";
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/pepflashplayer-x86.dll";
#popd;
docker run --rm \
-e GH_TOKEN=${GH_TOKEN} \
-e YARN_BUILD_CMD=${YARN_BUILD_CMD} \
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:16-wine \
/bin/bash -c "yarn --link-duplicates --pure-lockfile --ignore-engines install && yarn run $YARN_BUILD_CMD --linux --x64"
else
#mkdir -p plugins-win;
#pushd plugins-win;
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/pepflashplayer-x86_64.dll";
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/pepflashplayer-x86.dll";
#popd;
docker run --rm \
-e GH_TOKEN=${GH_TOKEN} \
-e WIN_CSC_LINK=${WIN_CSC_LINK} \
-e WIN_CSC_KEY_PASSWORD=${WIN_CSC_KEY_PASSWORD} \
-e YARN_BUILD_CMD=${YARN_BUILD_CMD} \
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:16-wine \
/bin/bash -c "yarn --link-duplicates --pure-lockfile --ignore-engines install && yarn run $YARN_BUILD_CMD --win --x64 --ia32"
fi
else
#mkdir -p plugins-mac;
#pushd plugins-mac;
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/PepperFlashPlayer.plugin.zip";
#unzip PepperFlashPlayer.plugin.zip;
#rm PepperFlashPlayer.plugin.zip;
#popd;
yarn --link-duplicates --pure-lockfile --ignore-engines install
yarn run $YARN_BUILD_CMD
fi
docker run --rm \
-e GH_TOKEN=${GH_TOKEN} \
-e WIN_CSC_LINK=${WIN_CSC_LINK} \
-e WIN_CSC_KEY_PASSWORD=${WIN_CSC_KEY_PASSWORD} \
-e YARN_BUILD_CMD=${YARN_BUILD_CMD} \
-v ${PWD}:/project \
-v ~/.cache/electron:/root/.cache/electron \
-v ~/.cache/electron-builder:/root/.cache/electron-builder \
electronuserland/builder:16-wine \
/bin/bash -c "yarn --link-duplicates --pure-lockfile --ignore-engines install && yarn run $YARN_BUILD_CMD --win --x64 --ia32"
fi
else
#mkdir -p plugins-mac;
#pushd plugins-mac;
#wget "https://s3.amazonaws.com/webrecorder-builds/flashplugin/PepperFlashPlayer.plugin.zip";
#unzip PepperFlashPlayer.plugin.zip;
#rm PepperFlashPlayer.plugin.zip;
#popd;
yarn --link-duplicates --pure-lockfile --ignore-engines install
yarn run $YARN_BUILD_CMD
fi
4 changes: 2 additions & 2 deletions .github/workflows/buildext.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'yarn'
node-version: "18.x"
cache: "yarn"

- name: Yarn Install
run: yarn install --frozen-lockfile
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/npm-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
cache: "yarn"

- name: Yarn Install
run: yarn install --frozen-lockfile
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
!examples/*.warc
**/node_modules
.DS_Store
!dist/embed/*

dist
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LICENSE.md
static/*
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"runem.lit-plugin",
"streetsidesoftware.code-spell-checker"
]
}
67 changes: 67 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"cSpell.languageSettings": [
{
"languageId": "typescript",
"allowCompoundWords": true,
"dictionaries": ["typescript", "node", "html", "fonts", "css"]
},
{
"languageId": "javascript",
"allowCompoundWords": true,
"dictionaries": ["typescript", "node", "html", "fonts", "css"]
},
{
"languageId": "markdown",
"allowCompoundWords": true,
"dictionaries": ["typescript", "node", "html", "fonts", "css"]
}
],
"cSpell.words": [
"authed",
"autoipfs",
"browsertrix",
"btrix",
"Bulma",
"canonicalization",
"cdxj",
"Collec",
"colls",
"consts",
"electronuserland",
"flexsearch",
"gapi",
"gauth",
"gdrive",
"iframes",
"indexeddb",
"inited",
"ipfs",
"ival",
"kiwix",
"ndjson",
"pmarsceill",
"popd",
"pushd",
"pywb",
"reauth",
"recalc",
"replaybase",
"replayweb.page",
"sesh",
"Strs",
"surt",
"svgs",
"swmanager",
"swonly",
"Unfullscreen",
"unrewriting",
"unsharing",
"wabac",
"WACZ",
"WARC",
"warcio",
"webrecorder",
"wrlogo"
],
"cSpell.ignorePaths": ["node_modules", ".git", "*.lock", "package.json"]
}
Loading

0 comments on commit 793476a

Please sign in to comment.