@atmo-dev/kit 0.20.0 → 0.22.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.
Files changed (104) hide show
  1. package/README.md +1 -1
  2. package/dist/components/RichText.svelte +17 -9
  3. package/dist/components/RichTextEditor.svelte +67 -11
  4. package/dist/components/RichTextEditor.svelte.d.ts +0 -2
  5. package/dist/components/StreamplacePicker.svelte +2 -2
  6. package/dist/components/StreamplacePicker.svelte.d.ts +1 -1
  7. package/dist/components/composer/EmojiPanel.svelte +55 -0
  8. package/dist/components/composer/EmojiPanel.svelte.d.ts +6 -0
  9. package/dist/components/composer/EmojiPicker.svelte +2 -38
  10. package/dist/components/data/DataLabel.svelte +120 -0
  11. package/dist/components/data/DataLabel.svelte.d.ts +10 -0
  12. package/dist/components/data/issues.d.ts +5 -0
  13. package/dist/components/data/issues.js +52 -0
  14. package/dist/components/data/types.d.ts +28 -0
  15. package/dist/components/data/types.js +1 -0
  16. package/dist/components/data/visibility.d.ts +7 -0
  17. package/dist/components/data/visibility.js +15 -0
  18. package/dist/components/legal/links.js +1 -0
  19. package/dist/components/legal/types.d.ts +1 -1
  20. package/dist/components/notifications/NotificationList.svelte +137 -0
  21. package/dist/components/notifications/NotificationList.svelte.d.ts +19 -0
  22. package/dist/components/notifications/NotificationPushToggle.svelte +76 -0
  23. package/dist/components/notifications/NotificationPushToggle.svelte.d.ts +19 -0
  24. package/dist/components/notifications/NotificationSettings.svelte +125 -0
  25. package/dist/components/notifications/NotificationSettings.svelte.d.ts +16 -0
  26. package/dist/components/notifications/types.d.ts +37 -0
  27. package/dist/components/notifications/types.js +1 -0
  28. package/dist/editor/ImageDialog.svelte +87 -0
  29. package/dist/editor/ImageDialog.svelte.d.ts +16 -0
  30. package/dist/editor/image-node.d.ts +6 -2
  31. package/dist/editor/image-node.js +36 -37
  32. package/dist/events/EventCard.svelte +6 -1
  33. package/dist/events/VodPlayer.svelte +1 -1
  34. package/dist/events/atmo-rsvp.d.ts +6 -0
  35. package/dist/events/atmo-rsvp.js +34 -0
  36. package/dist/events/atproto-helpers.d.ts +1 -0
  37. package/dist/events/atproto-helpers.js +3 -0
  38. package/dist/events/event-link-embed.d.ts +7 -3
  39. package/dist/events/event-link-embed.js +11 -5
  40. package/dist/events/event-view/StreamPlacePlayer.svelte +14 -108
  41. package/dist/events/linked-records.d.ts +1 -1
  42. package/dist/events/linked-records.js +2 -2
  43. package/dist/events-card.d.ts +9 -0
  44. package/dist/events-card.js +7 -0
  45. package/dist/events-data.d.ts +1 -0
  46. package/dist/events-data.js +1 -0
  47. package/dist/gestures.d.ts +5 -1
  48. package/dist/gestures.js +6 -3
  49. package/dist/grain/xrpc.js +11 -4
  50. package/dist/index.d.ts +13 -1
  51. package/dist/index.js +7 -1
  52. package/dist/legal.d.ts +3 -0
  53. package/dist/legal.js +2 -0
  54. package/dist/richtext/serialize.js +13 -8
  55. package/dist/streamplace/StreamCard.svelte +184 -0
  56. package/dist/streamplace/StreamCard.svelte.d.ts +24 -0
  57. package/dist/streamplace/StreamLinkEmbed.svelte +59 -0
  58. package/dist/streamplace/StreamLinkEmbed.svelte.d.ts +5 -0
  59. package/dist/streamplace/StreamPlayer.svelte +539 -0
  60. package/dist/streamplace/StreamPlayer.svelte.d.ts +42 -0
  61. package/dist/streamplace/VideoCard.svelte +159 -0
  62. package/dist/streamplace/VideoCard.svelte.d.ts +17 -0
  63. package/dist/streamplace/api.d.ts +74 -0
  64. package/dist/streamplace/api.js +182 -0
  65. package/dist/streamplace/broadcast.d.ts +3 -0
  66. package/dist/streamplace/broadcast.js +110 -0
  67. package/dist/streamplace/channel.svelte.d.ts +74 -0
  68. package/dist/streamplace/channel.svelte.js +515 -0
  69. package/dist/streamplace/chat/Composer.svelte +232 -0
  70. package/dist/streamplace/chat/Composer.svelte.d.ts +15 -0
  71. package/dist/streamplace/chat/Embeds.svelte +135 -0
  72. package/dist/streamplace/chat/Embeds.svelte.d.ts +13 -0
  73. package/dist/streamplace/chat/Message.svelte +303 -0
  74. package/dist/streamplace/chat/Message.svelte.d.ts +25 -0
  75. package/dist/streamplace/chat/StreamChat.svelte +463 -0
  76. package/dist/streamplace/chat/StreamChat.svelte.d.ts +33 -0
  77. package/dist/streamplace/chat/StreamChatPopups.svelte +151 -0
  78. package/dist/streamplace/chat/StreamChatPopups.svelte.d.ts +15 -0
  79. package/dist/streamplace/chat/UserCard.svelte +76 -0
  80. package/dist/streamplace/chat/UserCard.svelte.d.ts +12 -0
  81. package/dist/streamplace/chat/color.d.ts +7 -0
  82. package/dist/streamplace/chat/color.js +33 -0
  83. package/dist/streamplace/chat/links.d.ts +10 -0
  84. package/dist/streamplace/chat/links.js +29 -0
  85. package/dist/streamplace/facets.d.ts +15 -0
  86. package/dist/streamplace/facets.js +112 -0
  87. package/dist/streamplace/link-embed.d.ts +13 -0
  88. package/dist/streamplace/link-embed.js +16 -0
  89. package/dist/streamplace/links.d.ts +6 -0
  90. package/dist/streamplace/links.js +1 -0
  91. package/dist/streamplace/reactions.d.ts +21 -0
  92. package/dist/streamplace/reactions.js +46 -0
  93. package/dist/streamplace/types.d.ts +200 -0
  94. package/dist/streamplace/types.js +1 -0
  95. package/dist/streamplace-data.d.ts +11 -0
  96. package/dist/streamplace-data.js +10 -0
  97. package/dist/streamplace.d.ts +14 -6
  98. package/dist/streamplace.js +11 -1
  99. package/dist/{events/event-view → video}/Player.svelte +69 -21
  100. package/dist/video/Player.svelte.d.ts +38 -0
  101. package/dist/video/engines.d.ts +59 -0
  102. package/dist/video/engines.js +647 -0
  103. package/package.json +11 -1
  104. package/dist/events/event-view/Player.svelte.d.ts +0 -24
