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*
|
lerna-debug.log*
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
/dist/*
|
||||||
dist-ssr
|
/dist-ssr/*
|
||||||
*.local
|
*.local
|
||||||
|
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
@ -24,3 +25,6 @@ dist-ssr
|
|||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.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>
|
|
28
.vscode/launch.json
vendored
28
.vscode/launch.json
vendored
@ -7,31 +7,41 @@
|
|||||||
{
|
{
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Tauri Development Debug",
|
"name": "Debug Tauri Development",
|
||||||
"cargo": {
|
"cargo": {
|
||||||
"args": [
|
"args": [
|
||||||
"build",
|
"build",
|
||||||
"--manifest-path=./src-tauri/Cargo.toml",
|
"--bin=ziemniak",
|
||||||
|
"--package=ziemniak",
|
||||||
"--no-default-features"
|
"--no-default-features"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
// task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json`
|
// task for the `beforeDevCommand` if used, must be configured in `.vscode/tasks.json`
|
||||||
"preLaunchTask": "ui:dev"
|
"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",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Tauri Production Debug",
|
"name": "Tauri Production Debug",
|
||||||
"cargo": {
|
"cargo": {
|
||||||
"args": [
|
"args": ["build", "--release", "--manifest-path=./src-tauri/Cargo.toml"]
|
||||||
"build",
|
|
||||||
"--release",
|
|
||||||
"--manifest-path=./src-tauri/Cargo.toml"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
// task for the `beforeBuildCommand` if used, must be configured in `.vscode/tasks.json`
|
// task for the `beforeBuildCommand` if used, must be configured in `.vscode/tasks.json`
|
||||||
"preLaunchTask": "ui:build"
|
"preLaunchTask": "ui:build"
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
22
.vscode/tasks.json
vendored
22
.vscode/tasks.json
vendored
@ -8,13 +8,10 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "cargo",
|
"command": "cargo",
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"args": [
|
"args": ["tauri", "dev"],
|
||||||
"tauri",
|
|
||||||
"dev"
|
|
||||||
],
|
|
||||||
"icon": {
|
"icon": {
|
||||||
"id": "run"
|
"id": "run"
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "ui:dev",
|
"label": "ui:dev",
|
||||||
@ -22,13 +19,7 @@
|
|||||||
"isBackground": true,
|
"isBackground": true,
|
||||||
"command": "npm",
|
"command": "npm",
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"args": [
|
"args": ["run", "dev", "--", "--clearScreen", "false"]
|
||||||
"run",
|
|
||||||
"dev",
|
|
||||||
"--",
|
|
||||||
"--clearScreen",
|
|
||||||
"false"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "ui:build",
|
"label": "ui:build",
|
||||||
@ -36,10 +27,7 @@
|
|||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "npm",
|
"command": "npm",
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"args": [
|
"args": ["run", "build"]
|
||||||
"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",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||||
"tauri": "tauri"
|
"tauri": "tauri",
|
||||||
|
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
|
||||||
|
"format": "prettier --write --plugin-search-dir=. ."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^1.0.1",
|
"@sveltejs/vite-plugin-svelte": "^1.0.1",
|
||||||
"@tauri-apps/cli": "^1.0.5",
|
"@tauri-apps/cli": "^1.0.5",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||||
|
"@typescript-eslint/parser": "^5.31.0",
|
||||||
"@tsconfig/svelte": "^3.0.0",
|
"@tsconfig/svelte": "^3.0.0",
|
||||||
"@types/luxon": "^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": "^3.49.0",
|
||||||
"svelte-check": "^2.8.0",
|
"svelte-check": "^2.8.0",
|
||||||
"svelte-preprocess": "^4.10.7",
|
"svelte-preprocess": "^4.10.7",
|
||||||
"tslib": "^2.4.0",
|
"tslib": "^2.4.0",
|
||||||
"typescript": "^4.6.4",
|
"typescript": "^4.7.4",
|
||||||
"vite": "^3.0.0"
|
"vite": "^3.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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 {
|
impl Timer {
|
||||||
fn new(message: &str, duration: Duration) -> Self {
|
fn new(message: &str, duration: Duration) -> Self {
|
||||||
return Self {
|
Self {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
duration: duration,
|
duration,
|
||||||
message: message.to_string(),
|
message: message.to_string(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn complete(self: &Self) -> bool {
|
fn complete(&self) -> bool {
|
||||||
return self.elapsed.map_or(false, |e| e >= self.duration);
|
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());
|
self.started = Some(Local::now().into());
|
||||||
let mut elapsed = Duration::from_secs(0);
|
let mut elapsed = Duration::from_secs(0);
|
||||||
self.elapsed = Some(elapsed);
|
self.elapsed = Some(elapsed);
|
||||||
@ -45,14 +45,14 @@ impl Timer {
|
|||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let duration = now - last_checked;
|
let duration = now - last_checked;
|
||||||
|
|
||||||
elapsed = elapsed + duration;
|
elapsed += duration;
|
||||||
self.elapsed = Some(elapsed);
|
self.elapsed = Some(elapsed);
|
||||||
|
|
||||||
if self.complete() {
|
if self.complete() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(_) = window.emit("timer-tick", self.clone()) {
|
if window.emit("timer-tick", self.clone()).is_err() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
last_checked = now;
|
last_checked = now;
|
||||||
@ -67,7 +67,7 @@ impl Timer {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn start_timer(window: Window, duration: Duration, message: &str) -> Uuid {
|
fn start_timer(window: Window, duration: Duration, message: &str) -> Uuid {
|
||||||
let mut timer = Timer::new(message, duration);
|
let mut timer = Timer::new(message, duration);
|
||||||
let timer_id = timer.id.clone();
|
let timer_id = timer.id;
|
||||||
|
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
timer.run(window).await;
|
timer.run(window).await;
|
||||||
|
@ -1,25 +1,41 @@
|
|||||||
<script>
|
<script type="ts">
|
||||||
import { onDestroy } from 'svelte'
|
import { onDestroy, onMount } from "svelte";
|
||||||
import { invoke } from '@tauri-apps/api'
|
import type { UnlistenFn } from "@tauri-apps/api/event";
|
||||||
import { listen, once } 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() {
|
function start_timer() {
|
||||||
invoke('start_timer', {
|
invoke("start_timer", {
|
||||||
duration: { secs: seconds, nanos: 0 },
|
duration: { secs: seconds, nanos: 0 },
|
||||||
message: "Hi!",
|
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>
|
</script>
|
||||||
|
|
||||||
@ -28,5 +44,5 @@
|
|||||||
Fire after
|
Fire after
|
||||||
<input type="number" bind:value={seconds} />
|
<input type="number" bind:value={seconds} />
|
||||||
</label>
|
</label>
|
||||||
<button on:click="{start_timer}">Fire!</button>
|
<button on:click={start_timer}>Fire!</button>
|
||||||
</main>
|
</main>
|
||||||
|
12
src/main.ts
12
src/main.ts
@ -1,8 +1,10 @@
|
|||||||
import './app.css'
|
import "./app.css";
|
||||||
import App from './App.svelte'
|
import App from "./App.svelte";
|
||||||
|
|
||||||
|
|
||||||
const app = new App({
|
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 {
|
export default {
|
||||||
// Consult https://github.com/sveltejs/svelte-preprocess
|
// Consult https://github.com/sveltejs/svelte-preprocess
|
||||||
// for more information about preprocessors
|
// for more information about preprocessors
|
||||||
preprocess: sveltePreprocess()
|
preprocess: sveltePreprocess(),
|
||||||
}
|
};
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from "vite";
|
||||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
||||||
|
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [svelte()],
|
plugins: [svelte()],
|
||||||
build: {
|
build: {
|
||||||
write: true
|
write: true,
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user