@atmo-dev/kit 0.13.1 → 0.14.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.
@@ -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 { safeHttpUrl as safeWebUrl } from '../urls.js';
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: PostData[];
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
- <div class="space-y-6" data-slot="comments">
25
- {#each comments as comment (comment.uri)}
26
- {@const href = socialPostUrl(comment.uri, socialClient) ?? safeWebUrl(comment.href)}
27
- <article class="min-w-0">
28
- <div class="flex items-start gap-3">
29
- <a
30
- href={socialProfileUrl(comment.author.did, socialClient)}
31
- target="_blank"
32
- rel="noopener noreferrer"
33
- class="shrink-0"
34
- ><Avatar name={comment.author.name} src={comment.author.avatar} size={32} /></a
35
- >
36
- <div class="min-w-0 flex-1">
37
- <div class="mb-1 flex flex-wrap items-baseline gap-x-2 text-xs">
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
- {href}
40
- target="_blank"
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">@{comment.author.handle}</span
45
- >{#if comment.createdAt && !Number.isNaN(Date.parse(comment.createdAt))}<time
46
- datetime={comment.createdAt}
47
- class="text-[.6875rem] text-base-600 dark:text-base-400"
48
- >{new Date(comment.createdAt).toLocaleDateString(undefined, {
49
- month: 'short',
50
- day: 'numeric'
51
- })}</time
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
- </div>
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
- </div>
69
- {#if comment.replies?.length}<div
70
- class="mt-4 border-l border-base-300 pl-3 sm:ml-4 sm:pl-6 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))]"
71
- >
72
- <NestedComments comments={comment.replies} {socialClient} {embedProviders} />
73
- </div>{/if}
74
- </article>
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
- </div>
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
- type $$ComponentProps = {
6
- comments: PostData[];
7
- socialClient?: PreferredSocialClient | null;
8
- embedProviders?: readonly ExternalEmbedProvider[];
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 const NestedComments: import("svelte").Component<$$ComponentProps, {}, "">;
11
- type NestedComments = ReturnType<typeof NestedComments>;
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;
@@ -10,6 +10,8 @@
10
10
  import type { ExternalEmbedProvider } from '../social/external-embeds.js';
11
11
  import ExternalEmbed from './ExternalEmbed.svelte';
12
12
  import PostVideo from './PostVideo.svelte';
13
+ import PostImages from './PostImages.svelte';
14
+ import Avatar from './Avatar.svelte';
13
15
  import PostContent from './PostContent.svelte';
14
16
  let {
15
17
  post,
@@ -31,32 +33,16 @@
31
33
 
32
34
  {#if post.text}<RichText text={post.text} facets={post.facets} class="text-sm" />{/if}
33
35
  {#each post.embeds ?? [] as embed, index (index)}
34
- <div class="mt-3">
36
+ <div class={post.text || index ? 'mt-2.5' : ''}>
35
37
  {#if embed.type === 'external'}<ExternalEmbed {embed} providers={embedProviders} />
36
- {:else if embed.type === 'images'}<div
37
- class="grid gap-1 overflow-hidden rounded-ui border border-base-300 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))]"
38
- class:grid-cols-2={embed.images.length > 1}
39
- >
40
- {#each embed.images as image, imageIndex (imageIndex)}<a
41
- href={safeWebUrl(image.fullsize ?? image.src)}
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>
38
+ {:else if embed.type === 'images'}<PostImages images={embed.images} />
55
39
  {:else if embed.type === 'video'}<PostVideo
56
40
  playlist={embed.playlist}
57
41
  poster={embed.poster}
58
42
  label={embed.alt}
59
43
  href={post.href}
44
+ aspectRatio={embed.aspectRatio}
45
+ gif={embed.gif}
60
46
  />
61
47
  {:else if embed.type === 'record'}
62
48
  {@const kind = recordKinds[embed.kind]}
@@ -94,8 +80,14 @@
94
80
  href={socialPostUrl(embed.post.uri, socialClient) ?? safeWebUrl(embed.post.href)}
95
81
  target="_blank"
96
82
  rel="noopener noreferrer"
97
- class="mb-2 block text-xs font-medium text-base-600 dark:text-base-400"
98
- >{embed.post.author.name} · @{embed.post.author.handle}</a
83
+ 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}`}
84
+ ><Avatar name={embed.post.author.name} src={embed.post.author.avatar} size={18} /><span
85
+ class="min-w-0 truncate"
86
+ ><span class="font-medium text-base-950 dark:text-base-50"
87
+ >{embed.post.author.name}</span
88
+ >
89
+ @{embed.post.author.handle}</span
90
+ ></a
99
91
  ><PostContent post={embed.post} {socialClient} {embedProviders} />{:else}<p
100
92
  class="text-xs text-base-600 dark:text-base-400"
101
93
  >
@@ -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
- }: { playlist: string; poster?: string; label?: string; href: string } = $props();
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>;
@@ -26,7 +26,8 @@
26
26
  * a moderation label (itself, its author, or a post it quotes) is left out, with the replies
27
27
  * beneath it.
28
28
  */
29
- function threadToComments(replies: unknown[]): PostData[] {
29
+ const DEPTH = 6;
30
+ function threadToComments(replies: unknown[], level = 1): PostData[] {
30
31
  return (replies as Array<{ $type?: string; post?: unknown; replies?: unknown[] }>)
31
32
  .filter(
32
33
  (r) =>
@@ -36,9 +37,8 @@
36
37
  const postData = blueskyPostToPostData(
37
38
  r.post as Parameters<typeof blueskyPostToPostData>[0]
38
39
  );
39
- if (r.replies?.length) {
40
- postData.replies = threadToComments(r.replies);
41
- }
40
+ // Below the requested depth nothing was loaded; the comment links to the rest instead.
41
+ if (level < DEPTH) postData.replies = threadToComments(r.replies ?? [], level + 1);
42
42
  return postData;
43
43
  });
44
44
  }
@@ -48,7 +48,7 @@
48
48
  errorMessage = null;
49
49
  try {
50
50
  const res = await fetch(
51
- `${appviewUrl()}/xrpc/app.bsky.feed.getPostThread?uri=${encodeURIComponent(uri)}&depth=6`,
51
+ `${appviewUrl()}/xrpc/app.bsky.feed.getPostThread?uri=${encodeURIComponent(uri)}&depth=${DEPTH}`,
52
52
  { signal }
53
53
  );
54
54
  if (!res.ok) throw new Error(`Failed to load thread (${res.status})`);
@@ -542,7 +542,7 @@
542
542
  <VodPlayer
543
543
  playlistUrl={data.vod.playlistUrl}
544
544
  title={eventData.name}
545
- subtitlesUrl="/vods/{rkey}-karaoke.vtt"
545
+ subtitlesUrl={data.vod.subtitlesUrl}
546
546
  bind:currentTime={vodCurrentTime}
547
547
  bind:api={vodApi}
548
548
  />
@@ -32,6 +32,7 @@ export interface EventViewData {
32
32
  parentScheduleUrl?: string | null;
33
33
  vod?: {
34
34
  playlistUrl: string;
35
+ subtitlesUrl?: string;
35
36
  } | null;
36
37
  conferenceTalks?: FlatEventRecord[];
37
38
  /** Plain-text talk descriptions keyed by talk URI, e.g. from `richTextToPlainText`. */
@@ -19,6 +19,10 @@ export type PostEmbed = {
19
19
  playlist: string;
20
20
  poster?: string;
21
21
  alt?: string;
22
+ /** Width divided by height. */
23
+ aspectRatio?: number;
24
+ /** A looping, silent clip presented like a GIF. */
25
+ gif?: boolean;
22
26
  } | {
23
27
  type: 'quote';
24
28
  post?: PostData;
@@ -51,6 +55,7 @@ export type PostData = {
51
55
  repostCount?: number;
52
56
  likeCount?: number;
53
57
  embeds?: PostEmbed[];
58
+ /** Leave undefined when replies were not loaded; `NestedComments` then links to the rest. */
54
59
  replies?: PostData[];
55
60
  };
56
61
  type PostRecord = {
@@ -130,6 +135,11 @@ type BlueskyEmbedView = {
130
135
  playlist?: string;
131
136
  thumbnail?: string;
132
137
  alt?: string;
138
+ aspectRatio?: {
139
+ width: number;
140
+ height: number;
141
+ };
142
+ presentation?: string;
133
143
  record?: RecordView;
134
144
  media?: BlueskyEmbedView;
135
145
  };
@@ -147,7 +147,11 @@ export function blueskyPostToPostData(post, depth = 0) {
147
147
  type: 'video',
148
148
  playlist: embed.playlist,
149
149
  poster: embed.thumbnail,
150
- alt: embed.alt
150
+ alt: embed.alt,
151
+ aspectRatio: embed.aspectRatio?.width && embed.aspectRatio.height
152
+ ? embed.aspectRatio.width / embed.aspectRatio.height
153
+ : undefined,
154
+ gif: embed.presentation === 'gif' || undefined
151
155
  });
152
156
  }
153
157
  else if (!embed.record && !embed.media) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atmo-dev/kit",
3
- "version": "0.13.1",
3
+ "version": "0.14.0",
4
4
  "description": "The shared UI foundation for Atmo apps.",
5
5
  "license": "MIT",
6
6
  "repository": {