@standard-reader/renderer-react 0.1.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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +304 -0
  3. package/dist/components/context.d.ts +7 -0
  4. package/dist/components/context.d.ts.map +1 -0
  5. package/dist/components/context.js +18 -0
  6. package/dist/components/context.js.map +1 -0
  7. package/dist/components/defaults.d.ts +9 -0
  8. package/dist/components/defaults.d.ts.map +1 -0
  9. package/dist/components/defaults.js +71 -0
  10. package/dist/components/defaults.js.map +1 -0
  11. package/dist/components/merge.d.ts +9 -0
  12. package/dist/components/merge.d.ts.map +1 -0
  13. package/dist/components/merge.js +18 -0
  14. package/dist/components/merge.js.map +1 -0
  15. package/dist/components/types.d.ts +258 -0
  16. package/dist/components/types.d.ts.map +1 -0
  17. package/dist/components/types.js +2 -0
  18. package/dist/components/types.js.map +1 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +5 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/render/blocks.d.ts +5 -0
  24. package/dist/render/blocks.d.ts.map +1 -0
  25. package/dist/render/blocks.js +114 -0
  26. package/dist/render/blocks.js.map +1 -0
  27. package/dist/render/document.d.ts +18 -0
  28. package/dist/render/document.d.ts.map +1 -0
  29. package/dist/render/document.js +21 -0
  30. package/dist/render/document.js.map +1 -0
  31. package/dist/render/faceted-text.d.ts +14 -0
  32. package/dist/render/faceted-text.d.ts.map +1 -0
  33. package/dist/render/faceted-text.js +63 -0
  34. package/dist/render/faceted-text.js.map +1 -0
  35. package/dist/types.d.ts +10 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +2 -0
  38. package/dist/types.js.map +1 -0
  39. package/package.json +54 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andrew Lisowski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,304 @@
