@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.
- package/README.md +1 -1
- package/dist/components/RichText.svelte +17 -9
- package/dist/components/RichTextEditor.svelte +67 -11
- package/dist/components/RichTextEditor.svelte.d.ts +0 -2
- package/dist/components/StreamplacePicker.svelte +2 -2
- package/dist/components/StreamplacePicker.svelte.d.ts +1 -1
- package/dist/components/composer/EmojiPanel.svelte +55 -0
- package/dist/components/composer/EmojiPanel.svelte.d.ts +6 -0
- package/dist/components/composer/EmojiPicker.svelte +2 -38
- package/dist/components/data/DataLabel.svelte +120 -0
- package/dist/components/data/DataLabel.svelte.d.ts +10 -0
- package/dist/components/data/issues.d.ts +5 -0
- package/dist/components/data/issues.js +52 -0
- package/dist/components/data/types.d.ts +28 -0
- package/dist/components/data/types.js +1 -0
- package/dist/components/data/visibility.d.ts +7 -0
- package/dist/components/data/visibility.js +15 -0
- package/dist/components/legal/links.js +1 -0
- package/dist/components/legal/types.d.ts +1 -1
- package/dist/components/notifications/NotificationList.svelte +137 -0
- package/dist/components/notifications/NotificationList.svelte.d.ts +19 -0
- package/dist/components/notifications/NotificationPushToggle.svelte +76 -0
- package/dist/components/notifications/NotificationPushToggle.svelte.d.ts +19 -0
- package/dist/components/notifications/NotificationSettings.svelte +125 -0
- package/dist/components/notifications/NotificationSettings.svelte.d.ts +16 -0
- package/dist/components/notifications/types.d.ts +37 -0
- package/dist/components/notifications/types.js +1 -0
- package/dist/editor/ImageDialog.svelte +87 -0
- package/dist/editor/ImageDialog.svelte.d.ts +16 -0
- package/dist/editor/image-node.d.ts +6 -2
- package/dist/editor/image-node.js +36 -37
- package/dist/events/EventCard.svelte +6 -1
- package/dist/events/VodPlayer.svelte +1 -1
- package/dist/events/atmo-rsvp.d.ts +6 -0
- package/dist/events/atmo-rsvp.js +34 -0
- package/dist/events/atproto-helpers.d.ts +1 -0
- package/dist/events/atproto-helpers.js +3 -0
- package/dist/events/event-link-embed.d.ts +7 -3
- package/dist/events/event-link-embed.js +11 -5
- package/dist/events/event-view/StreamPlacePlayer.svelte +14 -108
- package/dist/events/linked-records.d.ts +1 -1
- package/dist/events/linked-records.js +2 -2
- package/dist/events-card.d.ts +9 -0
- package/dist/events-card.js +7 -0
- package/dist/events-data.d.ts +1 -0
- package/dist/events-data.js +1 -0
- package/dist/grain/xrpc.js +11 -4
- package/dist/index.d.ts +13 -1
- package/dist/index.js +7 -1
- package/dist/legal.d.ts +3 -0
- package/dist/legal.js +2 -0
- package/dist/richtext/serialize.js +13 -8
- package/dist/streamplace/StreamCard.svelte +184 -0
- package/dist/streamplace/StreamCard.svelte.d.ts +24 -0
- package/dist/streamplace/StreamLinkEmbed.svelte +59 -0
- package/dist/streamplace/StreamLinkEmbed.svelte.d.ts +5 -0
- package/dist/streamplace/StreamPlayer.svelte +539 -0
- package/dist/streamplace/StreamPlayer.svelte.d.ts +42 -0
- package/dist/streamplace/VideoCard.svelte +159 -0
- package/dist/streamplace/VideoCard.svelte.d.ts +17 -0
- package/dist/streamplace/api.d.ts +74 -0
- package/dist/streamplace/api.js +182 -0
- package/dist/streamplace/broadcast.d.ts +3 -0
- package/dist/streamplace/broadcast.js +110 -0
- package/dist/streamplace/channel.svelte.d.ts +74 -0
- package/dist/streamplace/channel.svelte.js +515 -0
- package/dist/streamplace/chat/Composer.svelte +232 -0
- package/dist/streamplace/chat/Composer.svelte.d.ts +15 -0
- package/dist/streamplace/chat/Embeds.svelte +135 -0
- package/dist/streamplace/chat/Embeds.svelte.d.ts +13 -0
- package/dist/streamplace/chat/Message.svelte +303 -0
- package/dist/streamplace/chat/Message.svelte.d.ts +25 -0
- package/dist/streamplace/chat/StreamChat.svelte +463 -0
- package/dist/streamplace/chat/StreamChat.svelte.d.ts +33 -0
- package/dist/streamplace/chat/StreamChatPopups.svelte +151 -0
- package/dist/streamplace/chat/StreamChatPopups.svelte.d.ts +15 -0
- package/dist/streamplace/chat/UserCard.svelte +76 -0
- package/dist/streamplace/chat/UserCard.svelte.d.ts +12 -0
- package/dist/streamplace/chat/color.d.ts +7 -0
- package/dist/streamplace/chat/color.js +33 -0
- package/dist/streamplace/chat/links.d.ts +10 -0
- package/dist/streamplace/chat/links.js +29 -0
- package/dist/streamplace/facets.d.ts +15 -0
- package/dist/streamplace/facets.js +112 -0
- package/dist/streamplace/link-embed.d.ts +13 -0
- package/dist/streamplace/link-embed.js +16 -0
- package/dist/streamplace/links.d.ts +6 -0
- package/dist/streamplace/links.js +1 -0
- package/dist/streamplace/reactions.d.ts +21 -0
- package/dist/streamplace/reactions.js +46 -0
- package/dist/streamplace/types.d.ts +200 -0
- package/dist/streamplace/types.js +1 -0
- package/dist/streamplace-data.d.ts +11 -0
- package/dist/streamplace-data.js +10 -0
- package/dist/streamplace.d.ts +14 -6
- package/dist/streamplace.js +11 -1
- package/dist/{events/event-view → video}/Player.svelte +69 -21
- package/dist/video/Player.svelte.d.ts +38 -0
- package/dist/video/engines.d.ts +59 -0
- package/dist/video/engines.js +647 -0
- package/package.json +11 -1
- package/dist/events/event-view/Player.svelte.d.ts +0 -24
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ pnpm dev
|
|
|
36
36
|
|
|
37
37
|
Browse `/components` for visual previews of every public component. Select one
|
|
38
38
|
for its interactive example at `/components/<name>`. The combined playgrounds
|
|
39
|
-
remain at `/`, `/examples`, `/navigation`, `/login`, and `/
|
|
39
|
+
remain at `/`, `/examples`, `/navigation`, `/login`, `/legal`, and `/data`.
|
|
40
40
|
|
|
41
41
|
Run `pnpm lint`, `pnpm check`, `pnpm test:ci`, and `pnpm build` to validate changes.
|
|
42
42
|
See [development](docs/development.md) for tests and package checks, and
|
|
@@ -294,15 +294,23 @@
|
|
|
294
294
|
/>
|
|
295
295
|
{:else if node.type === 'image'}
|
|
296
296
|
{@const source = src(node)}
|
|
297
|
-
{
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
297
|
+
{@const caption = string(node.title).trim()}
|
|
298
|
+
{#if source}
|
|
299
|
+
<figure>
|
|
300
|
+
<img
|
|
301
|
+
src={source}
|
|
302
|
+
alt={string(node.alt)}
|
|
303
|
+
loading="lazy"
|
|
304
|
+
decoding="async"
|
|
305
|
+
referrerpolicy="no-referrer"
|
|
306
|
+
class="mx-auto max-w-full rounded-md"
|
|
307
|
+
/>
|
|
308
|
+
{#if caption}
|
|
309
|
+
<figcaption class="mt-2 text-center text-sm text-base-600 dark:text-base-400">
|
|
310
|
+
{caption}
|
|
311
|
+
</figcaption>
|
|
312
|
+
{/if}
|
|
313
|
+
</figure>
|
|
306
314
|
{:else if string(node.alt)}<p>{string(node.alt)}</p>{/if}
|
|
307
315
|
{:else if node.type === 'table'}
|
|
308
316
|
{@const rows = cells(node.rows)}
|
|
@@ -50,8 +50,6 @@
|
|
|
50
50
|
upload?: (file: File) => Promise<string>;
|
|
51
51
|
/** The address to load a destination from, for those that are not HTTP(S). */
|
|
52
52
|
src?: (url: string) => string | undefined;
|
|
53
|
-
/** Label of the description field below an image. */
|
|
54
|
-
altLabel?: string;
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
export type RichTextEditorProps = {
|
|
@@ -135,6 +133,42 @@
|
|
|
135
133
|
};
|
|
136
134
|
const imageSrc = (url: string) => safeHttpUrl(url) ?? images?.src?.(url);
|
|
137
135
|
|
|
136
|
+
/** The dialog for an image's description and caption, loaded when one is first opened. */
|
|
137
|
+
let ImageDialog = $state.raw<typeof import('../editor/ImageDialog.svelte').default>();
|
|
138
|
+
let imageOpen = $state(false);
|
|
139
|
+
/** The image the dialog is about. */
|
|
140
|
+
let image = $state.raw<{ position: number; url: string; alt: string; title: string }>();
|
|
141
|
+
|
|
142
|
+
function editImage(position: number): void {
|
|
143
|
+
if (!editor || editor.isDestroyed || !editor.isEditable) return;
|
|
144
|
+
if (position < 0 || position > editor.state.doc.content.size) return;
|
|
145
|
+
const node = editor.state.doc.nodeAt(position);
|
|
146
|
+
if (node?.type.name !== IMAGE) return;
|
|
147
|
+
editor.commands.setNodeSelection(position);
|
|
148
|
+
image = {
|
|
149
|
+
position,
|
|
150
|
+
url: String(node.attrs.url ?? ''),
|
|
151
|
+
alt: String(node.attrs.alt ?? ''),
|
|
152
|
+
title: String(node.attrs.title ?? '')
|
|
153
|
+
};
|
|
154
|
+
imageOpen = true;
|
|
155
|
+
if (!ImageDialog)
|
|
156
|
+
void import('../editor/ImageDialog.svelte').then(
|
|
157
|
+
(module) => (ImageDialog = module.default),
|
|
158
|
+
() => (imageOpen = false)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
/** Applies `change` to the image the dialog is about, if it is still where it was. */
|
|
162
|
+
function withImage(
|
|
163
|
+
change: (position: number, attrs: Record<string, unknown>, size: number) => void
|
|
164
|
+
): void {
|
|
165
|
+
if (!image || !editor || editor.isDestroyed || !editor.isEditable) return;
|
|
166
|
+
if (image.position < 0 || image.position > editor.state.doc.content.size) return;
|
|
167
|
+
const node = editor.state.doc.nodeAt(image.position);
|
|
168
|
+
if (node?.type.name !== IMAGE || node.attrs.url !== image.url) return;
|
|
169
|
+
change(image.position, node.attrs, node.nodeSize);
|
|
170
|
+
}
|
|
171
|
+
|
|
138
172
|
function load(text: string, textFacets?: unknown): JSONContent {
|
|
139
173
|
const document = markdownTools
|
|
140
174
|
? markdownTools.parseMarkdown(text, {
|
|
@@ -222,7 +256,7 @@
|
|
|
222
256
|
// The same look as `RichText`, so that what is typed is what will be shown.
|
|
223
257
|
// Nothing here reaches into an embed, which brings its own lists, links and code.
|
|
224
258
|
const markdownClass =
|
|
225
|
-
'space-y-3 leading-relaxed whitespace-pre-wrap [&_strong:not([data-link-embed]_*)]:font-semibold [&_h1:not([data-link-embed]_*)]:text-xl [&_h2:not([data-link-embed]_*)]:text-lg [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:leading-snug [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:font-semibold [&_blockquote:not([data-link-embed]_*)]:space-y-3 [&_blockquote:not([data-link-embed]_*)]:border-l-2 [&_blockquote:not([data-link-embed]_*)]:border-base-300 [&_blockquote:not([data-link-embed]_*)]:pl-4 dark:[&_blockquote:not([data-link-embed]_*)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_:is(ul,ol):not([data-link-embed]_*)]:space-y-1 [&_:is(ul,ol):not([data-link-embed]_*)]:pl-6 [&_ul:not([data-link-embed]_*)]:list-disc [&_ol:not([data-link-embed]_*)]:list-decimal [&_li:not([data-link-embed]_*)]:space-y-3 [&_:not(pre)>code:not([data-link-embed]_*)]:rounded [&_:not(pre)>code:not([data-link-embed]_*)]:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] [&_:not(pre)>code:not([data-link-embed]_*)]:px-1 [&_:not(pre)>code:not([data-link-embed]_*)]:py-0.5 [&_:not(pre)>code:not([data-link-embed]_*)]:font-mono [&_:not(pre)>code:not([data-link-embed]_*)]:text-[0.875em] dark:[&_:not(pre)>code:not([data-link-embed]_*)]:bg-base-950 [&_pre:not([data-link-embed]_*)]:overflow-x-auto [&_pre:not([data-link-embed]_*)]:rounded-md [&_pre:not([data-link-embed]_*)]:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] [&_pre:not([data-link-embed]_*)]:p-3 [&_pre:not([data-link-embed]_*)]:font-mono [&_pre:not([data-link-embed]_*)]:text-[0.875em] dark:[&_pre:not([data-link-embed]_*)]:bg-base-950 [&_hr:not([data-link-embed]_*)]:border-base-300 dark:[&_hr:not([data-link-embed]_*)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_a:not([data-link-embed]_*)]:text-accent-700 [&_a:not([data-link-embed]_*)]:underline [&_a:not([data-link-embed]_*)]:decoration-accent-700/40 [&_a:not([data-link-embed]_*)]:underline-offset-2 dark:[&_a:not([data-link-embed]_*)]:text-accent-300 dark:[&_a:not([data-link-embed]_*)]:decoration-accent-300/40 [&
|
|
259
|
+
'space-y-3 leading-relaxed whitespace-pre-wrap [&_strong:not([data-link-embed]_*)]:font-semibold [&_h1:not([data-link-embed]_*)]:text-xl [&_h2:not([data-link-embed]_*)]:text-lg [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:leading-snug [&_:is(h1,h2,h3,h4,h5,h6):not([data-link-embed]_*)]:font-semibold [&_blockquote:not([data-link-embed]_*)]:space-y-3 [&_blockquote:not([data-link-embed]_*)]:border-l-2 [&_blockquote:not([data-link-embed]_*)]:border-base-300 [&_blockquote:not([data-link-embed]_*)]:pl-4 dark:[&_blockquote:not([data-link-embed]_*)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_:is(ul,ol):not([data-link-embed]_*)]:space-y-1 [&_:is(ul,ol):not([data-link-embed]_*)]:pl-6 [&_ul:not([data-link-embed]_*)]:list-disc [&_ol:not([data-link-embed]_*)]:list-decimal [&_li:not([data-link-embed]_*)]:space-y-3 [&_:not(pre)>code:not([data-link-embed]_*)]:rounded [&_:not(pre)>code:not([data-link-embed]_*)]:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] [&_:not(pre)>code:not([data-link-embed]_*)]:px-1 [&_:not(pre)>code:not([data-link-embed]_*)]:py-0.5 [&_:not(pre)>code:not([data-link-embed]_*)]:font-mono [&_:not(pre)>code:not([data-link-embed]_*)]:text-[0.875em] dark:[&_:not(pre)>code:not([data-link-embed]_*)]:bg-base-950 [&_pre:not([data-link-embed]_*)]:overflow-x-auto [&_pre:not([data-link-embed]_*)]:rounded-md [&_pre:not([data-link-embed]_*)]:bg-[color-mix(in_srgb,var(--base-100)_75%,var(--base-200))] [&_pre:not([data-link-embed]_*)]:p-3 [&_pre:not([data-link-embed]_*)]:font-mono [&_pre:not([data-link-embed]_*)]:text-[0.875em] dark:[&_pre:not([data-link-embed]_*)]:bg-base-950 [&_hr:not([data-link-embed]_*)]:border-base-300 dark:[&_hr:not([data-link-embed]_*)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_a:not([data-link-embed]_*)]:text-accent-700 [&_a:not([data-link-embed]_*)]:underline [&_a:not([data-link-embed]_*)]:decoration-accent-700/40 [&_a:not([data-link-embed]_*)]:underline-offset-2 dark:[&_a:not([data-link-embed]_*)]:text-accent-300 dark:[&_a:not([data-link-embed]_*)]:decoration-accent-300/40 [&[contenteditable=true]_[data-image]]:cursor-pointer [&_[data-image]]:whitespace-normal [&_[data-image]>img]:mx-auto [&_[data-image]>img]:max-w-full [&_[data-image]>img]:rounded-md [&_[data-image]>figcaption]:mt-2 [&_[data-image]>figcaption]:text-center [&_[data-image]>figcaption]:text-sm [&_[data-image]>figcaption]:text-base-600 dark:[&_[data-image]>figcaption]:text-base-400 [&_.tableWrapper]:overflow-x-auto [&_table]:border-collapse [&_table]:text-left [&_table]:whitespace-normal [&_:is(th,td)]:border [&_:is(th,td)]:border-base-300 [&_:is(th,td)]:px-3 [&_:is(th,td)]:py-1.5 [&_:is(th,td)]:align-top [&_:is(th,td)]:min-w-16 dark:[&_:is(th,td)]:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))] [&_th]:font-semibold [&_.selectedCell]:bg-accent-500/10';
|
|
226
260
|
// Task lists, math and footnotes of article Markdown.
|
|
227
261
|
const articleClass =
|
|
228
262
|
"[&_li[data-task]]:relative [&_li[data-task]]:list-none [&_li[data-task]]:before:absolute [&_li[data-task]]:before:-left-5 [&_li[data-task=false]]:before:content-['☐'] [&_li[data-task=true]]:before:content-['☑'] [&_ul[data-type=taskList]]:list-none! [&_ul[data-type=taskList]]:pl-0! [&_ul[data-type=taskList]>li]:flex [&_ul[data-type=taskList]>li]:gap-2 [&_ul[data-type=taskList]>li>label]:mt-0.5 [&_ul[data-type=taskList]>li>div]:min-w-0 [&_ul[data-type=taskList]>li>div]:flex-1 [&_ul[data-type=taskList]>li>div]:space-y-3 [&_ul[data-type=taskList]_input]:accent-accent-600 [&_[data-math]]:font-mono [&_[data-math]]:text-[0.875em] [&_[data-math]]:text-accent-700 [&_[data-math]]:before:content-['$'] [&_[data-math]]:after:content-['$'] [&_[data-math]]:before:opacity-50 [&_[data-math]]:after:opacity-50 dark:[&_[data-math]]:text-accent-300 [&_[data-footnote-ref]]:text-accent-700 dark:[&_[data-footnote-ref]]:text-accent-300 [&_[data-footnote]]:relative [&_[data-footnote]]:space-y-3 [&_[data-footnote]]:pl-10 [&_[data-footnote]]:text-[0.9em] [&_[data-footnote]]:before:absolute [&_[data-footnote]]:before:left-0 [&_[data-footnote]]:before:text-base-500 [&_[data-footnote]]:before:content-['['_attr(data-footnote)_']']";
|
|
@@ -242,14 +276,7 @@
|
|
|
242
276
|
...(markdownTools
|
|
243
277
|
? [
|
|
244
278
|
...markdownTools.markdownExtensions(article),
|
|
245
|
-
...(article
|
|
246
|
-
? [
|
|
247
|
-
ImageNode.configure({
|
|
248
|
-
src: imageSrc,
|
|
249
|
-
altLabel: images?.altLabel ?? 'Alt text'
|
|
250
|
-
})
|
|
251
|
-
]
|
|
252
|
-
: [])
|
|
279
|
+
...(article ? [ImageNode.configure({ src: imageSrc, edit: editImage })] : [])
|
|
253
280
|
]
|
|
254
281
|
: ([Document, Paragraph, Text, HardBreak, History] as AnyExtension[])),
|
|
255
282
|
Placeholder.configure({
|
|
@@ -377,12 +404,14 @@
|
|
|
377
404
|
if (editor && (value !== current || facetsKey !== currentFacets)) {
|
|
378
405
|
current = value;
|
|
379
406
|
currentFacets = facetsKey;
|
|
407
|
+
imageOpen = false;
|
|
380
408
|
editor.commands.setContent(load(value, facets), { emitUpdate: false });
|
|
381
409
|
}
|
|
382
410
|
});
|
|
383
411
|
$effect(() => {
|
|
384
412
|
editor?.setEditable(!disabled, false);
|
|
385
413
|
editor?.view.dom.setAttribute('aria-disabled', String(disabled));
|
|
414
|
+
if (disabled) imageOpen = false;
|
|
386
415
|
});
|
|
387
416
|
</script>
|
|
388
417
|
|
|
@@ -404,6 +433,33 @@
|
|
|
404
433
|
}}
|
|
405
434
|
>
|
|
406
435
|
<div bind:this={element}></div>
|
|
436
|
+
{#if ImageDialog && image}
|
|
437
|
+
<ImageDialog
|
|
438
|
+
bind:open={imageOpen}
|
|
439
|
+
src={imageSrc(image.url)}
|
|
440
|
+
alt={image.alt}
|
|
441
|
+
caption={image.title}
|
|
442
|
+
onCloseAutoFocus={(event) => {
|
|
443
|
+
if (editor && !editor.isDestroyed && editor.isEditable) {
|
|
444
|
+
event.preventDefault();
|
|
445
|
+
editor.commands.focus();
|
|
446
|
+
}
|
|
447
|
+
}}
|
|
448
|
+
onsave={({ alt, caption }) =>
|
|
449
|
+
withImage((position, attrs) =>
|
|
450
|
+
editor?.view.dispatch(
|
|
451
|
+
editor.state.tr.setNodeMarkup(position, undefined, { ...attrs, alt, title: caption })
|
|
452
|
+
)
|
|
453
|
+
)}
|
|
454
|
+
onremove={() =>
|
|
455
|
+
withImage((position, _attrs, size) =>
|
|
456
|
+
editor
|
|
457
|
+
?.chain()
|
|
458
|
+
.deleteRange({ from: position, to: position + size })
|
|
459
|
+
.run()
|
|
460
|
+
)}
|
|
461
|
+
/>
|
|
462
|
+
{/if}
|
|
407
463
|
{#if menuTools && editor && host}
|
|
408
464
|
<menuTools.EditorMenus {editor} context={commandContext} />
|
|
409
465
|
{#if images?.upload}
|
|
@@ -22,8 +22,6 @@ export type RichTextEditorImages = {
|
|
|
22
22
|
upload?: (file: File) => Promise<string>;
|
|
23
23
|
/** The address to load a destination from, for those that are not HTTP(S). */
|
|
24
24
|
src?: (url: string) => string | undefined;
|
|
25
|
-
/** Label of the description field below an image. */
|
|
26
|
-
altLabel?: string;
|
|
27
25
|
};
|
|
28
26
|
export type RichTextEditorProps = {
|
|
29
27
|
/** Markdown source with `markdown`, otherwise plain text. */
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import Button from './Button.svelte';
|
|
3
3
|
import Input from './Input.svelte';
|
|
4
4
|
import Modal from './Modal.svelte';
|
|
5
|
-
import { parseStreamplaceLink } from '../streamplace.js';
|
|
6
|
-
import type { StreamplaceSelection } from '../streamplace.js';
|
|
5
|
+
import { parseStreamplaceLink } from '../streamplace/links.js';
|
|
6
|
+
import type { StreamplaceSelection } from '../streamplace/links.js';
|
|
7
7
|
|
|
8
8
|
export type StreamplacePickerProps = {
|
|
9
9
|
open?: boolean;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
// Once loaded, later panels open without a loading state.
|
|
3
|
+
let loaded = false;
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { muted } from '../../styles.js';
|
|
8
|
+
|
|
9
|
+
let { onselect }: { onselect: (emoji: string) => void } = $props();
|
|
10
|
+
|
|
11
|
+
// The picker and its emoji data are only fetched when a panel is first shown.
|
|
12
|
+
let ready = $state(loaded);
|
|
13
|
+
$effect(() => {
|
|
14
|
+
if (ready) return;
|
|
15
|
+
let current = true;
|
|
16
|
+
void import('emoji-picker-element').then(() => {
|
|
17
|
+
loaded = true;
|
|
18
|
+
if (current) ready = true;
|
|
19
|
+
});
|
|
20
|
+
return () => (current = false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function attach(node: HTMLElement) {
|
|
24
|
+
const pick = (event: Event) => {
|
|
25
|
+
const detail = (event as CustomEvent<{ unicode?: string }>).detail;
|
|
26
|
+
if (detail.unicode) onselect(detail.unicode);
|
|
27
|
+
};
|
|
28
|
+
node.addEventListener('emoji-click', pick);
|
|
29
|
+
return () => node.removeEventListener('emoji-click', pick);
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
{#if ready}
|
|
34
|
+
<emoji-picker
|
|
35
|
+
{@attach attach}
|
|
36
|
+
class="emoji [--button-active-background:var(--base-300)] [--button-hover-background:var(--base-200)] [--input-border-color:var(--base-300)] [--input-font-color:var(--base-950)] [--input-placeholder-color:var(--base-600)] dark:[--button-active-background:var(--base-700)] dark:[--button-hover-background:var(--base-800)] dark:[--input-border-color:var(--base-800)] dark:[--input-font-color:var(--base-50)] dark:[--input-placeholder-color:var(--base-400)]"
|
|
37
|
+
></emoji-picker>
|
|
38
|
+
{:else}
|
|
39
|
+
<div class="grid h-80 w-80 place-items-center text-sm {muted}">Loading…</div>
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
<style>
|
|
43
|
+
.emoji {
|
|
44
|
+
--background: transparent;
|
|
45
|
+
--border-size: 0;
|
|
46
|
+
--border-color: transparent;
|
|
47
|
+
--indicator-color: var(--accent-500);
|
|
48
|
+
--outline-color: var(--accent-500);
|
|
49
|
+
--num-columns: 8;
|
|
50
|
+
--emoji-size: 1.35rem;
|
|
51
|
+
width: 21rem;
|
|
52
|
+
height: 22rem;
|
|
53
|
+
max-width: calc(100vw - 2rem);
|
|
54
|
+
}
|
|
55
|
+
</style>
|
|
@@ -1,55 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Smile } from '@sketchyicons/svelte';
|
|
3
|
-
import { muted } from '../../styles.js';
|
|
4
3
|
import Icon from '../Icon.svelte';
|
|
5
4
|
import IconButton from '../IconButton.svelte';
|
|
6
5
|
import Popover from '../Popover.svelte';
|
|
6
|
+
import EmojiPanel from './EmojiPanel.svelte';
|
|
7
7
|
|
|
8
8
|
let { onselect, disabled = false }: { onselect: (emoji: string) => void; disabled?: boolean } =
|
|
9
9
|
$props();
|
|
10
10
|
|
|
11
11
|
let open = $state(false);
|
|
12
|
-
let ready = $state(false);
|
|
13
|
-
// The picker and its emoji data are only fetched when first opened.
|
|
14
|
-
$effect(() => {
|
|
15
|
-
if (open && !ready) void import('emoji-picker-element').then(() => (ready = true));
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
function attach(node: HTMLElement) {
|
|
19
|
-
const pick = (event: Event) => {
|
|
20
|
-
const detail = (event as CustomEvent<{ unicode?: string }>).detail;
|
|
21
|
-
if (detail.unicode) onselect(detail.unicode);
|
|
22
|
-
};
|
|
23
|
-
node.addEventListener('emoji-click', pick);
|
|
24
|
-
return () => node.removeEventListener('emoji-click', pick);
|
|
25
|
-
}
|
|
26
12
|
</script>
|
|
27
13
|
|
|
28
14
|
<Popover bind:open class="overflow-hidden p-0" align="start">
|
|
29
15
|
{#snippet trigger({ props })}
|
|
30
16
|
<IconButton {...props} label="Emoji" {disabled}><Icon img={Smile} /></IconButton>
|
|
31
17
|
{/snippet}
|
|
32
|
-
{
|
|
33
|
-
<emoji-picker
|
|
34
|
-
{@attach attach}
|
|
35
|
-
class="emoji [--button-active-background:var(--base-300)] [--button-hover-background:var(--base-200)] [--input-border-color:var(--base-300)] [--input-font-color:var(--base-950)] [--input-placeholder-color:var(--base-600)] dark:[--button-active-background:var(--base-700)] dark:[--button-hover-background:var(--base-800)] dark:[--input-border-color:var(--base-800)] dark:[--input-font-color:var(--base-50)] dark:[--input-placeholder-color:var(--base-400)]"
|
|
36
|
-
></emoji-picker>
|
|
37
|
-
{:else}
|
|
38
|
-
<div class="grid h-80 w-80 place-items-center text-sm {muted}">Loading…</div>
|
|
39
|
-
{/if}
|
|
18
|
+
<EmojiPanel {onselect} />
|
|
40
19
|
</Popover>
|
|
41
|
-
|
|
42
|
-
<style>
|
|
43
|
-
.emoji {
|
|
44
|
-
--background: transparent;
|
|
45
|
-
--border-size: 0;
|
|
46
|
-
--border-color: transparent;
|
|
47
|
-
--indicator-color: var(--accent-500);
|
|
48
|
-
--outline-color: var(--accent-500);
|
|
49
|
-
--num-columns: 8;
|
|
50
|
-
--emoji-size: 1.35rem;
|
|
51
|
-
width: 21rem;
|
|
52
|
-
height: 22rem;
|
|
53
|
-
max-width: calc(100vw - 2rem);
|
|
54
|
-
}
|
|
55
|
-
</style>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { DataLabelData } from './types.js';
|
|
4
|
+
export type DataLabelProps = Omit<HTMLAttributes<HTMLElement>, 'children' | 'title'> & {
|
|
5
|
+
label: DataLabelData;
|
|
6
|
+
/** Pass an empty string when the page already has a heading. */
|
|
7
|
+
title?: string;
|
|
8
|
+
};
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { Globe, Users, Server, MonitorSmartphone, type IconNode } from '@sketchyicons/svelte';
|
|
13
|
+
import Icon from '../Icon.svelte';
|
|
14
|
+
import { cn } from '../../utils.js';
|
|
15
|
+
import { focus } from '../../styles.js';
|
|
16
|
+
import { safeRemovalHref } from './issues.js';
|
|
17
|
+
import { dataVisibilityLevels } from './visibility.js';
|
|
18
|
+
import type { DataVisibility } from './types.js';
|
|
19
|
+
|
|
20
|
+
let { label, title = 'Your data', class: className, ...rest }: DataLabelProps = $props();
|
|
21
|
+
const uid = $props.id();
|
|
22
|
+
const icons: Record<DataVisibility, IconNode> = {
|
|
23
|
+
public: Globe,
|
|
24
|
+
space: Users,
|
|
25
|
+
app: Server,
|
|
26
|
+
device: MonitorSmartphone
|
|
27
|
+
};
|
|
28
|
+
const groups = $derived(
|
|
29
|
+
dataVisibilityLevels
|
|
30
|
+
.map((level) => ({
|
|
31
|
+
...level,
|
|
32
|
+
entries: label.entries.filter((entry) => entry.visibility === level.id)
|
|
33
|
+
}))
|
|
34
|
+
.filter((group) => group.entries.length)
|
|
35
|
+
);
|
|
36
|
+
const hasIcons = $derived(label.entries.some((entry) => entry.icon));
|
|
37
|
+
const removalLabel = $derived(label.removal?.label.trim() ?? '');
|
|
38
|
+
const removalHref = $derived(
|
|
39
|
+
removalLabel && label.removal ? safeRemovalHref(label.removal.href) : undefined
|
|
40
|
+
);
|
|
41
|
+
const removalExternal = $derived(!!removalHref && /^https?:/i.test(removalHref));
|
|
42
|
+
const muted = 'text-base-600 dark:text-base-400';
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<article
|
|
46
|
+
{...rest}
|
|
47
|
+
class={cn('mx-auto max-w-3xl px-6 py-10 text-sm text-base-950 dark:text-base-50', className)}
|
|
48
|
+
>
|
|
49
|
+
{#if title || label.withoutAccount}
|
|
50
|
+
<header class="mb-8">
|
|
51
|
+
{#if title}<h1 class="m-0 text-3xl font-semibold tracking-tight">{title}</h1>{/if}
|
|
52
|
+
{#if label.withoutAccount}
|
|
53
|
+
<p class={cn('leading-relaxed', muted, title && 'mt-3')}>{label.withoutAccount}</p>
|
|
54
|
+
{/if}
|
|
55
|
+
</header>
|
|
56
|
+
{/if}
|
|
57
|
+
<div class="space-y-10">
|
|
58
|
+
{#each groups as group (group.id)}
|
|
59
|
+
<section aria-labelledby={`${uid}-${group.id}`} data-visibility={group.id}>
|
|
60
|
+
<div
|
|
61
|
+
class="border-b border-base-300 pb-3 dark:border-[color-mix(in_srgb,var(--base-800)_80%,var(--base-950))]"
|
|
62
|
+
>
|
|
63
|
+
<h2 id={`${uid}-${group.id}`} class="m-0 flex items-center gap-2 text-lg font-semibold">
|
|
64
|
+
<Icon
|
|
65
|
+
img={icons[group.id]}
|
|
66
|
+
size={20}
|
|
67
|
+
class={cn(
|
|
68
|
+
'shrink-0',
|
|
69
|
+
group.id === 'public' ? 'text-accent-700 dark:text-accent-300' : muted
|
|
70
|
+
)}
|
|
71
|
+
/>{group.label}
|
|
72
|
+
</h2>
|
|
73
|
+
<p class={cn('mt-1 leading-relaxed', muted)}>{group.description}</p>
|
|
74
|
+
</div>
|
|
75
|
+
<ul class="m-0 grid list-none gap-5 p-0 pt-5">
|
|
76
|
+
{#each group.entries as entry, index (index)}
|
|
77
|
+
<li class="flex items-start gap-3">
|
|
78
|
+
{#if hasIcons}
|
|
79
|
+
<span class="mt-0.5 flex size-5 shrink-0 justify-center">
|
|
80
|
+
{#if entry.icon}<Icon img={entry.icon} size={20} class={muted} />{/if}
|
|
81
|
+
</span>
|
|
82
|
+
{/if}
|
|
83
|
+
<div class="min-w-0 flex-1 space-y-1 wrap-anywhere">
|
|
84
|
+
<p class="leading-snug font-medium">
|
|
85
|
+
{entry.action}{#if entry.optional}<span class={cn('font-normal', muted)}
|
|
86
|
+
> (optional)</span
|
|
87
|
+
>{/if}
|
|
88
|
+
</p>
|
|
89
|
+
<p class={cn('leading-relaxed', muted)}>{entry.saves}</p>
|
|
90
|
+
{#if entry.note}<p class="leading-relaxed">{entry.note}</p>{/if}
|
|
91
|
+
{#if entry.collection}
|
|
92
|
+
<p class={cn('font-mono text-xs break-all', muted)}>{entry.collection}</p>
|
|
93
|
+
{/if}
|
|
94
|
+
</div>
|
|
95
|
+
</li>
|
|
96
|
+
{/each}
|
|
97
|
+
</ul>
|
|
98
|
+
</section>
|
|
99
|
+
{/each}
|
|
100
|
+
</div>
|
|
101
|
+
{#if removalHref || label.updated}
|
|
102
|
+
<footer class={cn('mt-10 space-y-2', muted)}>
|
|
103
|
+
{#if removalHref}
|
|
104
|
+
<p>
|
|
105
|
+
<a
|
|
106
|
+
href={removalHref}
|
|
107
|
+
rel={removalExternal ? 'noopener noreferrer' : undefined}
|
|
108
|
+
class={cn(
|
|
109
|
+
'rounded text-base-950 underline underline-offset-4 dark:text-base-50',
|
|
110
|
+
focus
|
|
111
|
+
)}>{removalLabel}</a
|
|
112
|
+
>
|
|
113
|
+
</p>
|
|
114
|
+
{/if}
|
|
115
|
+
{#if label.updated}
|
|
116
|
+
<p>Last updated: <time datetime={label.updated}>{label.updated}</time></p>
|
|
117
|
+
{/if}
|
|
118
|
+
</footer>
|
|
119
|
+
{/if}
|
|
120
|
+
</article>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { DataLabelData } from './types.js';
|
|
3
|
+
export type DataLabelProps = Omit<HTMLAttributes<HTMLElement>, 'children' | 'title'> & {
|
|
4
|
+
label: DataLabelData;
|
|
5
|
+
/** Pass an empty string when the page already has a heading. */
|
|
6
|
+
title?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const DataLabel: import("svelte").Component<DataLabelProps, {}, "">;
|
|
9
|
+
type DataLabel = ReturnType<typeof DataLabel>;
|
|
10
|
+
export default DataLabel;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DataLabelData } from './types.js';
|
|
2
|
+
/** Same-page fragment anchors are allowed alongside paths, web URLs and mailto links. */
|
|
3
|
+
export declare function safeRemovalHref(value: string): string | undefined;
|
|
4
|
+
/** Completeness checks only. They cannot tell whether the label matches what the app does. */
|
|
5
|
+
export declare function getDataLabelIssues(label: DataLabelData): string[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { safeLegalHref } from '../legal/links.js';
|
|
2
|
+
import { dataVisibilityLevels } from './visibility.js';
|
|
3
|
+
const nsid = /^[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+\.[a-zA-Z][a-zA-Z0-9]{0,62}$/;
|
|
4
|
+
const inAccount = new Set(['public', 'space']);
|
|
5
|
+
/** Same-page fragment anchors are allowed alongside paths, web URLs and mailto links. */
|
|
6
|
+
export function safeRemovalHref(value) {
|
|
7
|
+
if (value.startsWith('#') &&
|
|
8
|
+
value.length > 1 &&
|
|
9
|
+
!/\s/.test(value) &&
|
|
10
|
+
![...value].some((c) => c === '\\' || c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127))
|
|
11
|
+
return value;
|
|
12
|
+
return safeLegalHref(value, true);
|
|
13
|
+
}
|
|
14
|
+
/** Completeness checks only. They cannot tell whether the label matches what the app does. */
|
|
15
|
+
export function getDataLabelIssues(label) {
|
|
16
|
+
const issues = [];
|
|
17
|
+
if (!label.entries.length)
|
|
18
|
+
issues.push('List at least one thing the app saves.');
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
for (const entry of label.entries) {
|
|
21
|
+
const action = entry.action.trim();
|
|
22
|
+
const name = action || '(unnamed)';
|
|
23
|
+
if (!action)
|
|
24
|
+
issues.push('An entry is missing its action.');
|
|
25
|
+
if (!entry.saves.trim())
|
|
26
|
+
issues.push(`"${name}" does not say what is saved.`);
|
|
27
|
+
if (!dataVisibilityLevels.some(({ id }) => id === entry.visibility))
|
|
28
|
+
issues.push(`"${name}" has an unknown visibility.`);
|
|
29
|
+
if (action) {
|
|
30
|
+
const key = `${entry.visibility}:${action.toLowerCase()}`;
|
|
31
|
+
if (seen.has(key))
|
|
32
|
+
issues.push(`"${name}" is listed twice.`);
|
|
33
|
+
seen.add(key);
|
|
34
|
+
}
|
|
35
|
+
if (entry.collection !== undefined) {
|
|
36
|
+
if (entry.collection.length > 317 || !nsid.test(entry.collection))
|
|
37
|
+
issues.push(`"${name}" has an invalid collection name.`);
|
|
38
|
+
if (!inAccount.has(entry.visibility))
|
|
39
|
+
issues.push(`"${name}" names a collection but is not saved to the account.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (label.entries.some(({ visibility }) => inAccount.has(visibility)) && !label.removal)
|
|
43
|
+
issues.push('Add a link explaining how to delete account data.');
|
|
44
|
+
if (label.removal && (!label.removal.label.trim() || !safeRemovalHref(label.removal.href)))
|
|
45
|
+
issues.push('The delete link needs a label and a valid URL.');
|
|
46
|
+
if (label.updated !== undefined &&
|
|
47
|
+
(!/^\d{4}-\d{2}-\d{2}$/.test(label.updated) ||
|
|
48
|
+
!Number.isFinite(Date.parse(label.updated)) ||
|
|
49
|
+
new Date(label.updated).toISOString().slice(0, 10) !== label.updated))
|
|
50
|
+
issues.push('The updated date must be YYYY-MM-DD.');
|
|
51
|
+
return issues;
|
|
52
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IconNode } from '@sketchyicons/svelte';
|
|
2
|
+
import type { LegalLink } from '../legal/types.js';
|
|
3
|
+
/** Where a piece of data lives and who can read it, from most to least exposed. */
|
|
4
|
+
export type DataVisibility = 'public' | 'space' | 'app' | 'device';
|
|
5
|
+
export interface DataLabelEntry {
|
|
6
|
+
/** What the person does, e.g. "Like a station". */
|
|
7
|
+
action: string;
|
|
8
|
+
/** What is saved as a result, in plain words. */
|
|
9
|
+
saves: string;
|
|
10
|
+
visibility: DataVisibility;
|
|
11
|
+
icon?: IconNode;
|
|
12
|
+
/** Record collection NSID, shown small for people who want to look it up. */
|
|
13
|
+
collection?: string;
|
|
14
|
+
/** A caveat worth knowing, e.g. "Only the latest is kept." */
|
|
15
|
+
note?: string;
|
|
16
|
+
/** Only saved when the person opts in. */
|
|
17
|
+
optional?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** App-owned description of deployed behavior. Kit only owns the visibility wording. */
|
|
20
|
+
export interface DataLabelData {
|
|
21
|
+
entries: readonly DataLabelEntry[];
|
|
22
|
+
/** What works without signing in. */
|
|
23
|
+
withoutAccount?: string;
|
|
24
|
+
/** Where to learn how to delete saved data. */
|
|
25
|
+
removal?: LegalLink;
|
|
26
|
+
/** The app's reviewed revision date, not a Kit release date. */
|
|
27
|
+
updated?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Fixed wording, so the same level reads the same in every app. */
|
|
2
|
+
export const dataVisibilityLevels = [
|
|
3
|
+
{ id: 'public', label: 'Public', description: 'Saved to your account. Anyone can see it.' },
|
|
4
|
+
{
|
|
5
|
+
id: 'space',
|
|
6
|
+
label: 'Shared privately',
|
|
7
|
+
description: 'Saved to your account. Only people you share it with can see it.'
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
id: 'app',
|
|
11
|
+
label: 'Stored by this app',
|
|
12
|
+
description: "Saved on this app's servers, not in your account."
|
|
13
|
+
},
|
|
14
|
+
{ id: 'device', label: 'On this device', description: 'Saved only in your browser.' }
|
|
15
|
+
];
|
|
@@ -21,7 +21,7 @@ export interface LegalDocumentData {
|
|
|
21
21
|
}
|
|
22
22
|
/** Omit a link, or set it to false, to hide it. */
|
|
23
23
|
export type LegalFooterLink = string | false | LegalLink;
|
|
24
|
-
export type LegalFooterLinks = Partial<Record<LegalDocumentKind | 'report' | 'source', LegalFooterLink>>;
|
|
24
|
+
export type LegalFooterLinks = Partial<Record<LegalDocumentKind | 'data' | 'report' | 'source', LegalFooterLink>>;
|
|
25
25
|
export interface LegalDraftConfig {
|
|
26
26
|
app: {
|
|
27
27
|
name: string;
|