@@ -1 +1,11 @@
1
- export { parseStreamplaceLink } from './grain/urls.js';
1
+ /** Streamplace: live channels, chat and playback. Apps own sessions, routes and persistence. */
2
+ export * from './streamplace-data.js';
3
+ export { Channel } from './streamplace/channel.svelte.js';
4
+ export { default as StreamPlayer } from './streamplace/StreamPlayer.svelte';
5
+ export { default as StreamChat } from './streamplace/chat/StreamChat.svelte';
6
+ export { default as StreamChatPopups } from './streamplace/chat/StreamChatPopups.svelte';
7
+ export { streamLinkEmbed } from './streamplace/link-embed.js';
8
+ export { default as StreamCard } from './streamplace/StreamCard.svelte';
9
+ export { default as VideoCard } from './streamplace/VideoCard.svelte';
10
+ // For apps building their own playback, e.g. a go-live preview.
11
+ export { prefetchHls, startHls, startWebRTC, warmWebRTC } from './video/engines.js';
@@ -12,8 +12,8 @@
12
12
  </script>
13
13
 
14
14
  <script lang="ts">
15
- import type { Snippet } from 'svelte';
16
- import { Icon } from '../../index.js';
15
+ import { untrack, type Snippet } from 'svelte';
16
+ import Icon from '../components/Icon.svelte';
17
17
  import {
18
18
  Captions,
19
19
  CaptionsOff,
@@ -39,6 +39,13 @@
39
39
  video = $bindable(),
40
40
  currentTime = $bindable(0),
41
41
  controlsVisible = $bindable(true),
42
+ fullscreen = $bindable(false),
43
+ loading = false,
44
+ inactive = false,
45
+ keepControls = false,
46
+ shortcuts = 'focus',
47
+ liveStatus,
48
+ controls,
42
49
  onplay,
43
50
  children
44
51
  }: {
@@ -54,6 +61,20 @@
54
61
  currentTime?: number;
55
62
  /** Whether the controls are on screen, for overlays that come and go with them. */
56
63
  controlsVisible?: boolean;
64
+ /** Whether the player fills the screen. */
65
+ fullscreen?: boolean;
66
+ /** Media is being fetched or reconnected: a spinner replaces the play button. */
67
+ loading?: boolean;
68
+ /** Caller covers the video (e.g. offline/error): disable controls and shortcuts underneath. */
69
+ inactive?: boolean;
70
+ /** Keep the controls up, e.g. while a menu opened from them is showing. */
71
+ keepControls?: boolean;
72
+ /** Where the keyboard shortcuts work: with focus in the player, or anywhere on the page. */
73
+ shortcuts?: 'focus' | 'page';
74
+ /** Replaces the "Live" label of a live stream. */
75
+ liveStatus?: Snippet;
76
+ /** More buttons before the full-screen one; receives the class the built-in buttons use. */
77
+ controls?: Snippet<[string]>;
57
78
  onplay?: () => void;
58
79
  /** Overlay content, positioned by the caller inside the frame. */
59
80
  children?: Snippet;
@@ -70,7 +91,6 @@
70
91
  let duration = $state(0);
71
92
  let buffered = $state(0);
72
93
  let speed = $state(1);
73
- let fullscreen = $state(false);
74
94
  let hasCaptions = $state(false);
75
95
  // svelte-ignore state_referenced_locally
76
96
  let captions = $state(!!captionsUrl);
@@ -81,10 +101,16 @@
81
101
  let hideTimer: ReturnType<typeof setTimeout> | undefined;
82
102
 
83
103
  $effect(() => {
84
- controlsVisible = active || !playing || scrubbing || focused;
104
+ controlsVisible = active || !playing || scrubbing || focused || keepControls;
85
105
  });
86
106
  $effect(() => () => clearTimeout(hideTimer));
87
107
 
108
+ // Autoplay has to start muted. Set once, by hand: as a template attribute it is written
109
+ // again on every re-render, which undoes the viewer's own mute or unmute.
110
+ $effect(() => {
111
+ if (video && untrack(() => autoplay)) video.muted = true;
112
+ });
113
+
88
114
  // Caption tracks arrive from the `<track>` below or from the stream itself.
89
115
  const captionTracks = (node: HTMLVideoElement) =>
90
116
  [...node.textTracks].filter((track) => track.kind === 'captions' || track.kind === 'subtitles');
@@ -180,22 +206,33 @@
180
206
  currentTime = video.currentTime;
181
207
  }
