@atmo-dev/kit 0.21.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 (102) 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/grain/xrpc.js +11 -4
  48. package/dist/index.d.ts +13 -1
  49. package/dist/index.js +7 -1
  50. package/dist/legal.d.ts +3 -0
  51. package/dist/legal.js +2 -0
  52. package/dist/richtext/serialize.js +13 -8
  53. package/dist/streamplace/StreamCard.svelte +184 -0
  54. package/dist/streamplace/StreamCard.svelte.d.ts +24 -0
  55. package/dist/streamplace/StreamLinkEmbed.svelte +59 -0
  56. package/dist/streamplace/StreamLinkEmbed.svelte.d.ts +5 -0
  57. package/dist/streamplace/StreamPlayer.svelte +539 -0
  58. package/dist/streamplace/StreamPlayer.svelte.d.ts +42 -0
  59. package/dist/streamplace/VideoCard.svelte +159 -0
  60. package/dist/streamplace/VideoCard.svelte.d.ts +17 -0
  61. package/dist/streamplace/api.d.ts +74 -0
  62. package/dist/streamplace/api.js +182 -0
  63. package/dist/streamplace/broadcast.d.ts +3 -0
  64. package/dist/streamplace/broadcast.js +110 -0
  65. package/dist/streamplace/channel.svelte.d.ts +74 -0
  66. package/dist/streamplace/channel.svelte.js +515 -0
  67. package/dist/streamplace/chat/Composer.svelte +232 -0
  68. package/dist/streamplace/chat/Composer.svelte.d.ts +15 -0
  69. package/dist/streamplace/chat/Embeds.svelte +135 -0
  70. package/dist/streamplace/chat/Embeds.svelte.d.ts +13 -0
  71. package/dist/streamplace/chat/Message.svelte +303 -0
  72. package/dist/streamplace/chat/Message.svelte.d.ts +25 -0
  73. package/dist/streamplace/chat/StreamChat.svelte +463 -0
  74. package/dist/streamplace/chat/StreamChat.svelte.d.ts +33 -0
  75. package/dist/streamplace/chat/StreamChatPopups.svelte +151 -0
  76. package/dist/streamplace/chat/StreamChatPopups.svelte.d.ts +15 -0
  77. package/dist/streamplace/chat/UserCard.svelte +76 -0
  78. package/dist/streamplace/chat/UserCard.svelte.d.ts +12 -0
  79. package/dist/streamplace/chat/color.d.ts +7 -0
  80. package/dist/streamplace/chat/color.js +33 -0
  81. package/dist/streamplace/chat/links.d.ts +10 -0
  82. package/dist/streamplace/chat/links.js +29 -0
  83. package/dist/streamplace/facets.d.ts +15 -0
  84. package/dist/streamplace/facets.js +112 -0
  85. package/dist/streamplace/link-embed.d.ts +13 -0
  86. package/dist/streamplace/link-embed.js +16 -0
  87. package/dist/streamplace/links.d.ts +6 -0
  88. package/dist/streamplace/links.js +1 -0
  89. package/dist/streamplace/reactions.d.ts +21 -0
  90. package/dist/streamplace/reactions.js +46 -0
  91. package/dist/streamplace/types.d.ts +200 -0
  92. package/dist/streamplace/types.js +1 -0
  93. package/dist/streamplace-data.d.ts +11 -0
  94. package/dist/streamplace-data.js +10 -0
  95. package/dist/streamplace.d.ts +14 -6
  96. package/dist/streamplace.js +11 -1
  97. package/dist/{events/event-view → video}/Player.svelte +69 -21
  98. package/dist/video/Player.svelte.d.ts +38 -0
  99. package/dist/video/engines.d.ts +59 -0
  100. package/dist/video/engines.js +647 -0
  101. package/package.json +11 -1
  102. package/dist/events/event-view/Player.svelte.d.ts +0 -24
