From 1039c2694de560fb319b6afa9117b2e685852136 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Tue, 14 Oct 2025 21:35:40 +0300 Subject: [PATCH] Svelte 5 --- app/nextgraph/.prettierrc | 1 + app/nextgraph/index.html | 37 +++++----------- app/nextgraph/package.json | 7 ++- app/nextgraph/src/App.svelte | 23 ++++++++++ app/nextgraph/src/main.ts | 24 ++-------- app/nextgraph/svelte.config.js | 6 +++ app/nextgraph/tailwind.config.js | 19 ++++---- app/nextgraph/vite.config.ts | 67 ++++++++++++++-------------- pnpm-lock.yaml | 76 ++++++++++++++++++++++++++++++-- 9 files changed, 163 insertions(+), 97 deletions(-) create mode 100644 app/nextgraph/src/App.svelte create mode 100644 app/nextgraph/svelte.config.js diff --git a/app/nextgraph/.prettierrc b/app/nextgraph/.prettierrc index d4a47b9..5e3c25c 100644 --- a/app/nextgraph/.prettierrc +++ b/app/nextgraph/.prettierrc @@ -3,6 +3,7 @@ "singleQuote": false, "trailingComma": "none", "printWidth": 100, + "tabWidth": 4, "plugins": [ "prettier-plugin-svelte" ], diff --git a/app/nextgraph/index.html b/app/nextgraph/index.html index d9c7f43..e25b829 100644 --- a/app/nextgraph/index.html +++ b/app/nextgraph/index.html @@ -1,31 +1,14 @@ - - - - - Tauri App - - + + + + + NextGraph + + - - -
-

Garlic bread with cheese: What the science tells us

-

- For years parents have espoused the health benefits of eating garlic bread with cheese to their - children, with the food earning such an iconic status in our culture that kids will often dress - up as warm, cheesy loaf for Halloween. -

-

- But a recent study shows that the celebrated appetizer may be linked to a series of rabies cases - springing up around the country. -

- -
- + +
+ diff --git a/app/nextgraph/package.json b/app/nextgraph/package.json index eebd423..6bdb313 100644 --- a/app/nextgraph/package.json +++ b/app/nextgraph/package.json @@ -8,22 +8,25 @@ "build": "tsc && vite build", "preview": "vite preview", "tauri": "tauri", - "lint": "prettier --write ." + "format": "prettier --write .", + "check": "svelte-check --tsconfig ./tsconfig.json" }, "dependencies": { - "@tailwindcss/vite": "^4.1.14", + "@dvcol/svelte-simple-router": "^2.7.2", "@tauri-apps/api": "^2", "@tauri-apps/plugin-opener": "^2" }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^6.2.1", "@tailwindcss/typography": "^0.5.19", + "@tailwindcss/vite": "^4.1.14", "@tauri-apps/cli": "^2.8.4", "@tsconfig/svelte": "^5.0.5", "daisyui": "^5.3.1", "prettier": "^3.6.2", "prettier-plugin-svelte": "^3.4.0", "svelte": "^5.39.13", + "svelte-check": "^4.3.3", "tailwindcss": "^4.1.14", "typescript": "~5.6.2", "vite": "^7.1.7" diff --git a/app/nextgraph/src/App.svelte b/app/nextgraph/src/App.svelte new file mode 100644 index 0000000..23fe71d --- /dev/null +++ b/app/nextgraph/src/App.svelte @@ -0,0 +1,23 @@ + + + + +
+

Garlic bread with cheese: What the science tells us

+

+ For years parents have espoused the health benefits of eating garlic bread with cheese to + their children, with the food earning such an iconic status in our culture that kids will + often dress up as warm, cheesy loaf for Halloween. +

+

+ But a recent study shows that the celebrated appetizer may be linked to a series of rabies + cases springing up around the country. +

