@ewanc26/svelte-standard-site 0.2.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/LICENSE +661 -0
- package/README.md +108 -0
- package/dist/__tests__/content.test.d.ts +4 -0
- package/dist/__tests__/content.test.js +128 -0
- package/dist/client.d.ts +71 -0
- package/dist/client.js +307 -0
- package/dist/components/Comments.svelte +277 -0
- package/dist/components/Comments.svelte.d.ts +17 -0
- package/dist/components/DocumentCard.svelte +95 -0
- package/dist/components/DocumentCard.svelte.d.ts +11 -0
- package/dist/components/PublicationCard.svelte +54 -0
- package/dist/components/PublicationCard.svelte.d.ts +9 -0
- package/dist/components/StandardSiteLayout.svelte +102 -0
- package/dist/components/StandardSiteLayout.svelte.d.ts +18 -0
- package/dist/components/ThemeToggle.svelte +55 -0
- package/dist/components/ThemeToggle.svelte.d.ts +6 -0
- package/dist/components/common/DateDisplay.svelte +38 -0
- package/dist/components/common/DateDisplay.svelte.d.ts +11 -0
- package/dist/components/common/TagList.svelte +31 -0
- package/dist/components/common/TagList.svelte.d.ts +8 -0
- package/dist/components/common/ThemedCard.svelte +65 -0
- package/dist/components/common/ThemedCard.svelte.d.ts +11 -0
- package/dist/components/common/ThemedContainer.svelte +55 -0
- package/dist/components/common/ThemedContainer.svelte.d.ts +11 -0
- package/dist/components/common/ThemedText.svelte +75 -0
- package/dist/components/common/ThemedText.svelte.d.ts +11 -0
- package/dist/components/document/BlockRenderer.svelte +67 -0
- package/dist/components/document/BlockRenderer.svelte.d.ts +9 -0
- package/dist/components/document/CanvasRenderer.svelte +41 -0
- package/dist/components/document/CanvasRenderer.svelte.d.ts +22 -0
- package/dist/components/document/DocumentRenderer.svelte +68 -0
- package/dist/components/document/DocumentRenderer.svelte.d.ts +17 -0
- package/dist/components/document/InlineMath.svelte +41 -0
- package/dist/components/document/InlineMath.svelte.d.ts +7 -0
- package/dist/components/document/LeafletContentRenderer.svelte +64 -0
- package/dist/components/document/LeafletContentRenderer.svelte.d.ts +36 -0
- package/dist/components/document/LinearDocumentRenderer.svelte +45 -0
- package/dist/components/document/LinearDocumentRenderer.svelte.d.ts +18 -0
- package/dist/components/document/MarkdownRenderer.svelte +62 -0
- package/dist/components/document/MarkdownRenderer.svelte.d.ts +10 -0
- package/dist/components/document/RichText.svelte +272 -0
- package/dist/components/document/RichText.svelte.d.ts +18 -0
- package/dist/components/document/blocks/BlockquoteBlock.svelte +29 -0
- package/dist/components/document/blocks/BlockquoteBlock.svelte.d.ts +10 -0
- package/dist/components/document/blocks/BskyPostBlock.svelte +202 -0
- package/dist/components/document/blocks/BskyPostBlock.svelte.d.ts +13 -0
- package/dist/components/document/blocks/ButtonBlock.svelte +24 -0
- package/dist/components/document/blocks/ButtonBlock.svelte.d.ts +10 -0
- package/dist/components/document/blocks/CodeBlock.svelte +68 -0
- package/dist/components/document/blocks/CodeBlock.svelte.d.ts +12 -0
- package/dist/components/document/blocks/HeaderBlock.svelte +56 -0
- package/dist/components/document/blocks/HeaderBlock.svelte.d.ts +11 -0
- package/dist/components/document/blocks/HorizontalRuleBlock.svelte +14 -0
- package/dist/components/document/blocks/HorizontalRuleBlock.svelte.d.ts +6 -0
- package/dist/components/document/blocks/IframeBlock.svelte +32 -0
- package/dist/components/document/blocks/IframeBlock.svelte.d.ts +10 -0
- package/dist/components/document/blocks/ImageBlock.svelte +55 -0
- package/dist/components/document/blocks/ImageBlock.svelte.d.ts +25 -0
- package/dist/components/document/blocks/MathBlock.svelte +34 -0
- package/dist/components/document/blocks/MathBlock.svelte.d.ts +10 -0
- package/dist/components/document/blocks/PageBlock.svelte +66 -0
- package/dist/components/document/blocks/PageBlock.svelte.d.ts +10 -0
- package/dist/components/document/blocks/PollBlock.svelte +122 -0
- package/dist/components/document/blocks/PollBlock.svelte.d.ts +27 -0
- package/dist/components/document/blocks/TextBlock.svelte +26 -0
- package/dist/components/document/blocks/TextBlock.svelte.d.ts +11 -0
- package/dist/components/document/blocks/UnorderedListBlock.svelte +71 -0
- package/dist/components/document/blocks/UnorderedListBlock.svelte.d.ts +9 -0
- package/dist/components/document/blocks/WebsiteBlock.svelte +81 -0
- package/dist/components/document/blocks/WebsiteBlock.svelte.d.ts +21 -0
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.js +13 -0
- package/dist/config/env.d.ts +11 -0
- package/dist/config/env.js +26 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +23 -0
- package/dist/publisher.d.ts +193 -0
- package/dist/publisher.js +349 -0
- package/dist/schemas.d.ts +626 -0
- package/dist/schemas.js +113 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.js +1 -0
- package/dist/stores/theme.d.ts +11 -0
- package/dist/stores/theme.js +67 -0
- package/dist/styles/base.css +188 -0
- package/dist/styles/themes.css +5 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.js +4 -0
- package/dist/utils/agents.d.ts +35 -0
- package/dist/utils/agents.js +96 -0
- package/dist/utils/at-uri.d.ts +50 -0
- package/dist/utils/at-uri.js +71 -0
- package/dist/utils/cache.d.ts +14 -0
- package/dist/utils/cache.js +33 -0
- package/dist/utils/comments.d.ts +61 -0
- package/dist/utils/comments.js +159 -0
- package/dist/utils/content.d.ts +94 -0
- package/dist/utils/content.js +178 -0
- package/dist/utils/document.d.ts +23 -0
- package/dist/utils/document.js +33 -0
- package/dist/utils/theme-helpers.d.ts +34 -0
- package/dist/utils/theme-helpers.js +63 -0
- package/dist/utils/theme.d.ts +18 -0
- package/dist/utils/theme.js +24 -0
- package/dist/utils/verification.d.ts +129 -0
- package/dist/utils/verification.js +157 -0
- package/package.json +139 -0
- package/src/lib/__tests__/content.test.ts +155 -0
- package/src/lib/client.ts +368 -0
- package/src/lib/components/Comments.svelte +277 -0
- package/src/lib/components/DocumentCard.svelte +95 -0
- package/src/lib/components/PublicationCard.svelte +54 -0
- package/src/lib/components/StandardSiteLayout.svelte +102 -0
- package/src/lib/components/ThemeToggle.svelte +55 -0
- package/src/lib/components/common/DateDisplay.svelte +38 -0
- package/src/lib/components/common/TagList.svelte +31 -0
- package/src/lib/components/common/ThemedCard.svelte +65 -0
- package/src/lib/components/common/ThemedContainer.svelte +55 -0
- package/src/lib/components/common/ThemedText.svelte +75 -0
- package/src/lib/components/document/BlockRenderer.svelte +67 -0
- package/src/lib/components/document/CanvasRenderer.svelte +41 -0
- package/src/lib/components/document/DocumentRenderer.svelte +68 -0
- package/src/lib/components/document/InlineMath.svelte +41 -0
- package/src/lib/components/document/LeafletContentRenderer.svelte +64 -0
- package/src/lib/components/document/LinearDocumentRenderer.svelte +45 -0
- package/src/lib/components/document/MarkdownRenderer.svelte +62 -0
- package/src/lib/components/document/RichText.svelte +272 -0
- package/src/lib/components/document/blocks/BlockquoteBlock.svelte +29 -0
- package/src/lib/components/document/blocks/BskyPostBlock.svelte +202 -0
- package/src/lib/components/document/blocks/ButtonBlock.svelte +24 -0
- package/src/lib/components/document/blocks/CodeBlock.svelte +68 -0
- package/src/lib/components/document/blocks/HeaderBlock.svelte +56 -0
- package/src/lib/components/document/blocks/HorizontalRuleBlock.svelte +14 -0
- package/src/lib/components/document/blocks/IframeBlock.svelte +32 -0
- package/src/lib/components/document/blocks/ImageBlock.svelte +55 -0
- package/src/lib/components/document/blocks/MathBlock.svelte +34 -0
- package/src/lib/components/document/blocks/PageBlock.svelte +66 -0
- package/src/lib/components/document/blocks/PollBlock.svelte +122 -0
- package/src/lib/components/document/blocks/TextBlock.svelte +26 -0
- package/src/lib/components/document/blocks/UnorderedListBlock.svelte +71 -0
- package/src/lib/components/document/blocks/WebsiteBlock.svelte +81 -0
- package/src/lib/components/index.ts +15 -0
- package/src/lib/config/env.ts +31 -0
- package/src/lib/index.ts +104 -0
- package/src/lib/publisher.ts +489 -0
- package/src/lib/schemas.ts +137 -0
- package/src/lib/stores/index.ts +1 -0
- package/src/lib/stores/theme.ts +80 -0
- package/src/lib/styles/base.css +188 -0
- package/src/lib/styles/themes.css +5 -0
- package/src/lib/types.ts +116 -0
- package/src/lib/utils/agents.ts +124 -0
- package/src/lib/utils/at-uri.ts +89 -0
- package/src/lib/utils/cache.ts +46 -0
- package/src/lib/utils/comments.ts +217 -0
- package/src/lib/utils/content.ts +234 -0
- package/src/lib/utils/document.ts +41 -0
- package/src/lib/utils/theme-helpers.ts +87 -0
- package/src/lib/utils/theme.ts +33 -0
- package/src/lib/utils/verification.ts +180 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import RichText from '../RichText.svelte';
|
|
3
|
+
import UnorderedListBlock from './UnorderedListBlock.svelte';
|
|
4
|
+
|
|
5
|
+
export interface ListItem {
|
|
6
|
+
content?: {
|
|
7
|
+
plaintext: string;
|
|
8
|
+
facets?: any[];
|
|
9
|
+
};
|
|
10
|
+
children?: ListItem[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
block: {
|
|
15
|
+
children: ListItem[];
|
|
16
|
+
};
|
|
17
|
+
hasTheme?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const { block, hasTheme = false }: Props = $props();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<ul class="unordered-list pb-2">
|
|
24
|
+
{#each block.children as item}
|
|
25
|
+
<li class="flex flex-row gap-2 pb-0">
|
|
26
|
+
<div
|
|
27
|
+
class="listMarker z-1 mx-2 mt-3.5 h-1.25 w-1.25 shrink-0"
|
|
28
|
+
class:has-content={item.content}
|
|
29
|
+
class:themed={hasTheme}
|
|
30
|
+
></div>
|
|
31
|
+
|
|
32
|
+
<div class="flex w-full flex-col">
|
|
33
|
+
{#if item.content}
|
|
34
|
+
<div class="textBlock mt-1 mb-2">
|
|
35
|
+
<RichText plaintext={item.content.plaintext} facets={item.content.facets} {hasTheme} />
|
|
36
|
+
</div>
|
|
37
|
+
{/if}
|
|
38
|
+
{#if item.children && item.children.length > 0}
|
|
39
|
+
<UnorderedListBlock block={{ children: item.children }} {hasTheme} />
|
|
40
|
+
{/if}
|
|
41
|
+
</div>
|
|
42
|
+
</li>
|
|
43
|
+
{/each}
|
|
44
|
+
</ul>
|
|
45
|
+
|
|
46
|
+
<style>
|
|
47
|
+
.unordered-list {
|
|
48
|
+
list-style: none;
|
|
49
|
+
padding-left: 0;
|
|
50
|
+
margin-left: -1px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@media (min-width: 640px) {
|
|
54
|
+
.unordered-list {
|
|
55
|
+
margin-left: 9px;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.listMarker {
|
|
60
|
+
background-color: transparent;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.listMarker.has-content {
|
|
64
|
+
border-radius: 9999px;
|
|
65
|
+
background-color: rgb(107 114 128); /* Default gray color */
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.listMarker.has-content.themed {
|
|
69
|
+
background-color: var(--theme-accent);
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import UnorderedListBlock from './UnorderedListBlock.svelte';
|
|
2
|
+
declare const UnorderedListBlock: import("svelte").Component<{
|
|
3
|
+
block: {
|
|
4
|
+
children: ListItem[];
|
|
5
|
+
};
|
|
6
|
+
hasTheme?: boolean;
|
|
7
|
+
}, {}, "">;
|
|
8
|
+
type UnorderedListBlock = ReturnType<typeof UnorderedListBlock>;
|
|
9
|
+
export default UnorderedListBlock;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
function blobUrl(pds: string, did: string, cid: string): string {
|
|
3
|
+
return `${pds}/xrpc/com.atproto.sync.getBlob?did=${encodeURIComponent(did)}&cid=${encodeURIComponent(cid)}`;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
interface BlobRef {
|
|
7
|
+
$type?: 'blob';
|
|
8
|
+
ref?: { $link: string };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
block: {
|
|
13
|
+
/** Canonical field name per pub.leaflet.blocks.website lexicon */
|
|
14
|
+
src: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
previewImage?: BlobRef;
|
|
18
|
+
};
|
|
19
|
+
did?: string;
|
|
20
|
+
pds?: string;
|
|
21
|
+
hasTheme?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { block, did = '', pds = '', hasTheme = false }: Props = $props();
|
|
25
|
+
|
|
26
|
+
const previewCid = $derived(block.previewImage?.ref?.$link ?? '');
|
|
27
|
+
const previewSrc = $derived(
|
|
28
|
+
previewCid && did && pds ? blobUrl(pds, did, previewCid) : ''
|
|
29
|
+
);
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div
|
|
33
|
+
class="group/linkBlock relative my-2 flex h-[104px] overflow-hidden rounded-md border bg-white transition-colors dark:bg-gray-900"
|
|
34
|
+
style:border-color={hasTheme ? 'var(--theme-accent)' : undefined}
|
|
35
|
+
class:border-gray-200={!hasTheme}
|
|
36
|
+
class:hover:border-gray-300={!hasTheme}
|
|
37
|
+
class:dark:border-gray-700={!hasTheme}
|
|
38
|
+
class:dark:hover:border-gray-600={!hasTheme}
|
|
39
|
+
>
|
|
40
|
+
<a
|
|
41
|
+
href={block.src}
|
|
42
|
+
target="_blank"
|
|
43
|
+
rel="noopener noreferrer"
|
|
44
|
+
class="flex h-full w-full text-inherit no-underline hover:no-underline"
|
|
45
|
+
>
|
|
46
|
+
<div class="min-w-0 grow px-3 pt-2 pb-2">
|
|
47
|
+
<div class="flex h-full w-full min-w-0 flex-col">
|
|
48
|
+
{#if block.title}
|
|
49
|
+
<div
|
|
50
|
+
class="mb-0.5 line-clamp-1 text-base font-bold"
|
|
51
|
+
style="overflow: hidden; text-overflow: ellipsis; word-break: break-all;"
|
|
52
|
+
>
|
|
53
|
+
{block.title}
|
|
54
|
+
</div>
|
|
55
|
+
{/if}
|
|
56
|
+
|
|
57
|
+
{#if block.description}
|
|
58
|
+
<div class="line-clamp-2 grow text-sm text-gray-600 dark:text-gray-400">
|
|
59
|
+
{block.description}
|
|
60
|
+
</div>
|
|
61
|
+
{/if}
|
|
62
|
+
|
|
63
|
+
<div
|
|
64
|
+
class="line-clamp-1 w-full min-w-0 text-xs italic text-gray-500 group-hover/linkBlock:text-blue-600 dark:text-gray-500 dark:group-hover/linkBlock:text-blue-400"
|
|
65
|
+
style="word-break: break-word;"
|
|
66
|
+
style:color={hasTheme ? 'var(--theme-accent)' : undefined}
|
|
67
|
+
>
|
|
68
|
+
{block.src}
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
{#if previewSrc}
|
|
74
|
+
<div
|
|
75
|
+
class="m-2 -mb-2 w-[120px] shrink-0 origin-center rotate-[4deg] rounded-t-md border border-gray-200 bg-cover dark:border-gray-700"
|
|
76
|
+
style:background-image="url({previewSrc})"
|
|
77
|
+
style:background-position="center"
|
|
78
|
+
></div>
|
|
79
|
+
{/if}
|
|
80
|
+
</a>
|
|
81
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface BlobRef {
|
|
2
|
+
$type?: 'blob';
|
|
3
|
+
ref?: {
|
|
4
|
+
$link: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
interface Props {
|
|
8
|
+
block: {
|
|
9
|
+
/** Canonical field name per pub.leaflet.blocks.website lexicon */
|
|
10
|
+
src: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
previewImage?: BlobRef;
|
|
14
|
+
};
|
|
15
|
+
did?: string;
|
|
16
|
+
pds?: string;
|
|
17
|
+
hasTheme?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const WebsiteBlock: import("svelte").Component<Props, {}, "">;
|
|
20
|
+
type WebsiteBlock = ReturnType<typeof WebsiteBlock>;
|
|
21
|
+
export default WebsiteBlock;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default as DocumentCard } from './DocumentCard.svelte';
|
|
2
|
+
export { default as PublicationCard } from './PublicationCard.svelte';
|
|
3
|
+
export { default as ThemeToggle } from './ThemeToggle.svelte';
|
|
4
|
+
export { default as StandardSiteLayout } from './StandardSiteLayout.svelte';
|
|
5
|
+
export { default as DateDisplay } from './common/DateDisplay.svelte';
|
|
6
|
+
export { default as TagList } from './common/TagList.svelte';
|
|
7
|
+
export { default as ThemedContainer } from './common/ThemedContainer.svelte';
|
|
8
|
+
export { default as ThemedText } from './common/ThemedText.svelte';
|
|
9
|
+
export { default as ThemedCard } from './common/ThemedCard.svelte';
|
|
10
|
+
export { default as DocumentRenderer } from './document/DocumentRenderer.svelte';
|
|
11
|
+
export { default as MarkdownRenderer } from './document/MarkdownRenderer.svelte';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as DocumentCard } from './DocumentCard.svelte';
|
|
2
|
+
export { default as PublicationCard } from './PublicationCard.svelte';
|
|
3
|
+
export { default as ThemeToggle } from './ThemeToggle.svelte';
|
|
4
|
+
export { default as StandardSiteLayout } from './StandardSiteLayout.svelte';
|
|
5
|
+
// Common reusable components
|
|
6
|
+
export { default as DateDisplay } from './common/DateDisplay.svelte';
|
|
7
|
+
export { default as TagList } from './common/TagList.svelte';
|
|
8
|
+
export { default as ThemedContainer } from './common/ThemedContainer.svelte';
|
|
9
|
+
export { default as ThemedText } from './common/ThemedText.svelte';
|
|
10
|
+
export { default as ThemedCard } from './common/ThemedCard.svelte';
|
|
11
|
+
// Document rendering
|
|
12
|
+
export { default as DocumentRenderer } from './document/DocumentRenderer.svelte';
|
|
13
|
+
export { default as MarkdownRenderer } from './document/MarkdownRenderer.svelte';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SiteStandardConfig } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get configuration from environment variables
|
|
4
|
+
* @returns Configuration object or null if required vars are missing
|
|
5
|
+
*/
|
|
6
|
+
export declare function getConfigFromEnv(): SiteStandardConfig | null;
|
|
7
|
+
/**
|
|
8
|
+
* Validate that required environment variables are set
|
|
9
|
+
* @throws Error if required variables are missing
|
|
10
|
+
*/
|
|
11
|
+
export declare function validateEnv(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { env } from '$env/dynamic/public';
|
|
2
|
+
/**
|
|
3
|
+
* Get configuration from environment variables
|
|
4
|
+
* @returns Configuration object or null if required vars are missing
|
|
5
|
+
*/
|
|
6
|
+
export function getConfigFromEnv() {
|
|
7
|
+
const did = env.PUBLIC_ATPROTO_DID;
|
|
8
|
+
if (!did) {
|
|
9
|
+
console.error('Missing required environment variable: PUBLIC_ATPROTO_DID');
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
did,
|
|
14
|
+
pds: env.PUBLIC_ATPROTO_PDS || undefined,
|
|
15
|
+
cacheTTL: env.PUBLIC_CACHE_TTL ? parseInt(env.PUBLIC_CACHE_TTL) : undefined
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate that required environment variables are set
|
|
20
|
+
* @throws Error if required variables are missing
|
|
21
|
+
*/
|
|
22
|
+
export function validateEnv() {
|
|
23
|
+
if (!env.PUBLIC_ATPROTO_DID) {
|
|
24
|
+
throw new Error('Missing required environment variable: PUBLIC_ATPROTO_DID');
|
|
25
|
+
}
|
|
26
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { SiteStandardClient, createClient } from './client.js';
|
|
2
|
+
export { StandardSitePublisher } from './publisher.js';
|
|
3
|
+
export { DocumentCard, PublicationCard, ThemeToggle, StandardSiteLayout, DateDisplay, TagList, ThemedContainer, ThemedText, ThemedCard, DocumentRenderer, MarkdownRenderer } from './components/index.js';
|
|
4
|
+
export { default as Comments } from './components/Comments.svelte';
|
|
5
|
+
export { themeStore } from './stores/index.js';
|
|
6
|
+
export type { AtProtoBlob, StrongRef, RGBColor, BasicTheme, PublicationPreferences, Publication, Document, AtProtoRecord, ResolvedIdentity, SiteStandardConfig } from './types.js';
|
|
7
|
+
export type { PublisherConfig, ReaderConfig, LoaderConfig } from './schemas.js';
|
|
8
|
+
export { COLLECTIONS } from './schemas.js';
|
|
9
|
+
export { parseAtUri, atUriToHttps, buildAtUri, extractRkey, isAtUri } from './utils/at-uri.js';
|
|
10
|
+
export { resolveIdentity, buildPdsBlobUrl } from './utils/agents.js';
|
|
11
|
+
export { cache } from './utils/cache.js';
|
|
12
|
+
export { rgbToCSS, rgbToHex, getThemeVars } from './utils/theme.js';
|
|
13
|
+
export { mixThemeColor, getThemedTextColor, getThemedBackground, getThemedBorder, getThemedAccent, themeToCssVars } from './utils/theme-helpers.js';
|
|
14
|
+
export { getDocumentSlug, getDocumentUrl, extractRkey as extractRkeyFromUri } from './utils/document.js';
|
|
15
|
+
export { transformContent, convertSidenotes, convertComplexSidenotes, resolveRelativeLinks, stripToPlainText, countWords, calculateReadingTime } from './utils/content.js';
|
|
16
|
+
export type { TransformOptions, TransformResult } from './utils/content.js';
|
|
17
|
+
export { fetchComments, fetchMentionComments, formatRelativeTime } from './utils/comments.js';
|
|
18
|
+
export type { Comment, CommentAuthor, FetchCommentsOptions } from './utils/comments.js';
|
|
19
|
+
export { generatePublicationWellKnown, generateDocumentLinkTag, generatePublicationLinkTag, getDocumentAtUri, getPublicationAtUri, verifyPublicationWellKnown, extractDocumentLinkFromHtml, extractPublicationLinkFromHtml } from './utils/verification.js';
|
|
20
|
+
export type { PublishDocumentInput, PublishPublicationInput, PublishResult } from './publisher.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Main exports
|
|
2
|
+
export { SiteStandardClient, createClient } from './client.js';
|
|
3
|
+
export { StandardSitePublisher } from './publisher.js';
|
|
4
|
+
// Component exports
|
|
5
|
+
export { DocumentCard, PublicationCard, ThemeToggle, StandardSiteLayout, DateDisplay, TagList, ThemedContainer, ThemedText, ThemedCard, DocumentRenderer, MarkdownRenderer } from './components/index.js';
|
|
6
|
+
// Comments component
|
|
7
|
+
export { default as Comments } from './components/Comments.svelte';
|
|
8
|
+
// Store exports
|
|
9
|
+
export { themeStore } from './stores/index.js';
|
|
10
|
+
export { COLLECTIONS } from './schemas.js';
|
|
11
|
+
// Utility exports
|
|
12
|
+
export { parseAtUri, atUriToHttps, buildAtUri, extractRkey, isAtUri } from './utils/at-uri.js';
|
|
13
|
+
export { resolveIdentity, buildPdsBlobUrl } from './utils/agents.js';
|
|
14
|
+
export { cache } from './utils/cache.js';
|
|
15
|
+
export { rgbToCSS, rgbToHex, getThemeVars } from './utils/theme.js';
|
|
16
|
+
export { mixThemeColor, getThemedTextColor, getThemedBackground, getThemedBorder, getThemedAccent, themeToCssVars } from './utils/theme-helpers.js';
|
|
17
|
+
export { getDocumentSlug, getDocumentUrl, extractRkey as extractRkeyFromUri } from './utils/document.js';
|
|
18
|
+
// Content transformation exports
|
|
19
|
+
export { transformContent, convertSidenotes, convertComplexSidenotes, resolveRelativeLinks, stripToPlainText, countWords, calculateReadingTime } from './utils/content.js';
|
|
20
|
+
// Comments exports
|
|
21
|
+
export { fetchComments, fetchMentionComments, formatRelativeTime } from './utils/comments.js';
|
|
22
|
+
// Verification exports
|
|
23
|
+
export { generatePublicationWellKnown, generateDocumentLinkTag, generatePublicationLinkTag, getDocumentAtUri, getPublicationAtUri, verifyPublicationWellKnown, extractDocumentLinkFromHtml, extractPublicationLinkFromHtml } from './utils/verification.js';
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publisher for standard.site documents
|
|
3
|
+
*
|
|
4
|
+
* Publishes documents to ATProto repositories using the standard.site lexicon,
|
|
5
|
+
* enabling your SvelteKit site to sync content to Leaflet, WhiteWind, or any
|
|
6
|
+
* compatible platform.
|
|
7
|
+
*
|
|
8
|
+
* The publisher automatically resolves the correct PDS from your DID document,
|
|
9
|
+
* so it works with any PDS (bsky.app, Blacksky, self-hosted, etc.).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { StandardSitePublisher } from 'svelte-standard-site/publisher';
|
|
14
|
+
*
|
|
15
|
+
* const publisher = new StandardSitePublisher({
|
|
16
|
+
* identifier: 'your-handle.bsky.social',
|
|
17
|
+
* password: process.env.ATPROTO_APP_PASSWORD!,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* await publisher.login();
|
|
21
|
+
*
|
|
22
|
+
* await publisher.publishDocument({
|
|
23
|
+
* site: 'https://myblog.com',
|
|
24
|
+
* title: 'My Blog Post',
|
|
25
|
+
* publishedAt: new Date().toISOString(),
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { AtpAgent } from '@atproto/api';
|
|
30
|
+
import type { PublisherConfig, Document, Publication } from './schemas.js';
|
|
31
|
+
export interface PublishDocumentInput {
|
|
32
|
+
/** Site/publication URI (https or at-uri) - REQUIRED */
|
|
33
|
+
site: string;
|
|
34
|
+
/** Document title - REQUIRED */
|
|
35
|
+
title: string;
|
|
36
|
+
/** When the document was published (ISO 8601) - REQUIRED */
|
|
37
|
+
publishedAt: string;
|
|
38
|
+
/** Path to combine with site URL */
|
|
39
|
+
path?: string;
|
|
40
|
+
/** Document description/excerpt */
|
|
41
|
+
description?: string;
|
|
42
|
+
/** When the document was last updated (ISO 8601) */
|
|
43
|
+
updatedAt?: string;
|
|
44
|
+
/** Tags/categories */
|
|
45
|
+
tags?: string[];
|
|
46
|
+
/** Plain text content for indexing */
|
|
47
|
+
textContent?: string;
|
|
48
|
+
/** Platform-specific content */
|
|
49
|
+
content?: unknown;
|
|
50
|
+
/** Reference to associated Bluesky post */
|
|
51
|
+
bskyPostRef?: {
|
|
52
|
+
uri: string;
|
|
53
|
+
cid: string;
|
|
54
|
+
};
|
|
55
|
+
/** Cover image blob */
|
|
56
|
+
coverImage?: {
|
|
57
|
+
$type: 'blob';
|
|
58
|
+
ref: {
|
|
59
|
+
$link: string;
|
|
60
|
+
};
|
|
61
|
+
mimeType: string;
|
|
62
|
+
size: number;
|
|
63
|
+
};
|
|
64
|
+
/** Document-level preferences (overrides publication defaults) */
|
|
65
|
+
preferences?: {
|
|
66
|
+
showInDiscover?: boolean;
|
|
67
|
+
showComments?: boolean;
|
|
68
|
+
showMentions?: boolean;
|
|
69
|
+
showPrevNext?: boolean;
|
|
70
|
+
showRecommends?: boolean;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export interface PublishPublicationInput {
|
|
74
|
+
/** Publication name */
|
|
75
|
+
name: string;
|
|
76
|
+
/** Base URL */
|
|
77
|
+
url: string;
|
|
78
|
+
/** Description */
|
|
79
|
+
description?: string;
|
|
80
|
+
/** Icon blob */
|
|
81
|
+
icon?: {
|
|
82
|
+
$type: 'blob';
|
|
83
|
+
ref: {
|
|
84
|
+
$link: string;
|
|
85
|
+
};
|
|
86
|
+
mimeType: string;
|
|
87
|
+
size: number;
|
|
88
|
+
};
|
|
89
|
+
/** Basic theme colors */
|
|
90
|
+
basicTheme?: {
|
|
91
|
+
background: {
|
|
92
|
+
r: number;
|
|
93
|
+
g: number;
|
|
94
|
+
b: number;
|
|
95
|
+
};
|
|
96
|
+
foreground: {
|
|
97
|
+
r: number;
|
|
98
|
+
g: number;
|
|
99
|
+
b: number;
|
|
100
|
+
};
|
|
101
|
+
accent: {
|
|
102
|
+
r: number;
|
|
103
|
+
g: number;
|
|
104
|
+
b: number;
|
|
105
|
+
};
|
|
106
|
+
accentForeground: {
|
|
107
|
+
r: number;
|
|
108
|
+
g: number;
|
|
109
|
+
b: number;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
/** Publication preferences */
|
|
113
|
+
preferences?: {
|
|
114
|
+
showInDiscover?: boolean;
|
|
115
|
+
showComments?: boolean;
|
|
116
|
+
showMentions?: boolean;
|
|
117
|
+
showPrevNext?: boolean;
|
|
118
|
+
showRecommends?: boolean;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export interface PublishResult {
|
|
122
|
+
uri: string;
|
|
123
|
+
cid: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Publisher for standard.site documents on ATProto
|
|
127
|
+
*/
|
|
128
|
+
export declare class StandardSitePublisher {
|
|
129
|
+
private agent;
|
|
130
|
+
private config;
|
|
131
|
+
private did;
|
|
132
|
+
private pdsUrl;
|
|
133
|
+
constructor(config: Partial<PublisherConfig>);
|
|
134
|
+
/**
|
|
135
|
+
* Authenticate with the PDS
|
|
136
|
+
* Automatically resolves the correct PDS from the DID document
|
|
137
|
+
*/
|
|
138
|
+
login(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Get the authenticated DID
|
|
141
|
+
*/
|
|
142
|
+
getDid(): string;
|
|
143
|
+
/**
|
|
144
|
+
* Get the PDS URL being used
|
|
145
|
+
*/
|
|
146
|
+
getPdsUrl(): string;
|
|
147
|
+
private getAgent;
|
|
148
|
+
/**
|
|
149
|
+
* Publish a document record
|
|
150
|
+
*/
|
|
151
|
+
publishDocument(input: PublishDocumentInput): Promise<PublishResult>;
|
|
152
|
+
/**
|
|
153
|
+
* Update an existing document
|
|
154
|
+
*/
|
|
155
|
+
updateDocument(rkey: string, input: PublishDocumentInput): Promise<PublishResult>;
|
|
156
|
+
/**
|
|
157
|
+
* Delete a document
|
|
158
|
+
*/
|
|
159
|
+
deleteDocument(rkey: string): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Publish a publication record
|
|
162
|
+
*/
|
|
163
|
+
publishPublication(input: PublishPublicationInput): Promise<PublishResult>;
|
|
164
|
+
/**
|
|
165
|
+
* Update an existing publication
|
|
166
|
+
*/
|
|
167
|
+
updatePublication(rkey: string, input: PublishPublicationInput): Promise<PublishResult>;
|
|
168
|
+
/**
|
|
169
|
+
* Delete a publication
|
|
170
|
+
*/
|
|
171
|
+
deletePublication(rkey: string): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Get all documents for the current account
|
|
174
|
+
*/
|
|
175
|
+
listDocuments(limit?: number): Promise<Array<{
|
|
176
|
+
uri: string;
|
|
177
|
+
cid: string;
|
|
178
|
+
value: Document;
|
|
179
|
+
}>>;
|
|
180
|
+
/**
|
|
181
|
+
* Get all publications for the current account
|
|
182
|
+
*/
|
|
183
|
+
listPublications(limit?: number): Promise<Array<{
|
|
184
|
+
uri: string;
|
|
185
|
+
cid: string;
|
|
186
|
+
value: Publication;
|
|
187
|
+
}>>;
|
|
188
|
+
/**
|
|
189
|
+
* Get the underlying ATP agent for advanced operations
|
|
190
|
+
*/
|
|
191
|
+
getAtpAgent(): AtpAgent;
|
|
192
|
+
}
|
|
193
|
+
export type { PublisherConfig };
|