@atmo-dev/kit 0.15.1 → 0.17.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/events/EventCard.svelte +7 -4
- package/dist/events/EventCard.svelte.d.ts +3 -0
- package/dist/events/EventEditor.svelte +62 -11
- package/dist/events/EventEditor.svelte.d.ts +11 -2
- package/dist/events/EventView.svelte +7 -4
- package/dist/events/EventView.svelte.d.ts +3 -0
- package/dist/events/editor/adapter.d.ts +2 -2
- package/dist/events/editor/save.d.ts +2 -1
- package/dist/events/editor/save.js +3 -2
- package/dist/events/editor/types.d.ts +1 -1
- package/dist/events/event-media.d.ts +12 -0
- package/dist/events-data.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getCDNImageBlobUrl } from './atproto-helpers.js';
|
|
3
|
-
import { getEventThumbnail, getEventExternalImage } from './event-media.js';
|
|
3
|
+
import { getEventThumbnail, getEventExternalImage, type EventMediaUrl } from './event-media.js';
|
|
4
4
|
import { eventUrl, isEventOngoing, type FlatEventRecord } from './contrail.js';
|
|
5
5
|
import Avatar from 'svelte-boring-avatars';
|
|
6
6
|
import { Badge, Icon } from '../index.js';
|
|
@@ -10,12 +10,15 @@
|
|
|
10
10
|
let {
|
|
11
11
|
event,
|
|
12
12
|
actor,
|
|
13
|
-
href
|
|
13
|
+
href,
|
|
14
|
+
mediaUrl = getCDNImageBlobUrl
|
|
14
15
|
}: {
|
|
15
16
|
event: FlatEventRecord;
|
|
16
17
|
actor?: string;
|
|
17
18
|
/** Where the card links, for an event whose page is not its creator's. */
|
|
18
19
|
href?: string;
|
|
20
|
+
/** Where the card loads the event's own images from; the public CDN by default. */
|
|
21
|
+
mediaUrl?: EventMediaUrl;
|
|
19
22
|
} = $props();
|
|
20
23
|
|
|
21
24
|
function formatDateTime(dateStr: string): string {
|
|
@@ -68,13 +71,13 @@
|
|
|
68
71
|
function getThumbnail(event: FlatEventRecord): { url: string; alt: string } | null {
|
|
69
72
|
const media = getEventThumbnail(event.media);
|
|
70
73
|
if (media?.content) {
|
|
71
|
-
const url =
|
|
74
|
+
const url = mediaUrl({ did: event.did, blob: media.content });
|
|
72
75
|
if (url) return { url, alt: media.alt || event.name };
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
const banner = event.media?.find((m) => m.role === 'header');
|
|
76
79
|
if (banner?.content) {
|
|
77
|
-
const url =
|
|
80
|
+
const url = mediaUrl({ did: event.did, blob: banner.content });
|
|
78
81
|
if (url) return { url, alt: banner.alt || event.name };
|
|
79
82
|
}
|
|
80
83
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { type EventMediaUrl } from './event-media.js';
|
|
1
2
|
import { type FlatEventRecord } from './contrail.js';
|
|
2
3
|
type $$ComponentProps = {
|
|
3
4
|
event: FlatEventRecord;
|
|
4
5
|
actor?: string;
|
|
5
6
|
/** Where the card links, for an event whose page is not its creator's. */
|
|
6
7
|
href?: string;
|
|
8
|
+
/** Where the card loads the event's own images from; the public CDN by default. */
|
|
9
|
+
mediaUrl?: EventMediaUrl;
|
|
7
10
|
};
|
|
8
11
|
declare const EventCard: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
12
|
type EventCard = ReturnType<typeof EventCard>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getCDNImageBlobUrl } from './atproto-helpers.js';
|
|
3
|
-
import { getEventThumbnail } from './event-media.js';
|
|
3
|
+
import { getEventThumbnail, type EventMediaUrl } from './event-media.js';
|
|
4
4
|
import { Avatar, Button, ToggleGroup, ToggleGroupItem } from '../index.js';
|
|
5
5
|
import { onMount, untrack } from 'svelte';
|
|
6
6
|
import { InlineEditor, RichTextEditor, type Editor } from '../index.js';
|
|
@@ -39,7 +39,11 @@
|
|
|
39
39
|
adapter,
|
|
40
40
|
viewer,
|
|
41
41
|
initialTheme,
|
|
42
|
-
prefill = null
|
|
42
|
+
prefill = null,
|
|
43
|
+
mediaUrl = getCDNImageBlobUrl,
|
|
44
|
+
visibility = $bindable('public'),
|
|
45
|
+
visibilityOptions = ['public', 'unlisted'],
|
|
46
|
+
confirmVisibility
|
|
43
47
|
}: {
|
|
44
48
|
eventData: FlatEventRecord | null;
|
|
45
49
|
actorDid: string;
|
|
@@ -50,6 +54,14 @@
|
|
|
50
54
|
initialTheme?: Partial<EventTheme>;
|
|
51
55
|
/** Autofill payload for new events (e.g. imported from Luma/Meetup). */
|
|
52
56
|
prefill?: EventEditorPrefill | null;
|
|
57
|
+
/** Where the editor loads the event's current image from; the public CDN by default. */
|
|
58
|
+
mediaUrl?: EventMediaUrl;
|
|
59
|
+
/** Who can see the event. Bind it to follow the host's choice; an existing event's record sets it. */
|
|
60
|
+
visibility?: Visibility;
|
|
61
|
+
/** The choices the switch offers, in order. Public and Unlisted by default. */
|
|
62
|
+
visibilityOptions?: readonly Visibility[];
|
|
63
|
+
/** Asked before the choice changes; returning false keeps the current one. */
|
|
64
|
+
confirmVisibility?: (next: Visibility) => boolean | Promise<boolean>;
|
|
53
65
|
} = $props();
|
|
54
66
|
|
|
55
67
|
let isNew = $derived(eventData === null);
|
|
@@ -76,7 +88,6 @@
|
|
|
76
88
|
);
|
|
77
89
|
let timezone = $state(initialTimezone);
|
|
78
90
|
let mode: EventMode = $state(initialPrefill?.mode ?? 'inperson');
|
|
79
|
-
let visibility: Visibility = $state('public');
|
|
80
91
|
// svelte-ignore state_referenced_locally
|
|
81
92
|
let eventTheme: EventTheme = $state(
|
|
82
93
|
eventData === null
|
|
@@ -96,6 +107,10 @@
|
|
|
96
107
|
let selectedPreset: string | null = $state(
|
|
97
108
|
initialThumbnailFile ? null : eventData === null ? DEFAULT_PRESET : null
|
|
98
109
|
);
|
|
110
|
+
/** The cover drawn from the selected preset, once it is drawn for a save. */
|
|
111
|
+
let generatedThumbnail: File | null = null;
|
|
112
|
+
/** The host chose a cover, or took it away, rather than leaving a new event's default. */
|
|
113
|
+
let coverChosen = false;
|
|
99
114
|
let images = $derived(adapter.features.images !== false);
|
|
100
115
|
const embedOptions = linkEmbedOptions();
|
|
101
116
|
/** As on the event page: the app's embeds, plus cards for links to other events. */
|
|
@@ -117,6 +132,16 @@
|
|
|
117
132
|
];
|
|
118
133
|
});
|
|
119
134
|
let showVisibility = $derived(adapter.features.visibility !== false);
|
|
135
|
+
const VISIBILITY_LABELS: Record<Visibility, string> = {
|
|
136
|
+
public: 'Public',
|
|
137
|
+
unlisted: 'Unlisted',
|
|
138
|
+
private: 'Private'
|
|
139
|
+
};
|
|
140
|
+
async function chooseVisibility(next: Visibility) {
|
|
141
|
+
if (next === visibility) return;
|
|
142
|
+
if (confirmVisibility && !(await confirmVisibility(next))) return;
|
|
143
|
+
visibility = next;
|
|
144
|
+
}
|
|
120
145
|
let submitting = $state(false);
|
|
121
146
|
let error: string | null = $state(null);
|
|
122
147
|
let titleEditor = $state<Editor | null>(null);
|
|
@@ -159,7 +184,7 @@
|
|
|
159
184
|
if (eventData.media && eventData.media.length > 0) {
|
|
160
185
|
const media = getEventThumbnail(eventData.media);
|
|
161
186
|
if (media?.content) {
|
|
162
|
-
const url =
|
|
187
|
+
const url = mediaUrl({ did: actorDid, blob: media.content });
|
|
163
188
|
if (url) {
|
|
164
189
|
thumbnailPreview = url;
|
|
165
190
|
thumbnailChanged = false;
|
|
@@ -245,9 +270,19 @@
|
|
|
245
270
|
});
|
|
246
271
|
if (rendered) {
|
|
247
272
|
thumbnailFile = rendered;
|
|
273
|
+
generatedThumbnail = rendered;
|
|
248
274
|
thumbnailChanged = true;
|
|
249
275
|
}
|
|
250
276
|
}
|
|
277
|
+
// The default cover a new event gets without asking isn't worth losing the event over, so
|
|
278
|
+
// if it doesn't upload the event is saved without it. A cover the host chose, a preset as
|
|
279
|
+
// much as an image, fails the save instead, so it is never left out without their knowing.
|
|
280
|
+
const defaultCover =
|
|
281
|
+
isNew &&
|
|
282
|
+
!coverChosen &&
|
|
283
|
+
selectedPreset === DEFAULT_PRESET &&
|
|
284
|
+
thumbnailFile !== null &&
|
|
285
|
+
thumbnailFile === generatedThumbnail;
|
|
251
286
|
|
|
252
287
|
const existingMedia = (eventData?.media ?? []) as Array<Record<string, unknown>>;
|
|
253
288
|
const media = images
|
|
@@ -256,8 +291,15 @@
|
|
|
256
291
|
thumbnailChanged,
|
|
257
292
|
thumbnailFile,
|
|
258
293
|
existingMedia,
|
|
259
|
-
uploadBlob: (blob) =>
|
|
260
|
-
|
|
294
|
+
uploadBlob: async (blob) => {
|
|
295
|
+
try {
|
|
296
|
+
return (await adapter.uploadBlob(blob)) as unknown as Record<string, unknown>;
|
|
297
|
+
} catch (e) {
|
|
298
|
+
if (!defaultCover) throw e;
|
|
299
|
+
console.warn('Generated cover not uploaded; saving the event without it:', e);
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
261
303
|
})
|
|
262
304
|
: existingMedia.length > 0
|
|
263
305
|
? existingMedia
|
|
@@ -363,7 +405,13 @@
|
|
|
363
405
|
bind:thumbnailFile
|
|
364
406
|
bind:thumbnailPreview
|
|
365
407
|
bind:thumbnailChanged
|
|
366
|
-
bind:selectedPreset
|
|
408
|
+
bind:selectedPreset={
|
|
409
|
+
() => selectedPreset,
|
|
410
|
+
(preset) => {
|
|
411
|
+
selectedPreset = preset;
|
|
412
|
+
coverChosen = true;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
367
415
|
/>
|
|
368
416
|
{/if}
|
|
369
417
|
|
|
@@ -408,20 +456,23 @@
|
|
|
408
456
|
bind:value={
|
|
409
457
|
() => visibility,
|
|
410
458
|
(val) => {
|
|
411
|
-
if (val)
|
|
459
|
+
if (val) void chooseVisibility(val as Visibility);
|
|
412
460
|
}
|
|
413
461
|
}
|
|
414
462
|
class="w-fit"
|
|
415
463
|
size="xs"
|
|
416
464
|
>
|
|
417
|
-
|
|
418
|
-
|
|
465
|
+
{#each visibilityOptions as option (option)}
|
|
466
|
+
<ToggleGroupItem value={option}>{VISIBILITY_LABELS[option]}</ToggleGroupItem>
|
|
467
|
+
{/each}
|
|
419
468
|
</ToggleGroup>
|
|
420
469
|
<div class="mt-1.5 text-xs text-base-600 dark:text-base-400">
|
|
421
470
|
{#if visibility === 'public'}
|
|
422
471
|
Anyone can view and it appears in discovery.
|
|
423
|
-
{:else}
|
|
472
|
+
{:else if visibility === 'unlisted'}
|
|
424
473
|
Public to anyone with the link, but hidden from discovery.
|
|
474
|
+
{:else}
|
|
475
|
+
Only people you invite can see it.
|
|
425
476
|
{/if}
|
|
426
477
|
</div>
|
|
427
478
|
</div>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { type EventMediaUrl } from './event-media.js';
|
|
1
2
|
import type { FlatEventRecord } from './contrail.js';
|
|
2
3
|
import { type EventTheme } from './theme.js';
|
|
3
|
-
import { type EventEditorPrefill } from './editor/types';
|
|
4
|
+
import { type EventEditorPrefill, type Visibility } from './editor/types';
|
|
4
5
|
import type { EditorAdapter, EditorViewer } from './editor/adapter';
|
|
5
6
|
type $$ComponentProps = {
|
|
6
7
|
eventData: FlatEventRecord | null;
|
|
@@ -12,7 +13,15 @@ type $$ComponentProps = {
|
|
|
12
13
|
initialTheme?: Partial<EventTheme>;
|
|
13
14
|
/** Autofill payload for new events (e.g. imported from Luma/Meetup). */
|
|
14
15
|
prefill?: EventEditorPrefill | null;
|
|
16
|
+
/** Where the editor loads the event's current image from; the public CDN by default. */
|
|
17
|
+
mediaUrl?: EventMediaUrl;
|
|
18
|
+
/** Who can see the event. Bind it to follow the host's choice; an existing event's record sets it. */
|
|
19
|
+
visibility?: Visibility;
|
|
20
|
+
/** The choices the switch offers, in order. Public and Unlisted by default. */
|
|
21
|
+
visibilityOptions?: readonly Visibility[];
|
|
22
|
+
/** Asked before the choice changes; returning false keeps the current one. */
|
|
23
|
+
confirmVisibility?: (next: Visibility) => boolean | Promise<boolean>;
|
|
15
24
|
};
|
|
16
|
-
declare const EventEditor: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
25
|
+
declare const EventEditor: import("svelte").Component<$$ComponentProps, {}, "visibility">;
|
|
17
26
|
type EventEditor = ReturnType<typeof EventEditor>;
|
|
18
27
|
export default EventEditor;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { isEventOngoing, type AttendeeListLoader, type FlatEventRecord } from './contrail.js';
|
|
3
3
|
import type { EventViewData } from './view-data.js';
|
|
4
4
|
import { getCDNImageBlobUrl } from './atproto-helpers.js';
|
|
5
|
-
import { getEventThumbnail, getEventExternalImage } from './event-media.js';
|
|
5
|
+
import { getEventThumbnail, getEventExternalImage, type EventMediaUrl } from './event-media.js';
|
|
6
6
|
import { Button, ToggleGroup, ToggleGroupItem } from '../index.js';
|
|
7
7
|
import ShareModal from './ShareModal.svelte';
|
|
8
8
|
import EventComments from './EventComments.svelte';
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
share = true,
|
|
49
49
|
extraActions,
|
|
50
50
|
attendeeActions,
|
|
51
|
-
loadAttendees
|
|
51
|
+
loadAttendees,
|
|
52
|
+
mediaUrl = getCDNImageBlobUrl
|
|
52
53
|
}: {
|
|
53
54
|
data: EventViewData;
|
|
54
55
|
adapter: EditorAdapter;
|
|
@@ -70,6 +71,8 @@
|
|
|
70
71
|
/** Fetches the complete attendee lists the first time one is opened, when
|
|
71
72
|
* `data.attendees` holds only a sample of the counted RSVPs. */
|
|
72
73
|
loadAttendees?: AttendeeListLoader;
|
|
74
|
+
/** Where the page loads the event's own images from; the public CDN by default. */
|
|
75
|
+
mediaUrl?: EventMediaUrl;
|
|
73
76
|
} = $props();
|
|
74
77
|
|
|
75
78
|
let eventData: FlatEventRecord = $derived(data.eventData);
|
|
@@ -198,7 +201,7 @@
|
|
|
198
201
|
if (!eventData.media || eventData.media.length === 0) return null;
|
|
199
202
|
const media = getEventThumbnail(eventData.media);
|
|
200
203
|
if (!media?.content) return null;
|
|
201
|
-
const url =
|
|
204
|
+
const url = mediaUrl({ did, blob: media.content });
|
|
202
205
|
if (!url) return null;
|
|
203
206
|
return { url, alt: media.alt || eventData.name, aspectRatio: media.aspect_ratio };
|
|
204
207
|
});
|
|
@@ -207,7 +210,7 @@
|
|
|
207
210
|
if (!eventData.media || eventData.media.length === 0) return null;
|
|
208
211
|
const media = eventData.media.find((m) => m.role === 'header');
|
|
209
212
|
if (!media?.content) return null;
|
|
210
|
-
const url =
|
|
213
|
+
const url = mediaUrl({ did, blob: media.content });
|
|
211
214
|
if (!url) return null;
|
|
212
215
|
return { url, alt: media.alt || eventData.name, aspectRatio: media.aspect_ratio };
|
|
213
216
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AttendeeListLoader } from './contrail.js';
|
|
2
2
|
import type { EventViewData } from './view-data.js';
|
|
3
|
+
import { type EventMediaUrl } from './event-media.js';
|
|
3
4
|
import { type AttendeeCounts } from './EventAttendees.svelte';
|
|
4
5
|
import { type Snippet } from 'svelte';
|
|
5
6
|
import type { EditorAdapter, EditorViewer } from './editor/adapter.js';
|
|
@@ -24,6 +25,8 @@ type $$ComponentProps = {
|
|
|
24
25
|
/** Fetches the complete attendee lists the first time one is opened, when
|
|
25
26
|
* `data.attendees` holds only a sample of the counted RSVPs. */
|
|
26
27
|
loadAttendees?: AttendeeListLoader;
|
|
28
|
+
/** Where the page loads the event's own images from; the public CDN by default. */
|
|
29
|
+
mediaUrl?: EventMediaUrl;
|
|
27
30
|
};
|
|
28
31
|
declare const EventView: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
29
32
|
type EventView = ReturnType<typeof EventView>;
|
|
@@ -43,8 +43,8 @@ export type EditorAdapter = {
|
|
|
43
43
|
*/
|
|
44
44
|
images?: boolean;
|
|
45
45
|
/**
|
|
46
|
-
* False for an event with no public listing to appear in: no
|
|
47
|
-
*
|
|
46
|
+
* False for an event with no public listing to appear in: no visibility switch, and the
|
|
47
|
+
* record's discovery preference is left as it is.
|
|
48
48
|
*/
|
|
49
49
|
visibility?: boolean;
|
|
50
50
|
};
|
|
@@ -19,7 +19,8 @@ export declare function buildThumbnailMedia(args: {
|
|
|
19
19
|
thumbnailChanged: boolean;
|
|
20
20
|
thumbnailFile: File | null;
|
|
21
21
|
existingMedia: Array<Record<string, unknown>>;
|
|
22
|
-
|
|
22
|
+
/** Null leaves the new image out and keeps the media as it was. */
|
|
23
|
+
uploadBlob: (blob: Blob) => Promise<Record<string, unknown> | null>;
|
|
23
24
|
}): Promise<Array<Record<string, unknown>> | undefined>;
|
|
24
25
|
export declare function buildEventRecord(args: {
|
|
25
26
|
eventData: FlatEventRecord | null;
|
|
@@ -158,13 +158,14 @@ export async function buildEventRecord(args) {
|
|
|
158
158
|
if (Array.isArray(record.locations)) {
|
|
159
159
|
record.locations = normalizeEventLocations(record.locations);
|
|
160
160
|
}
|
|
161
|
-
// With no
|
|
161
|
+
// With no visibility choice offered, the record keeps whatever preference it had. Only a public
|
|
162
|
+
// event appears in discovery.
|
|
162
163
|
if (visibility !== null) {
|
|
163
164
|
const existingPrefs = (record.preferences ??
|
|
164
165
|
{});
|
|
165
166
|
record.preferences = {
|
|
166
167
|
...existingPrefs,
|
|
167
|
-
showInDiscovery: visibility
|
|
168
|
+
showInDiscovery: visibility === 'public'
|
|
168
169
|
};
|
|
169
170
|
}
|
|
170
171
|
return record;
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/** The address of an image in an event's `media`, from the event's DID and the image's blob, or
|
|
2
|
+
* null to leave that image out. The components use the public CDN's (`getCDNImageBlobUrl`) unless
|
|
3
|
+
* a page supplies its own, as one must for an event whose pictures shouldn't reach a public CDN. */
|
|
4
|
+
export type EventMediaUrl = (image: {
|
|
5
|
+
did: string;
|
|
6
|
+
blob: {
|
|
7
|
+
$type: 'blob';
|
|
8
|
+
ref: {
|
|
9
|
+
$link: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}) => string | null;
|
|
1
13
|
/** Select the event's thumbnail, falling back to a flyer before any header image. */
|
|
2
14
|
export declare function getEventThumbnail<T extends {
|
|
3
15
|
role?: unknown;
|
package/dist/events-data.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Event types and pure helpers. Safe to import without Svelte, CSS or browser players. */
|
|
2
2
|
export type { EventViewData } from './events/view-data.js';
|
|
3
3
|
export type { EditorAdapter, EditorBlobRef, EditorViewer } from './events/editor/adapter.js';
|
|
4
|
-
export type { EventEditorPrefill } from './events/editor/types.js';
|
|
4
|
+
export type { EventEditorPrefill, Visibility as EventVisibility } from './events/editor/types.js';
|
|
5
5
|
export type { EventData, EventLexiconMain, EventLocationVariant, EventStatus, EventMode as EventLexiconMode } from './events/event-types.js';
|
|
6
6
|
export type { FlatEventRecord, HostProfile, AttendeeInfo, AttendeeListLoader } from './events/contrail.js';
|
|
7
7
|
export { eventUrl, isEventOngoing, RSVP_GOING, RSVP_INTERESTED } from './events/contrail.js';
|
|
@@ -9,7 +9,7 @@ export * from './events/conference.js';
|
|
|
9
9
|
export * from './events/linked-records.js';
|
|
10
10
|
export * from './events/date-format.js';
|
|
11
11
|
export * from './events/theme.js';
|
|
12
|
-
export { getEventThumbnail, getEventExternalImage, type ExternalEventImage } from './events/event-media.js';
|
|
12
|
+
export { getEventThumbnail, getEventExternalImage, type EventMediaUrl, type ExternalEventImage } from './events/event-media.js';
|
|
13
13
|
export { getCDNImageBlobUrl, compressImage, configureAtproto } from './events/atproto-helpers.js';
|
|
14
14
|
export { getProfileUrl, getLocalProfileUrl } from './events/profile-url.js';
|
|
15
15
|
export { resolveEventUrls, type EventUrls, type ResolvedEventUrls } from './events/urls.js';
|