From 80269cf275aa5c6bd30e14d02f780c6830ec242e Mon Sep 17 00:00:00 2001 From: James Xylight Date: Tue, 4 Feb 2025 16:23:31 -0800 Subject: [PATCH] format: whole project --- .../components/input/ImagePreviewInput.svelte | 14 +- .../lemmy/comment/comments.svelte.ts | 2 +- src/lib/components/ui/Placeholder.svelte | 18 +- src/lib/components/ui/ProgressBar.svelte | 8 +- src/lib/components/ui/SectionTitle.svelte | 14 +- src/lib/components/ui/StickyCard.svelte | 7 +- src/lib/components/ui/layout/Shell.svelte | 5 - .../ui/navbar/commands/actions.svelte.ts | 6 +- src/lib/components/ui/text/TextProps.svelte | 11 +- .../components/util/FormattedNumber.svelte | 20 +- src/lib/components/util/RelativeDate.svelte | 25 ++- .../components/util/debug/DebugObject.svelte | 12 +- .../components/util/debug/DebugTree.svelte | 8 +- src/lib/fediseer/Fediseer.svelte | 184 +++++++++--------- src/lib/fediseer/fediseer.ts | 24 ++- src/lib/input/swipe.ts | 31 +-- src/lib/lemmy.ts | 12 +- src/lib/lemmy/contentview.ts | 10 +- src/lib/lemmy/inbox.ts | 4 +- src/lib/lemmy/item.ts | 13 +- src/lib/lemmy/postfeed.ts | 4 +- src/lib/lemmy/report.ts | 4 +- src/lib/lemmy/user.ts | 2 +- src/lib/mono/badge/Badge.svelte | 19 +- src/lib/mono/disclosure/Disclosure.svelte | 17 +- src/lib/mono/forms/Checkbox.svelte | 52 ++--- src/lib/mono/forms/Label.svelte | 17 +- src/lib/mono/forms/Radio.svelte | 20 +- src/lib/mono/forms/RadioGroup.svelte | 15 +- src/lib/mono/forms/Switch.svelte | 20 +- src/lib/mono/loader/Spinner.svelte | 4 +- src/lib/mono/materials/Material.svelte | 22 +-- src/lib/mono/modal/modal.ts | 92 ++++----- src/lib/mono/nav/Routebar.svelte | 20 +- src/lib/mono/note/Note.svelte | 6 +- src/lib/mono/popover/MenuDivider.svelte | 20 +- src/lib/mono/popover/Portal.svelte | 10 +- src/lib/mono/toast/Toast.svelte | 4 +- src/lib/mono/toast/toasts.ts | 88 +++++---- src/lib/mono/util/time.ts | 10 +- src/lib/session.ts | 4 +- src/lib/settings.svelte.ts | 28 ++- src/lib/translations.ts | 6 +- src/lib/ui/colors.ts | 14 +- src/routes/+layout.ts | 3 +- src/routes/about/Profile.svelte | 17 +- src/routes/admin/+page.ts | 2 +- src/routes/c/[name]/+layout.svelte | 2 +- src/routes/c/[name]/+page.ts | 3 +- src/routes/c/[name]/settings/+page.svelte | 13 +- src/routes/comment/[instance]/+page.ts | 2 +- src/routes/comment/[instance]/[id]/+page.ts | 2 +- src/routes/inbox/+page.ts | 2 +- .../messages/[user_id=integer]/+page.svelte | 21 +- src/routes/instances/+page.svelte | 10 +- src/routes/login_reset/+page.svelte | 2 +- src/routes/moderation/+page.ts | 2 +- src/routes/modlog/+page.ts | 4 +- src/routes/modlog/ModlogAction.svelte | 7 +- src/routes/modlog/item/ModlogItemCard.svelte | 4 +- src/routes/modlog/item/ModlogItemTable.svelte | 7 +- .../password_change/[token]/+page.svelte | 8 +- src/routes/post/[instance]/+page.ts | 4 +- .../profile/(local_user)/+layout.svelte | 12 +- .../(local_user)/blocks/+layout.svelte | 2 +- .../(local_user)/password/+page.svelte | 2 +- src/routes/profile/user/+page.svelte | 2 +- src/routes/profile/user/+page.ts | 4 +- src/routes/profile/voted/[type]/+page.svelte | 4 +- src/routes/saved/+page.ts | 2 +- src/routes/search/+page.ts | 2 +- src/routes/settings/Section.svelte | 16 +- src/routes/settings/Setting.svelte | 42 ++-- src/routes/settings/ToggleSetting.svelte | 33 ++-- src/routes/settings/nav/NavItem.svelte | 18 +- src/routes/signup/+page.svelte | 4 +- src/routes/signup/+page.ts | 8 +- src/routes/u/[name]/+page.ts | 4 +- src/routes/util/photonify/+page.svelte | 6 +- 79 files changed, 590 insertions(+), 612 deletions(-) diff --git a/src/lib/components/input/ImagePreviewInput.svelte b/src/lib/components/input/ImagePreviewInput.svelte index 6a553aa4..87e6031d 100644 --- a/src/lib/components/input/ImagePreviewInput.svelte +++ b/src/lib/components/input/ImagePreviewInput.svelte @@ -1,22 +1,22 @@
- import { run } from 'svelte/legacy'; + import { run } from 'svelte/legacy' import { expoOut } from 'svelte/easing' import { tweened } from 'svelte/motion' interface Props { - progress?: number; + progress?: number } - let { progress = 0 }: Props = $props(); + let { progress = 0 }: Props = $props() let tween = tweened(progress, { easing: expoOut }) run(() => { tween.set(progress) - }); + })
interface Props { - small?: boolean; - class?: string; - children?: import('svelte').Snippet; + small?: boolean + class?: string + children?: import('svelte').Snippet [key: string]: any } - let { small = false, class: clazz = '', children, ...rest }: Props = $props(); - + let { small = false, class: clazz = '', children, ...rest }: Props = $props() - + {@render children?.()} diff --git a/src/lib/components/ui/StickyCard.svelte b/src/lib/components/ui/StickyCard.svelte index da00cef7..df4e7550 100644 --- a/src/lib/components/ui/StickyCard.svelte +++ b/src/lib/components/ui/StickyCard.svelte @@ -1,11 +1,10 @@
diff --git a/src/lib/components/ui/navbar/commands/actions.svelte.ts b/src/lib/components/ui/navbar/commands/actions.svelte.ts index 4e62362f..25c26c05 100644 --- a/src/lib/components/ui/navbar/commands/actions.svelte.ts +++ b/src/lib/components/ui/navbar/commands/actions.svelte.ts @@ -338,16 +338,14 @@ export function getGroups( default: t.get('filter.view.compact'), }), icon: ViewColumns, - handle: () => - settings.view = 'compact' + handle: () => (settings.view = 'compact'), }, { name: t.get('nav.commands.setViewTo', { default: t.get('filter.view.cozy'), }), icon: ViewColumns, - handle: () => - settings.view = 'cozy' + handle: () => (settings.view = 'cozy'), }, ], }, diff --git a/src/lib/components/ui/text/TextProps.svelte b/src/lib/components/ui/text/TextProps.svelte index 2a8bb1f7..3381521e 100644 --- a/src/lib/components/ui/text/TextProps.svelte +++ b/src/lib/components/ui/text/TextProps.svelte @@ -6,15 +6,14 @@ diff --git a/src/lib/components/util/FormattedNumber.svelte b/src/lib/components/util/FormattedNumber.svelte index 89920f7b..fe64c33b 100644 --- a/src/lib/components/util/FormattedNumber.svelte +++ b/src/lib/components/util/FormattedNumber.svelte @@ -1,25 +1,21 @@ diff --git a/src/lib/components/util/RelativeDate.svelte b/src/lib/components/util/RelativeDate.svelte index 9a1f0270..65561930 100644 --- a/src/lib/components/util/RelativeDate.svelte +++ b/src/lib/components/util/RelativeDate.svelte @@ -3,7 +3,7 @@ date: Date, options: Intl.RelativeTimeFormatOptions, locale?: string, - relativeTo?: Date + relativeTo?: Date, ) { try { const now = relativeTo?.getTime() ?? Date.now() @@ -41,7 +41,6 @@ diff --git a/src/lib/components/util/debug/DebugObject.svelte b/src/lib/components/util/debug/DebugObject.svelte index 735ef64e..fa6a6498 100644 --- a/src/lib/components/util/debug/DebugObject.svelte +++ b/src/lib/components/util/debug/DebugObject.svelte @@ -3,17 +3,19 @@ import { Modal } from 'mono-svelte' interface Props { - object: any; - open?: boolean; - title?: import('svelte').Snippet; + object: any + open?: boolean + title?: import('svelte').Snippet } - let { object, open = $bindable(false), title }: Props = $props(); + let { object, open = $bindable(false), title }: Props = $props() {#snippet title()} - {#if title}{@render title()}{:else}Debug{/if} + + {#if title}{@render title()}{:else}Debug{/if} + {/snippet} diff --git a/src/lib/components/util/debug/DebugTree.svelte b/src/lib/components/util/debug/DebugTree.svelte index 70be7287..09c241e7 100644 --- a/src/lib/components/util/debug/DebugTree.svelte +++ b/src/lib/components/util/debug/DebugTree.svelte @@ -1,11 +1,11 @@
    diff --git a/src/lib/fediseer/Fediseer.svelte b/src/lib/fediseer/Fediseer.svelte index 99234925..ce623cc5 100644 --- a/src/lib/fediseer/Fediseer.svelte +++ b/src/lib/fediseer/Fediseer.svelte @@ -1,95 +1,105 @@ -
    - - {#snippet title()} - - Endorsements {data.endorsements.instances.length} - - {/snippet} -
    - {#each data.endorsements.instances as instance} -
    - - -
    - {/each} -
    -
    - - {#snippet title()} - - Guarantees {data.guarantees.instances.length} - - {/snippet} -
    - {#each data.guarantees.instances as instance} -
    - - -
    - {/each} -
    -
    - - {#snippet title()} - - Censures {data.censures.instances.length} - - {/snippet} -
    - {#each data.censures.instances as instance} -
    - - -
    - {/each} -
    -
    - - {#snippet title()} - - Hesitations {data.hesitations.instances.length} - - {/snippet} -
    - {#each data.hesitations.instances as instance} -
    - - -
    - {/each} -
    -
    -
    -
    \ No newline at end of file +
    + + {#snippet title()} + + Endorsements + {data.endorsements.instances.length} + + + {/snippet} +
    + {#each data.endorsements.instances as instance} +
    + +
    + {/each} +
    +
    + + {#snippet title()} + + Guarantees + {data.guarantees.instances.length} + + + {/snippet} +
    + {#each data.guarantees.instances as instance} +
    + +
    + {/each} +
    +
    + + {#snippet title()} + + Censures + {data.censures.instances.length} + + + {/snippet} +
    + {#each data.censures.instances as instance} +
    + +
    + {/each} +
    +
    + + {#snippet title()} + + Hesitations + {data.hesitations.instances.length} + + + {/snippet} +
    + {#each data.hesitations.instances as instance} +
    + +
    + {/each} +
    +
    +
    + diff --git a/src/lib/fediseer/fediseer.ts b/src/lib/fediseer/fediseer.ts index 81641240..1d631d13 100644 --- a/src/lib/fediseer/fediseer.ts +++ b/src/lib/fediseer/fediseer.ts @@ -41,15 +41,25 @@ class Fediseer { } async getInstanceInfo(domain: string): Promise { - const [endorsements, hesitations, guarantees, censures] = await Promise.all([ - fetch(`${this.url}/v1/endorsements/${domain}`).then(r => r.json()) as Promise, - fetch(`${this.url}/v1/hesitations/${domain}`).then(r => r.json()) as Promise, - fetch(`${this.url}/v1/guarantees/${domain}`).then(r => r.json()) as Promise, - fetch(`${this.url}/v1/censures/${domain}`).then(r => r.json()) as Promise - ]) + const [endorsements, hesitations, guarantees, censures] = await Promise.all( + [ + fetch(`${this.url}/v1/endorsements/${domain}`).then((r) => + r.json(), + ) as Promise, + fetch(`${this.url}/v1/hesitations/${domain}`).then((r) => + r.json(), + ) as Promise, + fetch(`${this.url}/v1/guarantees/${domain}`).then((r) => + r.json(), + ) as Promise, + fetch(`${this.url}/v1/censures/${domain}`).then((r) => + r.json(), + ) as Promise, + ], + ) return { endorsements, hesitations, guarantees, censures } } } -export const fediseer = new Fediseer('https://fediseer.com/api') \ No newline at end of file +export const fediseer = new Fediseer('https://fediseer.com/api') diff --git a/src/lib/input/swipe.ts b/src/lib/input/swipe.ts index 9144811d..9c478649 100644 --- a/src/lib/input/swipe.ts +++ b/src/lib/input/swipe.ts @@ -3,10 +3,13 @@ enum SwipeDirection { Down = 'down', Left = 'left', Right = 'right', - None = 'none' + None = 'none', } -export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) => any) { +export function swipeGesture( + node: HTMLElement, + swipe: (dir: SwipeDirection) => any, +) { let touchstartX = 0 let touchstartY = 0 let touchendX = 0 @@ -20,7 +23,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) => // @ts-ignore touchstartY = event?.screenY }, - false + false, ) node?.addEventListener( @@ -31,7 +34,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) => // @ts-ignore touchstartY = event?.screenY }, - false + false, ) node?.addEventListener( @@ -43,7 +46,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) => touchendY = event.screenY return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY)) }, - false + false, ) node?.addEventListener( @@ -55,7 +58,7 @@ export function swipeGesture(node: HTMLElement, swipe: (dir: SwipeDirection) => touchendY = event.screenY return swipe(swipeDir(touchstartX, touchstartY, touchendX, touchendY)) }, - false + false, ) } @@ -63,26 +66,26 @@ function swipeDir( touchStartX: number, touchStartY: number, touchEndX: number, - touchEndY: number + touchEndY: number, ): SwipeDirection { - const deltaX = touchEndX - touchStartX; - const deltaY = touchEndY - touchStartY; + const deltaX = touchEndX - touchStartX + const deltaY = touchEndY - touchStartY // Define a threshold for the minimum swipe distance - const minSwipeDistance = 10; // Adjust this value as needed + const minSwipeDistance = 10 // Adjust this value as needed // Check the absolute difference between deltaX and deltaY if (Math.abs(deltaX) >= Math.abs(deltaY)) { // Horizontal swipe if (Math.abs(deltaX) >= minSwipeDistance) { - return deltaX > 0 ? SwipeDirection.Right : SwipeDirection.Left; + return deltaX > 0 ? SwipeDirection.Right : SwipeDirection.Left } } else { // Vertical swipe if (Math.abs(deltaY) >= minSwipeDistance) { - return deltaY > 0 ? SwipeDirection.Down : SwipeDirection.Up; + return deltaY > 0 ? SwipeDirection.Down : SwipeDirection.Up } } - return SwipeDirection.None; -} \ No newline at end of file + return SwipeDirection.None +} diff --git a/src/lib/lemmy.ts b/src/lib/lemmy.ts index 2681abc5..925e9033 100644 --- a/src/lib/lemmy.ts +++ b/src/lib/lemmy.ts @@ -25,12 +25,12 @@ async function customFetch( func: | (( input: RequestInfo | URL, - init?: RequestInit | undefined + init?: RequestInit | undefined, ) => Promise) | undefined, input: RequestInfo | URL, init?: RequestInit | undefined, - auth?: string + auth?: string, ): Promise { const f = func ? func : fetch @@ -63,7 +63,7 @@ export function client({ instanceURL?: string func?: ( input: RequestInfo | URL, - init?: RequestInit | undefined + init?: RequestInit | undefined, ) => Promise auth?: string } = {}) { @@ -84,9 +84,9 @@ export function getClient( instanceURL?: string, func?: ( input: RequestInfo | URL, - init?: RequestInit | undefined + init?: RequestInit | undefined, ) => Promise, - auth?: string + auth?: string, ): LemmyHttp { return client({ instanceURL, func, auth }) } @@ -107,7 +107,7 @@ export async function validateInstance(instance: string): Promise { export function mayBeIncompatible( minVersion: string, - availableVersion: string + availableVersion: string, ) { if (minVersion.valueOf() === availableVersion.valueOf()) return false diff --git a/src/lib/lemmy/contentview.ts b/src/lib/lemmy/contentview.ts index 15884488..a4443aef 100644 --- a/src/lib/lemmy/contentview.ts +++ b/src/lib/lemmy/contentview.ts @@ -20,7 +20,7 @@ export interface ContentView { } const isSubmissionView = ( - item: SubmissionView | ContentView + item: SubmissionView | ContentView, ): item is SubmissionView => !('type' in item) const isSubmission = (item: Submission | ContentView): item is Submission => @@ -63,7 +63,7 @@ export const contentItem = (item: Submission): ContentView => { export async function save( item: ContentView | SubmissionView, save: boolean, - jwt: string + jwt: string, ): Promise { if (isSubmissionView(item)) item = contentView(item) @@ -88,7 +88,7 @@ export async function save( export async function deleteItem( item: ContentView | SubmissionView, deleted: boolean, - jwt: string + jwt: string, ): Promise { if (isSubmissionView(item)) item = contentView(item) @@ -113,7 +113,7 @@ export async function deleteItem( export async function vote( item: ContentView | Submission, vote: number, - jwt: string + jwt: string, ): Promise<{ upvotes: number; downvotes: number; score: number }> { if (isSubmission(item)) item = contentItem(item) @@ -138,7 +138,7 @@ export async function vote( export async function markAsRead( item: ContentView | Submission, read: boolean, - jwt: string + jwt: string, ): Promise { if (isSubmission(item)) item = contentItem(item) diff --git a/src/lib/lemmy/inbox.ts b/src/lib/lemmy/inbox.ts index eb95e47d..7da6274c 100644 --- a/src/lib/lemmy/inbox.ts +++ b/src/lib/lemmy/inbox.ts @@ -25,7 +25,7 @@ export const generalizeCommentReply = (item: CommentReplyView): InboxItem => ({ }) export const generalizePersonMention = ( - item: PersonMentionView + item: PersonMentionView, ): InboxItem => ({ type: 'person_mention', id: item.person_mention.id, @@ -38,7 +38,7 @@ export const generalizePersonMention = ( }) export const generalizePrivateMessage = ( - item: PrivateMessageView + item: PrivateMessageView, ): InboxItem => ({ type: 'private_message', id: item.private_message.id, diff --git a/src/lib/lemmy/item.ts b/src/lib/lemmy/item.ts index b08bd904..73d0f625 100644 --- a/src/lib/lemmy/item.ts +++ b/src/lib/lemmy/item.ts @@ -67,7 +67,7 @@ export const isCommentReport = (item: Result): item is CommentReportView => 'comment_report' in item export const isPrivateMessageReport = ( - item: Result + item: Result, ): item is PrivateMessageReportView => 'private_message_report' in item export interface ResumableItem { @@ -86,15 +86,18 @@ function resumableStore(limit: number = 10) { const { subscribe, set, update } = writable([]) return { - subscribe, set, update, + subscribe, + set, + update, add: (item: ResumableItem) => { - update(resumables => { - if (resumables.find(i => JSON.stringify(i) == JSON.stringify(item))) return resumables + update((resumables) => { + if (resumables.find((i) => JSON.stringify(i) == JSON.stringify(item))) + return resumables resumables.unshift(item) if (resumables.length > limit) resumables.pop() return resumables }) - } + }, } } diff --git a/src/lib/lemmy/postfeed.ts b/src/lib/lemmy/postfeed.ts index 3bcd2615..81112a8b 100644 --- a/src/lib/lemmy/postfeed.ts +++ b/src/lib/lemmy/postfeed.ts @@ -12,7 +12,7 @@ import { get, writable } from 'svelte/store' export const shouldReload = ( cache: PostFeed | undefined, url: URL, - instance: string + instance: string, ): boolean => cache?.instance != instance || cache?.url.toString() != url.toString() @@ -27,7 +27,7 @@ export async function postFeed(args: { url: URL fetch?: ( input: RequestInfo | URL, - init?: RequestInit | undefined + init?: RequestInit | undefined, ) => Promise }) { const feed = get(postFeeds)[args.id] diff --git a/src/lib/lemmy/report.ts b/src/lib/lemmy/report.ts index 22e0959e..b18a1462 100644 --- a/src/lib/lemmy/report.ts +++ b/src/lib/lemmy/report.ts @@ -37,7 +37,7 @@ interface BaseReport { } export const generalizeCommentReport = ( - report: CommentReportView + report: CommentReportView, ): ReportView => ({ creator: report.creator, item: { @@ -77,7 +77,7 @@ export const generalizePostReport = (report: PostReportView): ReportView => ({ }) export const generalizePrivateMessageReport = ( - report: PrivateMessageReportView + report: PrivateMessageReportView, ): ReportView => ({ creator: report.creator, item: report.private_message, diff --git a/src/lib/lemmy/user.ts b/src/lib/lemmy/user.ts index de6f90c5..6162d287 100644 --- a/src/lib/lemmy/user.ts +++ b/src/lib/lemmy/user.ts @@ -20,7 +20,7 @@ export const isBlocked = (me: MyUserInfo, user: number) => export const addSubscription = ( community: Community, - subscribe: boolean = true + subscribe: boolean = true, ) => { const p = get(profile) diff --git a/src/lib/mono/badge/Badge.svelte b/src/lib/mono/badge/Badge.svelte index 405a3a78..d66d2afe 100644 --- a/src/lib/mono/badge/Badge.svelte +++ b/src/lib/mono/badge/Badge.svelte @@ -1,5 +1,4 @@ ; - extended?: import('svelte').Snippet; - children?: import('svelte').Snippet<[any]>; + open?: boolean + class?: string + summary?: import('svelte').Snippet<[any]> + extended?: import('svelte').Snippet + children?: import('svelte').Snippet<[any]> [key: string]: any } @@ -18,18 +18,17 @@ extended, children, ...rest - }: Props = $props(); - + }: Props = $props()
    {@render extended?.()} {#if open}
    - {@render children?.({ open, })} + {@render children?.({ open })}
    {/if}
    diff --git a/src/lib/mono/forms/Checkbox.svelte b/src/lib/mono/forms/Checkbox.svelte index d3f2555c..e1e4673f 100644 --- a/src/lib/mono/forms/Checkbox.svelte +++ b/src/lib/mono/forms/Checkbox.svelte @@ -1,27 +1,35 @@ -
{@render children?.()} diff --git a/src/lib/mono/loader/Spinner.svelte b/src/lib/mono/loader/Spinner.svelte index f10fd16c..065bf39d 100644 --- a/src/lib/mono/loader/Spinner.svelte +++ b/src/lib/mono/loader/Spinner.svelte @@ -1,10 +1,10 @@ - import { createBubbler } from 'svelte/legacy'; + import { createBubbler } from 'svelte/legacy' - const bubble = createBubbler(); + const bubble = createBubbler() type Elevation = keyof typeof elevationClass type Padding = keyof typeof paddingClass type Rounding = keyof typeof roundedClass @@ -46,15 +46,14 @@ none: '', } - interface Props { - elevation?: Elevation; - padding?: Padding; - rounding?: Rounding; - color?: Color; - element?: string; - class?: string; - children?: import('svelte').Snippet; + elevation?: Elevation + padding?: Padding + rounding?: Rounding + color?: Color + element?: string + class?: string + children?: import('svelte').Snippet [key: string]: any } @@ -67,8 +66,7 @@ class: clazz = '', children, ...rest - }: Props = $props(); - + }: Props = $props() (undefined) interface Modal { - actions: Action[] - title: string - body?: string - /** - * Whether the modal has a close button or not - */ - dismissable: boolean - type: 'error' | 'info' | 'success' + actions: Action[] + title: string + body?: string + /** + * Whether the modal has a close button or not + */ + dismissable: boolean + type: 'error' | 'info' | 'success' } type Action = { - /** - * What function to run when this action is clicked. If undefined, it'll close the window. - */ - action: () => any - type: 'danger' | 'secondary' | 'primary' - content: string - icon?: IconSource - close: boolean + /** + * What function to run when this action is clicked. If undefined, it'll close the window. + */ + action: () => any + type: 'danger' | 'secondary' | 'primary' + content: string + icon?: IconSource + close: boolean } export const action = (action?: { - action?: () => any - type?: 'danger' | 'secondary' | 'primary' - content?: string - icon?: IconSource - close?: boolean + action?: () => any + type?: 'danger' | 'secondary' | 'primary' + content?: string + icon?: IconSource + close?: boolean }): Action => ({ - action: action?.action - ? () => { - action?.action?.() - if (action.close) shownModal.set(undefined) - } - : () => shownModal.set(undefined), - type: action?.type ?? 'secondary', - content: action?.content || 'OK', - close: action?.close ?? true + action: action?.action + ? () => { + action?.action?.() + if (action.close) shownModal.set(undefined) + } + : () => shownModal.set(undefined), + type: action?.type ?? 'secondary', + content: action?.content || 'OK', + close: action?.close ?? true, }) export function modal(inputModal: { - actions?: Action[] - title: string - body: string - /** - * Whether the modal has a close button or not - */ - dismissable?: boolean - type?: 'error' | 'info' | 'success' + actions?: Action[] + title: string + body: string + /** + * Whether the modal has a close button or not + */ + dismissable?: boolean + type?: 'error' | 'info' | 'success' }) { - const modal: Modal = { - actions: inputModal.actions ?? [action()], - dismissable: inputModal.dismissable ?? true, - title: inputModal.title, - body: inputModal.body, - type: inputModal.type ?? 'info' - } + const modal: Modal = { + actions: inputModal.actions ?? [action()], + dismissable: inputModal.dismissable ?? true, + title: inputModal.title, + body: inputModal.body, + type: inputModal.type ?? 'info', + } - shownModal.set(modal) + shownModal.set(modal) } diff --git a/src/lib/mono/nav/Routebar.svelte b/src/lib/mono/nav/Routebar.svelte index 9c51f364..457e57c2 100644 --- a/src/lib/mono/nav/Routebar.svelte +++ b/src/lib/mono/nav/Routebar.svelte @@ -1,5 +1,5 @@ diff --git a/src/lib/mono/note/Note.svelte b/src/lib/mono/note/Note.svelte index e95480b5..8ec95334 100644 --- a/src/lib/mono/note/Note.svelte +++ b/src/lib/mono/note/Note.svelte @@ -3,11 +3,11 @@ import { Icon, InformationCircle } from 'svelte-hero-icons' interface Props { - content?: string | undefined; - children?: import('svelte').Snippet; + content?: string | undefined + children?: import('svelte').Snippet } - let { content = undefined, children }: Props = $props(); + let { content = undefined, children }: Props = $props() - /** - * @typedef {Object} Props - * @property {import('svelte').Snippet} [children] - */ + /** + * @typedef {Object} Props + * @property {import('svelte').Snippet} [children] + */ - /** @type {Props} */ - let { children } = $props(); + /** @type {Props} */ + let { children } = $props()
-
{@render children?.()}
-
+
{@render children?.()}
+
diff --git a/src/lib/mono/popover/Portal.svelte b/src/lib/mono/popover/Portal.svelte index a54e4d77..09618504 100644 --- a/src/lib/mono/popover/Portal.svelte +++ b/src/lib/mono/popover/Portal.svelte @@ -3,7 +3,8 @@ // https://github.com/sveltejs/svelte/issues/3088#issuecomment-505785516 import { onMount, onDestroy, createEventDispatcher } from 'svelte' - let slottedElements: HTMLDivElement = $state(), portal: HTMLDivElement + let slottedElements: HTMLDivElement = $state(), + portal: HTMLDivElement const dispatch = createEventDispatcher<{ mounted: void }>() @@ -21,12 +22,11 @@ }) interface Props { - class?: string; - children?: import('svelte').Snippet; + class?: string + children?: import('svelte').Snippet } - let { class: clazz = '', children }: Props = $props(); - + let { class: clazz = '', children }: Props = $props()
diff --git a/src/lib/mono/toast/Toast.svelte b/src/lib/mono/toast/Toast.svelte index 2d232c6a..e7597e2a 100644 --- a/src/lib/mono/toast/Toast.svelte +++ b/src/lib/mono/toast/Toast.svelte @@ -14,10 +14,10 @@ import { fly } from 'svelte/transition' interface Props { - toast: Toast; + toast: Toast } - let { toast }: Props = $props(); + let { toast }: Props = $props()
any + id: number + title?: string + content: string + type: ToastType + loading?: boolean + action?: () => any } export const toasts = writable([]) export function toast({ - title, - content, - type = 'info', - duration = 5000, - loading = false, - action + title, + content, + type = 'info', + duration = 5000, + loading = false, + action, }: { - title?: string - content: string - type?: ToastType - duration?: number - loading?: boolean - action?: () => any + title?: string + content: string + type?: ToastType + duration?: number + loading?: boolean + action?: () => any }) { - let id = 0 + let id = 0 - toasts.update((toasts) => { - id = Math.floor(Math.random() * 10000) + toasts.update((toasts) => { + id = Math.floor(Math.random() * 10000) - return [ - ...toasts, - { - id: id, - content: content, - title: title, - type: type, - loading: loading, - action: action - } - ] - }) + return [ + ...toasts, + { + id: id, + content: content, + title: title, + type: type, + loading: loading, + action: action, + }, + ] + }) - setTimeout(() => { - toasts.update((toasts) => toasts.filter((toast) => toast.id != id)) - }, duration) + setTimeout(() => { + toasts.update((toasts) => toasts.filter((toast) => toast.id != id)) + }, duration) - return id + return id } export const removeToast = (id: number) => - toasts.update((toasts) => toasts.filter((toast) => toast.id != id)) + toasts.update((toasts) => toasts.filter((toast) => toast.id != id)) diff --git a/src/lib/mono/util/time.ts b/src/lib/mono/util/time.ts index 28ea0b66..f03681f9 100644 --- a/src/lib/mono/util/time.ts +++ b/src/lib/mono/util/time.ts @@ -1,7 +1,7 @@ export const debounce = (fn: Function, ms = 300) => { - let timeoutId: ReturnType - return function (this: any, ...args: any[]) { - clearTimeout(timeoutId) - timeoutId = setTimeout(() => fn.apply(this, args), ms) - } + let timeoutId: ReturnType + return function (this: any, ...args: any[]) { + clearTimeout(timeoutId) + timeoutId = setTimeout(() => fn.apply(this, args), ms) + } } diff --git a/src/lib/session.ts b/src/lib/session.ts index e74d38e2..a46accbd 100644 --- a/src/lib/session.ts +++ b/src/lib/session.ts @@ -19,7 +19,7 @@ interface SessionStorage { export const setSessionStorage = ( key: keyof SessionStorage, - value: SessionStorage[typeof key] + value: SessionStorage[typeof key], ) => { if (!browser) return if (value == undefined) { @@ -30,7 +30,7 @@ export const setSessionStorage = ( } export const getSessionStorage = ( - key: keyof SessionStorage + key: keyof SessionStorage, ): SessionStorage[typeof key] => { if (!browser) return return JSON.parse(sessionStorage.getItem(key)!) diff --git a/src/lib/settings.svelte.ts b/src/lib/settings.svelte.ts index 48a42f11..57a31151 100644 --- a/src/lib/settings.svelte.ts +++ b/src/lib/settings.svelte.ts @@ -187,8 +187,6 @@ export const defaultSettings: Settings = { logoColorMonth: null, } - - function createSettingsState(initial: Settings): Settings { let settings = $state(initial) if (browser) { @@ -197,9 +195,7 @@ function createSettingsState(initial: Settings): Settings { const merged = mergeDeep(initial, localSettings) settings = merged - } catch (e) { - } - + } catch (e) {} } return settings } @@ -208,7 +204,7 @@ export let settings = createSettingsState(defaultSettings) $effect.root(() => { $effect(() => { - localStorage.setItem('settings', JSON.stringify(settings)) + localStorage.setItem('settings', JSON.stringify(settings)) if (settings.language) { locale.set(settings.language) @@ -217,13 +213,11 @@ $effect.root(() => { } }) - return () => { - - } + return () => {} }) function isObject(item: any) { - return (item && typeof item === 'object' && !Array.isArray(item)); + return item && typeof item === 'object' && !Array.isArray(item) } /** @@ -232,19 +226,19 @@ function isObject(item: any) { * @param ...sources */ function mergeDeep(target: any, ...sources: any[]) { - if (!sources.length) return target; - const source = sources.shift(); + if (!sources.length) return target + const source = sources.shift() if (isObject(target) && isObject(source)) { for (const key in source) { if (isObject(source[key])) { - if (!target[key]) Object.assign(target, { [key]: {} }); - mergeDeep(target[key], source[key]); + if (!target[key]) Object.assign(target, { [key]: {} }) + mergeDeep(target[key], source[key]) } else { - Object.assign(target, { [key]: source[key] }); + Object.assign(target, { [key]: source[key] }) } } } - return mergeDeep(target, ...sources); -} \ No newline at end of file + return mergeDeep(target, ...sources) +} diff --git a/src/lib/translations.ts b/src/lib/translations.ts index 873d50b5..e4394f11 100644 --- a/src/lib/translations.ts +++ b/src/lib/translations.ts @@ -88,7 +88,7 @@ const config: Config = { loader: async () => (await import('./i18n/zh-Hant.json')).default, }, ], - fallbackLocale: 'en' + fallbackLocale: 'en', } export const aliases = new Map([ @@ -111,6 +111,4 @@ export const aliases = new Map([ ['he-IL', 'he'], ]) -export let { t, locale, locales, loading, loadTranslations } = new i18n( - config -) +export let { t, locale, locales, loading, loadTranslations } = new i18n(config) diff --git a/src/lib/ui/colors.ts b/src/lib/ui/colors.ts index 968387c3..5c7eaa7c 100644 --- a/src/lib/ui/colors.ts +++ b/src/lib/ui/colors.ts @@ -84,8 +84,8 @@ function themeStore( fn: ( values: ThemeData, set: (value: Theme) => void, - update: (fn: Updater) => void - ) => any + update: (fn: Updater) => void, + ) => any, ) { const derive: Readable = derived(data, fn) const { subscribe } = derive @@ -107,7 +107,7 @@ export let themeData = writable( scheme: 'system', themes: presets, currentTheme: 0, - } + }, ) themeData.subscribe((themeData) => { @@ -118,7 +118,7 @@ themeData.subscribe((themeData) => { JSON.stringify({ ...themeData, themes: filteredThemes, - }) + }), ) } }) @@ -126,7 +126,7 @@ themeData.subscribe((themeData) => { export let theme = themeStore( themeData, (data) => - data.themes.find((t) => t.id == data.currentTheme) ?? getDefaultTheme() + data.themes.find((t) => t.id == data.currentTheme) ?? getDefaultTheme(), ) export function calculateVars(theme: Theme) { @@ -145,7 +145,7 @@ export const themeVars = derived(theme, (t) => calculateVars(t as Theme)) const configuredColorScheme = env.PUBLIC_COLORSCHEME ?? 'system' export const colorScheme = writable( - configuredColorScheme as ColorScheme + configuredColorScheme as ColorScheme, ) export const toggleColorScheme = () => { @@ -175,7 +175,7 @@ function loadColorScheme() { colorScheme.subscribe((colorScheme) => { if (typeof document != 'undefined') { const prefersDark = window.matchMedia( - '(prefers-color-scheme: dark)' + '(prefers-color-scheme: dark)', ).matches const html = document.querySelector('html') diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 556d43bd..a1cf61e7 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -8,8 +8,7 @@ export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true' export const load = async ({}) => { if (browser) { - const initLocale = - settings.language ?? navigator?.language ?? 'en' + const initLocale = settings.language ?? navigator?.language ?? 'en' console.log(`Loading locale ${aliases.get(initLocale) ?? initLocale}`) diff --git a/src/routes/about/Profile.svelte b/src/routes/about/Profile.svelte index 499077e6..c16c19a0 100644 --- a/src/routes/about/Profile.svelte +++ b/src/routes/about/Profile.svelte @@ -1,14 +1,12 @@
diff --git a/src/routes/admin/+page.ts b/src/routes/admin/+page.ts index 2ac9c2e9..f85964a5 100644 --- a/src/routes/admin/+page.ts +++ b/src/routes/admin/+page.ts @@ -1,5 +1,5 @@ import { redirect } from '@sveltejs/kit' export const load = () => { - redirect(302, '/admin/config'); + redirect(302, '/admin/config') } diff --git a/src/routes/c/[name]/+layout.svelte b/src/routes/c/[name]/+layout.svelte index f6969f48..a9cc9301 100644 --- a/src/routes/c/[name]/+layout.svelte +++ b/src/routes/c/[name]/+layout.svelte @@ -1,5 +1,5 @@ diff --git a/src/routes/c/[name]/+page.ts b/src/routes/c/[name]/+page.ts index 21f19453..ddf2c4d9 100644 --- a/src/routes/c/[name]/+page.ts +++ b/src/routes/c/[name]/+page.ts @@ -10,8 +10,7 @@ export async function load({ params, fetch, url }) { const page = Number(url.searchParams.get('page')) || undefined const sort: SortType = - (url.searchParams.get('sort') as SortType) || - settings.defaultSort.sort + (url.searchParams.get('sort') as SortType) || settings.defaultSort.sort return await postFeed({ id: 'community', diff --git a/src/routes/c/[name]/settings/+page.svelte b/src/routes/c/[name]/settings/+page.svelte index b2315280..adcd75f9 100644 --- a/src/routes/c/[name]/settings/+page.svelte +++ b/src/routes/c/[name]/settings/+page.svelte @@ -3,18 +3,15 @@ import CommunityTitle from '$lib/components/lemmy/community/CommunityTitle.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte' - let { data } = $props(); + let { data } = $props()
Settings {#snippet extended()} - - {/snippet} + + {/snippet}
{#snippet formtitle()} - {''} - {/snippet} + {''} + {/snippet}
diff --git a/src/routes/comment/[instance]/+page.ts b/src/routes/comment/[instance]/+page.ts index f1e8b8a3..d4202c28 100644 --- a/src/routes/comment/[instance]/+page.ts +++ b/src/routes/comment/[instance]/+page.ts @@ -3,5 +3,5 @@ import { redirect } from '@sveltejs/kit' export function load({ params }) { // If you somehow got to /comment/instance, it likely means you passed in an ID, not an instance. - redirect(302, `/comment/${getInstance()}/${params.instance}`); + redirect(302, `/comment/${getInstance()}/${params.instance}`) } diff --git a/src/routes/comment/[instance]/[id]/+page.ts b/src/routes/comment/[instance]/[id]/+page.ts index 3f506aab..76e90416 100644 --- a/src/routes/comment/[instance]/[id]/+page.ts +++ b/src/routes/comment/[instance]/[id]/+page.ts @@ -13,6 +13,6 @@ export async function load({ params, fetch }) { redirect( 302, - `/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}` + `/post/${params.instance}/${comment.comment_view.post.id}?thread=${comment.comment_view.comment.path}#${comment.comment_view.comment.id}`, ) } diff --git a/src/routes/inbox/+page.ts b/src/routes/inbox/+page.ts index 580c505f..07446757 100644 --- a/src/routes/inbox/+page.ts +++ b/src/routes/inbox/+page.ts @@ -55,7 +55,7 @@ export async function load({ url, fetch }) { ].sort( (a, b) => publishedToDate(b.published).getTime() - - publishedToDate(a.published).getTime() + publishedToDate(a.published).getTime(), ) return { diff --git a/src/routes/inbox/messages/[user_id=integer]/+page.svelte b/src/routes/inbox/messages/[user_id=integer]/+page.svelte index e54bf781..bff9d798 100644 --- a/src/routes/inbox/messages/[user_id=integer]/+page.svelte +++ b/src/routes/inbox/messages/[user_id=integer]/+page.svelte @@ -1,5 +1,5 @@
Linked Instances
@@ -18,8 +18,8 @@ Linked {#snippet target()} - - {/snippet} + + {/snippet}

These are the instances your instance can see and interact with content from. @@ -60,8 +60,8 @@ {#snippet target()} - - {/snippet} + + {/snippet}

These are the instances your instance is explicitly blocking content from. diff --git a/src/routes/login_reset/+page.svelte b/src/routes/login_reset/+page.svelte index f1883583..2b930b36 100644 --- a/src/routes/login_reset/+page.svelte +++ b/src/routes/login_reset/+page.svelte @@ -1,5 +1,5 @@ diff --git a/src/routes/modlog/item/ModlogItemTable.svelte b/src/routes/modlog/item/ModlogItemTable.svelte index 563f4968..338cf565 100644 --- a/src/routes/modlog/item/ModlogItemTable.svelte +++ b/src/routes/modlog/item/ModlogItemTable.svelte @@ -7,10 +7,10 @@ import ModlogAction from '../ModlogAction.svelte' interface Props { - item: ModLog; + item: ModLog } - let { item }: Props = $props(); + let { item }: Props = $props() @@ -28,7 +28,8 @@ user={item.moderator} /> {:else} -

Hidden

+

Hidden

+

{/if} diff --git a/src/routes/password_change/[token]/+page.svelte b/src/routes/password_change/[token]/+page.svelte index 9166915e..31cfc2c0 100644 --- a/src/routes/password_change/[token]/+page.svelte +++ b/src/routes/password_change/[token]/+page.svelte @@ -1,5 +1,5 @@ {@render children?.()} diff --git a/src/routes/profile/(local_user)/blocks/+layout.svelte b/src/routes/profile/(local_user)/blocks/+layout.svelte index 79f3a8be..56b27f31 100644 --- a/src/routes/profile/(local_user)/blocks/+layout.svelte +++ b/src/routes/profile/(local_user)/blocks/+layout.svelte @@ -5,7 +5,7 @@ */ /** @type {Props} */ - let { children } = $props(); + let { children } = $props()
import UserPage from '../../u/[name]/+page.svelte' - let { data } = $props(); + let { data } = $props() {#if data.user && data.sort && data.type && data.page} diff --git a/src/routes/profile/user/+page.ts b/src/routes/profile/user/+page.ts index 0f4bdef2..e3d6cdb7 100644 --- a/src/routes/profile/user/+page.ts +++ b/src/routes/profile/user/+page.ts @@ -26,12 +26,12 @@ export async function load({ url, fetch, parent }) { (a, b) => b.counts.upvotes - b.counts.downvotes - - (a.counts.upvotes - a.counts.downvotes) + (a.counts.upvotes - a.counts.downvotes), ) } else if (sort == 'New') { items.sort( (a, b) => - Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)) + Date.parse(getItemPublished(b)) - Date.parse(getItemPublished(a)), ) } diff --git a/src/routes/profile/voted/[type]/+page.svelte b/src/routes/profile/voted/[type]/+page.svelte index 71e099d0..d3095db2 100644 --- a/src/routes/profile/voted/[type]/+page.svelte +++ b/src/routes/profile/voted/[type]/+page.svelte @@ -5,9 +5,9 @@ import Header from '$lib/components/ui/layout/pages/Header.svelte' import { t } from '$lib/translations' - let { data = $bindable() } = $props(); + let { data = $bindable() } = $props() - const SvelteComponent = $derived(browser ? VirtualFeed : PostFeed); + const SvelteComponent = $derived(browser ? VirtualFeed : PostFeed)
diff --git a/src/routes/saved/+page.ts b/src/routes/saved/+page.ts index 0eaa461e..6edaef6b 100644 --- a/src/routes/saved/+page.ts +++ b/src/routes/saved/+page.ts @@ -44,7 +44,7 @@ export async function load({ url, fetch }) { const everything = [...posts.posts, ...comments.comments].sort( (a, b) => Date.parse(getSavedItemPublished(b)) - - Date.parse(getSavedItemPublished(a)) + Date.parse(getSavedItemPublished(a)), ) return { page: page, data: everything, type: type } diff --git a/src/routes/search/+page.ts b/src/routes/search/+page.ts index 585b92a2..ae562fb2 100644 --- a/src/routes/search/+page.ts +++ b/src/routes/search/+page.ts @@ -46,7 +46,7 @@ export async function load({ url, fetch }) { everything.sort( (a, b) => new Date(getItemPublished(b)).getTime() - - new Date(getItemPublished(a)).getTime() + new Date(getItemPublished(a)).getTime(), ) } diff --git a/src/routes/settings/Section.svelte b/src/routes/settings/Section.svelte index 0ef1955d..ccfef762 100644 --- a/src/routes/settings/Section.svelte +++ b/src/routes/settings/Section.svelte @@ -4,20 +4,14 @@ import { backOut, expoOut } from 'svelte/easing' import { slide } from 'svelte/transition' - interface Props { - title: string; - id: string; - open?: boolean; - children?: import('svelte').Snippet; + title: string + id: string + open?: boolean + children?: import('svelte').Snippet } - let { - title, - id, - open = $bindable(true), - children - }: Props = $props(); + let { title, id, open = $bindable(true), children }: Props = $props()
diff --git a/src/routes/settings/Setting.svelte b/src/routes/settings/Setting.svelte index ea66e73c..2f9e3bb7 100644 --- a/src/routes/settings/Setting.svelte +++ b/src/routes/settings/Setting.svelte @@ -8,33 +8,31 @@ Icon, } from 'svelte-hero-icons' - interface Props { - supportedPlatforms?: any; - mainClass?: string; - itemsClass?: string; - optionClass?: string; - class?: string; - title?: import('svelte').Snippet; - description?: import('svelte').Snippet; - children?: import('svelte').Snippet; + supportedPlatforms?: any + mainClass?: string + itemsClass?: string + optionClass?: string + class?: string + title?: import('svelte').Snippet + description?: import('svelte').Snippet + children?: import('svelte').Snippet } let { supportedPlatforms = { - desktop: true, - tablet: true, - mobile: true, - }, + desktop: true, + tablet: true, + mobile: true, + }, mainClass = '', itemsClass = '', optionClass = '', class: clazz = '', title, description, - children - }: Props = $props(); - + children, + }: Props = $props()
{#snippet icon()} - - {/snippet} + + {/snippet} {$t('settings.desktop')} {/if} {#if supportedPlatforms.tablet} {#snippet icon()} - - {/snippet} + + {/snippet} {$t('settings.tablet')} {/if} {#if supportedPlatforms.mobile} {#snippet icon()} - - {/snippet} + + {/snippet} {$t('settings.mobile')} {/if} diff --git a/src/routes/settings/ToggleSetting.svelte b/src/routes/settings/ToggleSetting.svelte index 2b69168b..f16d5e58 100644 --- a/src/routes/settings/ToggleSetting.svelte +++ b/src/routes/settings/ToggleSetting.svelte @@ -9,13 +9,12 @@ Icon, } from 'svelte-hero-icons' - interface Props { - title: string; - description?: string | undefined; - checked?: boolean; - beta?: boolean; - supportedPlatforms?: any; + title: string + description?: string | undefined + checked?: boolean + beta?: boolean + supportedPlatforms?: any } let { @@ -24,11 +23,11 @@ checked = $bindable(false), beta = false, supportedPlatforms = { - desktop: true, - tablet: true, - mobile: true, - } - }: Props = $props(); + desktop: true, + tablet: true, + mobile: true, + }, + }: Props = $props()
@@ -41,24 +40,24 @@ {#if supportedPlatforms.desktop} {#snippet icon()} - - {/snippet} + + {/snippet} {$t('settings.desktop')} {/if} {#if supportedPlatforms.tablet} {#snippet icon()} - - {/snippet} + + {/snippet} {$t('settings.tablet')} {/if} {#if supportedPlatforms.mobile} {#snippet icon()} - - {/snippet} + + {/snippet} {$t('settings.mobile')} {/if} diff --git a/src/routes/settings/nav/NavItem.svelte b/src/routes/settings/nav/NavItem.svelte index 79d8b710..d9e4f0ab 100644 --- a/src/routes/settings/nav/NavItem.svelte +++ b/src/routes/settings/nav/NavItem.svelte @@ -2,18 +2,13 @@ import { Material, Popover } from 'mono-svelte' interface Props { - href: string; - size?: keyof typeof sizes; - title?: string; - children?: import('svelte').Snippet; + href: string + size?: keyof typeof sizes + title?: string + children?: import('svelte').Snippet } - let { - href, - size = 'medium', - title = '', - children - }: Props = $props(); + let { href, size = 'medium', title = '', children }: Props = $props() const sizes = { large: 'h-24', @@ -24,13 +19,12 @@ {#snippet target()} - + {@render children?.()} {/snippet} {#snippet popover()}

Photonify links