+
+ + diff --git a/app/nextgraph/src/main.ts b/app/nextgraph/src/main.ts index 4783341..1985ae2 100644 --- a/app/nextgraph/src/main.ts +++ b/app/nextgraph/src/main.ts @@ -1,22 +1,6 @@ -import { invoke } from "@tauri-apps/api/core"; +import { mount } from "svelte"; +import App from "./App.svelte"; -let greetInputEl: HTMLInputElement | null; -let greetMsgEl: HTMLElement | null; +const app = mount(App, { target: document.getElementById("app") as Element }); -async function greet() { - if (greetMsgEl && greetInputEl) { - // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ - greetMsgEl.textContent = await invoke("greet", { - name: greetInputEl.value, - }); - } -} - -window.addEventListener("DOMContentLoaded", () => { - greetInputEl = document.querySelector("#greet-input"); - greetMsgEl = document.querySelector("#greet-msg"); - document.querySelector("#greet-form")?.addEventListener("submit", (e) => { - e.preventDefault(); - greet(); - }); -}); +export default app; diff --git a/app/nextgraph/svelte.config.js b/app/nextgraph/svelte.config.js new file mode 100644 index 0000000..8773783 --- /dev/null +++ b/app/nextgraph/svelte.config.js @@ -0,0 +1,6 @@ +// svelte.config.js +export default { + vitePlugin: { + //inspector: true + } +}; diff --git a/app/nextgraph/tailwind.config.js b/app/nextgraph/tailwind.config.js index ee634ce..d5b2b91 100644 --- a/app/nextgraph/tailwind.config.js +++ b/app/nextgraph/tailwind.config.js @@ -1,12 +1,11 @@ /** @type {import('tailwindcss').Config} */ export default { - content: ['./src/**/*.{html,js,svelte,ts}'], - theme: { - extend: {}, - }, - plugins: [], - daisyui: { - //themes: ['valentine'] - } -} - + content: ["./src/**/*.{html,js,svelte,ts}"], + theme: { + extend: {} + }, + plugins: [], + daisyui: { + //themes: ['valentine'] + } +}; diff --git a/app/nextgraph/vite.config.ts b/app/nextgraph/vite.config.ts index 5199221..5fc4b94 100644 --- a/app/nextgraph/vite.config.ts +++ b/app/nextgraph/vite.config.ts @@ -1,44 +1,41 @@ -import tailwindcss from "@tailwindcss/vite" +import tailwindcss from "@tailwindcss/vite"; import { defineConfig } from "vite"; -import { svelte } from '@sveltejs/vite-plugin-svelte' +import { svelte } from "@sveltejs/vite-plugin-svelte"; const host = process.env.TAURI_DEV_HOST; // https://vite.dev/config/ export default defineConfig({ - plugins: [tailwindcss(), svelte()], - // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` - // - // 1. prevent Vite from obscuring rust errors - clearScreen: false, - // 2. tauri expects a fixed port, fail if that port is not available - server: { - port: 5173, - strictPort: true, - host: host || false, - hmr: host - ? { - protocol: "ws", - host, - port: 1421, + plugins: [tailwindcss(), svelte()], + // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` + // + // 1. prevent Vite from obscuring rust errors + clearScreen: false, + // 2. tauri expects a fixed port, fail if that port is not available + server: { + port: 5173, + strictPort: true, + host: host || false, + hmr: host + ? { + protocol: "ws", + host, + port: 1421 + } + : undefined, + watch: { + // 3. tell Vite to ignore watching `src-tauri` + ignored: ["**/src-tauri/**"] } - : undefined, - watch: { - // 3. tell Vite to ignore watching `src-tauri` - ignored: ["**/src-tauri/**"], }, - }, - // Env variables starting with the item of `envPrefix` will be exposed in tauri's source code through `import.meta.env`. - envPrefix: ['VITE_', 'TAURI_ENV_*'], - build: { - // Tauri uses Chromium on Windows and WebKit on macOS and Linux - target: - process.env.TAURI_ENV_PLATFORM == 'windows' - ? 'chrome105' - : 'safari13', - // don't minify for debug builds - minify: !process.env.TAURI_ENV_DEBUG ? 'esbuild' : false, - // produce sourcemaps for debug builds - sourcemap: !!process.env.TAURI_ENV_DEBUG, - }, + // Env variables starting with the item of `envPrefix` will be exposed in tauri's source code through `import.meta.env`. + envPrefix: ["VITE_", "TAURI_ENV_*"], + build: { + // Tauri uses Chromium on Windows and WebKit on macOS and Linux + target: process.env.TAURI_ENV_PLATFORM == "windows" ? "chrome105" : "safari13", + // don't minify for debug builds + minify: !process.env.TAURI_ENV_DEBUG ? "esbuild" : false, + // produce sourcemaps for debug builds + sourcemap: !!process.env.TAURI_ENV_DEBUG + } }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1da5a17..21c7883 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,9 +17,9 @@ importers: app/nextgraph: dependencies: - '@tailwindcss/vite': - specifier: ^4.1.14 - version: 4.1.14(vite@7.1.10(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.30.1)(yaml@2.8.1)) + '@dvcol/svelte-simple-router': + specifier: ^2.7.2 + version: 2.7.2(svelte@5.39.13) '@tauri-apps/api': specifier: ^2 version: 2.8.0 @@ -33,6 +33,9 @@ importers: '@tailwindcss/typography': specifier: ^0.5.19 version: 0.5.19(tailwindcss@4.1.14) + '@tailwindcss/vite': + specifier: ^4.1.14 + version: 4.1.14(vite@7.1.10(@types/node@24.3.0)(jiti@2.6.1)(lightningcss@1.30.1)(yaml@2.8.1)) '@tauri-apps/cli': specifier: ^2.8.4 version: 2.8.4 @@ -51,6 +54,9 @@ importers: svelte: specifier: ^5.39.13 version: 5.39.13 + svelte-check: + specifier: ^4.3.3 + version: 4.3.3(picomatch@4.0.3)(svelte@5.39.13)(typescript@5.6.3) tailwindcss: specifier: ^4.1.14 version: 4.1.14 @@ -1099,6 +1105,22 @@ packages: resolution: {integrity: sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==} engines: {node: '>=18'} + '@dvcol/common-utils@1.34.0': + resolution: {integrity: sha512-8PojenuhCK8FZyWcToYII5W0WNiaYw+wi6UPfPExHbA2gANuBtjVzdZVYVOJNEMdHXMNatR9b3m37ppl8+1Mnw==} + engines: {node: '>=20', pnpm: '>= 8'} + + '@dvcol/svelte-simple-router@2.7.2': + resolution: {integrity: sha512-n5lyygj6x1rEi66ZKTxeG1tucDL9Mxf20fuefupoKhhvGR5hssjkxlc44tmFAcCXI8B4koDcUDVSJ5ZRfbUMZg==} + engines: {node: '>=20', pnpm: '>= 8'} + peerDependencies: + svelte: '>=5' + + '@dvcol/svelte-utils@1.21.1': + resolution: {integrity: sha512-6o0phiLOZeCKgeRPeI5gfXbw/aLZfwAR6MKNcXVBDVt+84Yy2LJ6kSTAiQyCiAxsc3OGlY3IMylrBXf4Yp6ogw==} + engines: {node: '>=20', pnpm: '>= 8'} + peerDependencies: + svelte: '>=5' + '@emnapi/runtime@1.5.0': resolution: {integrity: sha512-97/BJ3iXHww3djw6hYIfErCZFee7qCtrneuLa20UXFCOTCfBM2cvQHjWJ2EG0s0MtdNwInarqCTz35i4wWXHsQ==} @@ -5167,6 +5189,10 @@ packages: engines: {node: '>=14'} hasBin: true + pretty-bytes@6.1.1: + resolution: {integrity: sha512-mQUvGU6aUFQ+rNvTIAcZuWGRT9a6f6Yrg9bHs4ImKF+HZCEK+plBvnAZYSIQztknZF2qnzNtr6F8s0+IuptdlQ==} + engines: {node: ^14.13.1 || >=16.0.0} + pretty-format@29.7.0: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -5674,6 +5700,14 @@ packages: peerDependencies: svelte: ^3.55.0 || ^4.0.0-next.0 || ^4.0.0 || ^5.0.0-next.0 + svelte-check@4.3.3: + resolution: {integrity: sha512-RYP0bEwenDXzfv0P1sKAwjZSlaRyqBn0Fz1TVni58lqyEiqgwztTpmodJrGzP6ZT2aHl4MbTvWP6gbmQ3FOnBg==} + engines: {node: '>= 18.0.0'} + hasBin: true + peerDependencies: + svelte: ^4.0.0 || ^5.0.0-next.0 + typescript: '>=5.0.0' + svelte-heros-v2@0.10.12: resolution: {integrity: sha512-0wspy0z9UFS9f/iPKQQ1JDHlNY6e7h+LVW+wJ0qJnuWDpvsJllmoCX2g0frYbMPDWZJEwh2pkO25Dp3lDGCxGQ==} peerDependencies: @@ -6122,6 +6156,10 @@ packages: resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==} hasBin: true + uuid@11.1.0: + resolution: {integrity: sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==} + hasBin: true + uuid@8.3.2: resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==} hasBin: true @@ -7301,6 +7339,22 @@ snapshots: '@csstools/css-tokenizer@3.0.4': optional: true + '@dvcol/common-utils@1.34.0': + dependencies: + pretty-bytes: 6.1.1 + uuid: 11.1.0 + + '@dvcol/svelte-simple-router@2.7.2(svelte@5.39.13)': + dependencies: + '@dvcol/common-utils': 1.34.0 + '@dvcol/svelte-utils': 1.21.1(svelte@5.39.13) + svelte: 5.39.13 + + '@dvcol/svelte-utils@1.21.1(svelte@5.39.13)': + dependencies: + '@dvcol/common-utils': 1.34.0 + svelte: 5.39.13 + '@emnapi/runtime@1.5.0': dependencies: tslib: 2.8.1 @@ -11589,6 +11643,8 @@ snapshots: prettier@3.6.2: {} + pretty-bytes@6.1.1: {} + pretty-format@29.7.0: dependencies: '@jest/schemas': 29.6.3 @@ -12327,6 +12383,18 @@ snapshots: - stylus - sugarss + svelte-check@4.3.3(picomatch@4.0.3)(svelte@5.39.13)(typescript@5.6.3): + dependencies: + '@jridgewell/trace-mapping': 0.3.31 + chokidar: 4.0.3 + fdir: 6.5.0(picomatch@4.0.3) + picocolors: 1.1.1 + sade: 1.8.1 + svelte: 5.39.13 + typescript: 5.6.3 + transitivePeerDependencies: + - picomatch + svelte-heros-v2@0.10.12(svelte@3.59.2): dependencies: svelte: 3.59.2 @@ -12782,6 +12850,8 @@ snapshots: uuid@10.0.0: {} + uuid@11.1.0: {} + uuid@8.3.2: {} uuid@9.0.1: {}