@atmo-dev/kit 0.11.1 → 0.13.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/RichText.svelte +17 -1
- package/dist/components/RichText.svelte.d.ts +8 -0
- package/dist/components/SembleCollectionPicker.svelte +221 -0
- package/dist/components/SembleCollectionPicker.svelte.d.ts +14 -0
- package/dist/components/SembleCollectionView.svelte +153 -0
- package/dist/components/SembleCollectionView.svelte.d.ts +10 -0
- package/dist/events/EventComments.svelte +15 -2
- package/dist/events/EventView.svelte +100 -28
- package/dist/events/VodPlayer.svelte +14 -73
- package/dist/events/VodPlayer.svelte.d.ts +0 -1
- package/dist/events/editor/LinkedRecordsPicker.svelte +44 -3
- package/dist/events/editor/LinksSection.svelte +29 -9
- package/dist/events/editor/adapter.d.ts +3 -0
- package/dist/events/event-view/EventLinkEmbed.svelte +49 -0
- package/dist/events/event-view/EventLinkEmbed.svelte.d.ts +14 -0
- package/dist/events/event-view/Player.svelte +431 -0
- package/dist/events/event-view/Player.svelte.d.ts +24 -0
- package/dist/events/event-view/PostLinkEmbed.svelte +71 -0
- package/dist/events/event-view/PostLinkEmbed.svelte.d.ts +11 -0
- package/dist/events/event-view/ProfileLinkEmbed.svelte +67 -0
- package/dist/events/event-view/ProfileLinkEmbed.svelte.d.ts +11 -0
- package/dist/events/event-view/StreamPlacePlayer.svelte +13 -46
- package/dist/events/event-view/StreamPlacePlayer.svelte.d.ts +0 -1
- package/dist/events/linked-records.d.ts +20 -0
- package/dist/events/linked-records.js +32 -2
- package/dist/events/schedule/ScheduleEventCell.svelte +2 -1
- package/dist/events/urls.d.ts +17 -0
- package/dist/events/urls.js +11 -0
- package/dist/events-data.d.ts +1 -0
- package/dist/events-data.js +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +5 -1
- package/dist/richtext/document.d.ts +9 -0
- package/dist/richtext/document.js +35 -0
- package/dist/richtext.d.ts +1 -1
- package/dist/richtext.js +1 -1
- package/dist/semble/types.d.ts +46 -0
- package/dist/semble/types.js +1 -0
- package/dist/semble/urls.d.ts +2 -0
- package/dist/semble/urls.js +43 -0
- package/dist/semble/xrpc.d.ts +3 -0
- package/dist/semble/xrpc.js +131 -0
- package/dist/semble.d.ts +3 -0
- package/dist/semble.js +2 -0
- package/dist/social/posts.d.ts +7 -0
- package/dist/social/posts.js +21 -0
- package/dist/social/urls.d.ts +10 -0
- package/dist/social/urls.js +43 -1
- package/dist/social.d.ts +3 -1
- package/dist/social.js +2 -1
- package/package.json +5 -6
- package/dist/events/event-view/plyr-icons.d.ts +0 -3
- package/dist/events/event-view/plyr-icons.js +0 -46
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
const SPEEDS = [1, 1.25, 1.5, 1.75, 2, 0.5, 0.75];
|
|
3
|
+
const clock = (seconds: number) => {
|
|
4
|
+
if (!Number.isFinite(seconds) || seconds < 0) seconds = 0;
|
|
5
|
+
const s = Math.floor(seconds % 60);
|
|
6
|
+
const m = Math.floor(seconds / 60) % 60;
|
|
7
|
+
const h = Math.floor(seconds / 3600);
|
|
8
|
+
return h
|
|
9
|
+
? `${h}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`
|
|
10
|
+
: `${m}:${String(s).padStart(2, '0')}`;
|
|
11
|
+
};
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import type { Snippet } from 'svelte';
|
|
16
|
+
import { Icon } from '../../index.js';
|
|
17
|
+
import {
|
|
18
|
+
Captions,
|
|
19
|
+
CaptionsOff,
|
|
20
|
+
Maximize,
|
|
21
|
+
Minimize,
|
|
22
|
+
Pause,
|
|
23
|
+
Play,
|
|
24
|
+
Volume2,
|
|
25
|
+
VolumeX
|
|
26
|
+
} from '@sketchyicons/svelte';
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
* The controls shared by the recording and live players. The caller attaches the media
|
|
30
|
+
* (an HLS playlist, a WebRTC stream) to the bound `video` element; this component only
|
|
31
|
+
* drives it.
|
|
32
|
+
*/
|
|
33
|
+
let {
|
|
34
|
+
title,
|
|
35
|
+
poster,
|
|
36
|
+
live = false,
|
|
37
|
+
autoplay = false,
|
|
38
|
+
captionsUrl,
|
|
39
|
+
video = $bindable(),
|
|
40
|
+
currentTime = $bindable(0),
|
|
41
|
+
controlsVisible = $bindable(true),
|
|
42
|
+
onplay,
|
|
43
|
+
children
|
|
44
|
+
}: {
|
|
45
|
+
title: string;
|
|
46
|
+
poster?: string;
|
|
47
|
+
/** A live stream has no timeline to scrub and no playback speed. */
|
|
48
|
+
live?: boolean;
|
|
49
|
+
/** Start playing, muted, as browsers require. */
|
|
50
|
+
autoplay?: boolean;
|
|
51
|
+
/** WebVTT captions, shown from the start. */
|
|
52
|
+
captionsUrl?: string;
|
|
53
|
+
video?: HTMLVideoElement;
|
|
54
|
+
currentTime?: number;
|
|
55
|
+
/** Whether the controls are on screen, for overlays that come and go with them. */
|
|
56
|
+
controlsVisible?: boolean;
|
|
57
|
+
onplay?: () => void;
|
|
58
|
+
/** Overlay content, positioned by the caller inside the frame. */
|
|
59
|
+
children?: Snippet;
|
|
60
|
+
} = $props();
|
|
61
|
+
|
|
62
|
+
let frame = $state<HTMLDivElement>();
|
|
63
|
+
let bar = $state<HTMLDivElement>();
|
|
64
|
+
let started = $state(false);
|
|
65
|
+
let playing = $state(false);
|
|
66
|
+
let waiting = $state(false);
|
|
67
|
+
// svelte-ignore state_referenced_locally
|
|
68
|
+
let muted = $state(autoplay);
|
|
69
|
+
let volume = $state(1);
|
|
70
|
+
let duration = $state(0);
|
|
71
|
+
let buffered = $state(0);
|
|
72
|
+
let speed = $state(1);
|
|
73
|
+
let fullscreen = $state(false);
|
|
74
|
+
let hasCaptions = $state(false);
|
|
75
|
+
// svelte-ignore state_referenced_locally
|
|
76
|
+
let captions = $state(!!captionsUrl);
|
|
77
|
+
let active = $state(true);
|
|
78
|
+
let scrubbing = $state(false);
|
|
79
|
+
/** A control holds keyboard focus; a control that was only clicked does not count. */
|
|
80
|
+
let focused = $state(false);
|
|
81
|
+
let hideTimer: ReturnType<typeof setTimeout> | undefined;
|
|
82
|
+
|
|
83
|
+
$effect(() => {
|
|
84
|
+
controlsVisible = active || !playing || scrubbing || focused;
|
|
85
|
+
});
|
|
86
|
+
$effect(() => () => clearTimeout(hideTimer));
|
|
87
|
+
|
|
88
|
+
// Caption tracks arrive from the `<track>` below or from the stream itself.
|
|
89
|
+
const captionTracks = (node: HTMLVideoElement) =>
|
|
90
|
+
[...node.textTracks].filter((track) => track.kind === 'captions' || track.kind === 'subtitles');
|
|
91
|
+
$effect(() => {
|
|
92
|
+
const node = video;
|
|
93
|
+
if (!node) return;
|
|
94
|
+
const sync = () => {
|
|
95
|
+
const tracks = captionTracks(node);
|
|
96
|
+
hasCaptions = tracks.length > 0;
|
|
97
|
+
tracks.forEach((track, index) => {
|
|
98
|
+
track.mode = captions && index === 0 ? 'showing' : 'disabled';
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
sync();
|
|
102
|
+
node.textTracks.addEventListener('addtrack', sync);
|
|
103
|
+
return () => node.textTracks.removeEventListener('addtrack', sync);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Captions sit at the bottom of the picture, where the controls are: lift them while
|
|
107
|
+
// the controls are up.
|
|
108
|
+
$effect(() => {
|
|
109
|
+
const node = video;
|
|
110
|
+
if (!node || !hasCaptions || !captions) return;
|
|
111
|
+
const line = controlsVisible ? -4 : 'auto';
|
|
112
|
+
const lift = () => {
|
|
113
|
+
for (const track of captionTracks(node))
|
|
114
|
+
for (const cue of track.cues ?? []) (cue as VTTCue).line = line;
|
|
115
|
+
};
|
|
116
|
+
lift();
|
|
117
|
+
const tracks = captionTracks(node);
|
|
118
|
+
tracks.forEach((track) => track.addEventListener('cuechange', lift));
|
|
119
|
+
return () => tracks.forEach((track) => track.removeEventListener('cuechange', lift));
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
export function seek(time: number) {
|
|
123
|
+
if (!video) return;
|
|
124
|
+
video.currentTime = time;
|
|
125
|
+
currentTime = time;
|
|
126
|
+
void video.play().catch(() => {});
|
|
127
|
+
}
|
|
128
|
+
export function pause() {
|
|
129
|
+
video?.pause();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function toggle() {
|
|
133
|
+
if (!video) return;
|
|
134
|
+
if (video.paused) void video.play().catch(() => {});
|
|
135
|
+
else video.pause();
|
|
136
|
+
poke();
|
|
137
|
+
}
|
|
138
|
+
function setMuted(next: boolean) {
|
|
139
|
+
if (!video) return;
|
|
140
|
+
if (!next && !volume) setVolume(1);
|
|
141
|
+
video.muted = next;
|
|
142
|
+
poke();
|
|
143
|
+
}
|
|
144
|
+
function setVolume(value: number) {
|
|
145
|
+
if (!video) return;
|
|
146
|
+
volume = value;
|
|
147
|
+
video.volume = value;
|
|
148
|
+
video.muted = value === 0;
|
|
149
|
+
}
|
|
150
|
+
function toggleCaptions() {
|
|
151
|
+
captions = !captions;
|
|
152
|
+
if (video)
|
|
153
|
+
captionTracks(video).forEach((track, index) => {
|
|
154
|
+
track.mode = captions && index === 0 ? 'showing' : 'disabled';
|
|
155
|
+
});
|
|
156
|
+
poke();
|
|
157
|
+
}
|
|
158
|
+
function nextSpeed() {
|
|
159
|
+
speed = SPEEDS[(SPEEDS.indexOf(speed) + 1) % SPEEDS.length];
|
|
160
|
+
if (video) video.playbackRate = speed;
|
|
161
|
+
poke();
|
|
162
|
+
}
|
|
163
|
+
function toggleFullscreen() {
|
|
164
|
+
if (document.fullscreenElement) void document.exitFullscreen();
|
|
165
|
+
else if (frame?.requestFullscreen) void frame.requestFullscreen();
|
|
166
|
+
// iPhones only put the video element itself in full screen.
|
|
167
|
+
else (video as unknown as { webkitEnterFullscreen?: () => void })?.webkitEnterFullscreen?.();
|
|
168
|
+
}
|
|
169
|
+
/** Keep the controls up for a moment after any interaction. */
|
|
170
|
+
function poke() {
|
|
171
|
+
active = true;
|
|
172
|
+
clearTimeout(hideTimer);
|
|
173
|
+
hideTimer = setTimeout(() => (active = false), 2500);
|
|
174
|
+
}
|
|
175
|
+
function seekTo(event: PointerEvent) {
|
|
176
|
+
if (!video || !bar || !duration) return;
|
|
177
|
+
const rect = bar.getBoundingClientRect();
|
|
178
|
+
video.currentTime =
|
|
179
|
+
Math.min(1, Math.max(0, (event.clientX - rect.left) / rect.width)) * duration;
|
|
180
|
+
currentTime = video.currentTime;
|
|
181
|
+
}
|
|
182
|
+
function key(event: KeyboardEvent) {
|
|
183
|
+
if (!video) return;
|
|
184
|
+
const target = event.target as HTMLElement;
|
|
185
|
+
// Buttons and the volume slider keep their own keys.
|
|
186
|
+
if (target.tagName === 'INPUT' || (target.tagName === 'BUTTON' && event.key === ' ')) return;
|
|
187
|
+
const step = (delta: number) => {
|
|
188
|
+
if (!live) seek(Math.min(duration || 0, Math.max(0, video!.currentTime + delta)));
|
|
189
|
+
};
|
|
190
|
+
switch (event.key) {
|
|
191
|
+
case ' ':
|
|
192
|
+
case 'k':
|
|
193
|
+
toggle();
|
|
194
|
+
break;
|
|
195
|
+
case 'ArrowLeft':
|
|
196
|
+
step(-5);
|
|
197
|
+
break;
|
|
198
|
+
case 'ArrowRight':
|
|
199
|
+
step(5);
|
|
200
|
+
break;
|
|
201
|
+
case 'm':
|
|
202
|
+
setMuted(!muted);
|
|
203
|
+
break;
|
|
204
|
+
case 'f':
|
|
205
|
+
toggleFullscreen();
|
|
206
|
+
break;
|
|
207
|
+
default:
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
poke();
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const button =
|
|
215
|
+
'grid size-9 shrink-0 cursor-pointer place-items-center rounded-full text-white hover:bg-white/15 focus-visible:outline-2 focus-visible:outline-white';
|
|
216
|
+
</script>
|
|
217
|
+
|
|
218
|
+
<svelte:document onfullscreenchange={() => (fullscreen = document.fullscreenElement === frame)} />
|
|
219
|
+
|
|
220
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
|
|
221
|
+
<div
|
|
222
|
+
bind:this={frame}
|
|
223
|
+
role="group"
|
|
224
|
+
aria-label={title}
|
|
225
|
+
tabindex="0"
|
|
226
|
+
class="group/player relative size-full overflow-hidden bg-black outline-none {controlsVisible
|
|
227
|
+
? ''
|
|
228
|
+
: 'cursor-none'}"
|
|
229
|
+
onpointermove={poke}
|
|
230
|
+
onpointerleave={() => playing && (active = false)}
|
|
231
|
+
onkeydown={key}
|
|
232
|
+
>
|
|
233
|
+
<video
|
|
234
|
+
bind:this={video}
|
|
235
|
+
{poster}
|
|
236
|
+
{autoplay}
|
|
237
|
+
muted={autoplay}
|
|
238
|
+
playsinline
|
|
239
|
+
crossorigin="anonymous"
|
|
240
|
+
class="size-full object-contain"
|
|
241
|
+
onclick={toggle}
|
|
242
|
+
ondblclick={toggleFullscreen}
|
|
243
|
+
onplay={() => {
|
|
244
|
+
playing = true;
|
|
245
|
+
started = true;
|
|
246
|
+
onplay?.();
|
|
247
|
+
}}
|
|
248
|
+
onpause={() => (playing = false)}
|
|
249
|
+
onwaiting={() => (waiting = true)}
|
|
250
|
+
onplaying={() => (waiting = false)}
|
|
251
|
+
oncanplay={() => (waiting = false)}
|
|
252
|
+
ontimeupdate={(event) => !scrubbing && (currentTime = event.currentTarget.currentTime)}
|
|
253
|
+
ondurationchange={(event) => (duration = event.currentTarget.duration)}
|
|
254
|
+
onprogress={(event) => {
|
|
255
|
+
const ranges = event.currentTarget.buffered;
|
|
256
|
+
buffered = ranges.length ? ranges.end(ranges.length - 1) : 0;
|
|
257
|
+
}}
|
|
258
|
+
onvolumechange={(event) => (muted = event.currentTarget.muted)}
|
|
259
|
+
>
|
|
260
|
+
{#if captionsUrl}
|
|
261
|
+
<track kind="captions" label="English" srclang="en" src={captionsUrl} default />
|
|
262
|
+
{/if}
|
|
263
|
+
</video>
|
|
264
|
+
|
|
265
|
+
{#if !playing && !waiting && !scrubbing}
|
|
266
|
+
<button
|
|
267
|
+
type="button"
|
|
268
|
+
aria-label="Play"
|
|
269
|
+
class="absolute inset-0 grid cursor-pointer place-items-center"
|
|
270
|
+
onclick={toggle}
|
|
271
|
+
>
|
|
272
|
+
<span
|
|
273
|
+
class="grid size-14 place-items-center rounded-full bg-black/60 text-white transition-transform duration-150 group-hover/player:scale-105 motion-reduce:transition-none"
|
|
274
|
+
>
|
|
275
|
+
<Icon img={Play} size={24} />
|
|
276
|
+
</span>
|
|
277
|
+
</button>
|
|
278
|
+
{/if}
|
|
279
|
+
|
|
280
|
+
{#if waiting && playing}
|
|
281
|
+
<div class="pointer-events-none absolute inset-0 grid place-items-center">
|
|
282
|
+
<span
|
|
283
|
+
class="size-9 animate-spin rounded-full border-[3px] border-white/25 border-t-white motion-reduce:animate-none"
|
|
284
|
+
></span>
|
|
285
|
+
</div>
|
|
286
|
+
{/if}
|
|
287
|
+
|
|
288
|
+
{@render children?.()}
|
|
289
|
+
|
|
290
|
+
<div
|
|
291
|
+
data-part="controls"
|
|
292
|
+
onfocusin={(event) => (focused = (event.target as Element).matches(':focus-visible'))}
|
|
293
|
+
onfocusout={() => (focused = false)}
|
|
294
|
+
class="absolute inset-x-0 bottom-0 bg-linear-to-t from-black/80 to-transparent px-2 pt-8 pb-1.5 transition-opacity duration-200 motion-reduce:transition-none {controlsVisible &&
|
|
295
|
+
(started || !live)
|
|
296
|
+
? 'opacity-100'
|
|
297
|
+
: 'pointer-events-none opacity-0'}"
|
|
298
|
+
>
|
|
299
|
+
{#if !live}
|
|
300
|
+
<div
|
|
301
|
+
bind:this={bar}
|
|
302
|
+
role="slider"
|
|
303
|
+
tabindex="0"
|
|
304
|
+
aria-label="Seek"
|
|
305
|
+
aria-valuemin="0"
|
|
306
|
+
aria-valuemax={Math.round(duration)}
|
|
307
|
+
aria-valuenow={Math.round(currentTime)}
|
|
308
|
+
aria-valuetext="{clock(currentTime)} of {clock(duration)}"
|
|
309
|
+
class="group/bar flex h-4 cursor-pointer touch-none items-center px-1.5 outline-none"
|
|
310
|
+
onpointerdown={(event) => {
|
|
311
|
+
scrubbing = true;
|
|
312
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
313
|
+
seekTo(event);
|
|
314
|
+
}}
|
|
315
|
+
onpointermove={(event) => scrubbing && seekTo(event)}
|
|
316
|
+
onpointerup={() => (scrubbing = false)}
|
|
317
|
+
onpointercancel={() => (scrubbing = false)}
|
|
318
|
+
>
|
|
319
|
+
<div
|
|
320
|
+
class="relative h-1 w-full rounded-full bg-white/25 transition-[height] group-hover/bar:h-1.5 group-focus-visible/bar:h-1.5"
|
|
321
|
+
>
|
|
322
|
+
<div
|
|
323
|
+
class="absolute inset-y-0 left-0 rounded-full bg-white/35"
|
|
324
|
+
style="width:{duration ? (buffered / duration) * 100 : 0}%"
|
|
325
|
+
></div>
|
|
326
|
+
<div
|
|
327
|
+
class="absolute inset-y-0 left-0 rounded-full bg-accent-400"
|
|
328
|
+
style="width:{duration ? (currentTime / duration) * 100 : 0}%"
|
|
329
|
+
>
|
|
330
|
+
<span
|
|
331
|
+
class="absolute top-1/2 right-0 size-3 translate-x-1/2 -translate-y-1/2 rounded-full bg-white opacity-0 group-hover/bar:opacity-100 group-focus-visible/bar:opacity-100 {scrubbing
|
|
332
|
+
? 'opacity-100'
|
|
333
|
+
: ''}"
|
|
334
|
+
></span>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
{/if}
|
|
339
|
+
|
|
340
|
+
<div class="flex items-center gap-0.5">
|
|
341
|
+
<button type="button" class={button} aria-label={playing ? 'Pause' : 'Play'} onclick={toggle}>
|
|
342
|
+
<Icon img={playing ? Pause : Play} size={18} />
|
|
343
|
+
</button>
|
|
344
|
+
{#if live}
|
|
345
|
+
<span class="px-1.5 text-xs font-medium text-white">Live</span>
|
|
346
|
+
{:else}
|
|
347
|
+
<span class="px-1.5 text-xs text-white tabular-nums"
|
|
348
|
+
>{clock(currentTime)} / {clock(duration)}</span
|
|
349
|
+
>
|
|
350
|
+
{/if}
|
|
351
|
+
<span class="flex-1"></span>
|
|
352
|
+
<div class="group/volume flex items-center">
|
|
353
|
+
<input
|
|
354
|
+
type="range"
|
|
355
|
+
min="0"
|
|
356
|
+
max="1"
|
|
357
|
+
step="0.05"
|
|
358
|
+
value={muted ? 0 : volume}
|
|
359
|
+
aria-label="Volume"
|
|
360
|
+
class="volume mr-1 hidden w-16 group-focus-within/volume:block group-hover/volume:block pointer-coarse:!hidden"
|
|
361
|
+
oninput={(event) => setVolume(Number(event.currentTarget.value))}
|
|
362
|
+
/>
|
|
363
|
+
<button
|
|
364
|
+
type="button"
|
|
365
|
+
class={button}
|
|
366
|
+
aria-label={muted ? 'Unmute' : 'Mute'}
|
|
367
|
+
onclick={() => setMuted(!muted)}
|
|
368
|
+
>
|
|
369
|
+
<Icon img={muted ? VolumeX : Volume2} size={18} />
|
|
370
|
+
</button>
|
|
371
|
+
</div>
|
|
372
|
+
{#if hasCaptions}
|
|
373
|
+
<button
|
|
374
|
+
type="button"
|
|
375
|
+
class={button}
|
|
376
|
+
aria-label={captions ? 'Hide captions' : 'Show captions'}
|
|
377
|
+
aria-pressed={captions}
|
|
378
|
+
onclick={toggleCaptions}
|
|
379
|
+
>
|
|
380
|
+
<Icon img={captions ? Captions : CaptionsOff} size={18} />
|
|
381
|
+
</button>
|
|
382
|
+
{/if}
|
|
383
|
+
{#if !live}
|
|
384
|
+
<button
|
|
385
|
+
type="button"
|
|
386
|
+
class="{button} w-auto min-w-9 px-2 text-xs font-medium tabular-nums"
|
|
387
|
+
aria-label="Playback speed {speed}×"
|
|
388
|
+
onclick={nextSpeed}>{speed}×</button
|
|
389
|
+
>
|
|
390
|
+
{/if}
|
|
391
|
+
<button
|
|
392
|
+
type="button"
|
|
393
|
+
class={button}
|
|
394
|
+
aria-label={fullscreen ? 'Exit full screen' : 'Full screen'}
|
|
395
|
+
onclick={toggleFullscreen}
|
|
396
|
+
>
|
|
397
|
+
<Icon img={fullscreen ? Minimize : Maximize} size={17} />
|
|
398
|
+
</button>
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
|
|
403
|
+
<style>
|
|
404
|
+
.volume {
|
|
405
|
+
height: 4px;
|
|
406
|
+
appearance: none;
|
|
407
|
+
border-radius: 999px;
|
|
408
|
+
background: rgb(255 255 255 / 0.3);
|
|
409
|
+
accent-color: white;
|
|
410
|
+
cursor: pointer;
|
|
411
|
+
}
|
|
412
|
+
.volume::-webkit-slider-thumb {
|
|
413
|
+
appearance: none;
|
|
414
|
+
width: 12px;
|
|
415
|
+
height: 12px;
|
|
416
|
+
border-radius: 999px;
|
|
417
|
+
background: white;
|
|
418
|
+
}
|
|
419
|
+
.volume::-moz-range-thumb {
|
|
420
|
+
width: 12px;
|
|
421
|
+
height: 12px;
|
|
422
|
+
border: 0;
|
|
423
|
+
border-radius: 999px;
|
|
424
|
+
background: white;
|
|
425
|
+
}
|
|
426
|
+
video::cue {
|
|
427
|
+
font-family: inherit;
|
|
428
|
+
font-size: 0.9em;
|
|
429
|
+
background: rgb(0 0 0 / 0.7);
|
|
430
|
+
}
|
|
431
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
title: string;
|
|
4
|
+
poster?: string;
|
|
5
|
+
/** A live stream has no timeline to scrub and no playback speed. */
|
|
6
|
+
live?: boolean;
|
|
7
|
+
/** Start playing, muted, as browsers require. */
|
|
8
|
+
autoplay?: boolean;
|
|
9
|
+
/** WebVTT captions, shown from the start. */
|
|
10
|
+
captionsUrl?: string;
|
|
11
|
+
video?: HTMLVideoElement;
|
|
12
|
+
currentTime?: number;
|
|
13
|
+
/** Whether the controls are on screen, for overlays that come and go with them. */
|
|
14
|
+
controlsVisible?: boolean;
|
|
15
|
+
onplay?: () => void;
|
|
16
|
+
/** Overlay content, positioned by the caller inside the frame. */
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
};
|
|
19
|
+
declare const Player: import("svelte").Component<$$ComponentProps, {
|
|
20
|
+
seek: (time: number) => void;
|
|
21
|
+
pause: () => void;
|
|
22
|
+
}, "video" | "currentTime" | "controlsVisible">;
|
|
23
|
+
type Player = ReturnType<typeof Player>;
|
|
24
|
+
export default Player;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import NestedComments from '../../components/NestedComments.svelte';
|
|
4
|
+
import Surface from '../../components/Surface.svelte';
|
|
5
|
+
import {
|
|
6
|
+
blueskyPostToPostData,
|
|
7
|
+
hasModerationLabel,
|
|
8
|
+
type BlueskyPostView,
|
|
9
|
+
type PostData
|
|
10
|
+
} from '../../social/posts.js';
|
|
11
|
+
import type { PreferredSocialClient } from '../../social/preferred-client.js';
|
|
12
|
+
import { parseSocialPostUrl, socialPostUrl } from '../../social/urls.js';
|
|
13
|
+
import { safeHttpUrl } from '../../urls.js';
|
|
14
|
+
import { appviewUrl } from '../atproto-helpers.js';
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
url,
|
|
18
|
+
fallback,
|
|
19
|
+
socialClient
|
|
20
|
+
}: {
|
|
21
|
+
url: string;
|
|
22
|
+
/** The ordinary link, shown until the post loads and whenever it can't be shown. */
|
|
23
|
+
fallback: Snippet;
|
|
24
|
+
socialClient?: PreferredSocialClient | null;
|
|
25
|
+
} = $props();
|
|
26
|
+
|
|
27
|
+
/** Without the viewer's moderation preferences, labeled posts stay plain links. */
|
|
28
|
+
type ThreadPost = BlueskyPostView & { author: { did?: string } };
|
|
29
|
+
|
|
30
|
+
let post = $state<PostData | null>(null);
|
|
31
|
+
$effect(() => {
|
|
32
|
+
const ref = parseSocialPostUrl(url);
|
|
33
|
+
post = null;
|
|
34
|
+
if (!ref) return;
|
|
35
|
+
const controller = new AbortController();
|
|
36
|
+
fetch(
|
|
37
|
+
`${appviewUrl()}/xrpc/app.bsky.feed.getPostThread?uri=${encodeURIComponent(ref.uri)}&depth=0&parentHeight=0`,
|
|
38
|
+
{ signal: controller.signal }
|
|
39
|
+
)
|
|
40
|
+
.then((response) => (response.ok ? response.json() : null))
|
|
41
|
+
.then((data: { thread?: { $type?: string; post?: ThreadPost } } | null) => {
|
|
42
|
+
const view = data?.thread?.post;
|
|
43
|
+
if (
|
|
44
|
+
controller.signal.aborted ||
|
|
45
|
+
data?.thread?.$type !== 'app.bsky.feed.defs#threadViewPost' ||
|
|
46
|
+
!view?.uri ||
|
|
47
|
+
!view.author?.did ||
|
|
48
|
+
hasModerationLabel(view)
|
|
49
|
+
)
|
|
50
|
+
return;
|
|
51
|
+
post = blueskyPostToPostData(view);
|
|
52
|
+
})
|
|
53
|
+
.catch(() => {});
|
|
54
|
+
return () => controller.abort();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/** Clicking anywhere on the post opens it; links, media and selected text keep their own behavior. */
|
|
58
|
+
function open(event: MouseEvent) {
|
|
59
|
+
if (!post || event.defaultPrevented || window.getSelection()?.toString()) return;
|
|
60
|
+
if ((event.target as Element).closest('a, button, video, iframe, [role="button"]')) return;
|
|
61
|
+
const href = socialPostUrl(post.uri, socialClient) ?? safeHttpUrl(post.href);
|
|
62
|
+
if (href) window.open(href, '_blank', 'noopener,noreferrer');
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
{#if post}
|
|
67
|
+
<!-- Pointer convenience only: the author, date and count links inside open the same post. -->
|
|
68
|
+
<Surface onclick={open} class="cursor-pointer p-4">
|
|
69
|
+
<NestedComments comments={[post]} {socialClient} />
|
|
70
|
+
</Surface>
|
|
71
|
+
{:else}{@render fallback()}{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { PreferredSocialClient } from '../../social/preferred-client.js';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
url: string;
|
|
5
|
+
/** The ordinary link, shown until the post loads and whenever it can't be shown. */
|
|
6
|
+
fallback: Snippet;
|
|
7
|
+
socialClient?: PreferredSocialClient | null;
|
|
8
|
+
};
|
|
9
|
+
declare const PostLinkEmbed: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type PostLinkEmbed = ReturnType<typeof PostLinkEmbed>;
|
|
11
|
+
export default PostLinkEmbed;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import Avatar from '../../components/Avatar.svelte';
|
|
4
|
+
import Surface from '../../components/Surface.svelte';
|
|
5
|
+
import { blueskyProfileToProfileData, type ProfileData } from '../../social/profile.js';
|
|
6
|
+
import type { PreferredSocialClient } from '../../social/preferred-client.js';
|
|
7
|
+
import { parseSocialProfileUrl, socialProfileUrl } from '../../social/urls.js';
|
|
8
|
+
import { focus } from '../../styles.js';
|
|
9
|
+
import { appviewUrl } from '../atproto-helpers.js';
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
url,
|
|
13
|
+
fallback,
|
|
14
|
+
socialClient
|
|
15
|
+
}: {
|
|
16
|
+
url: string;
|
|
17
|
+
/** The ordinary link, shown until the profile loads and whenever it can't be shown. */
|
|
18
|
+
fallback: Snippet;
|
|
19
|
+
socialClient?: PreferredSocialClient | null;
|
|
20
|
+
} = $props();
|
|
21
|
+
|
|
22
|
+
let profile = $state<ProfileData | null>(null);
|
|
23
|
+
$effect(() => {
|
|
24
|
+
const ref = parseSocialProfileUrl(url);
|
|
25
|
+
profile = null;
|
|
26
|
+
if (!ref) return;
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
fetch(`${appviewUrl()}/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(ref.actor)}`, {
|
|
29
|
+
signal: controller.signal
|
|
30
|
+
})
|
|
31
|
+
.then((response) => (response.ok ? response.json() : null))
|
|
32
|
+
.then((view: { labels?: { neg?: boolean }[] } | null) => {
|
|
33
|
+
// Profiles with a moderation label, or hidden from logged-out viewers, stay plain links.
|
|
34
|
+
if (
|
|
35
|
+
controller.signal.aborted ||
|
|
36
|
+
(Array.isArray(view?.labels) && view.labels.some((label) => !label?.neg))
|
|
37
|
+
)
|
|
38
|
+
return;
|
|
39
|
+
profile = blueskyProfileToProfileData(view) ?? null;
|
|
40
|
+
})
|
|
41
|
+
.catch(() => {});
|
|
42
|
+
return () => controller.abort();
|
|
43
|
+
});
|
|
44
|
+
let name = $derived(profile?.displayName || profile?.handle || profile?.did || '');
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
{#if profile}
|
|
48
|
+
<a
|
|
49
|
+
href={socialProfileUrl(profile.did, socialClient)}
|
|
50
|
+
target="_blank"
|
|
51
|
+
rel="noopener noreferrer"
|
|
52
|
+
class={`group block w-fit max-w-full rounded-panel no-underline ${focus}`}
|
|
53
|
+
>
|
|
54
|
+
<Surface class="flex items-center gap-3 py-3 pr-5 pl-3">
|
|
55
|
+
<Avatar {name} src={profile.avatar} size={40} />
|
|
56
|
+
<span class="min-w-0">
|
|
57
|
+
<span
|
|
58
|
+
class="block truncate text-sm font-medium group-hover:text-accent-700 dark:group-hover:text-accent-300"
|
|
59
|
+
><bdi>{name}</bdi></span
|
|
60
|
+
>
|
|
61
|
+
{#if profile.handle}<span class="block truncate text-xs text-base-600 dark:text-base-400"
|
|
62
|
+
><bdi>@{profile.handle}</bdi></span
|
|
63
|
+
>{/if}
|
|
64
|
+
</span>
|
|
65
|
+
</Surface>
|
|
66
|
+
</a>
|
|
67
|
+
{:else}{@render fallback()}{/if}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { PreferredSocialClient } from '../../social/preferred-client.js';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
url: string;
|
|
5
|
+
/** The ordinary link, shown until the profile loads and whenever it can't be shown. */
|
|
6
|
+
fallback: Snippet;
|
|
7
|
+
socialClient?: PreferredSocialClient | null;
|
|
8
|
+
};
|
|
9
|
+
declare const ProfileLinkEmbed: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type ProfileLinkEmbed = ReturnType<typeof ProfileLinkEmbed>;
|
|
11
|
+
export default ProfileLinkEmbed;
|