@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.
Files changed (53) hide show
  1. package/dist/components/RichText.svelte +17 -1
  2. package/dist/components/RichText.svelte.d.ts +8 -0
  3. package/dist/components/SembleCollectionPicker.svelte +221 -0
  4. package/dist/components/SembleCollectionPicker.svelte.d.ts +14 -0
  5. package/dist/components/SembleCollectionView.svelte +153 -0
  6. package/dist/components/SembleCollectionView.svelte.d.ts +10 -0
  7. package/dist/events/EventComments.svelte +15 -2
  8. package/dist/events/EventView.svelte +100 -28
  9. package/dist/events/VodPlayer.svelte +14 -73
  10. package/dist/events/VodPlayer.svelte.d.ts +0 -1
  11. package/dist/events/editor/LinkedRecordsPicker.svelte +44 -3
  12. package/dist/events/editor/LinksSection.svelte +29 -9
  13. package/dist/events/editor/adapter.d.ts +3 -0
  14. package/dist/events/event-view/EventLinkEmbed.svelte +49 -0
  15. package/dist/events/event-view/EventLinkEmbed.svelte.d.ts +14 -0
  16. package/dist/events/event-view/Player.svelte +431 -0
  17. package/dist/events/event-view/Player.svelte.d.ts +24 -0
  18. package/dist/events/event-view/PostLinkEmbed.svelte +71 -0
  19. package/dist/events/event-view/PostLinkEmbed.svelte.d.ts +11 -0
  20. package/dist/events/event-view/ProfileLinkEmbed.svelte +67 -0
  21. package/dist/events/event-view/ProfileLinkEmbed.svelte.d.ts +11 -0
  22. package/dist/events/event-view/StreamPlacePlayer.svelte +13 -46
  23. package/dist/events/event-view/StreamPlacePlayer.svelte.d.ts +0 -1
  24. package/dist/events/linked-records.d.ts +20 -0
  25. package/dist/events/linked-records.js +32 -2
  26. package/dist/events/schedule/ScheduleEventCell.svelte +2 -1
  27. package/dist/events/urls.d.ts +17 -0
  28. package/dist/events/urls.js +11 -0
  29. package/dist/events-data.d.ts +1 -0
  30. package/dist/events-data.js +1 -0
  31. package/dist/index.d.ts +7 -1
  32. package/dist/index.js +5 -1
  33. package/dist/richtext/document.d.ts +9 -0
  34. package/dist/richtext/document.js +35 -0
  35. package/dist/richtext.d.ts +1 -1
  36. package/dist/richtext.js +1 -1
  37. package/dist/semble/types.d.ts +46 -0
  38. package/dist/semble/types.js +1 -0
  39. package/dist/semble/urls.d.ts +2 -0
  40. package/dist/semble/urls.js +43 -0
  41. package/dist/semble/xrpc.d.ts +3 -0
  42. package/dist/semble/xrpc.js +131 -0
  43. package/dist/semble.d.ts +3 -0
  44. package/dist/semble.js +2 -0
  45. package/dist/social/posts.d.ts +7 -0
  46. package/dist/social/posts.js +21 -0
  47. package/dist/social/urls.d.ts +10 -0
  48. package/dist/social/urls.js +43 -1
  49. package/dist/social.d.ts +3 -1
  50. package/dist/social.js +2 -1
  51. package/package.json +5 -6
  52. package/dist/events/event-view/plyr-icons.d.ts +0 -3
  53. package/dist/events/event-view/plyr-icons.js +0 -46
@@ -1,10 +1,5 @@
1
1
  <script lang="ts">
2
- import {
3
- eventUrl,
4
- isEventOngoing,
5
- type AttendeeListLoader,
6
- type FlatEventRecord
7
- } from './contrail.js';
2
+ import { isEventOngoing, type AttendeeListLoader, type FlatEventRecord } from './contrail.js';
8
3
  import type { EventViewData } from './view-data.js';
