Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
phenomen committed Feb 24, 2025
2 parents 23115e9 + cf1c04d commit 124e88b
Show file tree
Hide file tree
Showing 10 changed files with 371 additions and 355 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

# v6.9.6

- `better-fetch` for type-safe server status check.
- Updated all deps.

# v6.9.5

- Switch from `tauri:http` to a default `fetch`.
Expand Down
548 changes: 273 additions & 275 deletions package-lock.json

Large diffs are not rendered by default.

37 changes: 18 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flc",
"version": "6.9.5",
"version": "6.9.6",
"description": "Foundry Lightweight Client",
"type": "module",
"scripts": {
Expand All @@ -12,47 +12,46 @@
"tauri": "tauri",
"format": "prettier --write .",
"lint": "prettier --check . && eslint .",
"ui:add": "npx [email protected].4 add",
"ui:update": "npx [email protected].4 update"
"ui:add": "npx [email protected].5 add",
"ui:update": "npx [email protected].5 update"
},
"license": "MIT",
"devDependencies": {
"@better-fetch/fetch": "^1.1.15",
"@fontsource-variable/inter": "^5.1.1",
"@sveltejs/adapter-static": "^3.0.8",
"@sveltejs/kit": "^2.16.1",
"@sveltejs/kit": "^2.17.2",
"@sveltejs/vite-plugin-svelte": "^5.0.3",
"@tauri-apps/api": "^2.2.0",
"@tauri-apps/cli": "^2.2.7",
"@tauri-apps/plugin-dialog": "^2.2.0",
"@tauri-apps/plugin-global-shortcut": "^2.2.0",
"@tauri-apps/plugin-shell": "^2.2.0",
"@tauri-apps/plugin-updater": "^2.4.0",
"@tauri-apps/plugin-updater": "^2.5.1",
"@types/eslint": "^9.6.1",
"autoprefixer": "^10.4.20",
"bits-ui": "^1.0.0-next.79",
"bits-ui": "^1.3.2",
"clsx": "^2.1.1",
"eslint": "^9.19.0",
"eslint": "^9.21.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-svelte": "^2.46.1",
"globals": "^15.14.0",
"lucide-svelte": "^0.474.0",
"globals": "^16.0.0",
"lucide-svelte": "^0.475.0",
"mode-watcher": "^0.5.1",
"prettier": "^3.4.2",
"prettier": "^3.5.2",
"prettier-plugin-svelte": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.11",
"runed": "^0.23.1",
"svelte": "^5.19.5",
"runed": "^0.23.4",
"svelte": "^5.20.4",
"svelte-check": "^4.1.4",
"tailwind-merge": "^2.6.0",
"tailwind-merge": "^3.0.2",
"tailwind-variants": "^0.3.1",
"tailwindcss": "^3.4.17",
"tailwindcss-animate": "^1.0.7",
"tslib": "^2.8.1",
"typescript": "^5.7.3",
"typescript-eslint": "^8.22.0",
"valibot": "^1.0.0-beta.14",
"vite": "^6.0.11"
},
"dependencies": {
"@fontsource-variable/inter": "^5.1.1"
"typescript-eslint": "^8.25.0",
"valibot": "^1.0.0-rc.1",
"vite": "^6.1.1"
}
}
8 changes: 4 additions & 4 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flc"
version = "6.9.5"
version = "6.9.6"
description = "Foundry Lightweight Client"
authors = ["phenomen"]
license = "MIT"
Expand All @@ -14,9 +14,9 @@ incremental = true # Compile your binary in smaller steps.

[profile.release]
codegen-units = 1 # Allows LLVM to perform better optimization.
lto = true # Enables link-time-optimizations.
panic = "abort" # Higher performance by disabling panic handlers.
strip = true # Ensures debug symbols are removed.
lto = true # Enables link-time-optimizations.
panic = "abort" # Higher performance by disabling panic handlers.
strip = true # Ensures debug symbols are removed.

[lib]
# The `_lib` suffix may seem redundant but it is necessary
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "FLC",
"version": "6.9.5",
"version": "6.9.6",
"identifier": "com.phenomen.flc",
"build": {
"beforeDevCommand": "npm run dev",
Expand Down
10 changes: 6 additions & 4 deletions src/lib/components/ServerCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
SmileIcon,
ZapIcon,
DicesIcon,
HexagonIcon,
ArrowUpIcon,
ArrowDownIcon
HexagonIcon
} from "lucide-svelte";
import type { ServerStatus } from "$scripts/servers.svelte.js";
Expand Down Expand Up @@ -68,7 +66,11 @@
async function handleCheckStatus() {
status = undefined;
({ status } = await checkStatus(url));
const response = await checkStatus(url);
if (response.status) {
status = response.status;
}
}
onMount(async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ui/avatar/avatar-fallback.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

<AvatarPrimitive.Fallback
bind:ref
class={cn("bg-muted flex h-full w-full items-center justify-center rounded-full", className)}
class={cn("bg-muted flex size-full items-center justify-center", className)}
{...restProps}
/>
6 changes: 1 addition & 5 deletions src/lib/components/ui/avatar/avatar-image.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@
}: AvatarPrimitive.ImageProps = $props();
</script>