182
208
  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;
209
+ if (!video || inactive || event.defaultPrevented) return;
210
+ if (event.metaKey || event.ctrlKey || event.altKey) return;
211
+ // `composedPath` sees inputs inside shadow DOM (such as an emoji picker's search field).
212
+ const target = (event.composedPath?.()[0] ?? event.target) as HTMLElement | null;
213
+ if (!target) return;
214
+ // Inputs, editable regions and buttons (for Space) keep their own keys.
215
+ if (
216
+ target.isContentEditable ||
217
+ /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName) ||
218
+ (target.tagName === 'BUTTON' && event.key === ' ')
219
+ )
220
+ return;
187
221
  const step = (delta: number) => {
188
222
  if (!live) seek(Math.min(duration || 0, Math.max(0, video!.currentTime + delta)));
189
223
  };
190
- switch (event.key) {
224
+ switch (event.key.length === 1 ? event.key.toLowerCase() : event.key) {
191
225
  case ' ':
192
226
  case 'k':
193
227
  toggle();
194
228
  break;
229
+ // A live stream has nothing to step through; the page keeps its arrow keys.
195
230
  case 'ArrowLeft':
231
+ if (live) return;
196
232
  step(-5);
197
233
  break;
198
234
  case 'ArrowRight':
235
+ if (live) return;
199
236
  step(5);
200
237
  break;
201
238
  case 'm':
@@ -216,27 +253,30 @@
216
253
  </script>
217
254
 
218
255
  <svelte:document onfullscreenchange={() => (fullscreen = document.fullscreenElement === frame)} />
256
+ <svelte:window onkeydown={shortcuts === 'page' ? key : undefined} />
219
257
 
220
258
  <!-- svelte-ignore a11y_no_noninteractive_tabindex, a11y_no_noninteractive_element_interactions -->
221
259
  <div
222
260
  bind:this={frame}
223
261
  role="group"
224
262
  aria-label={title}
225
- tabindex="0"
226
- class="group/player relative size-full overflow-hidden bg-black outline-none {controlsVisible
263
+ tabindex={inactive ? undefined : 0}
264
+ class="group/player relative size-full overflow-hidden bg-black outline-none {controlsVisible ||
265
+ inactive
227
266
  ? ''
228
267
  : 'cursor-none'}"
229
268
  onpointermove={poke}
230
269
  onpointerleave={() => playing && (active = false)}
231
- onkeydown={key}
270
+ onkeydown={shortcuts === 'page' ? undefined : key}
232
271
  >
272
+ <!-- A captions file from another origin needs CORS mode. Without one it stays off: in CORS
273
+ mode the poster is fetched that way too, and image hosts without CORS headers are blocked. -->
233
274
  <video
234
275
  bind:this={video}
235
276
  {poster}
236
277
  {autoplay}
237
- muted={autoplay}
238
278
  playsinline
239
- crossorigin="anonymous"
279
+ crossorigin={captionsUrl ? 'anonymous' : undefined}
240
280
  class="size-full object-contain"
241
281
  onclick={toggle}
242
282
  ondblclick={toggleFullscreen}
@@ -255,14 +295,17 @@
255
295
  const ranges = event.currentTarget.buffered;
256
296
  buffered = ranges.length ? ranges.end(ranges.length - 1) : 0;
257
297
  }}
