From 17c700b7960ee87af8d33cfa760ea99e09d6148e Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Thu, 18 Aug 2022 10:28:58 +0300 Subject: [PATCH] refactor frontend; switch to svelte --- app/.gitignore | 25 +- app/.vscode/extensions.json | 3 + app/README.md | 48 ++ app/index.html | 25 ++ app/jsconfig.json | 34 ++ app/package.json | 16 + app/pnpm-lock.yaml | 424 ++++++++++++++++++ app/public/assets/download.svg | 49 -- app/public/favicon.png | Bin 3127 -> 0 bytes app/public/global.css | 124 ----- .../public/ico}/android-icon-192x192.png | Bin .../public/ico}/apple-icon-114x114.png | Bin .../public/ico}/apple-icon-120x120.png | Bin .../public/ico}/apple-icon-144x144.png | Bin .../public/ico}/apple-icon-152x152.png | Bin .../public/ico}/apple-icon-180x180.png | Bin .../public/ico}/apple-icon-57x57.png | Bin .../public/ico}/apple-icon-60x60.png | Bin .../public/ico}/apple-icon-72x72.png | Bin .../public/ico}/apple-icon-76x76.png | Bin .../public/ico}/favicon-16x16.png | Bin .../public/ico}/favicon-32x32.png | Bin .../public/ico}/favicon-96x96.png | Bin {public-old => app/public/ico}/manifest.json | 0 app/public/index.html | 18 - app/public/robots.txt | 2 - app/public/vite.svg | 1 + app/src/App.svelte | 145 ++++-- app/src/Download.svelte | 45 -- app/src/Loading.svelte | 51 --- app/src/Search.svelte | 55 --- app/src/Track.svelte | 98 ---- app/src/api.js | 9 - app/src/app.css | 59 +++ app/src/download.js | 10 - app/src/{ => lib}/Album.svelte | 211 ++++++--- app/src/lib/Header.svelte | 47 ++ app/src/lib/Loading.svelte | 50 +++ app/src/lib/ProgressBar.svelte | 41 ++ app/src/lib/Search.svelte | 89 ++++ app/src/lib/ThemeSwitcher.svelte | 94 ++++ app/src/lib/Track.svelte | 99 ++++ app/src/lib/download.js | 68 +++ app/src/lib/format.js | 3 + app/src/lib/stores.js | 3 + app/src/main.js | 11 +- app/src/stores.js | 19 - app/src/vite-env.d.ts | 2 + app/src/websocket.js | 37 -- app/vite.config.js | 7 + package.json | 5 +- pnpm-lock.yaml | 119 +++-- public-old/index.css | 163 ------- public-old/index.html | 45 -- public-old/index.js | 257 ----------- src/index.ts | 3 +- 56 files changed, 1495 insertions(+), 1119 deletions(-) create mode 100644 app/.vscode/extensions.json create mode 100644 app/README.md create mode 100644 app/index.html create mode 100644 app/jsconfig.json create mode 100644 app/package.json create mode 100644 app/pnpm-lock.yaml delete mode 100644 app/public/assets/download.svg delete mode 100644 app/public/favicon.png delete mode 100644 app/public/global.css rename {public-old => app/public/ico}/android-icon-192x192.png (100%) rename {public-old => app/public/ico}/apple-icon-114x114.png (100%) rename {public-old => app/public/ico}/apple-icon-120x120.png (100%) rename {public-old => app/public/ico}/apple-icon-144x144.png (100%) rename {public-old => app/public/ico}/apple-icon-152x152.png (100%) rename {public-old => app/public/ico}/apple-icon-180x180.png (100%) rename {public-old => app/public/ico}/apple-icon-57x57.png (100%) rename {public-old => app/public/ico}/apple-icon-60x60.png (100%) rename {public-old => app/public/ico}/apple-icon-72x72.png (100%) rename {public-old => app/public/ico}/apple-icon-76x76.png (100%) rename {public-old => app/public/ico}/favicon-16x16.png (100%) rename {public-old => app/public/ico}/favicon-32x32.png (100%) rename {public-old => app/public/ico}/favicon-96x96.png (100%) rename {public-old => app/public/ico}/manifest.json (100%) delete mode 100644 app/public/index.html delete mode 100644 app/public/robots.txt create mode 100644 app/public/vite.svg delete mode 100644 app/src/Download.svelte delete mode 100644 app/src/Loading.svelte delete mode 100644 app/src/Search.svelte delete mode 100644 app/src/Track.svelte delete mode 100644 app/src/api.js create mode 100644 app/src/app.css delete mode 100644 app/src/download.js rename app/src/{ => lib}/Album.svelte (50%) create mode 100644 app/src/lib/Header.svelte create mode 100644 app/src/lib/Loading.svelte create mode 100644 app/src/lib/ProgressBar.svelte create mode 100644 app/src/lib/Search.svelte create mode 100644 app/src/lib/ThemeSwitcher.svelte create mode 100644 app/src/lib/Track.svelte create mode 100644 app/src/lib/download.js create mode 100644 app/src/lib/format.js create mode 100644 app/src/lib/stores.js delete mode 100644 app/src/stores.js create mode 100644 app/src/vite-env.d.ts delete mode 100644 app/src/websocket.js create mode 100644 app/vite.config.js delete mode 100644 public-old/index.css delete mode 100644 public-old/index.html delete mode 100644 public-old/index.js diff --git a/app/.gitignore b/app/.gitignore index 886bda8..a547bf3 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -1 +1,24 @@ -/public/build/ \ No newline at end of file +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/app/.vscode/extensions.json b/app/.vscode/extensions.json new file mode 100644 index 0000000..bdef820 --- /dev/null +++ b/app/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["svelte.svelte-vscode"] +} diff --git a/app/README.md b/app/README.md new file mode 100644 index 0000000..50ea7ed --- /dev/null +++ b/app/README.md @@ -0,0 +1,48 @@ +# Svelte + Vite + +This template should help get you started developing with Svelte in Vite. + +## Recommended IDE Setup + +[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). + +## Need an official Svelte framework? + +Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more. + +## Technical considerations + +**Why use this over SvelteKit?** + +- It brings its own routing solution which might not be preferable for some users. +- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app. + `vite dev` and `vite build` wouldn't work in a SvelteKit environment, for example. + +This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project. + +Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate. + +**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?** + +Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information. + +**Why include `.vscode/extensions.json`?** + +Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project. + +**Why enable `checkJs` in the JS template?** + +It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration. + +**Why is HMR not preserving my local component state?** + +HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr). + +If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR. + +```js +// store.js +// An extremely simple external store +import { writable } from 'svelte/store' +export default writable(0) +``` diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000..7c21d0c --- /dev/null +++ b/app/index.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/jsconfig.json b/app/jsconfig.json new file mode 100644 index 0000000..ee5e92f --- /dev/null +++ b/app/jsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "moduleResolution": "Node", + "target": "ESNext", + "module": "ESNext", + /** + * svelte-preprocess cannot figure out whether you have + * a value or a type, so tell TypeScript to enforce using + * `import type` instead of `import` for Types. + */ + "importsNotUsedAsValues": "error", + "isolatedModules": true, + "resolveJsonModule": true, + /** + * To have warnings / errors of the Svelte compiler at the + * correct position, enable source maps by default. + */ + "sourceMap": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "baseUrl": ".", + /** + * Typecheck JS in `.svelte` and `.js` files by default. + * Disable this if you'd like to use dynamic types. + */ + "checkJs": true + }, + /** + * Use global.d.ts instead of compilerOptions.types + * to avoid limiting type declarations. + */ + "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] +} diff --git a/app/package.json b/app/package.json new file mode 100644 index 0000000..f042f9f --- /dev/null +++ b/app/package.json @@ -0,0 +1,16 @@ +{ + "name": "app", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^1.0.1", + "svelte": "^3.49.0", + "vite": "^3.0.7" + } +} \ No newline at end of file diff --git a/app/pnpm-lock.yaml b/app/pnpm-lock.yaml new file mode 100644 index 0000000..bd5169c --- /dev/null +++ b/app/pnpm-lock.yaml @@ -0,0 +1,424 @@ +lockfileVersion: 5.4 + +specifiers: + '@sveltejs/vite-plugin-svelte': ^1.0.1 + svelte: ^3.49.0 + vite: ^3.0.7 + +devDependencies: + '@sveltejs/vite-plugin-svelte': 1.0.1_svelte@3.49.0+vite@3.0.8 + svelte: 3.49.0 + vite: 3.0.8 + +packages: + + /@esbuild/linux-loong64/0.14.54: + resolution: {integrity: sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/pluginutils/4.2.1: + resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==} + engines: {node: '>= 8.0.0'} + dependencies: + estree-walker: 2.0.2 + picomatch: 2.3.1 + dev: true + + /@sveltejs/vite-plugin-svelte/1.0.1_svelte@3.49.0+vite@3.0.8: + resolution: {integrity: sha512-PorCgUounn0VXcpeJu+hOweZODKmGuLHsLomwqSj+p26IwjjGffmYQfVHtiTWq+NqaUuuHWWG7vPge6UFw4Aeg==} + engines: {node: ^14.18.0 || >= 16} + peerDependencies: + diff-match-patch: ^1.0.5 + svelte: ^3.44.0 + vite: ^3.0.0 + peerDependenciesMeta: + diff-match-patch: + optional: true + dependencies: + '@rollup/pluginutils': 4.2.1 + debug: 4.3.4 + deepmerge: 4.2.2 + kleur: 4.1.5 + magic-string: 0.26.2 + svelte: 3.49.0 + svelte-hmr: 0.14.12_svelte@3.49.0 + vite: 3.0.8 + transitivePeerDependencies: + - supports-color + dev: true + + /debug/4.3.4: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + dev: true + + /deepmerge/4.2.2: + resolution: {integrity: sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==} + engines: {node: '>=0.10.0'} + dev: true + + /esbuild-android-64/0.14.54: + resolution: {integrity: sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /esbuild-android-arm64/0.14.54: + resolution: {integrity: sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /esbuild-darwin-64/0.14.54: + resolution: {integrity: sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /esbuild-darwin-arm64/0.14.54: + resolution: {integrity: sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /esbuild-freebsd-64/0.14.54: + resolution: {integrity: sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-freebsd-arm64/0.14.54: + resolution: {integrity: sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-32/0.14.54: + resolution: {integrity: sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-64/0.14.54: + resolution: {integrity: sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-arm/0.14.54: + resolution: {integrity: sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-arm64/0.14.54: + resolution: {integrity: sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-mips64le/0.14.54: + resolution: {integrity: sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-ppc64le/0.14.54: + resolution: {integrity: sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-riscv64/0.14.54: + resolution: {integrity: sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-linux-s390x/0.14.54: + resolution: {integrity: sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /esbuild-netbsd-64/0.14.54: + resolution: {integrity: sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-openbsd-64/0.14.54: + resolution: {integrity: sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /esbuild-sunos-64/0.14.54: + resolution: {integrity: sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-32/0.14.54: + resolution: {integrity: sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-64/0.14.54: + resolution: {integrity: sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild-windows-arm64/0.14.54: + resolution: {integrity: sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /esbuild/0.14.54: + resolution: {integrity: sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/linux-loong64': 0.14.54 + esbuild-android-64: 0.14.54 + esbuild-android-arm64: 0.14.54 + esbuild-darwin-64: 0.14.54 + esbuild-darwin-arm64: 0.14.54 + esbuild-freebsd-64: 0.14.54 + esbuild-freebsd-arm64: 0.14.54 + esbuild-linux-32: 0.14.54 + esbuild-linux-64: 0.14.54 + esbuild-linux-arm: 0.14.54 + esbuild-linux-arm64: 0.14.54 + esbuild-linux-mips64le: 0.14.54 + esbuild-linux-ppc64le: 0.14.54 + esbuild-linux-riscv64: 0.14.54 + esbuild-linux-s390x: 0.14.54 + esbuild-netbsd-64: 0.14.54 + esbuild-openbsd-64: 0.14.54 + esbuild-sunos-64: 0.14.54 + esbuild-windows-32: 0.14.54 + esbuild-windows-64: 0.14.54 + esbuild-windows-arm64: 0.14.54 + dev: true + + /estree-walker/2.0.2: + resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + dev: true + + /fsevents/2.3.2: + resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /function-bind/1.1.1: + resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} + dev: true + + /has/1.0.3: + resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} + engines: {node: '>= 0.4.0'} + dependencies: + function-bind: 1.1.1 + dev: true + + /is-core-module/2.10.0: + resolution: {integrity: sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==} + dependencies: + has: 1.0.3 + dev: true + + /kleur/4.1.5: + resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} + engines: {node: '>=6'} + dev: true + + /magic-string/0.26.2: + resolution: {integrity: sha512-NzzlXpclt5zAbmo6h6jNc8zl2gNRGHvmsZW4IvZhTC4W7k4OlLP+S5YLussa/r3ixNT66KOQfNORlXHSOy/X4A==} + engines: {node: '>=12'} + dependencies: + sourcemap-codec: 1.4.8 + dev: true + + /ms/2.1.2: + resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} + dev: true + + /nanoid/3.3.4: + resolution: {integrity: sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + dev: true + + /path-parse/1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + dev: true + + /picocolors/1.0.0: + resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} + dev: true + + /picomatch/2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + dev: true + + /postcss/8.4.16: + resolution: {integrity: sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.3.4 + picocolors: 1.0.0 + source-map-js: 1.0.2 + dev: true + + /resolve/1.22.1: + resolution: {integrity: sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==} + hasBin: true + dependencies: + is-core-module: 2.10.0 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + dev: true + + /rollup/2.77.3: + resolution: {integrity: sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==} + engines: {node: '>=10.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.2 + dev: true + + /source-map-js/1.0.2: + resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} + engines: {node: '>=0.10.0'} + dev: true + + /sourcemap-codec/1.4.8: + resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==} + dev: true + + /supports-preserve-symlinks-flag/1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + dev: true + + /svelte-hmr/0.14.12_svelte@3.49.0: + resolution: {integrity: sha512-4QSW/VvXuqVcFZ+RhxiR8/newmwOCTlbYIezvkeN6302YFRE8cXy0naamHcjz8Y9Ce3ITTZtrHrIL0AGfyo61w==} + engines: {node: ^12.20 || ^14.13.1 || >= 16} + peerDependencies: + svelte: '>=3.19.0' + dependencies: + svelte: 3.49.0 + dev: true + + /svelte/3.49.0: + resolution: {integrity: sha512-+lmjic1pApJWDfPCpUUTc1m8azDqYCG1JN9YEngrx/hUyIcFJo6VZhj0A1Ai0wqoHcEIuQy+e9tk+4uDgdtsFA==} + engines: {node: '>= 8'} + dev: true + + /vite/3.0.8: + resolution: {integrity: sha512-AOZ4eN7mrkJiOLuw8IA7piS4IdOQyQCA81GxGsAQvAZzMRi9ZwGB3TOaYsj4uLAWK46T5L4AfQ6InNGlxX30IQ==} + engines: {node: ^14.18.0 || >=16.0.0} + hasBin: true + peerDependencies: + less: '*' + sass: '*' + stylus: '*' + terser: ^5.4.0 + peerDependenciesMeta: + less: + optional: true + sass: + optional: true + stylus: + optional: true + terser: + optional: true + dependencies: + esbuild: 0.14.54 + postcss: 8.4.16 + resolve: 1.22.1 + rollup: 2.77.3 + optionalDependencies: + fsevents: 2.3.2 + dev: true diff --git a/app/public/assets/download.svg b/app/public/assets/download.svg deleted file mode 100644 index 8bdd638..0000000 --- a/app/public/assets/download.svg +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - diff --git a/app/public/favicon.png b/app/public/favicon.png deleted file mode 100644 index 7e6f5eb5a2f1f1c882d265cf479de25caa925645..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3127 zcmV-749N3|P)i z7)}s4L53SJCkR}iVi00SFk;`MXX*#X*kkwKs@nFGS}c;=?XFjU|G$3t^5sjIVS2G+ zw)WGF83CpoGXhLGW(1gW%uV|X7>1P6VhCX=Ux)Lb!*DZ%@I3!{Gsf7d?gtIQ%nQiK z3%(LUSkBji;C5Rfgd6$VsF@H`Pk@xtY6t<>FNR-pD}=C~$?)9pdm3XZ36N5PNWYjb z$xd$yNQR9N!dfj-Vd@BwQo^FIIWPPmT&sZyQ$v81(sCBV=PGy{0wltEjB%~h157*t zvbe_!{=I_783x!0t1-r#-d{Y?ae$Q4N_Nd^Ui^@y(%)Gjou6y<3^XJdu{rmUf-Me?)zZ>9OR&6U5H*cK; z$gUlB{g0O4gN0sLSO|Of?hU(l?;h(jA3uH!Z{EBKuV23ouU@^Y6#%v+QG;>e*E}%?wlu-NT4DG zs)z)7WbLr)vGAu(ohrKc^em@OpO&f~6_>E61n_e0_V3@{U3^O;j{`^mNCJUj_>;7v zsMs6Hu3g7+@v+lSo;=yTYFqq}jZmQ-BK8K{C4kqi_i*jBaQE(Au0607V-zKeT;EPg zX(`vrn=L+e74+-Tqeok@_`tDa$G9I|$nTU5H*2V8@y()n*zqM?J1G!-1aX;CfDC9B zTnJ#j_%*n8Qb1)re*Bno7g0RG{Eb;IK14irJYJp$5Z6ac9~b_P?+5t~95~SRG$g?1 znFJ7p$xV&GZ18m~79TGRdfsc-BcX$9yXTR*n)mPD@1~O(_?cT$ZvFPucRmGlq&se0 zKrcUf^k}4hM*biEJOWKzz!qQe;CB_ZtSOO9Owg#lZAc=s65^rb{fZe(TYu_rk!wKkEf}RIt=#Om( zR8mN`DM<^xj~59euMMspBolVN zAPTr8sSDI104orIAdmL$uOXn*6hga1G+0WD0E?UtabxC#VC~vf3|10|phW;yQ3CY8 z2CM=)ErF;xq-YJ5G|um}>*1#E+O_Mu|Nr#qQ&G1P-NMq@f?@*XUcSbV?tX=)ilM-Q zBZP|!Bpv0V;#ojKcpc7$=eqO;#Uy~#?^kNI{vSZfLx&DEt~LTmaKWXcx=joubklI<*Aw z>LtMaQ7DR<1I2LkWvwyu#Rwn~;ezT}_g(@5l3h?W%-a86Y-t#O1PubP+z<%?V5D(U zy57A6{h+{?kOZp7&WKZR+=sznMJ}+Dnpo=C_0%R_x_t~J5T?E_{+))l5v1%52>)d-`iiZyx|5!%M2Fb2dU zW3~MwwpEH9Rhue+k$UIOoo($Ds!NbOyMR36fRHu;*15(YcA7siIZk#%JWz>P!qX1?IUojG&nKR>^gArBt2 zit(ETyZ=@V&7mv_Fi4bABcnwP+jzQuHcfU&BrAV91u-rFvEi7y-KnWsvHH=d2 zgAk(GKm_S8RcTJ>2N3~&Hbwp{Z3NF_Xeh}g4Eke)V&dY{W(3&b1j9t4yK_aYJisZZ{1rcU5- z;eD>K;ndPq&B-8yA_S0F!4ThA&{1{x)H<#?k9a#6Pc6L?V^s0``ynL&D;p(!Nmx`Y zFkHex{4p!Ggm^@DlehW}iHHVi}~u=$&N? z(NEBLQ#UxxAkdW>X9LnqUr#t4Lu0=9L8&o>JsqTtT5|%gb3QA~hr0pED71+iFFr)dZ=Q=E6ng{NE{Z~0)C?deO#?Aj zSDQ$z#TeC2T^|=}6GBo-&$;E{HL3!q3Z-szuf)O=G#zDjin4SSP%o%6+2IT#sLjQa ziyxFFz~LMjWY+_a5H!U6%a<=b7QVP^ z*90a62;bVq{?@)P6^DWd^Yilq4|YTV2Nw!Yu;a1lPI-sxR)rf@Fe5DhDP7FH zZZ%4S*1C30P;|O+jB!1;m|rXT90Sm5*RBbQN`PKu+hDD*S^yE(CdtSfg=z>u$cIj> z - - - - - - Svelte app - - - - - - - - - - - diff --git a/app/public/robots.txt b/app/public/robots.txt deleted file mode 100644 index 1f53798..0000000 --- a/app/public/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Disallow: / diff --git a/app/public/vite.svg b/app/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/app/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/src/App.svelte b/app/src/App.svelte index 67e473f..f594c18 100644 --- a/app/src/App.svelte +++ b/app/src/App.svelte @@ -1,32 +1,123 @@ - + +
+ +
+ + ps. sorry for shitty mobile support on rewrite i'll fix it soon i promiseeeee -oat + {#if loading} + + {/if} + {#if searchAlbums.length > 0} +
+ {#each searchAlbums as album, i} + + {/each} +
+ {/if} + +
+ 0}> +