9
4
  import { getCDNImageBlobUrl } from './atproto-helpers.js';
10
5
  import { getEventThumbnail, getEventExternalImage } from './event-media.js';
@@ -32,13 +27,22 @@
32
27
  import EventLocationMap from './event-view/EventLocationMap.svelte';
33
28
  import EventHostedBy from './event-view/EventHostedBy.svelte';
34
29
  import EventLinksList from './event-view/EventLinksList.svelte';
35
- import { GrainAlbumView } from '../index.js';
36
- import { eventStreamLink, parseGrainLink } from './linked-records.js';
30
+ import { GrainAlbumView, SembleCollectionView } from '../index.js';
31
+ import {
32
+ eventStreamLink,
33
+ eventTabLink,
34
+ parseEventLink,
35
+ parseSembleLink
36
+ } from './linked-records.js';
37
37
  import AddToCalendarButton from './event-view/AddToCalendarButton.svelte';
38
38
  import ExternalRsvpNotice from './event-view/ExternalRsvpNotice.svelte';
39
39
  import RichText from '../components/RichText.svelte';
40
+ import PostLinkEmbed from './event-view/PostLinkEmbed.svelte';
41
+ import EventLinkEmbed from './event-view/EventLinkEmbed.svelte';
42
+ import ProfileLinkEmbed from './event-view/ProfileLinkEmbed.svelte';
43
+ import { parseSocialPostUrl, parseSocialProfileUrl } from '../social/urls.js';
40
44
  import { richTextToPlainText } from '../richtext/document.js';
41
- import { getLocalProfileUrl } from './profile-url.js';
45
+ import { resolveEventUrls } from './urls.js';
42
46
  import { getLocations, resolveGeoLocation, type GeoLocation } from './event-view/locations.js';
43
47
 
