@atmo-dev/kit 0.13.2 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ExternalEmbed.svelte +30 -29
- package/dist/components/ExternalEmbed.svelte.d.ts +8 -0
- package/dist/components/InlineEditor.svelte +15 -95
- package/dist/components/InlineEditor.svelte.d.ts +1 -1
- package/dist/components/LinkCard.svelte +54 -25
- package/dist/components/LinkCard.svelte.d.ts +2 -0
- package/dist/components/LinkEmbed.svelte +75 -0
- package/dist/components/LinkEmbed.svelte.d.ts +13 -0
- package/dist/components/NestedComments.svelte +205 -52
- package/dist/components/NestedComments.svelte.d.ts +49 -6
- package/dist/components/PostContent.svelte +26 -25
- package/dist/components/PostContent.svelte.d.ts +3 -0
- package/dist/components/PostImages.svelte +85 -0
- package/dist/components/PostImages.svelte.d.ts +9 -0
- package/dist/components/PostVideo.svelte +16 -2
- package/dist/components/PostVideo.svelte.d.ts +4 -0
- package/dist/components/RichText.svelte +47 -5
- package/dist/components/RichText.svelte.d.ts +5 -2
- package/dist/components/RichTextEditor.svelte +271 -0
- package/dist/components/RichTextEditor.svelte.d.ts +44 -0
- package/dist/components/composer/AltText.svelte +63 -0
- package/dist/components/composer/AltText.svelte.d.ts +11 -0
- package/dist/components/composer/CharRing.svelte +39 -0
- package/dist/components/composer/CharRing.svelte.d.ts +7 -0
- package/dist/components/composer/ComposerPost.svelte +321 -0
- package/dist/components/composer/ComposerPost.svelte.d.ts +29 -0
- package/dist/components/composer/Drafts.svelte +82 -0
- package/dist/components/composer/Drafts.svelte.d.ts +9 -0
- package/dist/components/composer/EmojiPicker.svelte +55 -0
- package/dist/components/composer/EmojiPicker.svelte.d.ts +7 -0
- package/dist/components/composer/GifPicker.svelte +118 -0
- package/dist/components/composer/GifPicker.svelte.d.ts +11 -0
- package/dist/components/composer/PostComposer.svelte +599 -0
- package/dist/components/composer/PostComposer.svelte.d.ts +71 -0
- package/dist/components/composer/PostComposerDialog.svelte +75 -0
- package/dist/components/composer/PostComposerDialog.svelte.d.ts +10 -0
- package/dist/components/composer/ReplySettings.svelte +150 -0
- package/dist/components/composer/ReplySettings.svelte.d.ts +18 -0
- package/dist/components/login/search.d.ts +29 -1
- package/dist/components/login/search.js +31 -3
- package/dist/editor/EditorLinkEmbed.svelte +35 -0
- package/dist/editor/EditorLinkEmbed.svelte.d.ts +12 -0
- package/dist/editor/detect-plugin.d.ts +5 -0
- package/dist/editor/detect-plugin.js +51 -0
- package/dist/editor/document.d.ts +17 -0
- package/dist/editor/document.js +269 -0
- package/dist/editor/link-embed-node.d.ts +17 -0
- package/dist/editor/link-embed-node.js +96 -0
- package/dist/editor/markdown-extensions.d.ts +6 -0
- package/dist/editor/markdown-extensions.js +42 -0
- package/dist/editor/markdown.d.ts +3 -0
- package/dist/editor/markdown.js +4 -0
- package/dist/embeds/PlayerLinkEmbed.svelte +9 -0
- package/dist/embeds/PlayerLinkEmbed.svelte.d.ts +7 -0
- package/dist/{events/event-view → embeds}/PostLinkEmbed.svelte +7 -7
- package/dist/{events/event-view → embeds}/PostLinkEmbed.svelte.d.ts +1 -1
- package/dist/{events/event-view → embeds}/ProfileLinkEmbed.svelte +7 -7
- package/dist/{events/event-view → embeds}/ProfileLinkEmbed.svelte.d.ts +1 -1
- package/dist/embeds/context.d.ts +10 -0
- package/dist/embeds/context.js +20 -0
- package/dist/embeds/defaults.d.ts +27 -0
- package/dist/embeds/defaults.js +38 -0
- package/dist/embeds/resolve.d.ts +9 -0
- package/dist/embeds/resolve.js +27 -0
- package/dist/embeds/types.d.ts +39 -0
- package/dist/embeds/types.js +1 -0
- package/dist/events/EventComments.svelte +5 -5
- package/dist/events/EventEditor.svelte +7 -6
- package/dist/events/EventView.svelte +21 -38
- package/dist/events/PostToBlueskyModal.svelte +12 -4
- package/dist/events/event-link-embed.d.ts +22 -0
- package/dist/events/event-link-embed.js +15 -0
- package/dist/events/event-view/EventLinkEmbed.svelte +12 -30
- package/dist/events/event-view/EventLinkEmbed.svelte.d.ts +3 -12
- package/dist/events.d.ts +2 -0
- package/dist/events.js +1 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +10 -2
- package/dist/richtext/detect.js +1 -1
- package/dist/richtext/document.d.ts +10 -0
- package/dist/richtext/document.js +44 -4
- package/dist/richtext/markdown.js +5 -1
- package/dist/richtext/serialize.d.ts +11 -0
- package/dist/richtext/serialize.js +462 -0
- package/dist/richtext.d.ts +1 -0
- package/dist/richtext.js +1 -0
- package/dist/social/MentionOptions.svelte +30 -0
- package/dist/social/MentionOptions.svelte.d.ts +12 -0
- package/dist/social/composer.d.ts +143 -0
- package/dist/social/composer.js +141 -0
- package/dist/social/{mention-suggestions.d.ts → mention-suggestions.svelte.d.ts} +1 -1
- package/dist/social/{mention-suggestions.js → mention-suggestions.svelte.js} +36 -46
- package/dist/social/posts.d.ts +10 -0
- package/dist/social/posts.js +5 -1
- package/dist/social/richtext.js +2 -0
- package/dist/social.d.ts +2 -0
- package/dist/social.js +1 -0
- package/dist/styles.d.ts +5 -0
- package/dist/styles.js +5 -0
- package/package.json +4 -1
- package/dist/components/PostComposer.svelte +0 -41
- package/dist/components/PostComposer.svelte.d.ts +0 -16
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" generics="T extends PostData & { replies?: T[] }">
|
|
2
|
+
import { tick, type Snippet } from 'svelte';
|
|
3
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
2
4
|
import type { PostData } from '../social/posts.js';
|
|
3
5
|
import type { ExternalEmbedProvider } from '../social/external-embeds.js';
|
|
4
|
-
import {
|
|
6
|
+
import { safeLinkHref } from '../urls.js';
|
|
5
7
|
import { socialPostUrl, socialProfileUrl } from '../social/urls.js';
|
|
6
8
|
import type { PreferredSocialClient } from '../social/preferred-client.js';
|
|
7
9
|
import { Heart, MessageCircle, Repeat2 } from '@sketchyicons/svelte';
|
|
@@ -13,64 +15,215 @@
|
|
|
13
15
|
let {
|
|
14
16
|
comments,
|
|
15
17
|
socialClient,
|
|
16
|
-
embedProviders
|
|
18
|
+
embedProviders,
|
|
19
|
+
content,
|
|
20
|
+
actions,
|
|
21
|
+
postUrl,
|
|
22
|
+
profileUrl,
|
|
23
|
+
maxDepth = 6,
|
|
24
|
+
depth = 0
|
|
17
25
|
}: {
|
|
18
|
-
comments:
|
|
26
|
+
comments: T[];
|
|
19
27
|
socialClient?: PreferredSocialClient | null;
|
|
20
28
|
embedProviders?: readonly ExternalEmbedProvider[];
|
|
29
|
+
/** Replaces a comment's text and embeds, for apps with their own post rendering. */
|
|
30
|
+
content?: Snippet<[T]>;
|
|
31
|
+
/** Replaces the outbound reply, repost and like links, e.g. with working buttons. */
|
|
32
|
+
actions?: Snippet<[T]>;
|
|
33
|
+
/** Where a comment opens. Defaults to the preferred client; root-relative paths stay in this tab. */
|
|
34
|
+
postUrl?: (comment: T) => string | null | undefined;
|
|
35
|
+
/** Where a comment's author opens. Same rules as `postUrl`. */
|
|
36
|
+
profileUrl?: (comment: T) => string | null | undefined;
|
|
37
|
+
/** Levels of replies shown before linking to the rest of a branch. */
|
|
38
|
+
maxDepth?: number;
|
|
39
|
+
/** Set by the component for its nested levels. */
|
|
40
|
+
depth?: number;
|
|
21
41
|
} = $props();
|
|
42
|
+
|
|
43
|
+
/** Comments whose replies the viewer has folded away. */
|
|
44
|
+
const folded = new SvelteSet<string>();
|
|
45
|
+
/** Folding swaps one control for another; focus follows to the one that takes its place. */
|
|
46
|
+
async function toggle(event: MouseEvent, uri: string) {
|
|
47
|
+
const item = (event.currentTarget as HTMLElement).closest('li');
|
|
48
|
+
if (folded.has(uri)) folded.delete(uri);
|
|
49
|
+
else folded.add(uri);
|
|
50
|
+
await tick();
|
|
51
|
+
item
|
|
52
|
+
?.querySelector<HTMLElement>(
|
|
53
|
+
':scope > [data-thread-toggle], :scope > div > [data-thread-toggle]'
|
|
54
|
+
)
|
|
55
|
+
?.focus({ preventScroll: true });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function link(href: string | null | undefined) {
|
|
59
|
+
const safe = safeLinkHref(href);
|
|
60
|
+
return safe?.startsWith('/')
|
|
61
|
+
? { href: safe }
|
|
62
|
+
: { href: safe, target: '_blank', rel: 'noopener noreferrer' };
|
|
63
|
+
}
|
|
64
|
+
function total(replies: PostData[]): number {
|
|
65
|
+
return replies.reduce((sum, reply) => sum + 1 + total(reply.replies ?? []), 0);
|
|
66
|
+
}
|
|
67
|
+
const plural = (count: number) => `${count} ${count === 1 ? 'reply' : 'replies'}`;
|
|
68
|
+
|
|
69
|
+
const date = (value: Date, year: boolean) =>
|
|
70
|
+
value.toLocaleDateString(undefined, {
|
|
71
|
+
month: 'short',
|
|
72
|
+
day: 'numeric',
|
|
73
|
+
year: year ? 'numeric' : undefined
|
|
74
|
+
});
|
|
75
|
+
function ago(value: Date): string {
|
|
76
|
+
const minutes = Math.floor((Date.now() - value.getTime()) / 60_000);
|
|
77
|
+
if (minutes < 1) return 'now';
|
|
78
|
+
if (minutes < 60) return `${minutes}m`;
|
|
79
|
+
if (minutes < 60 * 24) return `${Math.floor(minutes / 60)}h`;
|
|
80
|
+
if (minutes < 60 * 24 * 7) return `${Math.floor(minutes / (60 * 24))}d`;
|
|
81
|
+
return date(value, value.getFullYear() !== new Date().getFullYear());
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// The hover shade is set here so it follows the theme's dark variant.
|
|
85
|
+
const line =
|
|
86
|
+
'border-base-300 dark:border-base-700 [--thread-hover:var(--base-400)] dark:[--thread-hover:var(--base-500)]';
|
|
87
|
+
const quiet = `rounded-ui text-xs font-medium text-accent-700 hover:underline dark:text-accent-300 ${focus}`;
|
|
22
88
|
</script>
|
|
23
89
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
90
|
+
<!-- The curve from a parent's line into a reply, and the line on to the next reply. -->
|
|
91
|
+
{#snippet branch(last: boolean, height: string)}
|
|
92
|
+
<span
|
|
93
|
+
data-thread-line
|
|
94
|
+
aria-hidden="true"
|
|
95
|
+
class="pointer-events-none absolute top-0 left-[calc(-1*var(--thread-indent))] w-[calc(var(--thread-indent)-4px)] rounded-bl-[10px] border-b-2 border-l-2 {line} {height}"
|
|
96
|
+
></span>
|
|
97
|
+
{#if !last}<span
|
|
98
|
+
data-thread-line
|
|
99
|
+
aria-hidden="true"
|
|
100
|
+
class="pointer-events-none absolute inset-y-0 left-[calc(-1*var(--thread-indent))] border-l-2 {line}"
|
|
101
|
+
></span>{/if}
|
|
102
|
+
{/snippet}
|
|
103
|
+
|
|
104
|
+
<ul
|
|
105
|
+
role="list"
|
|
106
|
+
data-slot="comments"
|
|
107
|
+
class={depth
|
|
108
|
+
? 'ml-[13px] pl-(--thread-indent)'
|
|
109
|
+
: 'space-y-5 [--thread-indent:18px] sm:[--thread-indent:26px]'}
|
|
110
|
+
>
|
|
111
|
+
{#each comments as comment, index (comment.uri)}
|
|
112
|
+
{@const post = link(
|
|
113
|
+
postUrl ? postUrl(comment) : (socialPostUrl(comment.uri, socialClient) ?? comment.href)
|
|
114
|
+
)}
|
|
115
|
+
{@const profile = link(
|
|
116
|
+
profileUrl ? profileUrl(comment) : socialProfileUrl(comment.author.did, socialClient)
|
|
117
|
+
)}
|
|
118
|
+
{@const posted =
|
|
119
|
+
comment.createdAt && !Number.isNaN(Date.parse(comment.createdAt))
|
|
120
|
+
? new Date(comment.createdAt)
|
|
121
|
+
: undefined}
|
|
122
|
+
{@const replies = comment.replies ?? []}
|
|
123
|
+
{@const nested = replies.length > 0 && depth + 1 < maxDepth}
|
|
124
|
+
{@const open = nested && !folded.has(comment.uri)}
|
|
125
|
+
<!-- Replies that were not loaded, or sit deeper than this view goes. -->
|
|
126
|
+
{@const more = nested
|
|
127
|
+
? 0
|
|
128
|
+
: replies.length
|
|
129
|
+
? total(replies)
|
|
130
|
+
: comment.replies
|
|
131
|
+
? 0
|
|
132
|
+
: (comment.replyCount ?? 0)}
|
|
133
|
+
<li class="thread-item relative min-w-0 {depth ? 'pt-3' : ''}">
|
|
134
|
+
{#if depth}{@render branch(index === comments.length - 1, 'h-[27px]')}{/if}
|
|
135
|
+
<article class="relative min-w-0">
|
|
136
|
+
{#if nested || more}<span
|
|
137
|
+
data-thread-line
|
|
138
|
+
aria-hidden="true"
|
|
139
|
+
class="pointer-events-none absolute top-8 bottom-0 left-[13px] border-l-2 {line}"
|
|
140
|
+
></span>{/if}
|
|
141
|
+
<div class="flex min-w-0 items-center gap-2.5 text-sm">
|
|
142
|
+
<a {...profile} class={`shrink-0 rounded-full ${focus}`}
|
|
143
|
+
><Avatar name={comment.author.name} src={comment.author.avatar} size={28} /></a
|
|
144
|
+
>
|
|
145
|
+
<span class="flex min-w-0 items-baseline gap-x-1.5">
|
|
38
146
|
<a
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
rel="noopener noreferrer"
|
|
42
|
-
class="font-medium text-base-950 hover:underline dark:text-base-50"
|
|
147
|
+
{...profile}
|
|
148
|
+
class={`max-w-[65%] shrink-0 truncate rounded-ui font-medium text-base-950 hover:underline dark:text-base-50 ${focus}`}
|
|
43
149
|
>{comment.author.name}</a
|
|
44
|
-
><span class="truncate text-base-600 dark:text-base-400"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
150
|
+
><span class="min-w-0 truncate text-base-600 dark:text-base-400"
|
|
151
|
+
>@{comment.author.handle}</span
|
|
152
|
+
>{#if posted}<span class="text-base-600 dark:text-base-400" aria-hidden="true">·</span
|
|
153
|
+
><a
|
|
154
|
+
{...post}
|
|
155
|
+
class={`shrink-0 rounded-ui text-base-600 hover:underline dark:text-base-400 ${focus}`}
|
|
156
|
+
><time datetime={comment.createdAt} title={posted.toLocaleString()}
|
|
157
|
+
>{ago(posted)}</time
|
|
158
|
+
></a
|
|
52
159
|
>{/if}
|
|
53
|
-
</
|
|
54
|
-
<PostContent post={comment} {socialClient} {embedProviders} />
|
|
55
|
-
<div class="mt-1 flex items-center gap-5 text-xs text-base-600 dark:text-base-400">
|
|
56
|
-
{#each [{ icon: MessageCircle, count: comment.replyCount ?? 0, singular: 'reply', plural: 'replies' }, { icon: Repeat2, count: comment.repostCount ?? 0, singular: 'repost', plural: 'reposts' }, { icon: Heart, count: comment.likeCount ?? 0, singular: 'like', plural: 'likes' }] as action (action.singular)}
|
|
57
|
-
<a
|
|
58
|
-
{href}
|
|
59
|
-
target="_blank"
|
|
60
|
-
rel="noopener noreferrer"
|
|
61
|
-
aria-label={`${action.count} ${action.count === 1 ? action.singular : action.plural}`}
|
|
62
|
-
class={`inline-flex min-h-8 items-center gap-1.5 rounded-ui tabular-nums transition-colors hover:text-accent-700 dark:hover:text-accent-300 ${focus}`}
|
|
63
|
-
><Icon img={action.icon} size={16} /><span>{action.count}</span></a
|
|
64
|
-
>
|
|
65
|
-
{/each}
|
|
66
|
-
</div>
|
|
160
|
+
</span>
|
|
67
161
|
</div>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
162
|
+
<div class="min-w-0 pt-0.5 pl-[38px]">
|
|
163
|
+
{#if content}{@render content(comment)}{:else}<PostContent
|
|
164
|
+
post={comment}
|
|
165
|
+
{socialClient}
|
|
166
|
+
{embedProviders}
|
|
167
|
+
/>{/if}
|
|
168
|
+
{#if actions}{@render actions(comment)}{:else}
|
|
169
|
+
<div class="mt-1 flex items-center gap-5 text-xs text-base-600 dark:text-base-400">
|
|
170
|
+
{#each [{ icon: MessageCircle, count: comment.replyCount ?? 0, singular: 'reply', plural: 'replies' }, { icon: Repeat2, count: comment.repostCount ?? 0, singular: 'repost', plural: 'reposts' }, { icon: Heart, count: comment.likeCount ?? 0, singular: 'like', plural: 'likes' }] as action (action.singular)}
|
|
171
|
+
<a
|
|
172
|
+
{...post}
|
|
173
|
+
aria-label={`${action.count} ${action.count === 1 ? action.singular : action.plural}`}
|
|
174
|
+
class={`inline-flex min-h-8 items-center gap-1.5 rounded-ui tabular-nums transition-colors hover:text-accent-700 dark:hover:text-accent-300 ${focus}`}
|
|
175
|
+
><Icon img={action.icon} size={16} /><span>{action.count}</span></a
|
|
176
|
+
>
|
|
177
|
+
{/each}
|
|
178
|
+
</div>
|
|
179
|
+
{/if}
|
|
180
|
+
</div>
|
|
181
|
+
</article>
|
|
182
|
+
{#if open}
|
|
183
|
+
<button
|
|
184
|
+
type="button"
|
|
185
|
+
class={`thread-fold absolute top-8 bottom-0 left-1 z-1 w-5 cursor-pointer rounded-ui ${focus}`}
|
|
186
|
+
aria-expanded="true"
|
|
187
|
+
aria-label={`Hide ${plural(total(replies))} to ${comment.author.name}`}
|
|
188
|
+
data-thread-toggle
|
|
189
|
+
onclick={(event) => toggle(event, comment.uri)}
|
|
190
|
+
></button>
|
|
191
|
+
<NestedComments
|
|
192
|
+
comments={replies}
|
|
193
|
+
{socialClient}
|
|
194
|
+
{embedProviders}
|
|
195
|
+
{content}
|
|
196
|
+
{actions}
|
|
197
|
+
{postUrl}
|
|
198
|
+
{profileUrl}
|
|
199
|
+
{maxDepth}
|
|
200
|
+
depth={depth + 1}
|
|
201
|
+
/>
|
|
202
|
+
{:else if nested}
|
|
203
|
+
<div class="relative ml-[calc(13px+var(--thread-indent))] flex h-9 items-center">
|
|
204
|
+
{@render branch(true, 'h-[19px]')}
|
|
205
|
+
<button
|
|
206
|
+
type="button"
|
|
207
|
+
class={`cursor-pointer ${quiet}`}
|
|
208
|
+
aria-expanded="false"
|
|
209
|
+
data-thread-toggle
|
|
210
|
+
onclick={(event) => toggle(event, comment.uri)}>Show {plural(total(replies))}</button
|
|
211
|
+
>
|
|
212
|
+
</div>
|
|
213
|
+
{:else if more}
|
|
214
|
+
<div class="relative ml-[calc(13px+var(--thread-indent))] flex h-9 items-center">
|
|
215
|
+
{@render branch(true, 'h-[19px]')}
|
|
216
|
+
<a {...post} class={quiet}>{more} more {more === 1 ? 'reply' : 'replies'}</a>
|
|
217
|
+
</div>
|
|
218
|
+
{/if}
|
|
219
|
+
</li>
|
|
75
220
|
{/each}
|
|
76
|
-
</
|
|
221
|
+
</ul>
|
|
222
|
+
|
|
223
|
+
<style>
|
|
224
|
+
/* Pointing at a comment's line marks the replies it would hide. */
|
|
225
|
+
.thread-item:has(> .thread-fold:hover) > article > [data-thread-line],
|
|
226
|
+
.thread-item:has(> .thread-fold:hover) > :global(ul > li > [data-thread-line]) {
|
|
227
|
+
border-color: var(--thread-hover);
|
|
228
|
+
}
|
|
229
|
+
</style>
|
|
@@ -1,12 +1,55 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
1
2
|
import type { PostData } from '../social/posts.js';
|
|
2
3
|
import type { ExternalEmbedProvider } from '../social/external-embeds.js';
|
|
3
4
|
import type { PreferredSocialClient } from '../social/preferred-client.js';
|
|
4
5
|
import NestedComments from './NestedComments.svelte';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
declare function $$render<T extends PostData & {
|
|
7
|
+
replies?: T[];
|
|
8
|
+
}>(): {
|
|
9
|
+
props: {
|
|
10
|
+
comments: T[];
|
|
11
|
+
socialClient?: PreferredSocialClient | null;
|
|
12
|
+
embedProviders?: readonly ExternalEmbedProvider[];
|
|
13
|
+
/** Replaces a comment's text and embeds, for apps with their own post rendering. */
|
|
14
|
+
content?: Snippet<[T]>;
|
|
15
|
+
/** Replaces the outbound reply, repost and like links, e.g. with working buttons. */
|
|
16
|
+
actions?: Snippet<[T]>;
|
|
17
|
+
/** Where a comment opens. Defaults to the preferred client; root-relative paths stay in this tab. */
|
|
18
|
+
postUrl?: (comment: T) => string | null | undefined;
|
|
19
|
+
/** Where a comment's author opens. Same rules as `postUrl`. */
|
|
20
|
+
profileUrl?: (comment: T) => string | null | undefined;
|
|
21
|
+
/** Levels of replies shown before linking to the rest of a branch. */
|
|
22
|
+
maxDepth?: number;
|
|
23
|
+
/** Set by the component for its nested levels. */
|
|
24
|
+
depth?: number;
|
|
25
|
+
};
|
|
26
|
+
exports: {};
|
|
27
|
+
bindings: "";
|
|
28
|
+
slots: {};
|
|
29
|
+
events: {};
|
|
9
30
|
};
|
|
10
|
-
declare
|
|
11
|
-
|
|
31
|
+
declare class __sveltets_Render<T extends PostData & {
|
|
32
|
+
replies?: T[];
|
|
33
|
+
}> {
|
|
34
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
35
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
36
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
37
|
+
bindings(): "";
|
|
38
|
+
exports(): {};
|
|
39
|
+
}
|
|
40
|
+
interface $$IsomorphicComponent {
|
|
41
|
+
new <T extends PostData & {
|
|
42
|
+
replies?: T[];
|
|
43
|
+
}>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
44
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
45
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
46
|
+
<T extends PostData & {
|
|
47
|
+
replies?: T[];
|
|
48
|
+
}>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
49
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
50
|
+
}
|
|
51
|
+
declare const NestedComments: $$IsomorphicComponent;
|
|
52
|
+
type NestedComments<T extends PostData & {
|
|
53
|
+
replies?: T[];
|
|
54
|
+
}> = InstanceType<typeof NestedComments<T>>;
|
|
12
55
|
export default NestedComments;
|
|
@@ -9,17 +9,23 @@
|
|
|
9
9
|
import RichText from './RichText.svelte';
|
|
10
10
|
import type { ExternalEmbedProvider } from '../social/external-embeds.js';
|
|
11
11
|
import ExternalEmbed from './ExternalEmbed.svelte';
|
|
12
|
+
import type { LinkEmbed } from '../embeds/types.js';
|
|
12
13
|
import PostVideo from './PostVideo.svelte';
|
|
14
|
+
import PostImages from './PostImages.svelte';
|
|
15
|
+
import Avatar from './Avatar.svelte';
|
|
13
16
|
import PostContent from './PostContent.svelte';
|
|
14
17
|
let {
|
|
15
18
|
post,
|
|
16
19
|
socialClient,
|
|
17
|
-
embedProviders
|
|
20
|
+
embedProviders,
|
|
21
|
+
linkEmbeds = false
|
|
18
22
|
}: {
|
|
19
23
|
post: PostData;
|
|
20
24
|
socialClient?: PreferredSocialClient | null;
|
|
21
25
|
/** Defaults to YouTube and Klipy. Pass [] to render only ordinary link cards. */
|
|
22
26
|
embedProviders?: readonly ExternalEmbedProvider[];
|
|
27
|
+
/** Show links to posts, profiles and other known pages as embeds instead of cards. */
|
|
28
|
+
linkEmbeds?: boolean | readonly LinkEmbed[];
|
|
23
29
|
} = $props();
|
|
24
30
|
const recordKinds = {
|
|
25
31
|
feed: { label: 'Feed', icon: Radio },
|
|
@@ -31,32 +37,21 @@
|
|
|
31
37
|
|
|
32
38
|
{#if post.text}<RichText text={post.text} facets={post.facets} class="text-sm" />{/if}
|
|
33
39
|
{#each post.embeds ?? [] as embed, index (index)}
|
|
34
|
-
<div class=
|
|
35
|
-
{#if embed.type === 'external'}<ExternalEmbed
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
target="_blank"
|
|
43
|
-
rel="noopener noreferrer"
|
|
44
|
-
><img
|
|
45
|
-
src={safeWebUrl(image.src)}
|
|
46
|
-
alt={image.alt}
|
|
47
|
-
loading="lazy"
|
|
48
|
-
width={image.width}
|
|
49
|
-
height={image.height}
|
|
50
|
-
class="max-h-80 w-full object-cover"
|
|
51
|
-
class:aspect-square={embed.images.length > 1}
|
|
52
|
-
/></a
|
|
53
|
-
>{/each}
|
|
54
|
-
</div>
|
|
40
|
+
<div class={post.text || index ? 'mt-2.5' : ''}>
|
|
41
|
+
{#if embed.type === 'external'}<ExternalEmbed
|
|
42
|
+
{embed}
|
|
43
|
+
providers={embedProviders}
|
|
44
|
+
embeds={linkEmbeds}
|
|
45
|
+
{socialClient}
|
|
46
|
+
/>
|
|
47
|
+
{:else if embed.type === 'images'}<PostImages images={embed.images} />
|
|
55
48
|
{:else if embed.type === 'video'}<PostVideo
|
|
56
49
|
playlist={embed.playlist}
|
|
57
50
|
poster={embed.poster}
|
|
58
51
|
label={embed.alt}
|
|
59
52
|
href={post.href}
|
|
53
|
+
aspectRatio={embed.aspectRatio}
|
|
54
|
+
gif={embed.gif}
|
|
60
55
|
/>
|
|
61
56
|
{:else if embed.type === 'record'}
|
|
62
57
|
{@const kind = recordKinds[embed.kind]}
|
|
@@ -94,9 +89,15 @@
|
|
|
94
89
|
href={socialPostUrl(embed.post.uri, socialClient) ?? safeWebUrl(embed.post.href)}
|
|
95
90
|
target="_blank"
|
|
96
91
|
rel="noopener noreferrer"
|
|
97
|
-
class=
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
class={`mb-1.5 flex min-w-0 items-center gap-2 rounded-ui text-xs text-base-600 no-underline dark:text-base-400 ${focus}`}
|
|
93
|
+
><Avatar name={embed.post.author.name} src={embed.post.author.avatar} size={18} /><span
|
|
94
|
+
class="min-w-0 truncate"
|
|
95
|
+
><span class="font-medium text-base-950 dark:text-base-50"
|
|
96
|
+
>{embed.post.author.name}</span
|
|
97
|
+
>
|
|
98
|
+
@{embed.post.author.handle}</span
|
|
99
|
+
></a
|
|
100
|
+
><PostContent post={embed.post} {socialClient} {embedProviders} {linkEmbeds} />{:else}<p
|
|
100
101
|
class="text-xs text-base-600 dark:text-base-400"
|
|
101
102
|
>
|
|
102
103
|
{embed.reason === 'blocked'
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { PostData } from '../social/posts.js';
|
|
2
2
|
import type { PreferredSocialClient } from '../social/preferred-client.js';
|
|
3
3
|
import type { ExternalEmbedProvider } from '../social/external-embeds.js';
|
|
4
|
+
import type { LinkEmbed } from '../embeds/types.js';
|
|
4
5
|
import PostContent from './PostContent.svelte';
|
|
5
6
|
type $$ComponentProps = {
|
|
6
7
|
post: PostData;
|
|
7
8
|
socialClient?: PreferredSocialClient | null;
|
|
8
9
|
/** Defaults to YouTube and Klipy. Pass [] to render only ordinary link cards. */
|
|
9
10
|
embedProviders?: readonly ExternalEmbedProvider[];
|
|
11
|
+
/** Show links to posts, profiles and other known pages as embeds instead of cards. */
|
|
12
|
+
linkEmbeds?: boolean | readonly LinkEmbed[];
|
|
10
13
|
};
|
|
11
14
|
declare const PostContent: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
12
15
|
type PostContent = ReturnType<typeof PostContent>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PostEmbed } from '../social/posts.js';
|
|
3
|
+
import { safeHttpUrl } from '../urls.js';
|
|
4
|
+
import { focus } from '../styles.js';
|
|
5
|
+
import PhotoLightbox from './PhotoLightbox.svelte';
|
|
6
|
+
|
|
7
|
+
let { images }: { images: Extract<PostEmbed, { type: 'images' }>['images'] } = $props();
|
|
8
|
+
|
|
9
|
+
/** Web images, or files served by the app itself. */
|
|
10
|
+
const source = (value: string | undefined) =>
|
|
11
|
+
safeHttpUrl(value) ?? (value?.startsWith('/') && !value.startsWith('//') ? value : undefined);
|
|
12
|
+
let safe = $derived(
|
|
13
|
+
images.flatMap((image) => {
|
|
14
|
+
const src = source(image.src);
|
|
15
|
+
return src ? [{ ...image, src, fullsize: source(image.fullsize) ?? src }] : [];
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
// Up to four tiles; the last one counts the rest, which the viewer still shows.
|
|
19
|
+
let shown = $derived(safe.slice(0, 4));
|
|
20
|
+
let photos = $derived(
|
|
21
|
+
safe.map((image) => ({
|
|
22
|
+
src: image.fullsize,
|
|
23
|
+
thumbnail: image.src,
|
|
24
|
+
alt: image.alt,
|
|
25
|
+
width: image.width,
|
|
26
|
+
height: image.height
|
|
27
|
+
}))
|
|
28
|
+
);
|
|
29
|
+
// A single image keeps its shape within sensible bounds; groups use fixed tiles.
|
|
30
|
+
let single = $derived.by(() => {
|
|
31
|
+
const { width, height } = safe[0] ?? {};
|
|
32
|
+
return width && height ? Math.min(3, Math.max(0.6, width / height)) : 1.5;
|
|
33
|
+
});
|
|
34
|
+
let open = $state(false);
|
|
35
|
+
let index = $state(0);
|
|
36
|
+
let trigger = $state<HTMLButtonElement | null>(null);
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
{#if shown.length}
|
|
40
|
+
<div
|
|
41
|
+
class="grid max-h-[28rem] gap-0.5 overflow-hidden rounded-ui {shown.length > 1
|
|
42
|
+
? 'aspect-[3/2] grid-cols-2'
|
|
43
|
+
: ''} {shown.length > 2 ? 'grid-rows-2' : ''}"
|
|
44
|
+
style:aspect-ratio={shown.length === 1 ? single : undefined}
|
|
45
|
+
>
|
|
46
|
+
{#each shown as image, i (i)}
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
class={`relative min-h-0 min-w-0 cursor-zoom-in bg-base-100 focus-visible:z-10 dark:bg-base-900 ${focus} focus-visible:-outline-offset-2 ${
|
|
50
|
+
shown.length === 3 && i === 0 ? 'row-span-2' : ''
|
|
51
|
+
}`}
|
|
52
|
+
onclick={(event) => {
|
|
53
|
+
trigger = event.currentTarget;
|
|
54
|
+
index = i;
|
|
55
|
+
open = true;
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<img
|
|
59
|
+
src={image.src}
|
|
60
|
+
alt={image.alt}
|
|
61
|
+
loading="lazy"
|
|
62
|
+
decoding="async"
|
|
63
|
+
class="absolute inset-0 size-full object-cover"
|
|
64
|
+
/>
|
|
65
|
+
{#if !image.alt}<span class="sr-only">View image {i + 1} of {safe.length}</span>{/if}
|
|
66
|
+
<!-- Recessed edge, drawn above the image. -->
|
|
67
|
+
<span
|
|
68
|
+
class="pointer-events-none absolute inset-0 shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--base-950)_8%,transparent),inset_0_2px_5px_color-mix(in_srgb,var(--base-950)_8%,transparent)] dark:shadow-[inset_0_0_0_1px_#0006,inset_0_2px_5px_#0006]"
|
|
69
|
+
></span>
|
|
70
|
+
{#if i === 3 && safe.length > 4}
|
|
71
|
+
<span
|
|
72
|
+
class="absolute inset-0 grid place-items-center bg-black/55 text-lg font-medium text-white"
|
|
73
|
+
aria-hidden="true">+{safe.length - 4}</span
|
|
74
|
+
>
|
|
75
|
+
{:else if image.alt}
|
|
76
|
+
<span
|
|
77
|
+
class="absolute bottom-1.5 left-1.5 rounded bg-black/65 px-1 py-px text-[10px] font-semibold tracking-wide text-white"
|
|
78
|
+
aria-hidden="true">ALT</span
|
|
79
|
+
>
|
|
80
|
+
{/if}
|
|
81
|
+
</button>
|
|
82
|
+
{/each}
|
|
83
|
+
</div>
|
|
84
|
+
<PhotoLightbox {photos} bind:open bind:index returnFocus={trigger} />
|
|
85
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PostEmbed } from '../social/posts.js';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
images: Extract<PostEmbed, {
|
|
4
|
+
type: 'images';
|
|
5
|
+
}>['images'];
|
|
6
|
+
};
|
|
7
|
+
declare const PostImages: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type PostImages = ReturnType<typeof PostImages>;
|
|
9
|
+
export default PostImages;
|
|
@@ -6,8 +6,19 @@
|
|
|
6
6
|
playlist,
|
|
7
7
|
poster,
|
|
8
8
|
label,
|
|
9
|
-
href
|
|
10
|
-
|
|
9
|
+
href,
|
|
10
|
+
aspectRatio,
|
|
11
|
+
gif = false
|
|
12
|
+
}: {
|
|
13
|
+
playlist: string;
|
|
14
|
+
poster?: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
href: string;
|
|
17
|
+
/** Width divided by height; reserves the player's space before it loads. */
|
|
18
|
+
aspectRatio?: number;
|
|
19
|
+
/** Loop without sound, like a GIF. */
|
|
20
|
+
gif?: boolean;
|
|
21
|
+
} = $props();
|
|
11
22
|
let video = $state<HTMLVideoElement | null>(null);
|
|
12
23
|
// Writable derived state resets a playback failure when the source changes.
|
|
13
24
|
let failed = $derived(!safeWebUrl(playlist));
|
|
@@ -61,6 +72,9 @@
|
|
|
61
72
|
controls
|
|
62
73
|
playsinline
|
|
63
74
|
preload="none"
|
|
75
|
+
loop={gif}
|
|
76
|
+
muted={gif}
|
|
77
|
+
style:aspect-ratio={aspectRatio ? Math.min(3, Math.max(0.6, aspectRatio)) : undefined}
|
|
64
78
|
class="max-h-96 w-full rounded-ui bg-black"
|
|
65
79
|
onerror={() => (failed = true)}
|
|
66
80
|
></video>
|
|
@@ -3,6 +3,10 @@ type $$ComponentProps = {
|
|
|
3
3
|
poster?: string;
|
|
4
4
|
label?: string;
|
|
5
5
|
href: string;
|
|
6
|
+
/** Width divided by height; reserves the player's space before it loads. */
|
|
7
|
+
aspectRatio?: number;
|
|
8
|
+
/** Loop without sound, like a GIF. */
|
|
9
|
+
gif?: boolean;
|
|
6
10
|
};
|
|
7
11
|
declare const PostVideo: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
12
|
type PostVideo = ReturnType<typeof PostVideo>;
|