diff --git a/bun.lockb b/bun.lockb index 6480ec87..266733a0 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/eslint.config.js b/eslint.config.js index fd8ed3c7..5fb6b567 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -23,11 +23,11 @@ export default ts.config( 'no-undef': 'off', // sveltekit should make this native then 'svelte/valid-prop-names-in-kit-pages': 'off', - 'svelte/no-at-html-tags': 'warn', - '@typescript-eslint/no-unsafe-function-type': 'warn', + 'svelte/no-at-html-tags': 'off', + '@typescript-eslint/no-unsafe-function-type': 'off', 'svelte/require-each-key': 'off', - 'svelte/prefer-writable-derived': 'warn', - 'no-console': 'warn', + 'svelte/prefer-writable-derived': 'off', + 'no-console': 'off', }, }, { diff --git a/package.json b/package.json index cb3d499c..99d009e6 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@types/nprogress": "^0.2.0", "@types/ua-parser-js": "^0.7.39", "eslint": "^9.28.0", - "eslint-plugin-svelte": "^3.9.1", + "eslint-plugin-svelte": "^3.11.0", "jsdom": "^22.1.0", "lemmy-js-client": "0.19.11-donation-dialog.1", "linkify-it": "^5.0.0", @@ -27,7 +27,7 @@ "postcss": "^8.4.30", "prettier": "^3.3.3", "prettier-plugin-svelte": "^3.2.7", - "svelte": "^5.34.8", + "svelte": "^5.37.3", "svelte-adapter-bun-next": "^1.0.3", "svelte-check": "^4.0.0", "svelte-floating-ui": "^1.5.9", 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/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/feed/crosspost.svelte.ts b/src/lib/components/lemmy/post/feed/crosspost.svelte.ts index e81431e7..f900203b 100644 --- a/src/lib/components/lemmy/post/feed/crosspost.svelte.ts +++ b/src/lib/components/lemmy/post/feed/crosspost.svelte.ts @@ -1,5 +1,6 @@ import { settings } from '$lib/settings.svelte' import type { PostView } from 'lemmy-js-client' +import { SvelteMap, SvelteSet } from 'svelte/reactivity' export type PostViewWithCrossposts = PostView & { withCrossposts: true @@ -10,12 +11,12 @@ export type PostViewWithoutCrossposts = PostView & { withCrossposts?: false } export const combineCrossposts = ( posts: PostView[], ): (PostViewWithCrossposts | PostViewWithoutCrossposts)[] => { - const urlMap = new Map< + const urlMap = new SvelteMap< string, PostViewWithCrossposts | PostViewWithoutCrossposts >() const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = [] - const seenUrls = new Set() + const seenUrls = new SvelteSet() posts?.forEach(post => { if ( diff --git a/src/lib/components/ui/Pageination.svelte b/src/lib/components/ui/Pageination.svelte index d0ce5459..b9f51f94 100644 --- a/src/lib/components/ui/Pageination.svelte +++ b/src/lib/components/ui/Pageination.svelte @@ -6,6 +6,7 @@ import { fly } from 'svelte/transition' import { page as pageData } from '$app/state' import { invalidate } from '$app/navigation' + import { SvelteURLSearchParams } from 'svelte/reactivity' interface Props { page?: number @@ -27,8 +28,8 @@ let customHref = (href?: string) => { if (href?.startsWith('?')) { - const current = new URLSearchParams(pageData.url.searchParams) - const newParams = new URLSearchParams(href) + const current = new SvelteURLSearchParams(pageData.url.searchParams) + const newParams = new SvelteURLSearchParams(href) current.delete(Array.from(newParams.keys())[0]) current.append( 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/util.svelte.ts b/src/lib/util.svelte.ts index 14077ac0..7fde5974 100644 --- a/src/lib/util.svelte.ts +++ b/src/lib/util.svelte.ts @@ -1,12 +1,11 @@ import { goto } from '$app/navigation' import { client } from '$lib/lemmy.svelte.js' import { settings } from '$lib/settings.svelte' -import { feature } from '$lib/version.js' import type { SubscribedType } from 'lemmy-js-client' 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 +28,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'], @@ -126,38 +125,12 @@ export async function uploadImage( const formData = new FormData() formData.append('images[]', image) - if (feature('unproxiedImageUpload', site.data?.version)) { - const res = await client({ auth: jwt, instanceURL: instance }).uploadImage({ - image: image, - }) + const res = await client({ auth: jwt, instanceURL: instance }).uploadImage({ + image: image, + }) - 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}`, - ) - } + if (res.url) return res.url + else throw new Error(`Failed to upload image. ${res.msg}`) } export const instanceToURL = (input: string) => @@ -167,7 +140,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 +148,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/inbox/+page.svelte b/src/routes/inbox/+page.svelte index c7c8d7d6..dabcef2b 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() @@ -43,10 +44,10 @@ newParamString: string, ) { // Create a new URLSearchParams object from the current search params - const updatedParams = new URLSearchParams(currentSearchParams) + 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)) {