From 7e0f83a19dfa8f2285039b4af32911dcf4b8e0e6 Mon Sep 17 00:00:00 2001 From: wukko Date: Tue, 16 Apr 2024 16:40:40 +0600 Subject: [PATCH] web: add svelte base and moved assets --- README.md | 2 +- web/.gitignore | 24 +++++++++ web/.vscode/extensions.json | 3 ++ web/README.md | 47 ++++++++++++++++++ web/index.html | 28 +++++++++++ web/jsconfig.json | 19 +++++++ web/package.json | 16 ++++++ .../public}/icons/android-chrome-192x192.png | Bin .../public}/icons/android-chrome-512x512.png | Bin .../public}/icons/apple-touch-icon.png | Bin .../public}/icons/favicon-16x16.png | Bin .../public}/icons/favicon-32x32.png | Bin {src/front => web/public}/icons/favicon.ico | Bin {src/front => web/public}/icons/generic.png | Bin {src/front => web/public}/icons/pattern.png | Bin .../public/manifest.json | 0 .../assets => web/public}/meowbalt/error.png | Bin .../public}/meowbalt/question.png | Bin {src/front => web/public}/robots.txt | 0 web/src/app.css | 5 ++ web/src/cobalt.svelte | 3 ++ web/src/main.js | 8 +++ web/src/vite-env.d.ts | 2 + web/svelte.config.js | 7 +++ web/vite.config.js | 7 +++ 25 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 web/.gitignore create mode 100644 web/.vscode/extensions.json create mode 100644 web/README.md create mode 100644 web/index.html create mode 100644 web/jsconfig.json create mode 100644 web/package.json rename {src/front => web/public}/icons/android-chrome-192x192.png (100%) rename {src/front => web/public}/icons/android-chrome-512x512.png (100%) rename {src/front => web/public}/icons/apple-touch-icon.png (100%) rename {src/front => web/public}/icons/favicon-16x16.png (100%) rename {src/front => web/public}/icons/favicon-32x32.png (100%) rename {src/front => web/public}/icons/favicon.ico (100%) rename {src/front => web/public}/icons/generic.png (100%) rename {src/front => web/public}/icons/pattern.png (100%) rename src/front/manifest.webmanifest => web/public/manifest.json (100%) rename {src/front/assets => web/public}/meowbalt/error.png (100%) rename {src/front/assets => web/public}/meowbalt/question.png (100%) rename {src/front => web/public}/robots.txt (100%) create mode 100644 web/src/app.css create mode 100644 web/src/cobalt.svelte create mode 100644 web/src/main.js create mode 100644 web/src/vite-env.d.ts create mode 100644 web/svelte.config.js create mode 100644 web/vite.config.js diff --git a/README.md b/README.md index 8374817a..9e70abf0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # cobalt best way to save what you love: [cobalt.tools](https://cobalt.tools/) -![cobalt logo with repeated logo (double arrow) pattern background](/src/front/icons/pattern.png "cobalt logo with repeated logo (double arrow) pattern background") +![cobalt logo with repeated logo (double arrow) pattern background](/web/public/icons/pattern.png "cobalt logo with repeated logo (double arrow) pattern background") ## what's cobalt? cobalt is a media downloader that doesn't piss you off. it's fast, friendly, and doesn't have any bullshit that modern web is filled with: ***no ads, trackers, or invasive analytics***. diff --git a/web/.gitignore b/web/.gitignore new file mode 100644 index 00000000..a547bf36 --- /dev/null +++ b/web/.gitignore @@ -0,0 +1,24 @@ +# 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/web/.vscode/extensions.json b/web/.vscode/extensions.json new file mode 100644 index 00000000..bdef8201 --- /dev/null +++ b/web/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["svelte.svelte-vscode"] +} diff --git a/web/README.md b/web/README.md new file mode 100644 index 00000000..382941e0 --- /dev/null +++ b/web/README.md @@ -0,0 +1,47 @@ +# 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. + +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/sveltejs/svelte-hmr/tree/master/packages/svelte-hmr#preservation-of-local-state). + +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/web/index.html b/web/index.html new file mode 100644 index 00000000..2472105e --- /dev/null +++ b/web/index.html @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + diff --git a/web/jsconfig.json b/web/jsconfig.json new file mode 100644 index 00000000..38e89d21 --- /dev/null +++ b/web/jsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "moduleResolution": "bundler", + "target": "ESNext", + "module": "ESNext", + "verbatimModuleSyntax": true, + "isolatedModules": true, + "resolveJsonModule": true, + "sourceMap": true, + "esModuleInterop": true, + "skipLibCheck": true, + "checkJs": true + }, + "include": [ + "src/**/*.d.ts", + "src/**/*.js", + "src/**/*.svelte" + ] +} \ No newline at end of file diff --git a/web/package.json b/web/package.json new file mode 100644 index 00000000..c4a65683 --- /dev/null +++ b/web/package.json @@ -0,0 +1,16 @@ +{ + "name": "cobalt-web", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.1.0", + "svelte": "^4.2.12", + "vite": "^5.2.0" + } +} \ No newline at end of file diff --git a/src/front/icons/android-chrome-192x192.png b/web/public/icons/android-chrome-192x192.png similarity index 100% rename from src/front/icons/android-chrome-192x192.png rename to web/public/icons/android-chrome-192x192.png diff --git a/src/front/icons/android-chrome-512x512.png b/web/public/icons/android-chrome-512x512.png similarity index 100% rename from src/front/icons/android-chrome-512x512.png rename to web/public/icons/android-chrome-512x512.png diff --git a/src/front/icons/apple-touch-icon.png b/web/public/icons/apple-touch-icon.png similarity index 100% rename from src/front/icons/apple-touch-icon.png rename to web/public/icons/apple-touch-icon.png diff --git a/src/front/icons/favicon-16x16.png b/web/public/icons/favicon-16x16.png similarity index 100% rename from src/front/icons/favicon-16x16.png rename to web/public/icons/favicon-16x16.png diff --git a/src/front/icons/favicon-32x32.png b/web/public/icons/favicon-32x32.png similarity index 100% rename from src/front/icons/favicon-32x32.png rename to web/public/icons/favicon-32x32.png diff --git a/src/front/icons/favicon.ico b/web/public/icons/favicon.ico similarity index 100% rename from src/front/icons/favicon.ico rename to web/public/icons/favicon.ico diff --git a/src/front/icons/generic.png b/web/public/icons/generic.png similarity index 100% rename from src/front/icons/generic.png rename to web/public/icons/generic.png diff --git a/src/front/icons/pattern.png b/web/public/icons/pattern.png similarity index 100% rename from src/front/icons/pattern.png rename to web/public/icons/pattern.png diff --git a/src/front/manifest.webmanifest b/web/public/manifest.json similarity index 100% rename from src/front/manifest.webmanifest rename to web/public/manifest.json diff --git a/src/front/assets/meowbalt/error.png b/web/public/meowbalt/error.png similarity index 100% rename from src/front/assets/meowbalt/error.png rename to web/public/meowbalt/error.png diff --git a/src/front/assets/meowbalt/question.png b/web/public/meowbalt/question.png similarity index 100% rename from src/front/assets/meowbalt/question.png rename to web/public/meowbalt/question.png diff --git a/src/front/robots.txt b/web/public/robots.txt similarity index 100% rename from src/front/robots.txt rename to web/public/robots.txt diff --git a/web/src/app.css b/web/src/app.css new file mode 100644 index 00000000..d8e3b664 --- /dev/null +++ b/web/src/app.css @@ -0,0 +1,5 @@ +html, +body { + margin: 0; + height: calc(100% + env(safe-area-inset-top)/2); +} \ No newline at end of file diff --git a/web/src/cobalt.svelte b/web/src/cobalt.svelte new file mode 100644 index 00000000..13f5cc13 --- /dev/null +++ b/web/src/cobalt.svelte @@ -0,0 +1,3 @@ +
+

Hello Bro

+
diff --git a/web/src/main.js b/web/src/main.js new file mode 100644 index 00000000..4e7515f4 --- /dev/null +++ b/web/src/main.js @@ -0,0 +1,8 @@ +import './app.css' +import App from './cobalt.svelte' + +const app = new App({ + target: document.getElementById('app'), +}) + +export default app diff --git a/web/src/vite-env.d.ts b/web/src/vite-env.d.ts new file mode 100644 index 00000000..4078e747 --- /dev/null +++ b/web/src/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/web/svelte.config.js b/web/svelte.config.js new file mode 100644 index 00000000..61eb947a --- /dev/null +++ b/web/svelte.config.js @@ -0,0 +1,7 @@ +import { vitePreprocess } from '@sveltejs/vite-plugin-svelte' + +export default { + // Consult https://svelte.dev/docs#compile-time-svelte-preprocess + // for more information about preprocessors + preprocess: vitePreprocess(), +} diff --git a/web/vite.config.js b/web/vite.config.js new file mode 100644 index 00000000..5f1c8cb2 --- /dev/null +++ b/web/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()], +})