Skip to content

Commit

Permalink
chore: biome
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben committed Oct 7, 2024
1 parent 176d239 commit 4b71890
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 56 deletions.
12 changes: 6 additions & 6 deletions src/lib/components/core/header/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { _, locale } from "svelte-i18n";
import block from "$assets/block.svg";
import leaphyLogo from "$assets/leaphy-logo.svg";
import Connect from "$components/core/popups/popups/Connect.svelte";
import ErrorPopup from "$components/core/popups/popups/Error.svelte";
import Button from "$components/ui/Button.svelte";
import ContextItem from "$components/ui/ContextItem.svelte";
import { loadWorkspaceFromString } from "$domain/blockly/blockly";
Expand Down Expand Up @@ -65,7 +66,6 @@ import SaveProject from "../popups/popups/Prompt.svelte";
import UploadLog from "../popups/popups/UploadLog.svelte";
import Uploader from "../popups/popups/Uploader.svelte";
import Warning from "../popups/popups/Warning.svelte";
import Error from "$components/core/popups/popups/Error.svelte";
async function upload() {
window._paq.push(["trackEvent", "Main", "UploadClicked"]);
Expand Down Expand Up @@ -149,7 +149,7 @@ async function openProject() {
} else {
if (get(mode) === Mode.BLOCKS) {
if (!loadWorkspaceFromString(await content.text(), $workspace)) {
return
return;
}
} else {
restore.set(JSON.parse(await content.text()));
Expand All @@ -158,14 +158,14 @@ async function openProject() {
if (!robots[file.name.split(".").at(-1)]) {
popups.open({
component: Error,
component: ErrorPopup,
data: {
title: "UNDEFINED_ROBOT",
message: "UNDEFINED_ROBOT_MESSAGE",
},
allowInteraction: false
})
return
allowInteraction: false,
});
return;
}
robot.set(robots[file.name.split(".").at(-1)]);
Expand Down
50 changes: 25 additions & 25 deletions src/lib/components/core/popups/popups/Error.svelte
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<script lang="ts">
import Button from "$components/ui/Button.svelte";
import { type PopupState, popups } from "$state/popup.svelte";
import { getContext } from "svelte";
import { _ } from "svelte-i18n";
import type { Writable } from "svelte/store";
import Fa from "svelte-fa";
import {faExclamationTriangle} from "@fortawesome/free-solid-svg-icons";
import Feedback from "$components/core/popups/popups/Feedback.svelte";
import Feedback from "$components/core/popups/popups/Feedback.svelte";
import Button from "$components/ui/Button.svelte";
import { type PopupState, popups } from "$state/popup.svelte";
import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons";
import { getContext } from "svelte";
import Fa from "svelte-fa";
import { _ } from "svelte-i18n";
import type { Writable } from "svelte/store";
interface Props {
title: string;
message: string;
}
interface Props {
title: string;
message: string;
}
const { title, message }: Props = $props();
const { title, message }: Props = $props();
const popupState = getContext<Writable<PopupState>>("state");
function ok() {
popups.close($popupState.id);
}
const popupState = getContext<Writable<PopupState>>("state");
function ok() {
popups.close($popupState.id);
}
function feedback() {
popups.close($popupState.id);
popups.open({
component: Feedback,
data: {},
allowInteraction: false
});
}
function feedback() {
popups.close($popupState.id);
popups.open({
component: Feedback,
data: {},
allowInteraction: false,
});
}
</script>

<div class="content">
Expand Down
12 changes: 6 additions & 6 deletions src/lib/components/core/popups/popups/SerialMonitor.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<script lang="ts">
import ErrorPopup from "$components/core/popups/popups/Error.svelte";
import Button from "$components/ui/Button.svelte";
import Chart from "$components/ui/Chart.svelte";
import TextInput from "$components/ui/TextInput.svelte";
import WindowButton from "$components/ui/WindowButton.svelte";
import { popups } from "$state/popup.svelte";
import { Prompt, log, port } from "$state/workspace.svelte";
import {
faArrowDown,
Expand All @@ -17,8 +19,6 @@ import Fa from "svelte-fa";
import { _ } from "svelte-i18n";
import { get } from "svelte/store";
import Windowed from "../Windowed.svelte";
import {popups} from "$state/popup.svelte";
import Error from "$components/core/popups/popups/Error.svelte";
enum Mode {
TEXT = 0,
Expand Down Expand Up @@ -52,13 +52,13 @@ function send(event: SubmitEvent) {
log.write(`${value}\n`);
} catch {
popups.open({
component: Error,
component: ErrorPopup,
data: {
title: "ROBOT_RESERVED",
message: "ROBOT_RESERVED_MESSAGE"
message: "ROBOT_RESERVED_MESSAGE",
},
allowInteraction: false
})
allowInteraction: false,
});
}
value = "";
Expand Down
12 changes: 6 additions & 6 deletions src/lib/components/core/popups/popups/Uploader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { _ } from "svelte-i18n";
import DriverInstall from "$components/core/popups/popups/DriverInstall.svelte";
import ErrorPopup from "$components/core/popups/popups/Error.svelte";
import Button from "$components/ui/Button.svelte";
import ProgressBar from "$components/ui/ProgressBar.svelte";
import { type PopupState, popups } from "$state/popup.svelte";
Expand All @@ -17,7 +18,6 @@ import JSZip from "jszip";
import { getContext, onMount } from "svelte";
import type { Writable } from "svelte/store";
import { downloadDrivers } from "../../../../drivers";
import Error from "$components/core/popups/popups/Error.svelte";
interface Props {
source?: string;
Expand All @@ -31,7 +31,7 @@ let error = $state<string | null>(null);
let done = $state(false);
let failed = $state(false);
class UploadError extends Error {
class UploadError extends ErrorPopup {
constructor(
public name: string,
public description: string,
Expand Down Expand Up @@ -76,13 +76,13 @@ async function upload(res: Record<string, string>) {
} catch {
popups.close($popupState.id);
return popups.open({
component: Error,
component: ErrorPopup,
data: {
title: "ROBOT_RESERVED",
message: "ROBOT_RESERVED_MESSAGE"
message: "ROBOT_RESERVED_MESSAGE",
},
allowInteraction: false
})
allowInteraction: false,
});
}
await $robot.programmer.upload($port, res);
Expand Down
14 changes: 7 additions & 7 deletions src/lib/domain/blockly/blockly.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Blockly from "blockly";
import "@blockly/field-bitmap";
import defaultProgram from "$assets/default-program.json?raw";
import ErrorPopup from "$components/core/popups/popups/Error.svelte";
import Explanation from "$components/core/popups/popups/Explanation.svelte";
import Prompt from "$components/core/popups/popups/Prompt.svelte";
import { type RobotDevice, inFilter } from "$domain/robots";
Expand Down Expand Up @@ -34,7 +35,6 @@ import { LeaphyCategory } from "./category-ui/category";
import { LeaphyToolbox } from "./category-ui/toolbox";
import PinSelectorField from "./fields";
import toolbox from "./toolbox";
import Error from "$components/core/popups/popups/Error.svelte";

Blockly.defineBlocksWithJsonArray(blocks);
Blockly.fieldRegistry.register("field_pin_selector", PinSelectorField);
Expand Down Expand Up @@ -171,18 +171,18 @@ export function loadWorkspaceFromString(content: string, workspace: Workspace) {
Blockly.Xml.domToWorkspace(xml, workspace);
} catch {
popups.open({
component: Error,
component: ErrorPopup,
data: {
title: "INVALID_WORKSPACE",
message: "INVALID_WORKSPACE_MESSAGE",
},
allowInteraction: false
})
return false
allowInteraction: false,
});
return false;
}
}

return true
return true;
}

