Updates and build chain improvements
This commit is contained in:
parent
7d42fff1fb
commit
3265015284
14
.eslintignore
Normal file
14
.eslintignore
Normal file
@ -0,0 +1,14 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
/src-tauri
|
||||
/target
|
24
.eslintrc.cjs
Normal file
24
.eslintrc.cjs
Normal file
@ -0,0 +1,24 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
parser: "@typescript-eslint/parser",
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"prettier",
|
||||
],
|
||||
plugins: ["svelte3", "@typescript-eslint"],
|
||||
ignorePatterns: ["*.cjs"],
|
||||
overrides: [{ files: ["*.svelte"], processor: "svelte3/svelte3" }],
|
||||
settings: {
|
||||
"svelte3/typescript": () => require("typescript"),
|
||||
},
|
||||
parserOptions: {
|
||||
sourceType: "module",
|
||||
ecmaVersion: 2020,
|
||||
},
|
||||
env: {
|
||||
browser: true,
|
||||
es2017: true,
|
||||
node: true,
|
||||
},
|
||||
};
|
8
.gitignore
vendored
8
.gitignore
vendored
@ -8,10 +8,11 @@ pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
/dist/*
|
||||
/dist-ssr/*
|
||||
*.local
|
||||
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
@ -24,3 +25,6 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
!/**/.gitkeep
|
||||
/target/
|
||||
|
15
.prettierignore
Normal file
15
.prettierignore
Normal file
@ -0,0 +1,15 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
/src-tauri
|
||||
/target
|
@ -1,19 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Run" type="CargoCommandRunConfiguration" factoryName="Cargo Command" singleton="false">
|
||||
<option name="command" value="run --manifest-path ./src-tauri/Cargo.toml --no-default-features" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,19 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Tauri Dev" type="CargoCommandRunConfiguration" factoryName="Cargo Command">
|
||||
<option name="command" value="tauri dev" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
@ -1,12 +0,0 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="UI Dev Build" type="js.build_tools.npm" singleton="false">
|
||||
<package-json value="$PROJECT_DIR$/package.json" />
|
||||
<command value="run" />
|
||||
<scripts>
|
||||
<script value="dev" />
|
||||
</scripts>
|
||||
<node-interpreter value="project" />
|
||||
<envs />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
30
.vscode/launch.json
vendored
30
.vscode/launch.json
vendored
@ -7,31 +7,41 @@
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Tauri Development Debug",
|
||||
"name": "Debug Tauri Development",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--manifest-path=./src-tauri/Cargo.toml",
|
||||
"--bin=ziemniak",
|
||||
"--package=ziemniak",
|
||||
"--no-default-features"
|
||||
]
|
||||
},
|
||||
// task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json`
|
||||
"preLaunchTask": "ui:dev"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug Tauri Unit Tests",
|
||||
"cargo": {
|
||||
"args": ["test", "--no-run", "--bin=ziemniak", "--package=ziemniak"],
|
||||
"filter": {
|
||||
"name": "ziemniak",
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Tauri Production Debug",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"--release",
|
||||
"--manifest-path=./src-tauri/Cargo.toml"
|
||||
]
|
||||
"args": ["build", "--release", "--manifest-path=./src-tauri/Cargo.toml"]
|
||||
},
|
||||
// task for the `beforeBuildCommand` if used, must be configured in `.vscode/tasks.json`
|
||||
"preLaunchTask": "ui:build"
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
|
24
.vscode/tasks.json
vendored
24
.vscode/tasks.json
vendored
@ -8,13 +8,10 @@
|
||||
"type": "shell",
|
||||
"command": "cargo",
|
||||
"problemMatcher": [],
|
||||
"args": [
|
||||
"tauri",
|
||||
"dev"
|
||||
],
|
||||
"args": ["tauri", "dev"],
|
||||
"icon": {
|
||||
"id": "run"
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "ui:dev",
|
||||
@ -22,13 +19,7 @@
|
||||
"isBackground": true,
|
||||
"command": "npm",
|
||||
"problemMatcher": [],
|
||||
"args": [
|
||||
"run",
|
||||
"dev",
|
||||
"--",
|
||||
"--clearScreen",
|
||||
"false"
|
||||
]
|
||||
"args": ["run", "dev", "--", "--clearScreen", "false"]
|
||||
},
|
||||
{
|
||||
"label": "ui:build",
|
||||
@ -36,10 +27,7 @@
|
||||
"type": "shell",
|
||||
"command": "npm",
|
||||
"problemMatcher": [],
|
||||
"args": [
|
||||
"run",
|
||||
"build"
|
||||
"args": ["run", "build"]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
|
3732
Cargo.lock
generated
Normal file
3732
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
2
Cargo.toml
Normal file
2
Cargo.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[workspace]
|
||||
members = ["src-tauri"]
|
1948
package-lock.json
generated
1948
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@ -9,22 +9,31 @@
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"tauri": "tauri"
|
||||
"tauri": "tauri",
|
||||
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
|
||||
"format": "prettier --write --plugin-search-dir=. ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^1.0.1",
|
||||
"@tauri-apps/cli": "^1.0.5",
|
||||
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||
"@typescript-eslint/parser": "^5.31.0",
|
||||
"@tsconfig/svelte": "^3.0.0",
|
||||
"@types/luxon": "^3.0.0",
|
||||
"luxon": "^3.0.1",
|
||||
"eslint": "^8.20.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"eslint-plugin-svelte3": "^4.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"prettier-plugin-svelte": "^2.7.0",
|
||||
"svelte": "^3.49.0",
|
||||
"svelte-check": "^2.8.0",
|
||||
"svelte-preprocess": "^4.10.7",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "^4.6.4",
|
||||
"typescript": "^4.7.4",
|
||||
"vite": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.0.2"
|
||||
"@tauri-apps/api": "^1.0.2",
|
||||
"luxon": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
3
src-tauri/.gitignore
vendored
3
src-tauri/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
@ -21,19 +21,19 @@ struct Timer {
|
||||
|
||||
impl Timer {
|
||||
fn new(message: &str, duration: Duration) -> Self {
|
||||
return Self {
|
||||
Self {
|
||||
id: Uuid::new_v4(),
|
||||
duration: duration,
|
||||
duration,
|
||||
message: message.to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn complete(self: &Self) -> bool {
|
||||
return self.elapsed.map_or(false, |e| e >= self.duration);
|
||||
fn complete(&self) -> bool {
|
||||
self.elapsed.map_or(false, |e| e >= self.duration)
|
||||
}
|
||||
|
||||
async fn run(self: &mut Self, window: Window) {
|
||||
async fn run(&mut self, window: Window) {
|
||||
self.started = Some(Local::now().into());
|
||||
let mut elapsed = Duration::from_secs(0);
|
||||
self.elapsed = Some(elapsed);
|
||||
@ -45,14 +45,14 @@ impl Timer {
|
||||
let now = Instant::now();
|
||||
let duration = now - last_checked;
|
||||
|
||||
elapsed = elapsed + duration;
|
||||
elapsed += duration;
|
||||
self.elapsed = Some(elapsed);
|
||||
|
||||
if self.complete() {
|
||||
break;
|
||||
}
|
||||
|
||||
if let Err(_) = window.emit("timer-tick", self.clone()) {
|
||||
if window.emit("timer-tick", self.clone()).is_err() {
|
||||
break;
|
||||
}
|
||||
last_checked = now;
|
||||
@ -67,7 +67,7 @@ impl Timer {
|
||||
#[tauri::command]
|
||||
fn start_timer(window: Window, duration: Duration, message: &str) -> Uuid {
|
||||
let mut timer = Timer::new(message, duration);
|
||||
let timer_id = timer.id.clone();
|
||||
let timer_id = timer.id;
|
||||
|
||||
spawn(async move {
|
||||
timer.run(window).await;
|
||||
|
@ -1,25 +1,41 @@
|
||||
<script>
|
||||
import { onDestroy } from 'svelte'
|
||||
import { invoke } from '@tauri-apps/api'
|
||||
import { listen, once } from '@tauri-apps/api/event'
|
||||
<script type="ts">
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import type { UnlistenFn } from "@tauri-apps/api/event";
|
||||
import { invoke } from "@tauri-apps/api";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
|
||||
let seconds = 5
|
||||
let seconds = 5;
|
||||
let timer_tick_unlisten: Promise<UnlistenFn> | null = null;
|
||||
let timer_done_unlisten: Promise<UnlistenFn> | null = null;
|
||||
|
||||
type Timer = {
|
||||
id: string;
|
||||
elapsed: {
|
||||
secs: number;
|
||||
nsecs: number;
|
||||
};
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
timer_tick_unlisten = listen<Timer>("timer-tick", (event) => {
|
||||
console.log("Tick!", event.payload.id, event.payload.elapsed);
|
||||
});
|
||||
|
||||
timer_done_unlisten = listen<Timer>("timer-done", (event) => {
|
||||
console.log("Done!", event.payload.id);
|
||||
});
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
timer_tick_unlisten?.then((ttu) => ttu());
|
||||
timer_done_unlisten?.then((tdu) => tdu());
|
||||
});
|
||||
|
||||
function start_timer() {
|
||||
invoke('start_timer', {
|
||||
invoke("start_timer", {
|
||||
duration: { secs: seconds, nanos: 0 },
|
||||
message: "Hi!",
|
||||
})
|
||||
|
||||
let timer_tick_unlisten = listen('timer-tick', (event) => {
|
||||
console.log("Tick!", event.payload.id, event.payload.elapsed)
|
||||
})
|
||||
|
||||
once('timer-done', (event) => {
|
||||
console.log("Done!", event.payload.id)
|
||||
|
||||
timer_tick_unlisten.then(ttu => ttu())
|
||||
})
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -28,5 +44,5 @@
|
||||
Fire after
|
||||
<input type="number" bind:value={seconds} />
|
||||
</label>
|
||||
<button on:click="{start_timer}">Fire!</button>
|
||||
<button on:click={start_timer}>Fire!</button>
|
||||
</main>
|
||||
|
12
src/main.ts
12
src/main.ts
@ -1,8 +1,10 @@
|
||||
import './app.css'
|
||||
import App from './App.svelte'
|
||||
import "./app.css";
|
||||
import App from "./App.svelte";
|
||||
|
||||
|
||||
const app = new App({
|
||||
target: document.getElementById('app')
|
||||
})
|
||||
target: document.getElementById("app"),
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
||||
export default app
|
||||
|
@ -1,7 +1,7 @@
|
||||
import sveltePreprocess from 'svelte-preprocess'
|
||||
import sveltePreprocess from "svelte-preprocess";
|
||||
|
||||
export default {
|
||||
// Consult https://github.com/sveltejs/svelte-preprocess
|
||||
// for more information about preprocessors
|
||||
preprocess: sveltePreprocess()
|
||||
}
|
||||
preprocess: sveltePreprocess(),
|
||||
};
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
import { defineConfig } from "vite";
|
||||
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
||||
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
build: {
|
||||
write: true
|
||||
}
|
||||
})
|
||||
write: true,
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user