1
+ # @standard-reader/renderer-react
2
+
3
+ A **headless, unstyled** React renderer for [Standard Site](https://standard.site) documents.
4
+
5
+ You give it a Standard Site document; it parses the content — Leaflet, pckt,
6
+ Offprint, and every third-party block format Standard Reader understands — into a
7
+ normalized block stream and renders each block with **your** components. It ships
8
+ no styles, no CSS, and no design system. The default components are the barest
9
+ semantic HTML, and every one of them is overridable.
10
+
11
+ This is the same renderer that powers the Standard Reader app, factored out so
12
+ you can drop richly-formatted cross-platform posts into your own UI.
13
+
14
+ > Built on [`@standard-reader/renderer-core`](../renderer-core), the
15
+ > framework-agnostic parser + render tree.
16
+
17
+ - **One prop for the document.** Pass the content payload; the format is detected
18
+ from its `$type`.
19
+ - **One prop for the components.** Override any block or inline mark. Components
20
+ come in two categories — **shared** (the common block/inline vocabulary) and
21
+ **platform** (blocks unique to one publishing platform).
22
+ - **Bring your own everything** — styling, links, image loading, mentions,
23
+ interactive embeds.
24
+
25
+ ## Install
26
+
27
+ ```sh
28
+ npm install @standard-reader/renderer-react
29
+ # peers:
30
+ npm install react react-dom
31
+ # to fetch documents to render (optional):
32
+ npm install @standard-reader/lexicons @atproto/lex-client
33
+ ```
34
+
35
+ ## Quick start
36
+
37
+ Fetch a document with the typed Standard Reader API client
38
+ ([`@standard-reader/lexicons`](https://www.npmjs.com/package/@standard-reader/lexicons) and [`@atproto/lex-client`](https://www.npmjs.com/package/@atproto/lex-client)) — a
39
+ single `getDocument` call returns the card metadata **and** the renderable body:
40
+
41
+ ```ts
42
+ import { Client } from "@atproto/lex-client";
43
+ import {
44
+ standardReader,
45
+ STANDARD_READER_SERVICE,
46
+ } from "@standard-reader/lexicons";
47
+
48
+ const client = new Client(STANDARD_READER_SERVICE);
49
+
50
+ const doc = await client.call(standardReader.getDocument, {
51
+ document: "at://did:plc:…/site.standard.document/…",
52
+ });
53
+ ```
54
+
55
+ `doc` lines up field-for-field with the renderer's `document` prop:
56
+
57
+ ```tsx
58
+ import { StandardDocumentRenderer } from "@standard-reader/renderer-react";
59
+
60
+ <StandardDocumentRenderer
61
+ document={{
62
+ content: doc.content, // the content-union payload (has a `$type`)
63
+ contentFormat: doc.contentFormat,
64
+ authorDid: doc.did, // repo that hosts image blobs
65
+ description: doc.description,
66
+ }}
67
+ />;
68
+ ```
69
+
70
+ With no `components` prop, the document renders as unstyled semantic HTML
71
+ (`<p>`, `<h2>`, `<figure><img>`, `<pre><code>`, `<ul>`, …). Data-backed platform
72
+ embeds (polls, galleries, note embeds, Offprint components) render nothing until
73
+ you supply components for them.
74
+
75
+ ## The `document` prop
76
+
77
+ ```ts
78
+ interface StandardSiteDocument {
79
+ /** The content-union payload — the `contentJson` of a document record. */
80
+ content: unknown;
81
+ /** Explicit format `$type`, used only when `content.$type` is absent. */
82
+ contentFormat?: string | null;
83
+ /** DID of the repo hosting image blobs (required for blob-backed images). */
84
+ authorDid?: string;
85
+ /** Header description; a leading heading matching it is dropped as a dupe. */
86
+ description?: string | null;
87
+ }
88
+ ```
89
+
90
+ Supported content formats:
91
+
92
+ | Family | `$type` | Vocabulary |
93
+ | ------------------ | --------------------------------------------- | ----------------- |
94
+ | Leaflet | `pub.leaflet.content`, `pub.leaflet.document` | Leaflet blocks |
95
+ | pckt | `blog.pckt.content` | pckt blocks |
96
+ | Offprint | `app.offprint.content` | shared structured |
97
+ | BlockNote | `org.blocknote.document#content` | shared structured |
98
+ | Fables | `ca.justexe.fables.blocks` | shared structured |
99
+ | OXA | `pub.oxa.document.document` | shared structured |
100
+ | WSS rich-text | `com.wss.content.rich-text` | shared structured |
101
+ | item-block formats | (several) | shared structured |
102
+
103
+ ## The `components` prop
104
+
105
+ `components` is a partial map; anything you omit falls back to the unstyled
106
+ default. It has four groups:
107
+
108
+ ```tsx
109
+ <StandardDocumentRenderer
110
+ document={doc}
111
+ components={{
112
+ shared: {/* block + inline components shared across every format */},
113
+ leaflet: {
114
+ /* Leaflet-only blocks: Poll, Signup, Separator, StandardSitePost,
115
+ StandardSitePublication, PageEmbed */
116
+ },
117
+ pckt: {/* pckt-only blocks: Gallery, NoteEmbed */},
118
+ offprint: {/* Offprint-only blocks: Component */},
119
+ }}
120
+ />
121
+ ```
122
+
123
+ ### Shared components
124
+
125
+ Override these once and they apply to Leaflet, pckt, Offprint and every
126
+ third-party format.
127
+
128
+ **Blocks:** `Root`, `Paragraph`, `Heading`, `Blockquote`, `Callout`,
129
+ `HorizontalRule`, `BulletList`, `OrderedList`, `ListItem`, `TaskList`,
130
+ `TaskListItem`, `Code`, `Image`, `Iframe`, `Website`, `Table`, `Math`,
131
+ `Button`, `BlueskyEmbed`, `ImageGrid`, `ImageCarousel`, `ImageDiff`,
132
+ `Footnotes`, `FootnoteItem`, `Unknown`.
133
+
134
+ **Inline (facets):** `FacetText`, `Strong`, `Emphasis`, `InlineCode`,
135
+ `Underline`, `Strikethrough`, `Highlight`, `Link`, `Mention`,
136
+ `FootnoteReference`.
137
+
138
+ ```tsx
139
+ import { StandardDocumentRenderer } from "@standard-reader/renderer-react";
140
+ import styles from "./article.module.css";
141
+
142
+ <StandardDocumentRenderer
143
+ document={doc}
144
+ components={{
145
+ shared: {
146
+ Root: ({ children }) => <div className={styles.prose}>{children}</div>,
147
+ Paragraph: ({ children, dropCap }) => (
148
+ <p className={dropCap ? styles.dropCap : styles.p}>{children}</p>
149
+ ),
150
+ Heading: ({ level, children }) => {
151
+ const Tag = `h${level}` as const;
152
+ return <Tag className={styles.heading}>{children}</Tag>;
153
+ },
154
+ Link: ({ href, children }) => (
155
+ <a className={styles.link} href={href}>
156
+ {children}
157
+ </a>
158
+ ),
159
+ },
160
+ }}
161
+ />;
162
+ ```
163
+
164
+ ### Platform components
165
+
166
+ These render blocks unique to one platform — usually interactive or data-backed
167
+ embeds the headless defaults can't fetch. Supply your own to make them live:
168
+
169
+ ```tsx
170
+ <StandardDocumentRenderer
171
+ document={doc}
172
+ components={{
173
+ leaflet: {
174
+ Poll: ({ pollUri }) => <LivePoll uri={pollUri} />,
175
+ StandardSitePublication: ({ uri }) => <PublicationCard uri={uri} />,
176
+ },
177
+ pckt: {
178
+ Gallery: ({ ref }) => <PcktGallery recordUri={ref} />,
179
+ NoteEmbed: ({ uri }) => <NoteCard uri={uri} />,
180
+ },
181
+ offprint: {
182
+ Component: ({ componentUri }) => <OffprintComponent uri={componentUri} />,
183
+ },
184
+ }}
185
+ />
186
+ ```
187
+
188
+ > **Resolving the data these components need.** The platform components — and
189
+ > the inline `Mention` / `Link` components — hand you AT-URIs and DIDs
190
+ > (`pollUri`, `ref`, `componentUri`, `uri`, `did`, …) that you resolve to
191
+ > records and identities yourself. A hosted AT Protocol data service like
192
+ > [**microcosm**](https://www.microcosm.blue/) works great for many of them, so
193
+ > you don't have to stand up your own AppView:
194
+ >
195
+ > - [**Slingshot**](https://slingshot.microcosm.blue/) — an edge record +
196
+ > identity cache. Resolve a record by AT-URI (the poll, gallery blob, note
197
+ > post, Offprint component, embedded publication/document) or resolve a
198
+ > handle/DID (`identity.resolveMiniDoc`) to build `Mention` chips and smart
199
+ > `Link`s.
200
+ > - [**Constellation**](https://constellation.microcosm.blue/) — a network-wide
201
+ > backlink index, handy for the interaction data these embeds show (poll
202
+ > tallies, who-embedded-this, reply counts).
203
+ >
204
+ > Both are free and hosted, and pair naturally with a data-fetching layer
205
+ > (TanStack Query, SWR, or your framework's own data layer) inside your platform
206
+ > components.
207
+
208
+ ### Customizing inline formatting
209
+
210
+ Inline marks are shared components too. Override a single mark to restyle it, or
211
+ inject app behavior — e.g. resolve `@`-mentions to profile chips, or route links
212
+ through your client-side router:
213
+
214
+ ```tsx
215
+ components={{
216
+ shared: {
217
+ Mention: ({ did, atUri, children }) => (
218
+ <MentionChip did={did} atUri={atUri}>{children}</MentionChip>
219
+ ),
220
+ Link: ({ href, children }) => <SmartLink href={href}>{children}</SmartLink>,
221
+ },
222
+ }}
223
+ ```
224
+
225
+ To take **full** control of inline rendering, override `FacetText` — it receives
226
+ the raw `{ plaintext, facets }` and you render however you like. Otherwise the
227
+ default `FacetText` segments the text and composes the individual mark
228
+ components above.
229
+
230
+ ## Options
231
+
232
+ ```ts
233
+ interface RendererOptions {
234
+ /** Drop cap on the first paragraph (passed as `dropCap` to `Paragraph`). */
235
+ dropCap?: boolean;
236
+ /** Drop a leading image block (e.g. when a hero is shown above the body). */
237
+ skipLeadingImage?: boolean;
238
+ /** Override how blob refs become image URLs. */
239
+ resolveImageUrl?: ImageUrlResolver;
240
+ }
241
+ ```
242
+
243
+ ### Images
244
+
245
+ By default, blob-backed images resolve to a Bluesky CDN URL built from the blob
246
+ CID and `authorDid` (the CDN serves any PDS blob by `(did, cid)`); absolute
247
+ `https` sources pass through. Override `resolveImageUrl` to route through your
248
+ own image proxy:
249
+
250
+ ```tsx
251
+ <StandardDocumentRenderer
252
+ document={doc}
253
+ options={{
254
+ resolveImageUrl: ({ blob, externalSrc, authorDid }) =>
255
+ externalSrc ?? myCdn(authorDid, blob),
256
+ }}
257
+ />
258
+ ```
259
+
260
+ The resolved URL is passed to your `shared.Image` component as `src`.
261
+
262
+ ## Parsing without rendering
263
+
264
+ The pure parsers, the render tree, and the block-vocabulary types are not in
265
+ this package — they live in the framework-agnostic core. Install
266
+ [`@standard-reader/renderer-core`](../renderer-core) directly when you want to
267
+ pre-process a document, index it, or build your own renderer:
268
+
269
+ ```ts
270
+ import {
271
+ buildRenderTree,
272
+ segmentInline,
273
+ leafletBlocks,
274
+ pcktBlocks,
275
+ offprintBlocks,
276
+ structuredFormatBlocks,
277
+ type LeafletRenderableBlock,
278
+ type StructuredRenderableBlock,
279
+ } from "@standard-reader/renderer-core";
280
+
281
+ const blocks = leafletBlocks(content); // Array<LeafletRenderableBlock>
282
+ ```
283
+
284
+ ## TypeScript
285
+
286
+ Every component contract is exported, so custom components are fully typed:
287
+
288
+ ```ts
289
+ import type {
290
+ RendererComponentsInput,
291
+ ImageProps,
292
+ MentionProps,
293
+ } from "@standard-reader/renderer-react";
294
+
295
+ const components: RendererComponentsInput = {
296
+ shared: {
297
+ Image: (props: ImageProps) => <MyImage {...props} />,
298
+ },
299
+ };
300
+ ```
301
+
302
+ ## License
303
+
304
+ MIT
@@ -0,0 +1,7 @@
1
+ import type { RendererComponents } from "./types";
2
+ export declare const ComponentsProvider: import("react").Provider<RendererComponents | null>;
3
+ export declare const FootnoteNumbersProvider: import("react").Provider<ReadonlyMap<string, number>>;
4
+ export declare function useComponents(): RendererComponents;
5
+ /** The footnote numbering map for the current document. */
6
+ export declare function useFootnoteNumbers(): ReadonlyMap<string, number>;
7
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/components/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AASlD,eAAO,MAAM,kBAAkB,qDAA6B,CAAC;AAC7D,eAAO,MAAM,uBAAuB,uDAAkC,CAAC;AAEvE,wBAAgB,aAAa,IAAI,kBAAkB,CAQlD;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAEhE"}
@@ -0,0 +1,18 @@
1
+ import { createContext, useContext } from "react";
2
+ const ComponentsContext = createContext(null);
3
+ /** `footnoteId` → 1-based display number, for inline footnote references. */
4
+ const FootnoteNumbersContext = createContext(new Map());
5
+ export const ComponentsProvider = ComponentsContext.Provider;
6
+ export const FootnoteNumbersProvider = FootnoteNumbersContext.Provider;
7
+ export function useComponents() {
8
+ const value = useContext(ComponentsContext);
9
+ if (!value) {
10
+ throw new Error("Standard Reader renderer components are unavailable. Render inside <StandardDocumentRenderer>.");
11
+ }
12
+ return value;
13
+ }
14
+ /** The footnote numbering map for the current document. */
15
+ export function useFootnoteNumbers() {
16
+ return useContext(FootnoteNumbersContext);
17
+ }
18
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/components/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIlD,MAAM,iBAAiB,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAC;AAEzE,6EAA6E;AAC7E,MAAM,sBAAsB,GAAG,aAAa,CAC1C,IAAI,GAAG,EAAE,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,QAAQ,CAAC;AAC7D,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAC,QAAQ,CAAC;AAEvE,MAAM,UAAU,aAAa;IAC3B,MAAM,KAAK,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAC5C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,kBAAkB;IAChC,OAAO,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RendererComponents } from "./types";
2
+ /**
3
+ * The default, unstyled component registry: semantic HTML with no class names,
4
+ * inline styles, or theming. Data-backed platform embeds render nothing by
5
+ * default — supply platform components to make them live. Everything here is
6
+ * overridable through the `components` prop.
7
+ */
8
+ export declare const defaultComponents: RendererComponents;
9
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/components/defaults.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAsM/B,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createElement } from "react";
3
+ import { DefaultFacetText } from "../render/faceted-text";
4
+ /**
5
+ * The default, unstyled component registry: semantic HTML with no class names,
6
+ * inline styles, or theming. Data-backed platform embeds render nothing by
7
+ * default — supply platform components to make them live. Everything here is
8
+ * overridable through the `components` prop.
9
+ */
10
+ export const defaultComponents = {
11
+ shared: {
12
+ // Inline
13
+ FacetText: DefaultFacetText,
14
+ Strong: ({ children }) => _jsx("strong", { children: children }),
15
+ Emphasis: ({ children }) => _jsx("em", { children: children }),
16
+ InlineCode: ({ children }) => _jsx("code", { children: children }),
17
+ Underline: ({ children }) => _jsx("u", { children: children }),
18
+ Strikethrough: ({ children }) => _jsx("s", { children: children }),
19
+ Highlight: ({ children }) => _jsx("mark", { children: children }),
20
+ Link: ({ href, children }) => (_jsx("a", { href: href, rel: "noopener noreferrer nofollow", children: children })),
21
+ // Mentions need resolution the headless package can't do; show the text.
22
+ Mention: ({ children }) => _jsx(_Fragment, { children: children }),
23
+ FootnoteReference: ({ footnoteId, number, contentPlaintext }) => number == null ? null : (_jsx("sup", { children: _jsx("a", { id: `fnref-${footnoteId}`, href: `#fn-${footnoteId}`, title: contentPlaintext || undefined, "aria-label": `Footnote ${number}`, children: number }) })),
24
+ // Blocks
25
+ Root: ({ children }) => _jsx("div", { dir: "auto", children: children }),
26
+ Paragraph: ({ children, dropCap }) => (_jsx("p", { "data-drop-cap": dropCap || undefined, children: children })),
27
+ Heading: ({ level, children }) => createElement(`h${Math.min(6, Math.max(1, level))}`, null, children),
28
+ Blockquote: ({ children }) => _jsx("blockquote", { children: children }),
29
+ Callout: ({ emoji, children }) => (_jsxs("aside", { role: "note", children: [emoji ? _jsxs("span", { "aria-hidden": "true", children: [emoji, " "] }) : null, children] })),
30
+ HorizontalRule: () => _jsx("hr", {}),
31
+ BulletList: ({ children }) => _jsx("ul", { children: children }),
32
+ OrderedList: ({ start, children }) => _jsx("ol", { start: start, children: children }),
33
+ ListItem: ({ children }) => _jsx("li", { children: children }),
34
+ TaskList: ({ children }) => _jsx("ul", { role: "list", children: children }),
35
+ TaskListItem: ({ checked, children }) => (_jsxs("li", { children: [_jsx("input", { type: "checkbox", checked: checked ?? false, readOnly: true, disabled: true }), " ", children] })),
36
+ Code: ({ code, language }) => (_jsx("pre", { children: _jsx("code", { className: language ? `language-${language}` : undefined, children: code }) })),
37
+ Image: ({ src, alt, caption }) => (_jsxs("figure", { children: [_jsx("img", { src: src, alt: alt, referrerPolicy: "no-referrer", loading: "lazy" }), caption ? _jsx("figcaption", { children: caption }) : null] })),
38
+ Iframe: ({ url, height }) => (_jsx("iframe", { src: url, height: height, loading: "lazy", sandbox: "allow-scripts allow-same-origin allow-popups allow-forms", title: "Embedded content" })),
39
+ Website: ({ src, title, description }) => (_jsxs("a", { href: src, rel: "noopener noreferrer nofollow", children: [_jsx("span", { children: title || src }), description ? _jsx("span", { children: description }) : null] })),
40
+ Table: ({ rows }) => (_jsx("table", { children: _jsx("tbody", { children: rows.map((row, rowIndex) => (_jsx("tr", { children: row.map((cell, cellIndex) => cell.header ? (_jsx("th", { scope: "col", children: cell.children }, cellIndex)) : (_jsx("td", { children: cell.children }, cellIndex))) }, rowIndex))) }) })),
41
+ // Headless default renders the raw TeX; plug in KaTeX/MathML for display.
42
+ Math: ({ tex }) => _jsx("code", { "data-tex": "", children: tex }),
43
+ Button: ({ text, href, caption }) => (_jsxs("span", { children: [_jsx("a", { href: href, rel: "noopener noreferrer nofollow", children: text }), caption ? _jsx("small", { children: caption }) : null] })),
44
+ BlueskyEmbed: ({ postUri }) => (_jsx("a", { "data-bluesky-embed": postUri, href: postUri, children: postUri })),
45
+ ImageGrid: ({ images, caption }) => (_jsxs("figure", { children: [images.map((image, index) => (_jsx("img", { src: image.src, alt: image.alt, referrerPolicy: "no-referrer", loading: "lazy" }, index))), caption ? _jsx("figcaption", { children: caption }) : null] })),
46
+ ImageCarousel: ({ images, caption }) => (_jsxs("figure", { children: [images.map((image, index) => (_jsx("img", { src: image.src, alt: image.alt, referrerPolicy: "no-referrer", loading: "lazy" }, index))), caption ? _jsx("figcaption", { children: caption }) : null] })),
47
+ ImageDiff: ({ before, after, caption, labels }) => (_jsxs("figure", { children: [_jsx("img", { src: before.src, alt: before.alt || labels?.[0] || "", referrerPolicy: "no-referrer", loading: "lazy" }), _jsx("img", { src: after.src, alt: after.alt || labels?.[1] || "", referrerPolicy: "no-referrer", loading: "lazy" }), caption ? _jsx("figcaption", { children: caption }) : null] })),
48
+ Footnotes: ({ children }) => (_jsxs("section", { "aria-label": "Footnotes", children: [_jsx("hr", {}), _jsx("ol", { children: children })] })),
49
+ FootnoteItem: ({ id, children }) => (_jsxs("li", { id: `fn-${id}`, children: [children, " ", _jsx("a", { href: `#fnref-${id}`, "aria-label": "Back to content", children: "\u21A9" })] })),
50
+ Unknown: () => null,
51
+ },
52
+ // Platform-specific blocks are typically interactive/data-backed. The
53
+ // headless defaults render nothing (except structural ones); supply your own
54
+ // to make them live.
55
+ leaflet: {
56
+ Poll: () => null,
57
+ Signup: () => null,
58
+ Separator: () => _jsx("hr", {}),
59
+ StandardSitePost: () => null,
60
+ StandardSitePublication: () => null,
61
+ PageEmbed: ({ children }) => _jsx("div", { "data-page-embed": "", children: children }),
62
+ },
63
+ pckt: {
64
+ Gallery: () => null,
65
+ NoteEmbed: () => null,
66
+ },
67
+ offprint: {
68
+ Component: () => null,
69
+ },
70
+ };
71
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/components/defaults.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAuB;IACnD,MAAM,EAAE;QACN,SAAS;QACT,SAAS,EAAE,gBAAgB;QAC3B,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,2BAAS,QAAQ,GAAU;QACrD,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,uBAAK,QAAQ,GAAM;QAC/C,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,yBAAO,QAAQ,GAAQ;QACrD,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,sBAAI,QAAQ,GAAK;QAC9C,aAAa,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,sBAAI,QAAQ,GAAK;QAClD,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,yBAAO,QAAQ,GAAQ;QACpD,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC5B,YAAG,IAAI,EAAE,IAAI,EAAE,GAAG,EAAC,8BAA8B,YAC9C,QAAQ,GACP,CACL;QACD,yEAAyE;QACzE,OAAO,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,EAAC,MAAM,GACd,EACD,OAAO,CAAC,CAAC,CAAC,+BAAa,OAAO,GAAc,CAAC,CAAC,CAAC,IAAI,IAC7C,CACV;QACD,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAC3B,iCAAoB,WAAW,aAC7B,cAAM,EACN,uBAAK,QAAQ,GAAM,IACX,CACX;QACD,YAAY,EAAE,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAClC,cAAI,EAAE,EAAE,MAAM,EAAE,EAAE,aACf,QAAQ,EAAE,GAAG,EACd,YAAG,IAAI,EAAE,UAAU,EAAE,EAAE,gBAAa,iBAAiB,uBAEjD,IACD,CACN;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;KACpB;IAED,sEAAsE;IACtE,6EAA6E;IAC7E,qBAAqB;IACrB,OAAO,EAAE;QACP,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI;QAChB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI;QAClB,SAAS,EAAE,GAAG,EAAE,CAAC,cAAM;QACvB,gBAAgB,EAAE,GAAG,EAAE,CAAC,IAAI;QAC5B,uBAAuB,EAAE,GAAG,EAAE,CAAC,IAAI;QACnC,SAAS,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,iCAAqB,EAAE,YAAE,QAAQ,GAAO;KACtE;IACD,IAAI,EAAE;QACJ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI;QACnB,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;KACtB;IACD,QAAQ,EAAE;QACR,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;KACtB;CACF,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RendererComponents, RendererComponentsInput } from "./types";
2
+ /**
3
+ * Merge a user's partial `components` prop over the unstyled defaults. The merge
4
+ * is shallow within each category (`shared`, `leaflet`, `pckt`, `offprint`) —
5
+ * every component is an atomic override, so a supplied `shared.Image` replaces
6
+ * only the image renderer and leaves the rest as defaults.
7
+ */
8
+ export declare function mergeComponents(input?: RendererComponentsInput): RendererComponents;
9
+ //# sourceMappingURL=merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/components/merge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAE3E;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,CAAC,EAAE,uBAAuB,GAC9B,kBAAkB,CAQpB"}
@@ -0,0 +1,18 @@
1
+ import { defaultComponents } from "./defaults";
2
+ /**
3
+ * Merge a user's partial `components` prop over the unstyled defaults. The merge
4
+ * is shallow within each category (`shared`, `leaflet`, `pckt`, `offprint`) —
5
+ * every component is an atomic override, so a supplied `shared.Image` replaces
6
+ * only the image renderer and leaves the rest as defaults.
7
+ */
8
+ export function mergeComponents(input) {
9
+ if (!input)
10
+ return defaultComponents;
11
+ return {
12
+ shared: { ...defaultComponents.shared, ...input.shared },
13
+ leaflet: { ...defaultComponents.leaflet, ...input.leaflet },
14
+ pckt: { ...defaultComponents.pckt, ...input.pckt },
15
+ offprint: { ...defaultComponents.offprint, ...input.offprint },
16
+ };
17
+ }
18
+ //# sourceMappingURL=merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/components/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,KAA+B;IAE/B,IAAI,CAAC,KAAK;QAAE,OAAO,iBAAiB,CAAC;IACrC,OAAO;QACL,MAAM,EAAE,EAAE,GAAG,iBAAiB,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE;QACxD,OAAO,EAAE,EAAE,GAAG,iBAAiB,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE;QAC3D,IAAI,EAAE,EAAE,GAAG,iBAAiB,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE;QAClD,QAAQ,EAAE,EAAE,GAAG,iBAAiB,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE;KAC/D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,258 @@
1
+ import type { ComponentType, ReactNode } from "react";
2
+ import type { AspectRatio, TableRow } from "../types";
3
+ /**
4
+ * Components come in two categories:
5
+ *
6
+ * - **Shared** components render the block and inline vocabulary that every
7
+ * content format has in common (paragraphs, headings, images, code, lists,
8
+ * inline marks, …). Override these once and they apply across Leaflet, pckt,
9
+ * Offprint and every third-party format.
10
+ * - **Platform** components render the blocks unique to a single publishing
11
+ * platform (a Leaflet poll, a pckt gallery, an Offprint component, …). These
12
+ * are the interactive, often data-backed embeds; the headless defaults render
13
+ * inert placeholders, so supply your own to make them live.
14
+ */
15
+ export interface MentionProps {
16
+ /** AT-URI target of an `atMention` (e.g. a publication or document record). */
17
+ atUri?: string;
18
+ /** DID target of a `didMention`. */
19
+ did?: string;
20
+ /** The mention's display text. */
21
+ children: ReactNode;
22
+ }
23
+ export interface FacetLinkProps {
24
+ href: string;
25
+ children: ReactNode;
26
+ }
27
+ export interface FootnoteReferenceProps {
28
+ /** Stable id shared by the inline reference and the endnote entry. */
29
+ footnoteId: string;
30
+ /** 1-based display number, or `null` when the note has no registered entry. */
31
+ number: number | null;
32
+ /** The footnote body as plaintext, for a hover preview. */
33
+ contentPlaintext?: string;
34
+ }
35
+ export interface MarkProps {
36
+ children: ReactNode;
37
+ }
38
+ export interface FacetTextProps {
39
+ plaintext: string;
40
+ /** Raw AT-Proto facets (byte-indexed), in any supported format's dialect. */
41
+ facets?: Array<unknown>;
42
+ }
43
+ /** The inline components applied to spans of rich text. */
44
+ export interface InlineComponents {
45
+ /** Top-level renderer for a run of faceted plaintext. Override this to take
46
+ * full control of inline formatting; otherwise it composes the marks below. */
47
+ FacetText: ComponentType<FacetTextProps>;
48
+ Strong: ComponentType<MarkProps>;
49
+ Emphasis: ComponentType<MarkProps>;
50
+ InlineCode: ComponentType<MarkProps>;
51
+ Underline: ComponentType<MarkProps>;
52
+ Strikethrough: ComponentType<MarkProps>;
53
+ Highlight: ComponentType<MarkProps>;
54
+ Link: ComponentType<FacetLinkProps>;
55
+ Mention: ComponentType<MentionProps>;
56
+ FootnoteReference: ComponentType<FootnoteReferenceProps>;
57
+ }
58
+ export interface RootProps {
59
+ children: ReactNode;
60
+ }
61
+ export interface ParagraphProps {
62
+ children: ReactNode;
63
+ /** True for the body's first paragraph when drop caps are enabled. */
64
+ dropCap?: boolean;
65
+ }
66
+ export interface HeadingProps {
67
+ /** 1–6. */
68
+ level: number;
69
+ children: ReactNode;
70
+ }
71
+ export interface BlockquoteProps {
72
+ /** One rendered paragraph per quoted line. */
73
+ children: ReactNode;
74
+ }
75
+ export interface CalloutProps {
76
+ emoji?: string;
77
+ color?: string;
78
+ children: ReactNode;
79
+ }
80
+ export interface ListProps {
81
+ children: ReactNode;
82
+ }
83
+ export interface OrderedListProps {
84
+ start?: number;
85
+ children: ReactNode;
86
+ }
87
+ export interface ListItemProps {
88
+ children: ReactNode;
89
+ }
90
+ export interface TaskListItemProps {
91
+ checked?: boolean;
92
+ children: ReactNode;
93
+ }
94
+ export interface CodeProps {
95
+ code: string;
96
+ language?: string;
97
+ }
98
+ export interface ImageProps {
99
+ src: string;
100
+ alt: string;
101
+ aspectRatio?: AspectRatio;
102
+ /** Leaflet full-bleed images request edge-to-edge layout. */
103
+ fullBleed?: boolean;
104
+ /** Optional caption (defaults to the alt text where the platform uses it). */
105
+ caption?: string;
106
+ }
107
+ export interface IframeProps {
108
+ url: string;
109
+ height?: number;
110
+ aspectRatio?: {
111
+ width?: number;
112
+ height?: number;
113
+ };
114
+ }
115
+ export interface WebsiteProps {
116
+ src: string;
117
+ title?: string;
118
+ description?: string;
119
+ previewImage?: string;
120
+ }
121
+ export interface TableProps {
122
+ rows: Array<TableRow>;
123
+ }
124
+ export interface MathProps {
125
+ tex: string;
126
+ }
127
+ export interface ButtonProps {
128
+ text: string;
129
+ href: string;
130
+ caption?: string;
131
+ alignment?: string;
132
+ }
133
+ export interface BlueskyEmbedProps {
134
+ postUri: string;
135
+ }
136
+ export interface ImageCollectionImage {
137
+ src: string;
138
+ alt: string;
139
+ aspectRatio?: AspectRatio;
140
+ }
141
+ export interface ImageCollectionProps {
142
+ images: Array<ImageCollectionImage>;
143
+ caption?: string;
144
+ /** "grid" | "carousel" — the layout the source requested. */
145
+ layout?: string;
146
+ }
147
+ export interface ImageDiffProps {
148
+ before: ImageCollectionImage;
149
+ after: ImageCollectionImage;
150
+ caption?: string;
151
+ labels?: [string?, string?];
152
+ }
153
+ export interface FootnotesProps {
154
+ children: ReactNode;
155
+ }
156
+ export interface FootnoteItemProps {
157
+ id: string;
158
+ number: number;
159
+ children: ReactNode;
160
+ }
161
+ export interface UnknownBlockProps {
162
+ blockType: string;
163
+ }
164
+ /** The block components shared by every content format. */
165
+ export interface SharedBlockComponents {
166
+ /** Wraps the whole rendered body. */
167
+ Root: ComponentType<RootProps>;
168
+ Paragraph: ComponentType<ParagraphProps>;
169
+ Heading: ComponentType<HeadingProps>;
170
+ Blockquote: ComponentType<BlockquoteProps>;
171
+ Callout: ComponentType<CalloutProps>;
172
+ HorizontalRule: ComponentType<Record<string, never>>;
173
+ BulletList: ComponentType<ListProps>;
174
+ OrderedList: ComponentType<OrderedListProps>;
175
+ ListItem: ComponentType<ListItemProps>;
176
+ TaskList: ComponentType<ListProps>;
177
+ TaskListItem: ComponentType<TaskListItemProps>;
178
+ Code: ComponentType<CodeProps>;
179
+ Image: ComponentType<ImageProps>;
180
+ Iframe: ComponentType<IframeProps>;
181
+ Website: ComponentType<WebsiteProps>;
182
+ Table: ComponentType<TableProps>;
183
+ Math: ComponentType<MathProps>;
184
+ Button: ComponentType<ButtonProps>;
185
+ BlueskyEmbed: ComponentType<BlueskyEmbedProps>;
186
+ ImageGrid: ComponentType<ImageCollectionProps>;
187
+ ImageCarousel: ComponentType<ImageCollectionProps>;
188
+ ImageDiff: ComponentType<ImageDiffProps>;
189
+ Footnotes: ComponentType<FootnotesProps>;
190
+ FootnoteItem: ComponentType<FootnoteItemProps>;
191
+ Unknown: ComponentType<UnknownBlockProps>;
192
+ }
193
+ export type SharedComponents = SharedBlockComponents & InlineComponents;
194
+ export interface LeafletPollProps {
195
+ /** AT-URI of the poll record. */
196
+ pollUri: string;
197
+ }
198
+ export interface LeafletStandardSitePostProps {
199
+ /** AT-URI of the embedded `site.standard.document`. */
200
+ uri: string;
201
+ }
202
+ export interface LeafletStandardSitePublicationProps {
203
+ /** AT-URI of the embedded `site.standard.publication`. */
204
+ uri: string;
205
+ cid?: string;
206
+ showPublicationTheme?: boolean;
207
+ }
208
+ export interface LeafletPageEmbedProps {
209
+ pageId: string;
210
+ pageType?: string;
211
+ /** The embedded page's rendered blocks. */
212
+ children: ReactNode;
213
+ }
214
+ export interface LeafletComponents {
215
+ Poll: ComponentType<LeafletPollProps>;
216
+ Signup: ComponentType<Record<string, never>>;
217
+ Separator: ComponentType<Record<string, never>>;
218
+ StandardSitePost: ComponentType<LeafletStandardSitePostProps>;
219
+ StandardSitePublication: ComponentType<LeafletStandardSitePublicationProps>;
220
+ PageEmbed: ComponentType<LeafletPageEmbedProps>;
221
+ }
222
+ export interface PcktGalleryProps {
223
+ /** AT-URI of the gallery blob record. */
224
+ ref: string;
225
+ }
226
+ export interface PcktNoteEmbedProps {
227
+ /** AT-URI of the embedded `blog.pckt.mini.post`. */
228
+ uri?: string;
229
+ cid?: string;
230
+ }
231
+ export interface PcktComponents {
232
+ Gallery: ComponentType<PcktGalleryProps>;
233
+ NoteEmbed: ComponentType<PcktNoteEmbedProps>;
234
+ }
235
+ export interface OffprintComponentProps {
236
+ /** AT-URI of the `app.offprint.component` record to resolve on read. */
237
+ componentUri: string;
238
+ }
239
+ export interface OffprintComponents {
240
+ Component: ComponentType<OffprintComponentProps>;
241
+ }
242
+ /** The fully-resolved component registry used internally after merging. */
243
+ export interface RendererComponents {
244
+ shared: SharedComponents;
245
+ leaflet: LeafletComponents;
246
+ pckt: PcktComponents;
247
+ offprint: OffprintComponents;
248
+ }
249
+ type DeepPartial<T> = {
250
+ [K in keyof T]?: T[K] extends object ? Partial<T[K]> : T[K];
251
+ };
252
+ /**
253
+ * The `components` prop shape: override any subset of components; everything
254
+ * else falls back to the unstyled defaults.
255
+ */
256
+ export type RendererComponentsInput = DeepPartial<RendererComponents>;
257
+ export {};
258
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEtD;;;;;;;;;;;GAWG;AAMH,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7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AM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC5D,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export { StandardDocumentRenderer, type StandardDocumentRendererProps, } from "./render/document";
2
+ export { defaultComponents } from "./components/defaults";
3
+ export { mergeComponents } from "./components/merge";
4
+ export type { TableCell, TableRow } from "./types";
5
+ export type { RendererComponents, RendererComponentsInput, SharedComponents, SharedBlockComponents, InlineComponents, LeafletComponents, PcktComponents, OffprintComponents, FacetTextProps, MarkProps, FacetLinkProps, MentionProps, FootnoteReferenceProps, RootProps, ParagraphProps, HeadingProps, BlockquoteProps, CalloutProps, ListProps, OrderedListProps, ListItemProps, TaskListItemProps, CodeProps, ImageProps, IframeProps, WebsiteProps, TableProps, MathProps, ButtonProps, BlueskyEmbedProps, ImageCollectionProps, ImageCollectionImage, ImageDiffProps, FootnotesProps, FootnoteItemProps, UnknownBlockProps, LeafletPollProps, LeafletStandardSitePostProps, LeafletStandardSitePublicationProps, LeafletPageEmbedProps, PcktGalleryProps, PcktNoteEmbedProps, OffprintComponentProps, } from "./components/types";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,KAAK,6BAA6B,GACnC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnD,YAAY,EACV,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAElB,cAAc,EACd,SAAS,EACT,cAAc,EACd,YAAY,EACZ,sBAAsB,EAEtB,SAAS,EACT,cAAc,EACd,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EAEjB,gBAAgB,EAChB,4BAA4B,EAC5B,mCAAmC,EACnC,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Public entry point for @standard-reader/renderer-react.
2
+ export { StandardDocumentRenderer, } from "./render/document";
3
+ export { defaultComponents } from "./components/defaults";
4
+ export { mergeComponents } from "./components/merge";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,OAAO,EACL,wBAAwB,GAEzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { BlockNode } from "@standard-reader/renderer-core";
2
+ export declare function BlockList({ nodes }: {
3
+ nodes: Array<BlockNode>;
4
+ }): import("react").JSX.Element;
5
+ //# sourceMappingURL=blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/render/blocks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAIV,MAAM,gCAAgC,CAAC;AAKxC,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;CAAE,+BAQ/D"}
@@ -0,0 +1,114 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useComponents } from "../components/context";
3
+ export function BlockList({ nodes }) {
4
+ return (_jsx(_Fragment, { children: nodes.map((node, index) => (_jsx(RenderBlock, { node: node }, index))) }));
5
+ }
6
+ function Runs({ runs }) {
7
+ const { shared } = useComponents();
8
+ return (_jsx(_Fragment, { children: runs.map((run, index) => (_jsx(shared.FacetText, { plaintext: run.plaintext, facets: run.facets }, index))) }));
9
+ }
10
+ function ListItemView({ item }) {
11
+ const { shared } = useComponents();
12
+ return (_jsxs(shared.ListItem, { children: [_jsx(Runs, { runs: item.runs }), item.children.map((child, index) => (_jsx(RenderBlock, { node: child }, `child-${index}`)))] }));
13
+ }
14
+ function TaskItemView({ item }) {
15
+ const { shared } = useComponents();
16
+ return (_jsx(shared.TaskListItem, { checked: item.checked, children: _jsx(Runs, { runs: item.runs }) }));
17
+ }
18
+ function RenderBlock({ node }) {
19
+ const { shared, leaflet, pckt, offprint } = useComponents();
20
+ switch (node.type) {
21
+ case "paragraph": {
22
+ return (_jsx(shared.Paragraph, { dropCap: node.dropCap, children: _jsx(shared.FacetText, { plaintext: node.text.plaintext, facets: node.text.facets }) }));
23
+ }
24
+ case "heading": {
25
+ return (_jsx(shared.Heading, { level: node.level, children: _jsx(shared.FacetText, { plaintext: node.text.plaintext, facets: node.text.facets }) }));
26
+ }
27
+ case "blockquote": {
28
+ return (_jsx(shared.Blockquote, { children: node.paragraphs.map((text, index) => (_jsx(shared.Paragraph, { children: _jsx(shared.FacetText, { plaintext: text.plaintext, facets: text.facets }) }, index))) }));
29
+ }
30
+ case "callout": {
31
+ return (_jsx(shared.Callout, { emoji: node.emoji, color: node.color, children: _jsx(shared.FacetText, { plaintext: node.text.plaintext, facets: node.text.facets }) }));
32
+ }
33
+ case "horizontalRule": {
34
+ return _jsx(shared.HorizontalRule, {});
35
+ }
36
+ case "bulletList": {
37
+ return (_jsx(shared.BulletList, { children: node.items.map((item, index) => (_jsx(ListItemView, { item: item }, index))) }));
38
+ }
39
+ case "orderedList": {
40
+ return (_jsx(shared.OrderedList, { start: node.start, children: node.items.map((item, index) => (_jsx(ListItemView, { item: item }, index))) }));
41
+ }
42
+ case "taskList": {
43
+ return (_jsx(shared.TaskList, { children: node.items.map((item, index) => (_jsx(TaskItemView, { item: item }, index))) }));
44
+ }
45
+ case "code": {
46
+ return _jsx(shared.Code, { code: node.code, language: node.language });
47
+ }
48
+ case "image": {
49
+ return (_jsx(shared.Image, { src: node.src, alt: node.alt, aspectRatio: node.aspectRatio, fullBleed: node.fullBleed, caption: node.caption }));
50
+ }
51
+ case "iframe": {
52
+ return (_jsx(shared.Iframe, { url: node.url, height: node.height, aspectRatio: node.aspectRatio }));
53
+ }
54
+ case "website": {
55
+ return (_jsx(shared.Website, { src: node.src, title: node.title, description: node.description, previewImage: node.previewImage }));
56
+ }
57
+ case "table": {
58
+ const rows = node.rows.map((row) => row.map((cell) => ({
59
+ header: cell.header,
60
+ children: (_jsx(shared.FacetText, { plaintext: cell.text.plaintext, facets: cell.text.facets })),
61
+ })));
62
+ return _jsx(shared.Table, { rows: rows });
63
+ }
64
+ case "math": {
65
+ return _jsx(shared.Math, { tex: node.tex });
66
+ }
67
+ case "button": {
68
+ return (_jsx(shared.Button, { text: node.text, href: node.href, caption: node.caption, alignment: node.alignment }));
69
+ }
70
+ case "blueskyEmbed": {
71
+ return _jsx(shared.BlueskyEmbed, { postUri: node.postUri });
72
+ }
73
+ case "imageGrid": {
74
+ return (_jsx(shared.ImageGrid, { images: node.images, caption: node.caption, layout: node.layout }));
75
+ }
76
+ case "imageCarousel": {
77
+ return (_jsx(shared.ImageCarousel, { images: node.images, caption: node.caption, layout: node.layout }));
78
+ }
79
+ case "imageDiff": {
80
+ return (_jsx(shared.ImageDiff, { before: node.before, after: node.after, caption: node.caption, labels: node.labels }));
81
+ }
82
+ case "unknown": {
83
+ return _jsx(shared.Unknown, { blockType: node.blockType });
84
+ }
85
+ case "leaflet.poll": {
86
+ return _jsx(leaflet.Poll, { pollUri: node.pollUri });
87
+ }
88
+ case "leaflet.signup": {
89
+ return _jsx(leaflet.Signup, {});
90
+ }
91
+ case "leaflet.separator": {
92
+ return _jsx(leaflet.Separator, {});
93
+ }
94
+ case "leaflet.standardSitePost": {
95
+ return _jsx(leaflet.StandardSitePost, { uri: node.uri });
96
+ }
97
+ case "leaflet.standardSitePublication": {
98
+ return (_jsx(leaflet.StandardSitePublication, { uri: node.uri, cid: node.cid, showPublicationTheme: node.showPublicationTheme }));
99
+ }
100
+ case "leaflet.pageEmbed": {
101
+ return (_jsx(leaflet.PageEmbed, { pageId: node.pageId, pageType: node.pageType, children: _jsx(BlockList, { nodes: node.children }) }));
102
+ }
103
+ case "pckt.gallery": {
104
+ return _jsx(pckt.Gallery, { ref: node.ref });
105
+ }
106
+ case "pckt.noteEmbed": {
107
+ return _jsx(pckt.NoteEmbed, { uri: node.uri, cid: node.cid });
108
+ }
109
+ case "offprint.component": {
110
+ return _jsx(offprint.Component, { componentUri: node.componentUri });
111
+ }
112
+ }
113
+ }
114
+ //# sourceMappingURL=blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/render/blocks.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGtD,MAAM,UAAU,SAAS,CAAC,EAAE,KAAK,EAA+B;IAC9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CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,GAAI,CAAC;QAC1D,CAAC;QACD,KAAK,oBAAoB,CAAC,CAAC,CAAC;YAC1B,OAAO,KAAC,QAAQ,CAAC,SAAS,IAAC,YAAY,EAAE,IAAI,CAAC,YAAY,GAAI,CAAC;QACjE,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { RendererOptions, StandardSiteDocument } from "@standard-reader/renderer-core";
2
+ import type { RendererComponentsInput } from "../components/types";
3
+ export interface StandardDocumentRendererProps {
4
+ /** The Standard Site document to render. */
5
+ document: StandardSiteDocument;
6
+ /** Component overrides. Anything omitted uses the unstyled defaults. */
7
+ components?: RendererComponentsInput;
8
+ /** Rendering options (drop cap, leading-image handling, image URLs). */
9
+ options?: RendererOptions;
10
+ }
11
+ /**
12
+ * Headless renderer for a Standard Site document. Parsing and normalization are
13
+ * done by `@standard-reader/renderer-core`; this component walks the resulting
14
+ * render tree and maps each node to a React component from `components` (falling
15
+ * back to unstyled semantic-HTML defaults).
16
+ */
17
+ export declare function StandardDocumentRenderer({ document: doc, components, options, }: StandardDocumentRendererProps): import("react").JSX.Element | null;
18
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/render/document.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,gCAAgC,CAAC;AAQxC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAGnE,MAAM,WAAW,6BAA6B;IAC5C,4CAA4C;IAC5C,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,wEAAwE;IACxE,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,wEAAwE;IACxE,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EAAE,GAAG,EACb,UAAU,EACV,OAAO,GACR,EAAE,6BAA6B,sCAiC/B"}
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { buildRenderTree } from "@standard-reader/renderer-core";
3
+ import { useMemo } from "react";
4
+ import { ComponentsProvider, FootnoteNumbersProvider, } from "../components/context";
5
+ import { mergeComponents } from "../components/merge";
6
+ import { BlockList } from "./blocks";
7
+ /**
8
+ * Headless renderer for a Standard Site document. Parsing and normalization are
9
+ * done by `@standard-reader/renderer-core`; this component walks the resulting
10
+ * render tree and maps each node to a React component from `components` (falling
11
+ * back to unstyled semantic-HTML defaults).
12
+ */
13
+ export function StandardDocumentRenderer({ document: doc, components, options, }) {
14
+ const merged = useMemo(() => mergeComponents(components), [components]);
15
+ const tree = useMemo(() => buildRenderTree(doc, options), [doc, options]);
16
+ if (!tree)
17
+ return null;
18
+ const { Root, Footnotes, FootnoteItem, FacetText } = merged.shared;
19
+ return (_jsx(ComponentsProvider, { value: merged, children: _jsx(FootnoteNumbersProvider, { value: tree.footnoteNumbers, children: _jsxs(Root, { children: [_jsx(BlockList, { nodes: tree.children }), tree.footnotes.length > 0 ? (_jsx(Footnotes, { children: tree.footnotes.map((footnote) => (_jsx(FootnoteItem, { id: footnote.id, number: footnote.number, children: _jsx(FacetText, { plaintext: footnote.text.plaintext, facets: footnote.text.facets }) }, footnote.id))) })) : null] }) }) }));
20
+ }
21
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/render/document.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAKjE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,O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 -0,0 +1,14 @@
1
+ import type { InlineNode } from "@standard-reader/renderer-core";
2
+ import type { FacetTextProps } from "../components/types";
3
+ /**
4
+ * The default inline renderer: turn a run of faceted plaintext into the core's
5
+ * {@link InlineNode} tree and compose the shared inline mark components over it.
6
+ * Overriding `shared.FacetText` replaces this entirely; overriding an individual
7
+ * mark (e.g. `shared.Link` or `shared.Mention`) customizes one decoration while
8
+ * keeping this composition.
9
+ */
10
+ export declare function DefaultFacetText({ plaintext, facets }: FacetTextProps): import("react").JSX.Element;
11
+ export declare function InlineNodes({ nodes }: {
12
+ nodes: Array<InlineNode>;
13
+ }): import("react").JSX.Element;
14
+ //# sourceMappingURL=faceted-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faceted-text.d.ts","sourceRoot":"","sources":["../../src/render/faceted-text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,gCAAgC,CAAC;AAI3E,OAAO,KAAK,EAAE,cAAc,EAAa,MAAM,qBAAqB,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,cAAc,+BAIrE;AAED,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;CAAE,+BAUlE"}
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { segmentInline } from "@standard-reader/renderer-core";
3
+ import { Fragment } from "react";
4
+ import { useComponents, useFootnoteNumbers } from "../components/context";
5
+ /**
6
+ * The default inline renderer: turn a run of faceted plaintext into the core's
7
+ * {@link InlineNode} tree and compose the shared inline mark components over it.
8
+ * Overriding `shared.FacetText` replaces this entirely; overriding an individual
9
+ * mark (e.g. `shared.Link` or `shared.Mention`) customizes one decoration while
10
+ * keeping this composition.
11
+ */
12
+ export function DefaultFacetText({ plaintext, facets }) {
13
+ const footnoteNumbers = useFootnoteNumbers();
14
+ const nodes = segmentInline({ plaintext, facets }, footnoteNumbers);
15
+ return _jsx(InlineNodes, { nodes: nodes });
16
+ }
17
+ export function InlineNodes({ nodes }) {
18
+ return (_jsx(_Fragment, { children: nodes.map((node, index) => (_jsx(Fragment, { children: _jsx(RenderInline, { node: node }) }, index))) }));
19
+ }
20
+ function RenderInline({ node }) {
21
+ const { shared } = useComponents();
22
+ switch (node.type) {
23
+ case "text": {
24
+ return _jsx(_Fragment, { children: node.value });
25
+ }
26
+ case "mark": {
27
+ const Mark = markComponent(shared, node.mark);
28
+ return (_jsx(Mark, { children: _jsx(InlineNodes, { nodes: node.children }) }));
29
+ }
30
+ case "link": {
31
+ return (_jsx(shared.Link, { href: node.href, children: _jsx(InlineNodes, { nodes: node.children }) }));
32
+ }
33
+ case "mention": {
34
+ return (_jsx(shared.Mention, { atUri: node.atUri, did: node.did, children: _jsx(InlineNodes, { nodes: node.children }) }));
35
+ }
36
+ case "footnoteRef": {
37
+ return (_jsx(shared.FootnoteReference, { footnoteId: node.footnoteId, number: node.number, contentPlaintext: node.contentPlaintext }));
38
+ }
39
+ }
40
+ }
41
+ function markComponent(shared, mark) {
42
+ switch (mark) {
43
+ case "strong": {
44
+ return shared.Strong;
45
+ }
46
+ case "emphasis": {
47
+ return shared.Emphasis;
48
+ }
49
+ case "code": {
50
+ return shared.InlineCode;
51
+ }
52
+ case "underline": {
53
+ return shared.Underline;
54
+ }
55
+ case "strikethrough": {
56
+ return shared.Strikethrough;
57
+ }
58
+ case "highlight": {
59
+ return shared.Highlight;
60
+ }
61
+ }
62
+ }
63
+ //# sourceMappingURL=faceted-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faceted-text.js","sourceRoot":"","sources":["../../src/render/faceted-text.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE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E,IAAI,CAAC,QAAQ,GAAI,GACzB,CACf,CAAC;QACJ,CAAC;QACD,KAAK,SAAS,CAAC,CAAC,CAAC;YACf,OAAO,CACL,KAAC,MAAM,CAAC,OAAO,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,YAC9C,KAAC,WAAW,IAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,GAAI,GACtB,CAClB,CAAC;QACJ,CAAC;QACD,KAAK,aAAa,CAAC,CAAC,CAAC;YACnB,OAAO,CACL,KAAC,MAAM,CAAC,iBAAiB,IACvB,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,GACvC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CACpB,MAAkD,EAClD,IAAc;IAEd,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QACD,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,OAAO,MAAM,CAAC,QAAQ,CAAC;QACzB,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,OAAO,MAAM,CAAC,UAAU,CAAC;QAC3B,CAAC;QACD,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,OAAO,MAAM,CAAC,SAAS,CAAC;QAC1B,CAAC;QACD,KAAK,eAAe,CAAC,CAAC,CAAC;YACrB,OAAO,MAAM,CAAC,aAAa,CAAC;QAC9B,CAAC;QACD,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,OAAO,MAAM,CAAC,SAAS,CAAC;QAC1B,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from "react";
2
+ export type { StandardSiteDocument, RendererOptions, ImageUrlResolver, AspectRatio, } from "@standard-reader/renderer-core";
3
+ /** A single cell in a rendered table (children are already-rendered content). */
4
+ export interface TableCell {
5
+ header: boolean;
6
+ children: ReactNode;
7
+ }
8
+ /** A rendered table row. */
9
+ export type TableRow = Array<TableCell>;
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,WAAW,GACZ,MAAM,gCAAgC,CAAC;AAExC,iFAAiF;AACjF,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,4BAA4B;AAC5B,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@standard-reader/renderer-react",
3
+ "version": "0.1.0",
4
+ "description": "Headless, unstyled React renderer for Standard Site documents. Bring your own components.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "main": "./dist/index.js",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ }
20
+ },
21
+ "keywords": [
22
+ "standard-reader",
23
+ "atproto",
24
+ "leaflet",
25
+ "renderer",
26
+ "headless",
27
+ "react"
28
+ ],
29
+ "peerDependencies": {
30
+ "react": ">=18",
31
+ "react-dom": ">=18"
32
+ },
33
+ "dependencies": {
34
+ "@standard-reader/renderer-core": "0.1.0"
35
+ },
36
+ "devDependencies": {
37
+ "@testing-library/jest-dom": "^6.6.3",
38
+ "@testing-library/react": "^16.3.0",
39
+ "@types/react": "^19.2.0",
40
+ "@types/react-dom": "^19.2.0",
41
+ "jsdom": "^28.1.0",
42
+ "react": "19.3.0-canary-ad78e251-20260616",
43
+ "react-dom": "19.3.0-canary-ad78e251-20260616",
44
+ "typescript": "^6.0.2",
45
+ "vitest": "^4.1.5"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.build.json",
49
+ "clean": "rm -rf dist",
50
+ "typecheck": "tsc -p tsconfig.json --noEmit",
51
+ "test": "vitest run",
52
+ "test:watch": "vitest"
53
+ }
54
+ }