@@ -0,0 +1,184 @@
1
+ <script lang="ts" module>
2
+ import type { LivestreamView } from './types.js';
3
+
4
+ export type StreamCardProps = {
5
+ stream: LivestreamView;
6
+ /** Where the card leads: a path in this app, or stream.place by default. */
7
+ href?: string;
8
+ /**
9
+ * The picture. By default the node's current frame of the stream, shown over the
10
+ * stream's own thumbnail once it has loaded (the node is slow to send it).
11
+ */
12
+ thumbnail?: string;
13
+ /** Load the picture at once, for cards at the top of a page. */
14
+ eager?: boolean;
15
+ /** Play the stream in place, silently, while the mouse is on the card. */
16
+ preview?: boolean;
17
+ /**
18
+ * Start connecting to the stream as soon as the card is pointed at, focused or pressed,
19
+ * so the stream page that opens next plays at once. On for links within the app.
20
+ */
21
+ prefetch?: boolean;
22
+ class?: string;
23
+ };
24
+ </script>
25
+
26
+ <script lang="ts">
27
+ import Avatar from '../components/Avatar.svelte';
28
+ import { muted, recess } from '../styles.js';
29
+ import { cn } from '../utils.js';
30
+ import { startWebRTC, warmWebRTC } from '../video/engines.js';
31
+ import {
32
+ activityName,
33
+ blobImage,
34
+ displayName,
35
+ formatCount,
36
+ handleOf,
37
+ liveThumbnail,
38
+ whepUrl
39
+ } from './api.js';
40
+
41
+ let {
42
+ stream,
43
+ href,
44
+ thumbnail,
45
+ eager = false,
46
+ preview = true,
47
+ prefetch,
48
+ class: className
49
+ }: StreamCardProps = $props();
50
+
51
+ const handle = $derived(handleOf(stream.author));
52
+ const link = $derived(href ?? `https://stream.place/${encodeURIComponent(handle)}`);
53
+ const local = $derived(/^\/(?!\/)/.test(link));
54
+ const viewers = $derived(stream.viewerCount?.count ?? 0);
55
+ const byline = $derived(
56
+ [displayName(stream.author), activityName(stream.record.activity)].filter(Boolean).join(' · ')
57
+ );
58
+ // One picture per minute, so revisits reuse the cached frame.
59
+ const picture = $derived(
60
+ thumbnail ?? liveThumbnail(stream.author.did, Math.floor(Date.now() / 60_000))
61
+ );
62
+ // The stream's own thumbnail comes from a fast CDN, but is only as recent as the stream.
63
+ const stored = $derived(
64
+ thumbnail ? undefined : blobImage(stream.author.did, stream.record.thumb)
65
+ );
66
+ let loadedPicture = $state<string>();
67
+ const pictureLoaded = $derived(loadedPicture === picture);
68
+ /** A picture that finished loading before the page was interactive fires no `load`. */
69
+ function loaded(node: HTMLImageElement) {
70
+ const current = picture;
71
+ if (node.complete && node.naturalWidth) loadedPicture = current;
72
+ }
73
+
74
+ let video = $state<HTMLVideoElement>();
75
+ let previewing = $state(false);
76
+ let playing = $state(false);
77
+ /** The stream page plays the same session; it stays open this long after the card lets go. */
78
+ const KEEP = 15_000;
79
+ const prefetchEnabled = $derived(prefetch ?? local);
80
+
81
+ function warm() {
82
+ if (prefetchEnabled) warmWebRTC(whepUrl(stream.author.did), KEEP);
83
+ }
84
+ function enter(event: PointerEvent) {
85
+ warm();
86
+ // Not for touch, where there is no resting pointer, and not against reduced motion.
87
+ if (!preview || event.pointerType !== 'mouse') return;
88
+ if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
89
+ // No delay: the session is being opened anyway, and the picture only fades in once
90
+ // frames arrive, so passing over a card shows nothing.
91
+ previewing = true;
92
+ }
93
+ function leave() {
94
+ previewing = false;
95
+ }
96
+ $effect(() => {
97
+ if (!previewing || !video) return;
98
+ const element = video;
99
+ // One attempt: a preview that does not start is simply not shown.
100
+ // Only keep the session open for handoff when prefetching is enabled.
101
+ const engine = startWebRTC(
102
+ element,
103
+ whepUrl(stream.author.did),
104
+ { onready: () => void element.play().catch(() => {}), onfail: leave },
105
+ { attempts: 1, keep: prefetchEnabled ? KEEP : 0 }
106
+ );
107
+ return () => {
108
+ engine.destroy();
109
+ playing = false;
110
+ };
111
+ });
112
+ </script>
113
+
114
+ <a
115
+ href={link}
116
+ target={local ? undefined : '_blank'}
117
+ rel={local ? undefined : 'noopener noreferrer'}
118
+ class={cn(
119
+ 'group block min-w-0 text-base-950 no-underline outline-none dark:text-base-50',
120
+ className
121
+ )}
122
+ onpointerenter={enter}
123
+ onpointerleave={leave}
124
+ onpointerdown={warm}
125
+ onfocus={warm}
126
+ >
127
+ <div
128
+ class={cn(
129
+ 'relative aspect-video overflow-hidden rounded-ui group-focus-visible:outline-2 group-focus-visible:outline-offset-3 group-focus-visible:outline-accent-700 dark:group-focus-visible:outline-accent-300',
130
+ recess
131
+ )}
132
+ >
133
+ {#if stored}
134
+ <img
135
+ src={stored}
136
+ alt=""
137
+ loading={eager ? 'eager' : 'lazy'}
138
+ decoding="async"
139
+ class="absolute inset-0 size-full object-cover transition-transform duration-300 group-hover:scale-[1.02] motion-reduce:transition-none"
140
+ />
141
+ {/if}
142
+ <img
143
+ src={picture}
144
+ alt=""
145
+ loading={eager ? 'eager' : 'lazy'}
146
+ decoding="async"
147
+ {@attach loaded}
148
+ onload={() => (loadedPicture = picture)}
149
+ class={[
150
+ 'absolute inset-0 size-full object-cover transition-[opacity,transform] duration-300 group-hover:scale-[1.02] motion-reduce:transition-none',
151
+ stored && !pictureLoaded && 'opacity-0'
152
+ ]}
153
+ />
154
+ {#if previewing}
155
+ <video
156
+ bind:this={video}
157
+ muted
158
+ playsinline
159
+ disablepictureinpicture
160
+ aria-hidden="true"
161
+ tabindex="-1"
162
+ class={[
163
+ 'pointer-events-none absolute inset-0 size-full bg-black object-contain transition-opacity duration-200',
164
+ playing ? 'opacity-100' : 'opacity-0'
165
+ ]}
166
+ onplaying={() => (playing = true)}
167
+ ></video>
168
+ {/if}
169
+ <span
170
+ class="absolute bottom-2 left-2 flex items-center gap-1.5 rounded-md bg-black/70 px-1.5 py-0.5 text-[11px] font-medium text-white"
171
+ >
172
+ <span class="size-1.5 rounded-full bg-accent-500"></span>
173
+ {formatCount(viewers)}
174
+ <span class="sr-only">{viewers === 1 ? 'viewer' : 'viewers'}</span>
175
+ </span>
176
+ </div>
177
+ <div class="mt-2.5 flex gap-2.5">
178
+ <Avatar name={handle} src={stream.author.avatar} size={36} class="shrink-0" />
179
+ <div class="min-w-0">
180
+ <h3 class="line-clamp-2 text-sm leading-snug font-medium">{stream.record.title}</h3>
181
+ <p class={cn('mt-0.5 truncate text-[13px]', muted)}>{byline}</p>
182
+ </div>
183
+ </div>
184
+ </a>
@@ -0,0 +1,24 @@
1
+ import type { LivestreamView } from './types.js';
2
+ export type StreamCardProps = {
3
+ stream: LivestreamView;
4
+ /** Where the card leads: a path in this app, or stream.place by default. */
5
+ href?: string;
6
+ /**
7
+ * The picture. By default the node's current frame of the stream, shown over the
8
+ * stream's own thumbnail once it has loaded (the node is slow to send it).
9
+ */
10
+ thumbnail?: string;
11
+ /** Load the picture at once, for cards at the top of a page. */
12
+ eager?: boolean;
13
+ /** Play the stream in place, silently, while the mouse is on the card. */
14
+ preview?: boolean;
15
+ /**
16
+ * Start connecting to the stream as soon as the card is pointed at, focused or pressed,
17
+ * so the stream page that opens next plays at once. On for links within the app.
18
+ */
19
+ prefetch?: boolean;
20
+ class?: string;
21
+ };
22
+ declare const StreamCard: import("svelte").Component<StreamCardProps, {}, "">;
23
+ type StreamCard = ReturnType<typeof StreamCard>;
24
+ export default StreamCard;
@@ -0,0 +1,59 @@
1
+ <script lang="ts">
2
+ import type { LinkEmbedProps } from '../embeds/types.js';
3
+ import { getLivestream, getLiveStreamsCached, handleOf, liveThumbnail } from './api.js';
4
+ import type { StreamLinkEmbedRef } from './link-embed.js';
5
+ import type { LivestreamView } from './types.js';
6
+
7
+ let { ref, fallback }: LinkEmbedProps<StreamLinkEmbedRef> = $props();
8
+ const local = $derived(/^\/(?!\/)/.test(ref.href));
9
+
10
+ let stream = $state.raw<LivestreamView | null>();
11
+ $effect(() => {
12
+ let current = true;
13
+ stream = undefined;
14
+ getLivestream(ref.actor)
15
+ .then((result) => current && (stream = result))
16
+ .catch(() => current && (stream = null));
17
+ return () => (current = false);
18
+ });
19
+ let live = $state(false);
20
+ $effect(() => {
21
+ const did = stream?.author.did;
22
+ live = false;
23
+ if (!did) return;
24
+ let current = true;
25
+ void getLiveStreamsCached()
26
+ .then((streams) => {
27
+ if (current) live = streams.some((other) => other.author.did === did);
28
+ })
29
+ .catch(() => {});
30
+ return () => (current = false);
31
+ });
32
+ </script>
33
+
34
+ {#if stream}
35
+ <a
36
+ href={ref.href}
37
+ target={local ? undefined : '_blank'}
38
+ rel={local ? undefined : 'noopener noreferrer'}
39
+ class="flex items-center gap-3 rounded-lg border border-base-300 p-2 hover:bg-base-200/60 dark:border-base-800 dark:hover:bg-base-800/50"
40
+ >
41
+ {#if live}
42
+ <img
43
+ src={liveThumbnail(stream.author.did)}
44
+ alt=""
45
+ loading="lazy"
46
+ class="aspect-video w-24 shrink-0 rounded-md bg-black object-cover"
47
+ />
48
+ {/if}
49
+ <span class="min-w-0">
50
+ <span class="line-clamp-2 text-[13px] leading-snug font-medium">{stream.record.title}</span>
51
+ <span class="mt-0.5 flex items-center gap-1.5 text-xs text-base-600 dark:text-base-400">
52
+ {#if live}<span class="size-1.5 rounded-full bg-accent-500"></span>Live ·{/if}
53
+ <span class="truncate">@{handleOf(stream.author)}</span>
54
+ </span>
55
+ </span>
56
+ </a>
57
+ {:else}
58
+ {@render fallback()}
59
+ {/if}
@@ -0,0 +1,5 @@
1
+ import type { LinkEmbedProps } from '../embeds/types.js';
2
+ import type { StreamLinkEmbedRef } from './link-embed.js';
3
+ declare const StreamLinkEmbed: import("svelte").Component<LinkEmbedProps<StreamLinkEmbedRef>, {}, "">;
4
+ type StreamLinkEmbed = ReturnType<typeof StreamLinkEmbed>;
5
+ export default StreamLinkEmbed;