44
48
  let {
@@ -83,8 +87,12 @@
83
87
 
84
88
  let theme: EventTheme = $derived(eventData.theme ?? defaultTheme);
85
89
 
86
- let hostUrl = $derived(`/p/${hostProfile?.handle || did}`);
87
- let eventPath = $derived(eventUrl(eventData, hostProfile?.handle || did));
90
+ let urls = $derived(resolveEventUrls(adapter.urls));
91
+ let hostActor = $derived(hostProfile?.handle || did);
92
+ let hostUrl = $derived(urls.profile(hostActor));
93
+ let eventPath = $derived(urls.event(hostActor, rkey));
94
+ let editUrl = $derived(urls.edit(hostActor, rkey));
95
+ let talksUrl = $derived(urls.talks(hostActor, rkey));
88
96
  let shareUrl = $derived(
89
97
  shareUrlOverride
90
98
  ? shareUrlOverride
@@ -125,20 +133,49 @@
125
133
  let hasComments = $derived(!!eventData.bskyPostRef?.showComments && !!eventData.bskyPostRef?.uri);
126
134
  let hasDescription = $derived(!!eventData.description?.trim());
127
135
  let aboutCommentsTab = $state<string>('about');
128
- let photoLinks = $derived(eventData.uris?.filter((link) => parseGrainLink(link.uri)) ?? []);
136
+ let photoLinks = $derived(eventData.uris?.filter((l) => eventTabLink(l.uri) === 'photos') ?? []);
137
+ // Without a loader the collection stays an ordinary link.
138
+ let showCollections = $derived(!!adapter.linkedRecords?.getSembleCollection);
139
+ let collectionLinks = $derived(
140
+ showCollections
141
+ ? (eventData.uris?.filter((l) => eventTabLink(l.uri) === 'collections') ?? [])
142
+ : []
143
+ );
144
+ // Links without a tab of their own. A collection that can't be loaded stays a link, by its web
145
+ // address: the list shows only HTTP(S) destinations, and the record may hold an AT URI.
146
+ let sidebarLinks = $derived(
147
+ eventData.uris?.flatMap((link) => {
148
+ const tab = eventTabLink(link.uri);
149
+ if (tab === 'photos' || (tab === 'collections' && showCollections)) return [];
150
+ return [tab === 'collections' ? { ...link, uri: parseSembleLink(link.uri)!.url } : link];
151
+ })
152
+ );
129
153
  let contentTabs = $derived([
130
154
  ...(hasDescription ? [{ value: 'about', label: 'About' }] : []),
131
155
  ...(hasComments ? [{ value: 'comments', label: 'Comments' }] : []),
132
- ...(photoLinks.length ? [{ value: 'photos', label: 'Photos' }] : [])
156
+ ...(photoLinks.length ? [{ value: 'photos', label: 'Photos' }] : []),
157
+ ...(collectionLinks.length ? [{ value: 'collections', label: 'Collections' }] : [])
133
158
  ]);
134
159
  let activeTab = $derived(
135
160
  contentTabs.some((tab) => tab.value === aboutCommentsTab)
136
161
  ? aboutCommentsTab
137
162
  : contentTabs[0]?.value
138
163
  );
164
+ // Event links are recognized on the canonical site and on this page's own origin.
165
+ let eventOrigins = $derived([...new Set(['https://atmo.rsvp', pageUrl.origin])]);
166
+ let loadEvent = $derived(adapter.linkedRecords?.getEvent);
167
+ /** A link to another event, when the host can load it. */
168
+ function otherEvent(url: string): boolean {
169
+ const link = loadEvent && parseEventLink(url, eventOrigins);
170
+ return (
171
+ !!link && !(link.rkey === rkey && (link.actor === did || link.actor === hostProfile?.handle))
172
+ );
173
+ }
139
174
  let photosOpened = $state(false);
175
+ let collectionsOpened = $state(false);
140
176
  $effect(() => {
141
177
  if (activeTab === 'photos') photosOpened = true;
178
+ if (activeTab === 'collections') collectionsOpened = true;
142
179
  });
143
180
 
144
181
  onMount(() => {
@@ -216,6 +253,8 @@
216
253
 
217
254
  // Conference: when this event is a conference, render its talks as a timetable.
218
255
  let isConference = $derived(isConferenceEvent(eventData));
256
+ // An app without an editor has nothing to offer the owner here.
257
+ let ownerActions = $derived(isOwner && !!(editUrl || (isConference && talksUrl)));
219
258
  let eventActor = $derived(hostProfile?.handle || did);
220
259
  let conferenceRooms = $derived(getConferenceRooms(eventData));
221
260
  let scheduleEvents = $derived(
@@ -255,7 +294,7 @@
255
294
  avatar: viewer.avatar,
256
295
  name: viewer.displayName || viewer.handle || viewer.did,
257
296
  handle: viewer.handle,
258
- url: `/p/${encodeURIComponent(viewer.handle || viewer.did)}`
297
+ url: urls.profile(viewer.handle || viewer.did)
259
298
  },
260
299
  viewerRsvpStatus
261
300
  );
@@ -297,7 +336,7 @@
297
336
  class="grid grid-cols-1 gap-8 md:grid-cols-[14rem_1fr] md:grid-rows-[auto_1fr] md:gap-x-10 md:gap-y-6 lg:grid-cols-[16rem_1fr]"
298
337
  >
299
338
  <!-- Thumbnail image and owner controls (left column) -->
300
- {#if !showBanner || isOwner}
339
+ {#if !showBanner || ownerActions}
301
340
  <div class="order-1 max-w-sm md:order-0 md:col-start-1 md:max-w-none">
302
341
  {#if displayImage && !showBanner}
303
342
  <img
@@ -320,15 +359,15 @@
320
359
  />
321
360
  </div>
322
361
  {/if}
323
- {#if isOwner}
324
- <Button href="./{rkey}/edit" class={showBanner ? 'w-full' : 'mt-9 w-full'}>
325
- Edit Event
326
- </Button>
327
- {#if isConference}
328
- <Button href="./{rkey}/talks" variant="secondary" class="mt-2 w-full">
329
- Manage talks
362
+ {#if ownerActions}
363
+ {#if editUrl}
364
+ <Button href={editUrl} class={showBanner ? 'w-full' : 'mt-9 w-full'}>
365
+ Edit Event
330
366
  </Button>
331
367
  {/if}
368
+ {#if isConference && talksUrl}
369
+ <Button href={talksUrl} variant="secondary" class="mt-2 w-full">Manage talks</Button>
370
+ {/if}
332
371
  {/if}
333
372
  </div>
334
373
  {/if}
@@ -360,9 +399,13 @@
360
399
  >
361
400
  Part of
362
401
  </p>
363
- <EventCard event={data.parentEvent} actor={parentActor} />
402
+ <EventCard
403
+ event={data.parentEvent}
404
+ actor={parentActor}
405
+ href={urls.event(parentActor, data.parentEvent.rkey)}
406
+ />
364
407
  <Button
365
- href={data.parentScheduleUrl ?? `/p/${parentActor}/e/${data.parentEvent.rkey}`}
408
+ href={data.parentScheduleUrl ?? urls.event(parentActor, data.parentEvent.rkey)}
366
409
  size="lg"
367
410
  class="mt-6 w-full"
368
411
  >
@@ -401,7 +444,7 @@
401
444
  </div>
402
445
  {/if}
403
446
 
404
- <!-- About, comments and linked photo albums -->
447
+ <!-- About, comments, linked photo albums and link collections -->
405
448
  {#if contentTabs.length}
406
449
  <div class="mt-8 mb-8">
407
450
  {#if contentTabs.length > 1}
@@ -433,12 +476,32 @@
433
476
  content={data.description}
434
477
  text={eventData.description ?? ''}
435
478
  facets={eventData.facets}
436
- mentionUrl={getLocalProfileUrl}
479
+ mentionUrl={urls.profile}
437
480
  socialClient={viewer.preferredSocialClient}
438
481
  detectLinks
439
482
  headingOffset={1}
483
+ embedLink={(url) =>
484
+ !!parseSocialPostUrl(url) || !!parseSocialProfileUrl(url) || otherEvent(url)}
440
485
  class="text-base-700 dark:text-base-300"
441
- />
486
+ >
487
+ {#snippet linkEmbed(url, fallback)}
488
+ {#if loadEvent && otherEvent(url)}<EventLinkEmbed
489
+ {url}
490
+ origins={eventOrigins}
491
+ local={!embedMode}
492
+ {loadEvent}
493
+ {fallback}
494
+ />{:else if parseSocialProfileUrl(url)}<ProfileLinkEmbed
495
+ {url}
496
+ {fallback}
497
+ socialClient={viewer.preferredSocialClient}
498
+ />{:else}<PostLinkEmbed
499
+ {url}
500
+ {fallback}
501
+ socialClient={viewer.preferredSocialClient}
502
+ />{/if}
503
+ {/snippet}
504
+ </RichText>
442
505
  {:else if activeTab === 'comments' && eventData.bskyPostRef?.uri}
443
506
  <EventComments
444
507
  postUri={eventData.bskyPostRef.uri}
@@ -454,6 +517,15 @@
454
517
  />{/each}
455
518
  </div>
456
519
  {/if}
520
+ {#if collectionsOpened && collectionLinks.length}
521
+ <div hidden={activeTab !== 'collections'} class="space-y-8">
522
+ {#each collectionLinks as link, i (`${link.uri}-${i}`)}<SembleCollectionView
523
+ reference={link.uri}
524
+ title={link.name}
525
+ loadCollection={adapter.linkedRecords?.getSembleCollection}
526
+ />{/each}
527
+ </div>
528
+ {/if}
457
529
  </div>
458
530
  {/if}
459
531
 
@@ -482,7 +554,7 @@
482
554
  <div class="order-3 space-y-6 md:order-0 md:col-start-1">
483
555
  <EventHostedBy {hostProfile} {hostUrl} {did} {speakers} />
484
556
 
485
- <EventLinksList uris={eventData.uris?.filter((link) => !parseGrainLink(link.uri))} />
557
+ <EventLinksList uris={sidebarLinks} />
486
558
 
487
559
  <AddToCalendarButton {eventData} {eventUri} pageHref={pageUrl.href} />
488
560
  {@render extraActions?.()}
@@ -6,10 +6,8 @@
6
6
 
7
7
  <script lang="ts">
8
8
  import { onMount } from 'svelte';
9
- import 'plyr/dist/plyr.css';
10
9
  import type HlsType from 'hls.js';
11
- import type PlyrType from 'plyr';
12
- import { sketchyPlyrIcons } from './event-view/plyr-icons.js';
10
+ import Player from './event-view/Player.svelte';
13
11
 
14
12
  let {
15
13
  playlistUrl,
@@ -26,38 +24,30 @@
26
24
  } = $props();
27
25
 
28
26
  let videoEl: HTMLVideoElement | undefined = $state();
27
+ let player: Player | undefined = $state();
29
28
  let error = $state(false);
30
29
 
31
30
  let hls: HlsType | null = null;
32
- let plyr: PlyrType | null = null;
33
31
 
34
32
  api = {
35
33
  seek(time: number) {
36
- if (plyr) {
37
- plyr.currentTime = time;
38
- plyr.play();
39
- }
34
+ player?.seek(time);
40
35
  }
41
36
  };
42
37
 
43
38
  onMount(() => {
44
39
  init();
45
- return () => {
46
- hls?.destroy();
47
- plyr?.destroy();
48
- };
40
+ return () => hls?.destroy();
49
41
  });
50
42
 
51
43
  async function init() {
52
44
  if (!videoEl) return;
53
45
 
54
46
  try {
55
- const [{ default: Plyr }, { default: Hls }] = await Promise.all([
56
- import('plyr'),
57
- import('hls.js')
58
- ]);
47
+ const { default: Hls } = await import('hls.js');
59
48
 
60
49
  if (Hls.isSupported()) {
50
+ // Nothing is downloaded until the viewer presses play.
61
51
  hls = new Hls({ autoStartLoad: false });
62
52
  hls.loadSource(playlistUrl);
63
53
  hls.attachMedia(videoEl);
@@ -76,55 +66,6 @@
76
66
  videoEl.src = playlistUrl;
77
67
  } else {
78
68
  error = true;
79
- return;
80
- }
81
-
82
- plyr = new Plyr(videoEl, {
83
- ...sketchyPlyrIcons(),
84
- controls: [
85
- 'play-large',
86
- 'play',
87
- 'progress',
88
- 'current-time',
89
- 'mute',
90
- 'volume',
91
- 'captions',
92
- 'settings',
93
- 'fullscreen'
94
- ],
95
- settings: ['captions', 'speed'],
96
- speed: { selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2] },
97
- captions: { active: !!subtitlesUrl, language: 'en', update: true },
98
- ratio: '16:9'
99
- });
100
-
101
- plyr.on('play', () => {
102
- hls?.startLoad();
103
- });
104
-
105
- plyr.on('timeupdate', () => {
106
- currentTime = plyr?.currentTime ?? 0;
107
- });
108
-
109
- // Add track after Plyr init and force captions on
110
- if (subtitlesUrl) {
111
- const media = videoEl;
112
- // Remove any existing tracks first
113
- media.querySelectorAll('track').forEach((t) => t.remove());
114
- // Add fresh track
115
- const track = document.createElement('track');
116
- track.kind = 'captions';
117
- track.label = 'English';
118
- track.srclang = 'en';
119
- track.src = subtitlesUrl;
120
- track.default = true;
121
- media.appendChild(track);
122
- // Wait for track to load, then activate
123
- track.addEventListener('load', () => {
124
- plyr!.toggleCaptions(true);
125
- });
126
- // Also try toggling after a short delay as fallback
127
- setTimeout(() => plyr?.toggleCaptions(true), 500);
128
69
  }
129
70
  } catch {
130
71
  error = true;
@@ -142,13 +83,13 @@
142
83
  <div
143
84
  class="aspect-video w-full max-w-full overflow-hidden rounded-xl border border-base-300 dark:border-base-400/40"
144
85
  >
145
- <video bind:this={videoEl} class="h-full w-full" aria-label={title} crossorigin="anonymous"
146
- ></video>
86
+ <Player
87
+ bind:this={player}
88
+ bind:video={videoEl}
89
+ bind:currentTime
90
+ {title}
91
+ captionsUrl={subtitlesUrl}
92
+ onplay={() => hls?.startLoad()}
93
+ />
147
94
  </div>
148
95
  {/if}
149
-
150
- <style>
151
- * {
152
- --plyr-color-main: var(--color-accent-500);
153
- }
154
- </style>
@@ -1,7 +1,6 @@
1
1
  export type VodPlayerApi = {
2
2
  seek: (time: number) => void;
3
3
  };
4
- import 'plyr/dist/plyr.css';
5
4
  type $$ComponentProps = {
6
5
  playlistUrl: string;
7
6
  title: string;
@@ -1,9 +1,17 @@
1
1
  <script lang="ts">
2
- import { Button, Icon, Popover, GrainAlbumPicker, StreamplacePicker } from '../../index.js';
3
- import { Camera, Plus, Video } from '@sketchyicons/svelte';
2
+ import {
3
+ Button,
4
+ Icon,
5
+ Popover,
6
+ GrainAlbumPicker,
7
+ SembleCollectionPicker,
8
+ StreamplacePicker
9
+ } from '../../index.js';
10
+ import { Bookmark, Camera, Plus, Video } from '@sketchyicons/svelte';
11
+ import type { SembleCollection } from '../../semble.js';
4
12
  import type { GrainAlbum } from '../../grain.js';
5
13
  import type { EditorAdapter, EditorViewer } from './adapter.js';
6
- import { eventStreamLink, parseGrainLink } from '../linked-records.js';
14
+ import { eventStreamLink, parseGrainLink, parseSembleLink } from '../linked-records.js';
7
15
 
8
16
  let {
9
17
  links = $bindable(),
@@ -17,6 +25,7 @@
17
25
  let menuOpen = $state(false);
18
26
  let grainOpen = $state(false);
19
27
  let streamOpen = $state(false);
28
+ let sembleOpen = $state(false);
20
29
  let session = 0;
21
30
  let stream = $derived(links.find((link) => eventStreamLink(link.uri)));
22
31
  function added(album: GrainAlbum) {
@@ -51,6 +60,20 @@
51
60
  if (current !== session || !grainOpen) return;
52
61
  links = [...links, { uri: album.url, name: album.title }];
53
62
  }
63
+ function collectionAdded(collection: SembleCollection) {
64
+ return links.some((link) => {
65
+ const ref = parseSembleLink(link.uri);
66
+ return (
67
+ ref?.atUri === collection.uri ||
68
+ (ref?.actor === collection.creator.handle &&
69
+ ref?.rkey === parseSembleLink(collection.uri)?.rkey)
70
+ );
71
+ });
72
+ }
73
+ function attachCollection(collection: SembleCollection) {
74
+ if (collectionAdded(collection)) return 'This collection is already added.';
75
+ links = [...links, { uri: collection.url, name: collection.name }];
76
+ }
54
77
  </script>
55
78
 
56
79
  <Popover
@@ -80,6 +103,16 @@
80
103
  streamOpen = true;
81
104
  }}><Icon img={Video} size={16} />Streamplace stream</Button
82
105
  >
106
+ {#if adapter.linkedRecords?.getSembleCollection}
107
+ <Button
108
+ variant="ghost"
109
+ class="w-full justify-start"
110
+ onclick={() => {
111
+ menuOpen = false;
112
+ sembleOpen = true;
113
+ }}><Icon img={Bookmark} size={16} />Semble collection</Button
114
+ >
115
+ {/if}
83
116
  </Popover>
84
117
 
85
118
  <GrainAlbumPicker
@@ -90,6 +123,14 @@
90
123
  isSelected={added}
91
124
  onselect={attachAlbum}
92
125
  />
126
+ <SembleCollectionPicker
127
+ bind:open={sembleOpen}
128
+ actor={viewer.did}
129
+ listCollections={adapter.linkedRecords?.listSembleCollections}
130
+ loadCollection={adapter.linkedRecords?.getSembleCollection}
131
+ isSelected={collectionAdded}
132
+ onselect={attachCollection}
133
+ />
93
134
  <StreamplacePicker
94
135
  bind:open={streamOpen}
95
136
  actor={viewer.handle && viewer.handle !== 'handle.invalid' ? viewer.handle : viewer.did}
@@ -1,8 +1,13 @@
1
1
  <script lang="ts">
2
- import { Camera, Link as LinkIcon, Plus, Video, X } from '@sketchyicons/svelte';
2
+ import { Bookmark, Camera, Link as LinkIcon, Plus, Video, X } from '@sketchyicons/svelte';
3
3
  import { Button, Icon, Input, Popover } from '../../index.js';
4
4
  import { validateLink } from '../cal/helper.js';
5
- import { eventStreamLink, isLinkedRecord, parseGrainLink } from '../linked-records.js';
5
+ import {
6
+ eventStreamLink,
7
+ isLinkedRecord,
8
+ parseGrainLink,
9
+ parseSembleLink
10
+ } from '../linked-records.js';
6
11
  import type { EditorAdapter, EditorViewer } from './adapter.js';
7
12
  import LinkedRecordsPicker from './LinkedRecordsPicker.svelte';
8
13
 
@@ -32,6 +37,7 @@
32
37
  return;
33
38
  }
34
39
  const grain = parseGrainLink(uri),
40
+ semble = parseSembleLink(uri),
35
41
  stream = eventStreamLink(uri);
36
42
  // Keep one stream even when it was added through the generic URL input.
37
43
  if (stream && links.some((l) => eventStreamLink(l.uri))) {
@@ -44,7 +50,13 @@
44
50
  uri,
45
51
  name:
46
52
  newName.trim() ||
47
- (grain ? 'Grain photo album' : stream ? `Streamplace · ${stream.actor}` : '')
53
+ (grain
54
+ ? 'Grain photo album'
55
+ : semble
56
+ ? 'Semble collection'
57
+ : stream
58
+ ? `Streamplace · ${stream.actor}`
59
+ : '')
48
60
  }
49
61
  ];
50
62
  cancel();
@@ -60,10 +72,16 @@
60
72
  }
61
73
  </script>
62
74
 
63
- {#snippet row(link: Link, provider?: 'grain' | 'stream')}
75
+ {#snippet row(link: Link, provider?: 'grain' | 'semble' | 'stream')}
64
76
  <div class="group flex items-center gap-2">
65
77
  <Icon
66
- img={provider === 'grain' ? Camera : provider === 'stream' ? Video : LinkIcon}
78
+ img={provider === 'grain'
79
+ ? Camera
80
+ : provider === 'semble'
81
+ ? Bookmark
82
+ : provider === 'stream'
83
+ ? Video
84
+ : LinkIcon}
67
85
  size={16}
68
86
  class="shrink-0 text-base-600 dark:text-base-400"
69
87
  />
@@ -72,9 +90,11 @@
72
90
  {link.name ||
73
91
  (provider === 'grain'
74
92
  ? 'Grain photo album'
75
- : provider === 'stream'
76
- ? eventStreamLink(link.uri)?.actor
77
- : link.uri.replace(/^https?:\/\//, ''))}
93
+ : provider === 'semble'
94
+ ? 'Semble collection'
95
+ : provider === 'stream'
96
+ ? eventStreamLink(link.uri)?.actor
97
+ : link.uri.replace(/^https?:\/\//, ''))}
78
98
  </p>
79
99
  </div>
80
100
  <Button
@@ -103,7 +123,7 @@
103
123
  <div class="mb-4 space-y-3">
104
124
  {#each linked as link, i (i)}{@render row(
105
125
  link,
106
- parseGrainLink(link.uri) ? 'grain' : 'stream'
126
+ parseGrainLink(link.uri) ? 'grain' : parseSembleLink(link.uri) ? 'semble' : 'stream'
107
127
  )}{/each}
108
128
  </div>
109
129
  {/if}
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import type { PreferredSocialClient } from '../../social.js';
10
10
  import type { LinkedRecordsClient } from '../linked-records.js';
11
+ import type { EventUrls } from '../urls.js';
11
12
  export type EditorBlobRef = {
12
13
  $type: 'blob';
13
14
  ref: {
@@ -28,6 +29,8 @@ export type EditorViewer = {
28
29
  avatar?: string;
29
30
  };
30
31
  export type EditorAdapter = {
32
+ /** The host's routes for profiles, events and editing; see `EventUrls` for the defaults. */
33
+ urls?: EventUrls;
31
34
  /** Optional public read transport, supplied by the host (also used in embeds). */
32
35
  linkedRecords?: LinkedRecordsClient;
33
36
  features: {
@@ -0,0 +1,49 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import Surface from '../../components/Surface.svelte';
4
+ import EventCard from '../EventCard.svelte';
5
+ import type { FlatEventRecord } from '../contrail.js';
6
+ import { parseEventLink, type LinkedRecordsClient } from '../linked-records.js';
7
+
8
+ let {
9
+ url,
10
+ origins,
11
+ local,
12
+ loadEvent,
13
+ fallback
14
+ }: {
15
+ url: string;
16
+ origins: readonly string[];
17
+ /** Whether this app serves event pages itself; otherwise the card opens the linked URL. */
18
+ local: boolean;
19
+ loadEvent: NonNullable<LinkedRecordsClient['getEvent']>;
20
+ /** The ordinary link, shown until the event loads and whenever it can't be shown. */
21
+ fallback: Snippet;
22
+ } = $props();
23
+
24
+ let ref = $derived(parseEventLink(url, origins));
25
+ let event = $state<FlatEventRecord | null>(null);
26
+ $effect(() => {
27
+ const link = parseEventLink(url, origins);
28
+ const transport = loadEvent;
29
+ let current = true;
30
+ event = null;
31
+ if (link) {
32
+ void Promise.resolve()
33
+ .then(() => transport(link.actor, link.rkey))
34
+ .then((result) => {
35
+ if (current && result?.rkey === link.rkey && result.startsAt) event = result;
36
+ })
37
+ .catch(() => {});
38
+ }
39
+ return () => {
40
+ current = false;
41
+ };
42
+ });
43
+ </script>
44
+
45
+ {#if event && ref}
46
+ <Surface class="p-4"
47
+ ><EventCard {event} actor={ref.actor} href={local ? ref.path : url} /></Surface
48
+ >
49
+ {:else}{@render fallback()}{/if}
@@ -0,0 +1,14 @@
1
+ import type { Snippet } from 'svelte';
2
+ import { type LinkedRecordsClient } from '../linked-records.js';
3
+ type $$ComponentProps = {
4
+ url: string;
5
+ origins: readonly string[];
6
+ /** Whether this app serves event pages itself; otherwise the card opens the linked URL. */
7
+ local: boolean;
8
+ loadEvent: NonNullable<LinkedRecordsClient['getEvent']>;
9
+ /** The ordinary link, shown until the event loads and whenever it can't be shown. */
10
+ fallback: Snippet;
11
+ };
12
+ declare const EventLinkEmbed: import("svelte").Component<$$ComponentProps, {}, "">;
13
+ type EventLinkEmbed = ReturnType<typeof EventLinkEmbed>;
14
+ export default EventLinkEmbed;