<AvatarPrimitive.Image
bind:ref
class={cn("aspect-square h-full w-full", className)}
{...restProps}
/>
<AvatarPrimitive.Image bind:ref class={cn("aspect-square size-full", className)} {...restProps} />
46 changes: 35 additions & 11 deletions src/lib/components/ui/input/input.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,46 @@
<script lang="ts">
import type { HTMLInputAttributes } from "svelte/elements";
import type { HTMLInputAttributes, HTMLInputTypeAttribute } from "svelte/elements";
import type { WithElementRef } from "bits-ui";
import { cn } from "$lib/utils.js";
type InputType = Exclude<HTMLInputTypeAttribute, "file">;
type Props = WithElementRef<
Omit<HTMLInputAttributes, "type"> &
({ type: "file"; files?: FileList } | { type?: InputType; files?: undefined })
>;
let {
ref = $bindable(null),
value = $bindable(),
type,
files = $bindable(),
class: className,
...restProps
}: WithElementRef<HTMLInputAttributes> = $props();
}: Props = $props();
</script>

<input
bind:this={ref}
class={cn(
"border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-base file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
className
)}
bind:value
{...restProps}
/>
{#if type === "file"}
<input
bind:this={ref}
class={cn(
"border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-base file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
className
)}
type="file"
bind:files
bind:value
{...restProps}
/>
{:else}
<input
bind:this={ref}
class={cn(
"border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-base file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
className
)}
{type}
bind:value
{...restProps}
/>
{/if}
62 changes: 27 additions & 35 deletions src/lib/scripts/servers.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
import { PersistedState } from "runed";
import { nanoid } from "nanoid";
import * as v from "valibot";
import { betterFetch } from "@better-fetch/fetch";

const statusSchema = v.object({
active: v.optional(v.boolean()),
version: v.optional(v.string()),
world: v.optional(v.string()),
system: v.optional(v.string()),
users: v.optional(v.number()),
partner: v.optional(v.string())
});

export type ServerStatus = {
active?: boolean;
version?: string;
world?: string;
system?: string;
users?: number;
partner?: string;
};

type StatusResponse = {
status: ServerStatus | undefined;
};

const ERROR_MESSAGES = {
serverName: "Please enter a server name",
validUrl: "Please enter a correct URL starting with either http:// or https://"
};
export type ServerStatus = v.InferOutput<typeof statusSchema>;

const ServerSchema = v.object({
id: v.string(),
label: v.pipe(v.string(), v.trim(), v.minLength(1, ERROR_MESSAGES.serverName)),
url: v.pipe(v.string(), v.trim(), v.regex(/^https?:\/\//, ERROR_MESSAGES.validUrl)),
label: v.pipe(v.string(), v.trim(), v.minLength(1, "Please enter a server name")),
url: v.pipe(
v.string(),
v.trim(),
v.regex(/^https?:\/\//, "Please enter a correct URL starting with either http:// or https://")
),
notes: v.optional(v.string())
});

Expand Down Expand Up @@ -83,29 +81,23 @@ export function updateServer(data: Server) {
return result;
}

export async function checkStatus(url: string): Promise<StatusResponse> {
export async function checkStatus(url: string) {
const partner = PARTNERS.find((p) => url.includes(p.url))?.name;
if (partner) return { status: { partner } };

const cleanUrl = url.replace(/\/+$/, "").replace(/\/(game|join)$/, "");

try {
const response = await fetch(`${cleanUrl}/api/status`, {
method: "GET",
headers: {
"Content-Type": "application/json"
}
});

if (!response.ok) {
console.warn(`Server ${url} returned status ${response.status}`);
return { status: undefined };
const { data, error } = await betterFetch(`${cleanUrl}/api/status`, {
output: statusSchema,
method: "GET",
headers: {
"Content-Type": "application/json"
}
});

const status = await response.json();
return { status: { ...status, partner: undefined } };
} catch (error) {
console.warn(`Server ${url} is not responding`);
if (error) {
return { status: undefined };
}

return { status: data || undefined };
}

0 comments on commit 124e88b

Please sign in to comment.