258
- onvolumechange={(event) => (muted = event.currentTarget.muted)}
298
+ onvolumechange={(event) => {
299
+ muted = event.currentTarget.muted;
300
+ volume = event.currentTarget.volume;
301
+ }}
259
302
  >
260
303
  {#if captionsUrl}
261
304
  <track kind="captions" label="English" srclang="en" src={captionsUrl} default />
262
305
  {/if}
263
306
  </video>
264
307
 
265
- {#if !playing && !waiting && !scrubbing}
308
+ {#if !playing && !waiting && !scrubbing && !loading && !inactive}
266
309
  <button
267
310
  type="button"
268
311
  aria-label="Play"
@@ -277,7 +320,7 @@
277
320
  </button>
278
321
  {/if}
279
322
 
280
- {#if waiting && playing}
323
+ {#if loading || (waiting && playing)}
281
324
  <div class="pointer-events-none absolute inset-0 grid place-items-center">
282
325
  <span
283
326
  class="size-9 animate-spin rounded-full border-[3px] border-white/25 border-t-white motion-reduce:animate-none"
@@ -289,10 +332,12 @@
289
332
 
290
333
  <div
291
334
  data-part="controls"
335
+ inert={inactive}
292
336
  onfocusin={(event) => (focused = (event.target as Element).matches(':focus-visible'))}
293
337
  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)
338
+ 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 {keepControls
339
+ ? 'z-40'
340
+ : 'z-10'} {controlsVisible && (started || !live)
296
341
  ? 'opacity-100'
297
342
  : 'pointer-events-none opacity-0'}"
298
343
  >
@@ -303,7 +348,7 @@
303
348
  tabindex="0"
304
349
  aria-label="Seek"
305
350
  aria-valuemin="0"
306
- aria-valuemax={Math.round(duration)}
351
+ aria-valuemax={Number.isFinite(duration) ? Math.round(duration) : 0}
307
352
  aria-valuenow={Math.round(currentTime)}
308
353
  aria-valuetext="{clock(currentTime)} of {clock(duration)}"
309
354
  class="group/bar flex h-4 cursor-pointer touch-none items-center px-1.5 outline-none"
@@ -342,7 +387,9 @@
342
387
  <Icon img={playing ? Pause : Play} size={18} />
343
388
  </button>
344
389
  {#if live}
345
- <span class="px-1.5 text-xs font-medium text-white">Live</span>
390
+ {#if liveStatus}{@render liveStatus()}{:else}
391
+ <span class="px-1.5 text-xs font-medium text-white">Live</span>
392
+ {/if}
346
393
  {:else}
347
394
  <span class="px-1.5 text-xs text-white tabular-nums"
348
395
  >{clock(currentTime)} / {clock(duration)}</span
@@ -388,6 +435,7 @@
388
435
  onclick={nextSpeed}>{speed}×</button
389
436
  >
390
437
  {/if}
438
+ {@render controls?.(button)}
391
439
  <button
392
440
  type="button"
393
441
  class={button}
@@ -0,0 +1,38 @@
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
+ /** Whether the player fills the screen. */
16
+ fullscreen?: boolean;
17
+ /** Media is being fetched or reconnected: a spinner replaces the play button. */
18
+ loading?: boolean;
19
+ /** Caller covers the video (e.g. offline/error): disable controls and shortcuts underneath. */
20
+ inactive?: boolean;
21
+ /** Keep the controls up, e.g. while a menu opened from them is showing. */
22
+ keepControls?: boolean;
23
+ /** Where the keyboard shortcuts work: with focus in the player, or anywhere on the page. */
24
+ shortcuts?: 'focus' | 'page';
25
+ /** Replaces the "Live" label of a live stream. */
26
+ liveStatus?: Snippet;
27
+ /** More buttons before the full-screen one; receives the class the built-in buttons use. */
28
+ controls?: Snippet<[string]>;
29
+ onplay?: () => void;
30
+ /** Overlay content, positioned by the caller inside the frame. */
31
+ children?: Snippet;
32
+ };
33
+ declare const Player: import("svelte").Component<$$ComponentProps, {
34
+ seek: (time: number) => void;
35
+ pause: () => void;
36
+ }, "video" | "currentTime" | "controlsVisible" | "fullscreen">;
37
+ type Player = ReturnType<typeof Player>;
38
+ export default Player;
@@ -0,0 +1,59 @@
1
+ export type Level = {
2
+ index: number;
3
+ label: string;
4
+ };
5
+ export type EngineEvents = {
6
+ /** Media is attached and should start rendering soon. */
7
+ onready?: () => void;
8
+ /** The source is not available right now; the engine keeps retrying. */
9
+ onwaiting?: (reason: 'offline' | 'network') => void;
10
+ /** The engine gave up. */
11
+ onfail?: () => void;
12
+ onlevels?: (levels: Level[]) => void;
13
+ };
14
+ export type Engine = {
15
+ destroy: () => void;
16
+ /** -1 selects automatically. */
17
+ setLevel?: (index: number) => void;
18
+ /** Seconds behind the live edge, when known. */
19
+ latency?: () => number | undefined;
20
+ stats?: () => Promise<{
21
+ bitrate?: number;
22
+ resolution?: string;
23
+ dropped?: number;
24
+ }>;
25
+ toLive?: () => void;
26
+ };
27
+ /**
28
+ * Starts a WHEP session nobody watches yet, kept open for `keep` milliseconds, so that
29
+ * `startWebRTC` for the same URL begins with frames already arriving. Calling it again
30
+ * while the session is open only extends it.
31
+ */
32
+ export declare function warmWebRTC(url: string, keep?: number): void;
33
+ /**
34
+ * Sub-second playback over WHEP. Reconnects by itself and gives up after `attempts` failures
35
+ * in a row (4 by default; 1 never retries), or sooner when peers connect and no media ever
36
+ * arrives, as on networks that block it.
37
+ *
38
+ * Sessions are shared by URL: one opened by `warmWebRTC`, or by another engine (a hover
39
+ * preview), is taken over instead of negotiating again. `keep` leaves the session open that
40
+ * long after `destroy()`, for the next engine to take over.
41
+ */
42
+ export declare function startWebRTC(video: HTMLVideoElement, url: string, events: EngineEvents, options?: {
43
+ attempts?: number;
44
+ keep?: number;
45
+ }): Engine;
46
+ /**
47
+ * Loads a recording's playlists and its first `seconds` of media, so `startHls` for the same
48
+ * URL soon after starts from memory. With `seconds` at 0 only the playlists (and the small
49
+ * init segments) are loaded: cheap enough for every video in view, leaving the media for the
50
+ * moment a pointer reaches one. What is already loaded is not loaded again. Never throws.
51
+ */
52
+ export declare function prefetchHls(url: string, seconds?: number): Promise<void>;
53
+ type HlsOptions = {
54
+ live: boolean;
55
+ startAt?: number;
56
+ };
57
+ /** Buffered playback over HLS: a few seconds behind live, with quality levels. */
58
+ export declare function startHls(video: HTMLVideoElement, url: string, events: EngineEvents, options: HlsOptions): Engine;
59
+ export {};