Download Queue

+
+ {#each $queue as dl} +
+ + +
+ {/each} +
+
+
-
- - {#if $display === displays.AlbumSearch} - -
- {#each $albums as album} -
- {/each} -
- {/if} - {#if $display === displays.Download && $downloading} - - {/if} -
-
\ No newline at end of file + diff --git a/app/src/Download.svelte b/app/src/Download.svelte deleted file mode 100644 index 429e614..0000000 --- a/app/src/Download.svelte +++ /dev/null @@ -1,45 +0,0 @@ - - -{#if title && artist && coverArt} -
- -
- Cover -
-
- - {#if $progress > 0} -
- {/if} -{:else} - -{/if} \ No newline at end of file diff --git a/app/src/Loading.svelte b/app/src/Loading.svelte deleted file mode 100644 index 1eba3fe..0000000 --- a/app/src/Loading.svelte +++ /dev/null @@ -1,51 +0,0 @@ - - -
\ No newline at end of file diff --git a/app/src/Search.svelte b/app/src/Search.svelte deleted file mode 100644 index 0b60c7c..0000000 --- a/app/src/Search.svelte +++ /dev/null @@ -1,55 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/Track.svelte b/app/src/Track.svelte deleted file mode 100644 index 6719238..0000000 --- a/app/src/Track.svelte +++ /dev/null @@ -1,98 +0,0 @@ - - - - -
- {artist} - {title} - - - Download - - {formatTime(duration)} - -
\ No newline at end of file diff --git a/app/src/api.js b/app/src/api.js deleted file mode 100644 index e02aff0..0000000 --- a/app/src/api.js +++ /dev/null @@ -1,9 +0,0 @@ -export async function querySearch(q) { - let response = await fetch(`http://localhost:4500/api/search?search=${encodeURI(q)}`); - return await response.json(); -} - -export async function queryTracks(id) { - let response = await fetch(`http://localhost:4500/api/album?id=${id}`); - return await response.json(); -} \ No newline at end of file diff --git a/app/src/app.css b/app/src/app.css new file mode 100644 index 0000000..843fec4 --- /dev/null +++ b/app/src/app.css @@ -0,0 +1,59 @@ +* { + transition: 0.1s background-color ease-out; +} + +body { + margin: 0; + padding: 0; +} + +@media (prefers-color-scheme: dark) { + body { + background-color: #0a0a0f; + color: #fff; + accent-color: rgb(131, 131, 243); + } + .small { + color: #888; + } + .link { + color:rgb(131, 131, 243); + } + .link:hover { + color: rgb(151, 151, 255); + filter: drop-shadow( 0px 0px 2px #8383F3); + } +} +@media (prefers-color-scheme: light) { + body { + background-color: #f0f0f0; + color: #1e1e2d; + accent-color: #ea74ac; + } + .small { + color: #c8c8d2; + } + .link { + color:#ea74ac; + } + .link:hover { + color: #f484b6; + filter: drop-shadow( 0px 0px 2px #f484b6); + } +} + +body { + font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; +} + +.small { + font-size: medium; +} +.big { + font-weight: bold; +} + +.link { + cursor: pointer; + transition: 0.1s color ease-out; +} \ No newline at end of file diff --git a/app/src/download.js b/app/src/download.js deleted file mode 100644 index 5171f22..0000000 --- a/app/src/download.js +++ /dev/null @@ -1,10 +0,0 @@ -import {downloading, display, displays} from './stores'; - -export function downloadAlbum(id) { - display.set(displays.Download); - downloading.set({id: id, isAlbum: true}); -} -export function downloadTrack(id) { - display.set(displays.Download); - downloading.set({id: id, isAlbum: false}); -} \ No newline at end of file diff --git a/app/src/Album.svelte b/app/src/lib/Album.svelte similarity index 50% rename from app/src/Album.svelte rename to app/src/lib/Album.svelte index f0b408a..047d29f 100644 --- a/app/src/Album.svelte +++ b/app/src/lib/Album.svelte @@ -1,3 +1,94 @@ + + +
+ +
+ Cover for '{title}' +
+
+ +
+ {#if loadingTracks} + + {/if} + {#if album && !short} + {#each album.tracks as track} + + {/each} + {/if} +
+ - - - -
- -
- Cover -
-
- -
- {#if tracks.length === 0} - - {:else} - {#each tracks as track} - - {/each} - {/if} -
\ No newline at end of file + \ No newline at end of file diff --git a/app/src/lib/Header.svelte b/app/src/lib/Header.svelte new file mode 100644 index 0000000..95c3d90 --- /dev/null +++ b/app/src/lib/Header.svelte @@ -0,0 +1,47 @@ +
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/app/src/lib/Loading.svelte b/app/src/lib/Loading.svelte new file mode 100644 index 0000000..08c8793 --- /dev/null +++ b/app/src/lib/Loading.svelte @@ -0,0 +1,50 @@ +
+ + \ No newline at end of file diff --git a/app/src/lib/ProgressBar.svelte b/app/src/lib/ProgressBar.svelte new file mode 100644 index 0000000..26b00a7 --- /dev/null +++ b/app/src/lib/ProgressBar.svelte @@ -0,0 +1,41 @@ + + +
+ + \ No newline at end of file diff --git a/app/src/lib/Search.svelte b/app/src/lib/Search.svelte new file mode 100644 index 0000000..4204aec --- /dev/null +++ b/app/src/lib/Search.svelte @@ -0,0 +1,89 @@ + + + + + \ No newline at end of file diff --git a/app/src/lib/ThemeSwitcher.svelte b/app/src/lib/ThemeSwitcher.svelte new file mode 100644 index 0000000..f74b467 --- /dev/null +++ b/app/src/lib/ThemeSwitcher.svelte @@ -0,0 +1,94 @@ + + + + + \ No newline at end of file diff --git a/app/src/lib/Track.svelte b/app/src/lib/Track.svelte new file mode 100644 index 0000000..59a942b --- /dev/null +++ b/app/src/lib/Track.svelte @@ -0,0 +1,99 @@ + + +
+ {artist} - {title} + + {formatTime(duration)} + startDownload(id, {title, artist: {name: artist}, cover, album}, false)}> + + + +
+ + \ No newline at end of file diff --git a/app/src/lib/download.js b/app/src/lib/download.js new file mode 100644 index 0000000..365ab55 --- /dev/null +++ b/app/src/lib/download.js @@ -0,0 +1,68 @@ +import { get, writable } from "svelte/store"; +import { queue } from "./stores"; + +function getWebsocketLocation() { + return window.window.location.toString().replace('https://', 'wss://').replace('http://', 'ws://'); +} + +export function startDownload(id, metadata, isAlbum) { + let log = writable(['Connecting to WebSocket...']); + let logLocal = ['Connecting to WebSocket...']; + let progress = writable(0); + let success = writable(null); + let downloadLink = writable(null); + + let coverArt; + let title; + let artist; + + let queueItem = { + id: id, + ...metadata, + log, + progress, + isAlbum, + success, + downloadLink + }; + + queue.set([...get(queue), queueItem]); + + let type = isAlbum ? 'album' : 'track' + const ws = new WebSocket(`${getWebsocketLocation()}api/${type}?id=${id}`); + ws.onmessage = (m) => { + const d = JSON.parse(m.data); + console.log(d); + if (d.key === 'downloadInfo') { + logLocal.push(`[${d.data.data.title}] ${d.data.state}`); + log.set(logLocal); + } else if (d.key === 'updateQueue') { + if (d.data.progress) { + progress.set(d.data.progress); + } + } else if (d.key === 'download') { + downloadLink.set(d.data); + } else if (d.key === 'finishDownload') { + logLocal.push('Download finished'); + log.set(logLocal); + success.set(true); + } else if (d.key === 'zipping') { + logLocal.push('Creating zip archive'); + log.set(logLocal); + } + } + ws.onerror = (e) => { + console.error(e); + logLocal.push(`${e}`); + log.set(logLocal); + success.set(false); + } + ws.onclose = (e) => { + if (e.code !== 1000) { + console.error(`websocket closed unexpectedly with code ${e.code}\n${e.reason}`); + logLocal.push(`websocket closed unexpectedly with code ${e.code}`, `${e.reason}`); + log.set(logLocal); + success.set(false); + } + } +} \ No newline at end of file diff --git a/app/src/lib/format.js b/app/src/lib/format.js new file mode 100644 index 0000000..4e232ed --- /dev/null +++ b/app/src/lib/format.js @@ -0,0 +1,3 @@ +export function formatTime(s) { + return Math.floor(s / 60).toString().padStart(2, '0') + ':' + (s % 60).toString().padStart(2, '0'); +} \ No newline at end of file diff --git a/app/src/lib/stores.js b/app/src/lib/stores.js new file mode 100644 index 0000000..8a2f125 --- /dev/null +++ b/app/src/lib/stores.js @@ -0,0 +1,3 @@ +import { writable } from "svelte/store"; + +export let queue = writable([]); \ No newline at end of file diff --git a/app/src/main.js b/app/src/main.js index 1719c77..e0326e5 100644 --- a/app/src/main.js +++ b/app/src/main.js @@ -1,9 +1,8 @@ -import App from './App.svelte'; +import './app.css' +import App from './App.svelte' const app = new App({ - target: document.body, - props: { - } -}); + target: document.body +}) -export default app; \ No newline at end of file +export default app diff --git a/app/src/stores.js b/app/src/stores.js deleted file mode 100644 index 30aeab5..0000000 --- a/app/src/stores.js +++ /dev/null @@ -1,19 +0,0 @@ -import {writable} from 'svelte/store'; - -export const albums = writable([]); - -export function clearAlbums() { - albums.set([]); -} -export function pushAlbum(id) { - albums.update((l) => [...l, id]); -} - -export const displays = { - AlbumSearch: 0, - Download: 1, -} - -export let display = writable(displays.AlbumSearch); - -export let downloading = writable(null); \ No newline at end of file diff --git a/app/src/vite-env.d.ts b/app/src/vite-env.d.ts new file mode 100644 index 0000000..4078e74 --- /dev/null +++ b/app/src/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/app/src/websocket.js b/app/src/websocket.js deleted file mode 100644 index fa000e3..0000000 --- a/app/src/websocket.js +++ /dev/null @@ -1,37 +0,0 @@ -/* -function getWebsocketLocation() { - return window.window.location.toString().replace('https://', 'wss://').replace('http://', 'ws://'); -} -*/ -function getWebsocketLocation() { - return 'ws://localhost:4500/'; -} - -export function startWebsocket(id, isAlbum, log, coverArt, title, artist, progress) { - let type = isAlbum ? 'album' : 'track'; - const ws = new WebSocket(`${getWebsocketLocation()}api/${type}?id=${id}`); - - ws.onmessage = (m) => { - const d = JSON.parse(m.data); - console.log(d); - if (d.key === 'downloadInfo') { - log(`[${d.data.data.title}] ${d.data.state}`); - } else if (d.key === 'updateQueue') { - progress(d.data.progress); - } else if (d.key === 'coverArt') { - log('Fetched cover art'); - coverArt(d.data); - } else if (d.key === 'metadata') { - log('Fetched metadata'); - title(d.data.title); - artist(d.data.artist); - } else if (d.key === 'download') { - console.log(d.data); - download(d.data); - } else if (d.key === 'finishDownload') { - log('Download finished'); - } else if (d.key === 'zipping') { - log('Zipping up files'); - } - }; -} \ No newline at end of file diff --git a/app/vite.config.js b/app/vite.config.js new file mode 100644 index 0000000..401b4d4 --- /dev/null +++ b/app/vite.config.js @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import { svelte } from '@sveltejs/vite-plugin-svelte' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [svelte()] +}) diff --git a/package.json b/package.json index e495940..a17d514 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,15 @@ "author": "oatmealine", "license": "AGPL-3.0", "dependencies": { - "deemix": "git+https://git.freezerapp.xyz/RemixDev/deemix-js", + "@fortawesome/free-solid-svg-icons": "^6.1.2", + "deemix": "git+https://gitlab.com/RemixDev/deemix-js", "deezer-js": "^1.3.5", "dotenv": "^10.0.0", "express": "^4.17.3", "express-ws": "^5.0.2", "sirv-cli": "^2.0.2", + "svelte-fontawesome": "^0.0.3", + "svelte-inview": "^3.0.1", "timeago.js": "^4.0.2", "toml": "^3.0.0", "winston": "^3.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5a306ad..7c123fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,13 +1,14 @@ -lockfileVersion: 5.3 +lockfileVersion: 5.4 specifiers: + '@fortawesome/free-solid-svg-icons': ^6.1.2 '@rollup/plugin-commonjs': ^17.1.0 '@rollup/plugin-node-resolve': ^11.2.1 '@types/express': ^4.17.13 '@types/express-ws': ^3.0.1 '@types/ws': ^8.2.3 bufferutil: ^4.0.6 - deemix: git+https://git.freezerapp.xyz/RemixDev/deemix-js + deemix: git+https://gitlab.com/RemixDev/deemix-js deezer-js: ^1.3.5 dotenv: ^10.0.0 express: ^4.17.3 @@ -19,6 +20,8 @@ specifiers: rollup-plugin-terser: ^7.0.2 sirv-cli: ^2.0.2 svelte: ^3.46.4 + svelte-fontawesome: ^0.0.3 + svelte-inview: ^3.0.1 timeago.js: ^4.0.2 toml: ^3.0.0 typescript: ^4.5.5 @@ -27,16 +30,19 @@ specifiers: ws: ^8.5.0 dependencies: - deemix: git.freezerapp.xyz/RemixDev/deemix-js/58bd92bc303a338aafc56ccf51940713812756ec + '@fortawesome/free-solid-svg-icons': 6.1.2 + deemix: gitlab.com/RemixDev/deemix-js/a105b03beb93cc2efa5d723d7f2e3cb2237d4f08 deezer-js: 1.3.5 dotenv: 10.0.0 express: 4.17.3 - express-ws: 5.0.2_9938c0c959a5f2b516218250f750cbca + express-ws: 5.0.2_te4mbskzuxzlkfrbqjipouglzi sirv-cli: 2.0.2 + svelte-fontawesome: 0.0.3 + svelte-inview: 3.0.1_svelte@3.46.4 timeago.js: 4.0.2 toml: 3.0.0 winston: 3.6.0 - ws: 8.5.0_bffff4271b89d628e8333ead80d3d8e8 + ws: 8.5.0_x777ijy3rhlcr2bth2wybu6y5a optionalDependencies: bufferutil: 4.0.6 @@ -50,8 +56,8 @@ devDependencies: '@types/ws': 8.2.3 rollup: 2.68.0 rollup-plugin-css-only: 3.1.0_rollup@2.68.0 - rollup-plugin-livereload: 2.0.5_bffff4271b89d628e8333ead80d3d8e8 - rollup-plugin-svelte: 7.1.0_rollup@2.68.0+svelte@3.46.4 + rollup-plugin-livereload: 2.0.5_x777ijy3rhlcr2bth2wybu6y5a + rollup-plugin-svelte: 7.1.0_dni462kqdqwcnfey6ikyaliv44 rollup-plugin-terser: 7.0.2_rollup@2.68.0 svelte: 3.46.4 typescript: 4.5.5 @@ -92,6 +98,20 @@ packages: kuler: 2.0.0 dev: false + /@fortawesome/fontawesome-common-types/6.1.2: + resolution: {integrity: sha512-wBaAPGz1Awxg05e0PBRkDRuTsy4B3dpBm+zreTTyd9TH4uUM27cAL4xWyWR0rLJCrRwzVsQ4hF3FvM6rqydKPA==} + engines: {node: '>=6'} + requiresBuild: true + dev: false + + /@fortawesome/free-solid-svg-icons/6.1.2: + resolution: {integrity: sha512-lTgZz+cMpzjkHmCwOG3E1ilUZrnINYdqMmrkv30EC3XbRsGlbIOL8H9LaNp5SV4g0pNJDfQ4EdTWWaMvdwyLiQ==} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + '@fortawesome/fontawesome-common-types': 6.1.2 + dev: false + /@polka/url/1.0.0-next.21: resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} dev: false @@ -302,7 +322,7 @@ packages: dev: false /asynckit/0.4.0: - resolution: {integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=} + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} dev: false /balanced-match/1.0.2: @@ -328,6 +348,8 @@ packages: qs: 6.9.7 raw-body: 2.4.3 type-is: 1.6.18 + transitivePeerDependencies: + - supports-color dev: false /brace-expansion/1.1.11: @@ -354,8 +376,6 @@ packages: requiresBuild: true dependencies: node-gyp-build: 4.3.0 - dev: false - optional: true /builtin-modules/3.2.0: resolution: {integrity: sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==} @@ -417,7 +437,7 @@ packages: dev: true /clone-response/1.0.2: - resolution: {integrity: sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=} + resolution: {integrity: sha512-yjLXh88P599UOyPTFX0POsd7WxnbsVsGohcwzHOLspIhhpalPw1BcqED8NblyZLKcGrL8dTgMlcaZxV2jAD41Q==} dependencies: mimic-response: 1.0.1 dev: false @@ -515,12 +535,22 @@ packages: /debug/2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true dependencies: ms: 2.0.0 dev: false /debug/3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true dependencies: ms: 2.1.3 dev: false @@ -562,7 +592,7 @@ packages: dev: false /delayed-stream/1.0.0: - resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=} + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} dev: false @@ -625,14 +655,14 @@ packages: engines: {node: '>= 0.6'} dev: false - /express-ws/5.0.2_9938c0c959a5f2b516218250f750cbca: + /express-ws/5.0.2_te4mbskzuxzlkfrbqjipouglzi: resolution: {integrity: sha512-0uvmuk61O9HXgLhGl3QhNSEtRsQevtmbL94/eILaliEADZBHZOQUAiHFrGPrgsjikohyrmSG5g+sCfASTt0lkQ==} engines: {node: '>=4.5.0'} peerDependencies: express: ^4.0.0 || ^5.0.0-alpha.1 dependencies: express: 4.17.3 - ws: 7.5.7_bffff4271b89d628e8333ead80d3d8e8 + ws: 7.5.7_x777ijy3rhlcr2bth2wybu6y5a transitivePeerDependencies: - bufferutil - utf-8-validate @@ -672,6 +702,8 @@ packages: type-is: 1.6.18 utils-merge: 1.0.1 vary: 1.1.2 + transitivePeerDependencies: + - supports-color dev: false /fast-safe-stringify/2.1.1: @@ -700,6 +732,8 @@ packages: parseurl: 1.3.3 statuses: 1.5.0 unpipe: 1.0.0 + transitivePeerDependencies: + - supports-color dev: false /fn.name/1.1.0: @@ -951,7 +985,7 @@ packages: resolution: {integrity: sha512-a7Jipme3XIBIryJluWP5LQrEAvhobDPyScBe+q+MYwxBiMT2Ck7msy4tAdF8TAa33FMdJqX4guP81Yhiu6BkmQ==} dev: true - /livereload/0.9.3_bffff4271b89d628e8333ead80d3d8e8: + /livereload/0.9.3_x777ijy3rhlcr2bth2wybu6y5a: resolution: {integrity: sha512-q7Z71n3i4X0R9xthAryBdNGVGAO2R5X+/xXpmKeuPMrteg+W2U8VusTKV3YiJbXZwKsOlFlHe+go6uSNjfxrZw==} engines: {node: '>=8.0.0'} hasBin: true @@ -959,7 +993,7 @@ packages: chokidar: 3.5.3 livereload-js: 3.3.3 opts: 2.0.2 - ws: 7.5.7_bffff4271b89d628e8333ead80d3d8e8 + ws: 7.5.7_x777ijy3rhlcr2bth2wybu6y5a transitivePeerDependencies: - bufferutil - utf-8-validate @@ -1021,6 +1055,8 @@ packages: dependencies: commander: 8.3.0 probe-image-size: 7.2.3 + transitivePeerDependencies: + - supports-color dev: false /methods/1.1.2: @@ -1079,7 +1115,7 @@ packages: dev: false /ms/2.0.0: - resolution: {integrity: sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=} + resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} dev: false /ms/2.1.2: @@ -1098,6 +1134,8 @@ packages: debug: 3.2.7 iconv-lite: 0.4.24 sax: 1.2.4 + transitivePeerDependencies: + - supports-color dev: false /negotiator/0.6.3: @@ -1108,8 +1146,6 @@ packages: /node-gyp-build/4.3.0: resolution: {integrity: sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q==} hasBin: true - dev: false - optional: true /normalize-path/3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} @@ -1133,7 +1169,7 @@ packages: dev: false /once/1.4.0: - resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=} + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} dependencies: wrappy: 1.0.2 @@ -1181,6 +1217,8 @@ packages: lodash.merge: 4.6.2 needle: 2.9.1 stream-parser: 0.3.1 + transitivePeerDependencies: + - supports-color dev: false /proxy-addr/2.0.7: @@ -1294,17 +1332,17 @@ packages: rollup: 2.68.0 dev: true - /rollup-plugin-livereload/2.0.5_bffff4271b89d628e8333ead80d3d8e8: + /rollup-plugin-livereload/2.0.5_x777ijy3rhlcr2bth2wybu6y5a: resolution: {integrity: sha512-vqQZ/UQowTW7VoiKEM5ouNW90wE5/GZLfdWuR0ELxyKOJUIaj+uismPZZaICU4DnWPVjnpCDDxEqwU7pcKY/PA==} engines: {node: '>=8.3'} dependencies: - livereload: 0.9.3_bffff4271b89d628e8333ead80d3d8e8 + livereload: 0.9.3_x777ijy3rhlcr2bth2wybu6y5a transitivePeerDependencies: - bufferutil - utf-8-validate dev: true - /rollup-plugin-svelte/7.1.0_rollup@2.68.0+svelte@3.46.4: + /rollup-plugin-svelte/7.1.0_dni462kqdqwcnfey6ikyaliv44: resolution: {integrity: sha512-vopCUq3G+25sKjwF5VilIbiY6KCuMNHP1PFvx2Vr3REBNMDllKHFZN2B9jwwC+MqNc3UPKkjXnceLPEjTjXGXg==} engines: {node: '>=10'} peerDependencies: @@ -1396,6 +1434,8 @@ packages: on-finished: 2.3.0 range-parser: 1.2.1 statuses: 1.5.0 + transitivePeerDependencies: + - supports-color dev: false /serialize-javascript/4.0.0: @@ -1412,6 +1452,8 @@ packages: escape-html: 1.0.3 parseurl: 1.3.3 send: 0.17.2 + transitivePeerDependencies: + - supports-color dev: false /setprototypeof/1.2.0: @@ -1495,9 +1537,11 @@ packages: dev: false /stream-parser/0.3.1: - resolution: {integrity: sha1-FhhUhpRCACGhGC/wrxkRwSl2F3M=} + resolution: {integrity: sha512-bJ/HgKq41nlKvlhccD5kaCr/P+Hu0wPNKPJOH7en+YrJu/9EgqUF+88w5Jb6KNcjOFMhfX4B2asfeAtIGuHObQ==} dependencies: debug: 2.6.9 + transitivePeerDependencies: + - supports-color dev: false /string_decoder/1.3.0: @@ -1545,10 +1589,21 @@ packages: engines: {node: '>= 0.4'} dev: true + /svelte-fontawesome/0.0.3: + resolution: {integrity: sha512-iC3aqOiaQ2yBJ5kxDIlQNhLQ1rRxxb6yxTzpzUTkLfFJSVGRCFZPNuS+Yu5xy9pg5c0dDz/E3f6KcmpeUlk3Hw==} + dev: false + + /svelte-inview/3.0.1_svelte@3.46.4: + resolution: {integrity: sha512-kmlD4l/z5tqMqGuWLOSz6Ys2ISJ2WXg01jFVygugma0XA45UeYNGjoRazp+gMvaWoHqCQPx6D8cH9YQBS1pZxA==} + peerDependencies: + svelte: ^3.0.0 + dependencies: + svelte: 3.46.4 + dev: false + /svelte/3.46.4: resolution: {integrity: sha512-qKJzw6DpA33CIa+C/rGp4AUdSfii0DOTCzj/2YpSKKayw5WGSS624Et9L1nU1k2OVRS9vaENQXp2CVZNU+xvIg==} engines: {node: '>= 8'} - dev: true /terser/5.11.0: resolution: {integrity: sha512-uCA9DLanzzWSsN1UirKwylhhRz3aKPInlfmpGfw8VN6jHsAtu8HJtIpeeHHK23rxnE/cDc+yvmq5wqkIC6Kn0A==} @@ -1638,8 +1693,6 @@ packages: requiresBuild: true dependencies: node-gyp-build: 4.3.0 - dev: false - optional: true /util-deprecate/1.0.2: resolution: {integrity: sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=} @@ -1681,9 +1734,9 @@ packages: dev: false /wrappy/1.0.2: - resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=} + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - /ws/7.5.7_bffff4271b89d628e8333ead80d3d8e8: + /ws/7.5.7_x777ijy3rhlcr2bth2wybu6y5a: resolution: {integrity: sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==} engines: {node: '>=8.3.0'} peerDependencies: @@ -1698,7 +1751,7 @@ packages: bufferutil: 4.0.6 utf-8-validate: 5.0.8 - /ws/8.5.0_bffff4271b89d628e8333ead80d3d8e8: + /ws/8.5.0_x777ijy3rhlcr2bth2wybu6y5a: resolution: {integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==} engines: {node: '>=10.0.0'} peerDependencies: @@ -1718,10 +1771,10 @@ packages: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} dev: false - git.freezerapp.xyz/RemixDev/deemix-js/58bd92bc303a338aafc56ccf51940713812756ec: - resolution: {commit: 58bd92bc303a338aafc56ccf51940713812756ec, repo: https://git.freezerapp.xyz/RemixDev/deemix-js, type: git} + gitlab.com/RemixDev/deemix-js/a105b03beb93cc2efa5d723d7f2e3cb2237d4f08: + resolution: {tarball: https://gitlab.com/api/v4/projects/RemixDev%2Fdeemix-js/repository/archive.tar.gz?ref=a105b03beb93cc2efa5d723d7f2e3cb2237d4f08} name: deemix - version: 3.6.7 + version: 3.6.10 dependencies: async: 3.2.3 deezer-js: 1.3.5 diff --git a/public-old/index.css b/public-old/index.css deleted file mode 100644 index 4191457..0000000 --- a/public-old/index.css +++ /dev/null @@ -1,163 +0,0 @@ -@media (prefers-color-scheme: dark) { - .lds-ring div { - border: 8px solid #fff; - border-color: #fff transparent transparent transparent; - } - #progress-bar { - background-color: #161627; - } - #progress-bar-inner { - background-color: rgb(131, 131, 243); - } - .slider { - background-color: rgb(131, 131, 243); - } - .slider:hover { - filter: drop-shadow( 0px 0px 5px #8383F3); - } - #progress-state { - background-color: #0a0a0f; - } -} -@media (prefers-color-scheme: light) { - #progress-bar { - background-color: #fafafa; - } - #progress-bar-inner { - background-color: #ea74ac; - } - .slider { - background-color: #ea74ac; - } - .slider:hover { - filter: drop-shadow( 0px 0px 5px #ea74ac); - } - #git { - filter: invert(100%); - } - #progress-state { - background-color: #fafafa; - } -} - -#progress { - width: 600px; - max-width: 98%; -} - -#progress-bar { - border-radius: 10px; - width: 100%; - height: 12px; -} -#progress-bar-inner { - border-radius: 10px; -} - - -#header { - display: flex; - align-items: left; - justify-content: left; - flex-direction: row; -} -#header > * { - margin-left: 12px; - margin-right: 12px; -} -#header .link { - font-size: x-large; - text-decoration: none; -} -#header img { - position: relative; - top: 5px; -} - - /* The switch - the box around the slider */ -.switch { - position: relative; - display: inline-block; - width: 60px; - height: 34px; -} - -/* Hide default HTML checkbox */ -.switch input { - opacity: 0; - width: 0; - height: 0; -} - -/* The slider */ -.slider { - position: absolute; - cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; - -webkit-transition: .2s; - transition: .2s; -} - -.slider:before { - position: absolute; - content: ""; - height: 26px; - width: 26px; - left: 4px; - bottom: 4px; - background-color: white; - -webkit-transition: .2s; - transition: .2s; -} - -input:checked + .slider:before { - -webkit-transform: translateX(26px); - -ms-transform: translateX(26px); - transform: translateX(26px); -} - -/* Rounded sliders */ -.slider.round { - border-radius: 34px; -} - -.slider.round:before { - border-radius: 50%; -} - -#header-left { - width: 100%; -} -#header-left > * { - margin-right: 16px; -} - -#progress-state { - font-family: monospace; - font-size: 12px; - border-radius: 10px; - width: 80%; - padding: 6px; - height: 110px; -} - -.album-downloading { - border-radius: 10px; -} - -.error { - background-color: rgb(255, 155, 155, 0.3); - padding: 20px; - border-radius: 15px; - border: 3px solid rgb(255, 155, 155, 0.8); - text-align: center; - margin: 15px; - width: 400px; - display: none; /* this is changed by the js */ -} -.error .big { - font-size: x-large; -} \ No newline at end of file diff --git a/public-old/index.html b/public-old/index.html deleted file mode 100644 index aa08833..0000000 --- a/public-old/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
-
- - diff --git a/public-old/index.js b/public-old/index.js deleted file mode 100644 index a498071..0000000 --- a/public-old/index.js +++ /dev/null @@ -1,257 +0,0 @@ -const h = window.window.location.hostname; -if (!h || h.includes('localhost')) { - window.document.title = 'deemix-web-frontend'; -} else { - window.document.title = window.window.location.hostname -} - -function download(url) { - console.log(url); - fetch(url) - .then(response => response.blob()) - .then(blob => { - const link = document.createElement("a"); - link.href = URL.createObjectURL(blob); - link.download = url.split('/').pop(); - link.target = '_blank'; - link.click(); - }) - .catch(console.error); -} - -function formatTime(s) { - return Math.floor(s / 60).toString().padStart(2, '0') + ':' + (s % 60).toString().padStart(2, '0'); -} - -// this is literally a find replace in the css -function setTheme(theme) { - Array.from(document.styleSheets).map(e => { - try { - return Array.from(e.cssRules) - } catch (e) { - return [] - } - }).flat().map(e => { - if (e.constructor != CSSMediaRule) return; - if (e.originalConditionText) e.conditionText = e.originalConditionText; - else e.originalConditionText = e.conditionText - if (theme === 'system') return - let match = e.conditionText.match(/prefers-color-scheme:\s*(light|dark)/i) - if (!match) return; - e.conditionText = e.conditionText.replace(match[0], (match[1].toLowerCase() == theme ? 'min' : 'max') + '-width: 0') - }); -} - -function getWebsocketLocation() { - return window.window.location.toString().replace('https://', 'wss://').replace('http://', 'ws://'); -} - -function addlog(log, text) { - log += `
${text}`; - log = log.split('
').slice(-5).join('
'); - if (log.startsWith('
')) log = log.replace('
', ''); - return log; -} - -function startDownload(id, isAlbum) { - let log = ''; - - let coverArt; - let title; - let artist; - - let type = isAlbum ? 'album' : 'track' - document.getElementById('albums').innerHTML = ''; - document.getElementById('progress-album').innerHTML = '
'; - const ws = new WebSocket(`${getWebsocketLocation()}api/${type}?id=${id}`); - ws.onmessage = (m) => { - const d = JSON.parse(m.data); - console.log(d); - if (d.key === 'downloadInfo') { - log = addlog(log, `[${d.data.data.title}] ${d.data.state}`); - } else if (d.key === 'updateQueue') { - if (d.data.progress) { - document.getElementById('progress-bar-wrapper').innerHTML = `
` - } - } else if (d.key === 'coverArt') { - log = addlog(log, 'Fetched cover art'); - coverArt = d.data; - } else if (d.key === 'metadata') { - log = addlog(log, 'Fetched metadata'); - title = d.data.title; - artist = d.data.artist; - } else if (d.key === 'download') { - download(d.data); - } else if (d.key === 'finishDownload') { - log = addlog(log, 'Download finished'); - } else if (d.key === 'zipping') { - log = addlog(log, 'Zipping up files'); - } - - document.getElementById('progress-album').innerHTML = ` -
- -
- -
-
- `; - } - ws.onerror = (e) => { - console.log('error: ' + e); - error(e.toString()); - } - ws.onclose = (e) => { - change(); - if (e.code !== 1000) error(`websocket closed unexpectedly with code ${e.code}\n${e.reason}`); - } -} - -function error(e) { - document.getElementById('error').innerHTML = `
error!
${e.split('\n').join('
')}`; - document.getElementById('error').style.display = 'block'; - console.error(e); -} -function clearError() { - document.getElementById('error').innerHTML = ''; - document.getElementById('error').style.display = 'none'; -} - -let change; // fuck off js - -window.onload = () => { - clearError(); - - // dirty theme hacks :tm: - - const color = window.getComputedStyle(document.querySelector('body')).getPropertyValue('color'); - const rgbRegex = /rgb\((\d+), ?(\d+), ?(\d+)\)/; - const r = rgbRegex.exec(color); - - let brightness = (Number(r[1]) + Number(r[2]) + Number(r[3])) / (255 * 3); - - if (brightness > 0.5) { // light text, dark theme - document.getElementById('theme-switch').checked = true - } else { // dark text, light theme - document.getElementById('theme-switch').checked = false - } - - document.getElementById('theme-switch').addEventListener('click', () => { - setTheme(document.getElementById('theme-switch').checked ? 'dark' : 'light'); - }); - - // list of based music - const placeholders = [ - 'xilent - we are dust', - 'joyryde - brave', - 'phaseone - the risen ep', - // 'blanke & godlands - hellraiser', // deemix search sucks and this doesnt actually work - 'camellia - blackmagik blazing', - 't+pazolite - without permission', - 'the brig - vindicate', - 'bossfight - next wave', - 'matt doe - g.a.s.', - 'virtual riot - save yourself ep', - 'panda eyes - hold on', - 'clockvice - disgrace', - 'scheme - quake', - 'eliminate - belly of the beast ep', - 'apriskah - mistakes ep', - 'dog blood - turn off the lights', - 'silentroom - memory waves', - 'metaroom - metadata', - 'prismo - nightmare', - 'ray volpe - rise of the volpetron', - 'eliminate - mula', - 'vorso - full tilt', - 'billiummoto - link(init)', - 'voltra - radar dx', - 'zomboy - end game', - 'dr. ozi - host ep', - 'nitepunk - absolute zero', - '2 mello - sounds of tokyo-to future', - 'must die - crisis vision redux', - 'moe shop - notice', - 'cysmix - escapism', - 'rogue - rattlesnake' - ]; - - const search = document.getElementById('album-search'); - search.setAttribute('placeholder', placeholders[Math.floor(Math.random() * placeholders.length)]); - - change = async () => { - clearError(); - const value = document.getElementById('album-search').value; - if (value === '') return document.getElementById('albums').innerHTML = ''; - document.getElementById('progress-album').innerHTML = ''; - document.getElementById('progress-bar-wrapper').innerHTML = ''; - document.getElementById('albums').innerHTML = '
'; - let d; - try { - d = await axios.get('/api/search', {params: {search: value}}); - } catch(err) { - error(err.toString()); - document.getElementById('albums').innerHTML = ''; - return; - } - document.getElementById('albums').innerHTML = d.data.map(d => - ` -
- -
- -
-
- -
- ` - ).join('
'); - - if (d.data.length === 0) return document.getElementById('albums').innerHTML = 'Not found!'; - - for (c of document.getElementById('albums').children) { - let id = c.id.split('-')[1]; - if (document.getElementById('album-bottom-' + id)) { - document.getElementById('album-bottom-' + id).innerHTML = '
'; - let album; - try { - album = await axios.get('/api/album', {params: {id: id}}); - } catch(err) { - error(err.toString()); - document.getElementById('album-bottom-' + id).innerHTML = ''; - return; - } - - document.getElementById('album-bottom-' + id).innerHTML = album.data.tracks.map(d => - ` -
- ${d.artist} - ${d.title} - - - - - ${formatTime(d.duration)} - -
- ` - ).join(''); - } - } - } - - search.addEventListener('change', change); -}; diff --git a/src/index.ts b/src/index.ts index 250caef..0e9971e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,13 +22,14 @@ if (config.server.proxy) { logger.info('enabled express.js reverse proxy settings'); } +app.use(express.static('app/dist')); + app.use((req, res, next) => { logger.http(`${(config.server.proxy && req.headers['x-forwarded-for']) || req.connection.remoteAddress} ${req.method} ${req.originalUrl} `); res.setHeader('Access-Control-Allow-Origin', '*'); next(); }); -app.use(express.static('public')); app.use('/data', express.static('data', {extensions: ['flac', 'mp3']})); import get from './get';