export function setupWorkspace(
Expand Down Expand Up @@ -334,7 +334,7 @@ export async function explain(block: Blockly.BlockSvg) {
model: "Llama3-70b-8192",
}),
}).then(async (res) => {
if (!res.ok) throw new Error(res.statusText);
if (!res.ok) throw new ErrorPopup(res.statusText);
return JSON.parse(await res.text());
}),
},
Expand Down
12 changes: 6 additions & 6 deletions src/lib/state/workspace.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ErrorPopup from "$components/core/popups/popups/Error.svelte";
import Advanced from "$components/workspace/advanced/Advanced.svelte";
import Blocks from "$components/workspace/blocks/Blocks.svelte";
import Python from "$components/workspace/python/Python.svelte";
Expand All @@ -12,7 +13,6 @@ import type MicroPythonIO from "../micropython";
import type { IOEventTarget } from "../micropython";
import { workspace } from "./blockly.svelte";
import { popups } from "./popup.svelte";
import Error from "$components/core/popups/popups/Error.svelte";

export type LeaphyPort =
| SerialPort
Expand Down Expand Up @@ -132,13 +132,13 @@ function createPortState() {
set(undefined);
if (showFeedback) {
popups.open({
component: Error,
component: ErrorPopup,
data: {
title: "ROBOT_RESERVED",
message: "ROBOT_RESERVED_MESSAGE"
message: "ROBOT_RESERVED_MESSAGE",
},
allowInteraction: false
})
allowInteraction: false,
});
}

onFailure();
Expand Down Expand Up @@ -250,7 +250,7 @@ function createPortState() {
});

const port = await this.requestPort(prompt);
if (get({ subscribe }) === port) return onReady()
if (get({ subscribe }) === port) return onReady();

if ("addEventListener" in port) {
port.addEventListener("disconnect", async () => {
Expand Down

0 comments on commit 4b71890

Please sign in to comment.