diff --git a/bun.lockb b/bun.lockb index 6480ec87..232920a2 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index cb3d499c..ed884f52 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "@sveltejs/vite-plugin-svelte": "^4.0.0", "@tailwindcss/container-queries": "^0.1.1", "@tailwindcss/postcss": "^4.1.8", - "@types/nprogress": "^0.2.0", "@types/ua-parser-js": "^0.7.39", "eslint": "^9.28.0", "eslint-plugin-svelte": "^3.9.1", @@ -23,7 +22,6 @@ "linkify-it": "^5.0.0", "marked": "7.0.5", "marked-linkify-it": "^3.1.10", - "nprogress": "^0.2.0", "postcss": "^8.4.30", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.7", diff --git a/src/lib/components/lemmy/comment/comments.svelte.ts b/src/lib/components/lemmy/comment/comments.svelte.ts index 9a8b4aed..1234938e 100644 --- a/src/lib/components/lemmy/comment/comments.svelte.ts +++ b/src/lib/components/lemmy/comment/comments.svelte.ts @@ -1,4 +1,5 @@ import type { Comment, CommentView } from 'lemmy-js-client' +import { SvelteMap } from 'svelte/reactivity' export interface CommentNodeI { comment_view: CommentView @@ -28,7 +29,7 @@ export function buildCommentsTree( baseDepth: number = 0, filter: (c: CommentView) => boolean = () => true, ): CommentNodeI[] { - const map = new Map() + const map = new SvelteMap() let min_depth = Number.MAX_VALUE for (const comment_view of comments) { diff --git a/src/lib/components/lemmy/moderation/ModerationMenu.svelte b/src/lib/components/lemmy/moderation/ModerationMenu.svelte index ee02024e..ea56015a 100644 --- a/src/lib/components/lemmy/moderation/ModerationMenu.svelte +++ b/src/lib/components/lemmy/moderation/ModerationMenu.svelte @@ -2,9 +2,11 @@ import { profile } from '$lib/auth.svelte.js' import { t } from '$lib/i18n/translations' import { getClient } from '$lib/lemmy.svelte' + import { errorMessage } from '$lib/lemmy/error' import { isCommentView, isPostView } from '$lib/lemmy/item.js' import type { CommentView, PostView } from 'lemmy-js-client' - import { Button, Menu, MenuButton, MenuDivider, toast } from 'mono-svelte' + import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte' + import type { Snippet } from 'svelte' import { ArrowsUpDown, Fire, @@ -17,23 +19,19 @@ Trash, } from 'svelte-hero-icons' import { amMod, ban, isAdmin, remove, viewVotes } from './moderation' - import ShieldIcon from './ShieldIcon.svelte' - import { errorMessage } from '$lib/lemmy/error' interface Props { item: PostView | CommentView + target: Snippet<[boolean]> } - let { item = $bindable(), ...rest }: Props = $props() + let { item = $bindable(), target: passedTarget }: Props = $props() - let locking = $state(false) - let pinning = $state(false) - - let acting = $derived(locking || pinning) + let acting = $state(false) async function lock(lock: boolean) { if (!profile.current?.jwt || !isPostView(item)) return - locking = true + acting = true try { await getClient().lockPost({ @@ -49,13 +47,13 @@ }) } - locking = false + acting = false } async function pin(pinned: boolean, toInstance: boolean = false) { if (!profile.current?.jwt || !isPostView(item)) return - pinning = true + acting = true try { await getClient().featurePost({ @@ -72,21 +70,13 @@ }) } - pinning = false + acting = false } {#snippet target()} - + {@render passedTarget(acting)} {/snippet} {#if (profile.current?.user && amMod(profile.current.user, item.community)) || (profile.current?.user && isAdmin(profile.current.user))} @@ -99,8 +89,7 @@ lock(!item.post.locked)} - loading={locking} - disabled={locking} + loading={acting} > {#snippet prefix()} @@ -112,8 +101,7 @@ color="success-subtle" onclick={() => pin(isPostView(item) ? !item.post.featured_community : false)} - loading={pinning} - disabled={pinning} + loading={acting} >
- import { goto } from '$app/navigation' import { profile } from '$lib/auth.svelte' - import { mediaType, postLink } from '$lib/components/lemmy/post/helpers.js' + import { mediaType } from '$lib/components/lemmy/post/helpers.js' import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte' import PostMediaCompact from '$lib/components/lemmy/post/media/PostMediaCompact.svelte' import PostActions from '$lib/components/lemmy/post/PostActions.svelte' @@ -28,15 +27,6 @@ return rule } - function onClick(e: Event) { - const event = e as Event - const parent = document.getElementById(post.post.id.toString()) - - if (event.target == parent) { - goto(postLink(post.post)) - } - } - interface Props { post: PostView actions?: boolean @@ -86,8 +76,6 @@ This is the sole component for displaying posts. It adapts to all kinds of form factors for different contexts, such as feeds, full post view, and crosspost list. --> - -
{ - onClick(e) - }} - onkeydown={e => { - if (e.key == 'Enter') onClick(e) - }} - tabindex="0" {style} > {/if} {#if profile.current?.user && (amMod(profile.current.user, post.community) || isAdmin(profile.current.user))} - + {#await import('$lib/components/lemmy/moderation/ModerationMenu.svelte') then { default: ModerationMenu }} + + {#snippet target(acting)} + + {/snippet} + + {/await} {/if} {#if profile.current?.jwt} diff --git a/src/lib/components/lemmy/post/PostItem.svelte b/src/lib/components/lemmy/post/PostItem.svelte index d8e5bc18..91613a6a 100644 --- a/src/lib/components/lemmy/post/PostItem.svelte +++ b/src/lib/components/lemmy/post/PostItem.svelte @@ -6,7 +6,7 @@ post: PostView } - let { post } = $props() + let { post }: Props = $props() diff --git a/src/lib/components/lemmy/post/PostMeta.svelte b/src/lib/components/lemmy/post/PostMeta.svelte index 5e83fde4..11290170 100644 --- a/src/lib/components/lemmy/post/PostMeta.svelte +++ b/src/lib/components/lemmy/post/PostMeta.svelte @@ -1,4 +1,14 @@ + +
0 && 'use-transition', + ]} + style="width: {progress}%;" + id="progress-bar" +>
+ + diff --git a/src/lib/components/ui/layout/Shell.svelte b/src/lib/components/ui/layout/Shell.svelte index 42fbd284..9b588b9e 100644 --- a/src/lib/components/ui/layout/Shell.svelte +++ b/src/lib/components/ui/layout/Shell.svelte @@ -97,7 +97,7 @@ } } - @media (min-width: 1280px) { + @media (min-width: 80rem) { .content { grid-template-columns: 20% 60% 20%; justify-items: end center start; diff --git a/src/lib/components/ui/navbar/commands/actions.svelte.ts b/src/lib/components/ui/navbar/commands/actions.svelte.ts index 57f7321d..31b3243a 100644 --- a/src/lib/components/ui/navbar/commands/actions.svelte.ts +++ b/src/lib/components/ui/navbar/commands/actions.svelte.ts @@ -45,6 +45,7 @@ import { ViewColumns, type IconSource, } from 'svelte-hero-icons' +import { SvelteURL } from 'svelte/reactivity' export interface Group { name: string @@ -411,7 +412,7 @@ export function getGroups( f.community.name, f.community.actor_id, )}`, - detail: new URL(f.community.actor_id).hostname, + detail: new SvelteURL(f.community.actor_id).hostname, })) ?? [], }, ] diff --git a/src/lib/components/ui/sidebar/ProfileButton.svelte b/src/lib/components/ui/sidebar/ProfileButton.svelte index f11c52d8..15566bf8 100644 --- a/src/lib/components/ui/sidebar/ProfileButton.svelte +++ b/src/lib/components/ui/sidebar/ProfileButton.svelte @@ -18,9 +18,7 @@ { @@ -47,9 +45,10 @@ /> {/snippet} {prof.username ?? prof.user?.local_user_view.person.name} {#if !guest && !LINKED_INSTANCE_URL} diff --git a/src/lib/components/ui/sidebar/Sidebar.svelte b/src/lib/components/ui/sidebar/Sidebar.svelte index 6403e942..2188002b 100644 --- a/src/lib/components/ui/sidebar/Sidebar.svelte +++ b/src/lib/components/ui/sidebar/Sidebar.svelte @@ -34,29 +34,25 @@ {#if profile.current?.jwt} {#snippet label()} - - {$t('profile.profile')} - + {$t('profile.profile')} {/snippet} {#snippet label()} - - {$t('profile.inbox')} - {#if $notifications.inbox} - - {$notifications.inbox > 99 ? '∞' : $notifications.inbox} - - {/if} - + {$t('profile.inbox')} + {#if $notifications.inbox} + + {$notifications.inbox > 99 ? '∞' : $notifications.inbox} + + {/if} {/snippet} {#snippet label()} - {$t('profile.saved')} + {$t('profile.saved')} {/snippet} {:else} @@ -66,7 +62,7 @@ icon={ArrowLeftOnRectangle} > {#snippet label()} - {$t('account.login')} + {$t('account.login')} {/snippet} {#snippet label()} - {$t('account.signup')} + {$t('account.signup')} {/snippet} {#snippet label()} - {$t('nav.menu.settings')} + {$t('nav.menu.settings')} {/snippet} {/if} @@ -109,9 +105,7 @@ {/snippet}
{#each [...profile.meta.profiles] as prof, index} -
- -
+ {/each}
diff --git a/src/lib/mono/badge/Badge.svelte b/src/lib/mono/badge/Badge.svelte index d66d2afe..f69c5bdf 100644 --- a/src/lib/mono/badge/Badge.svelte +++ b/src/lib/mono/badge/Badge.svelte @@ -1,11 +1,5 @@ - -
-
-		{value}
-	
- {#if copy} - - {/if} -
diff --git a/src/lib/mono/forms/Radio.svelte b/src/lib/mono/forms/Radio.svelte deleted file mode 100644 index c3248295..00000000 --- a/src/lib/mono/forms/Radio.svelte +++ /dev/null @@ -1,58 +0,0 @@ - - -
- - -
diff --git a/src/lib/mono/forms/RadioGroup.svelte b/src/lib/mono/forms/RadioGroup.svelte deleted file mode 100644 index 6444b0f0..00000000 --- a/src/lib/mono/forms/RadioGroup.svelte +++ /dev/null @@ -1,25 +0,0 @@ - - -
-
- {@render children?.({ group })} -
-
diff --git a/src/lib/mono/index.ts b/src/lib/mono/index.ts index a2987180..5bd35ec5 100644 --- a/src/lib/mono/index.ts +++ b/src/lib/mono/index.ts @@ -3,7 +3,6 @@ export { default as Button } from './button/Button.svelte' export { buttonColor, buttonSize, buttonShadow } from './button/Button.svelte' export { default as Codeblock } from './code/Codeblock.svelte' -export { default as Snippet } from './code/Snippet.svelte' export { default as Spinner } from './loader/Spinner.svelte' export { default as Material } from './materials/Material.svelte' @@ -18,9 +17,6 @@ export { default as ImageInput } from './forms/ImageInput.svelte' export { default as Checkbox } from './forms/Checkbox.svelte' export { default as Switch } from './forms/Switch.svelte' -export { default as Radio } from './forms/Radio.svelte' -export { default as RadioGroup } from './forms/RadioGroup.svelte' - export { default as Popover } from './popover/Popover.svelte' export { default as Menu } from './popover/Menu.svelte' export { default as MenuDivider } from './popover/MenuDivider.svelte' diff --git a/src/lib/mono/popover/Popover.svelte b/src/lib/mono/popover/Popover.svelte index 107ebf61..6aecd57f 100644 --- a/src/lib/mono/popover/Popover.svelte +++ b/src/lib/mono/popover/Popover.svelte @@ -1,16 +1,3 @@ - - { if (open && e.key == 'Escape') { open = false - // @ts-expect-error svelte hell - el?.firstChild.focus() } }} /> diff --git a/src/lib/util.svelte.ts b/src/lib/util.svelte.ts index 14077ac0..d49e6eb2 100644 --- a/src/lib/util.svelte.ts +++ b/src/lib/util.svelte.ts @@ -7,6 +7,7 @@ import { toast } from 'mono-svelte' import { t } from './i18n/translations' import { site } from './lemmy.svelte' import { errorMessage } from './lemmy/error' +import { SvelteURL } from 'svelte/reactivity' // Despite the name, this will round up // Example: findClosestNumber([8, 16, 32, 64, 128], 76) will return 128 @@ -29,7 +30,7 @@ export const searchParam = ( } export const fullCommunityName = (name: string, actorId: string) => - `${name}@${new URL(actorId).hostname}` + `${name}@${new SvelteURL(actorId).hostname}` export const placeholders = { url: ['https://example.com'], @@ -133,30 +134,6 @@ export async function uploadImage( if (res.url) return res.url else throw new Error(`Failed to upload image. ${res.msg}`) - } else { - const response = await fetch( - `${ - window.location.origin - }/cors/${instance}/pictrs/image?${new URLSearchParams({ - auth: jwt, - })}`, - { - method: 'POST', - body: formData, - }, - ) - - const json = await response.json() - - if (json.msg == 'ok') { - return `https://${instance}/pictrs/image/${json.files?.[0]?.file}` - } - throw new Error( - `${ - (await response.text().catch(() => undefined)) ?? - 'Failed to upload image' - }: ${response.status}: ${response.statusText}`, - ) } } @@ -167,7 +144,7 @@ export const instanceToURL = (input: string) => export function canParseUrl(url: string): boolean { try { - new URL(url) + new SvelteURL(url) return true } catch { return false @@ -175,7 +152,7 @@ export function canParseUrl(url: string): boolean { } export function instanceId(actorId: string) { - return new URL(actorId).hostname + return new SvelteURL(actorId).hostname } export function escapeHtml(input: string): string { diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 5fa8148d..80895789 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,7 +2,6 @@ import { browser } from '$app/environment' import { navigating, page } from '$app/state' import Moderation from '$lib/components/lemmy/moderation/Moderation.svelte' - import SiteCard from '$lib/components/lemmy/SiteCard.svelte' import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte' import Shell from '$lib/components/ui/layout/Shell.svelte' import Navbar from '$lib/components/ui/navbar/Navbar.svelte' @@ -14,25 +13,17 @@ import { inDarkColorScheme, rgbToHex, theme } from '$lib/ui/colors.svelte.js' import { getDefaultColors } from '$lib/ui/presets' import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte' - import nProgress from 'nprogress' - import 'nprogress/nprogress.css' import { onMount } from 'svelte' import { Forward, Icon } from 'svelte-hero-icons' import '../style/app.css' + import NavigationProgress from '$lib/components/ui/layout/NavigationProgress.svelte' interface Props { children?: import('svelte').Snippet } let { children }: Props = $props() - nProgress.configure({ - minimum: 0.4, - trickleSpeed: 200, - easing: 'ease-out', - speed: 300, - showSpinner: false, - }) - + let progressBar = $state<{ start: () => void; stop: () => void }>() onMount(() => { if (browser) { if (window.location.hash == 'main') { @@ -72,12 +63,12 @@ document.documentElement.dir = ($locale == 'he' || $locale == 'ar') && settings.useRtl ? 'rtl' : 'ltr' }) - } - $effect(() => { - if (navigating.to) nProgress.start() - else nProgress.done() - }) + $effect(() => { + if (navigating.to) progressBar?.start() + else progressBar?.stop() + }) + } @@ -105,6 +96,7 @@ + + @@ -139,12 +133,14 @@ {@const SvelteComponent = page.data.slots.sidebar.component} {:else if site.data} - + {#await import('$lib/components/lemmy/SiteCard.svelte') then { default: SiteCard }} + + {/await} {:else}
diff --git a/src/routes/inbox/+page.svelte b/src/routes/inbox/+page.svelte index c7c8d7d6..f3cd08b6 100644 --- a/src/routes/inbox/+page.svelte +++ b/src/routes/inbox/+page.svelte @@ -12,6 +12,7 @@ import { Button } from 'mono-svelte' import { ArrowPath, Check, Icon, Inbox } from 'svelte-hero-icons' import InboxItem from './InboxItem.svelte' + import { SvelteURLSearchParams } from 'svelte/reactivity' let { data } = $props() @@ -42,11 +43,11 @@ currentSearchParams: URLSearchParams, newParamString: string, ) { - // Create a new URLSearchParams object from the current search params - const updatedParams = new URLSearchParams(currentSearchParams) + // Create a new SvelteURLSearchParams object from the current search params + const updatedParams = new SvelteURLSearchParams(currentSearchParams) // Parse the new parameter string - const newParam = new URLSearchParams(newParamString) + const newParam = new SvelteURLSearchParams(newParamString) // Get the key and value of the new parameter const [key, value]: [string, string] = newParam.entries().next().value! diff --git a/src/routes/inbox/messages/+page.svelte b/src/routes/inbox/messages/+page.svelte index 2deaecd2..4dab47b8 100644 --- a/src/routes/inbox/messages/+page.svelte +++ b/src/routes/inbox/messages/+page.svelte @@ -16,6 +16,7 @@ import { Button, Modal } from 'mono-svelte' import { ChatBubbleOvalLeftEllipsis, Icon, Inbox } from 'svelte-hero-icons' import { expoOut } from 'svelte/easing' + import { SvelteSet } from 'svelte/reactivity' import { fly } from 'svelte/transition' interface ConversationPreview { @@ -34,7 +35,7 @@ } function filterDuplicates(array: T[], predicate: (item: T) => K): T[] { - const seen = new Set() + const seen = new SvelteSet() return array.filter(element => { const value = predicate(element) if (seen.has(value)) { diff --git a/src/routes/you_died/+page.svelte b/src/routes/you_died/+page.svelte deleted file mode 100644 index 07f309a6..00000000 --- a/src/routes/you_died/+page.svelte +++ /dev/null @@ -1,48 +0,0 @@ - - - - -
-
-

{profile.current.username ?? 'You'} was slain by Command Palette

-
- Minecraft 'you died' -
-
- - diff --git a/static/other/mc.mp3 b/static/other/mc.mp3 deleted file mode 100644 index 402a18b6..00000000 Binary files a/static/other/mc.mp3 and /dev/null differ diff --git a/static/other/mc.png b/static/other/mc.png deleted file mode 100644 index 73383cdf..00000000 Binary files a/static/other/mc.png and /dev/null differ