a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto
bluesky
typescript
npm
1# @atcute/leaflet
2
3[Leaflet](https://leaflet.pub/) (pub.leaflet.\*) schema definitions
4
5```sh
6npm install @atcute/leaflet
7```
8
9## usage
10
11```ts
12import { PubLeafletDocument } from '@atcute/leaflet';
13import { is } from '@atcute/lexicons';
14
15const document: PubLeafletDocument.Main = {
16 $type: 'pub.leaflet.document',
17 title: 'Article title',
18 author: 'did:plc:ia76kvnndjutgedggx2ibrem',
19 description: 'Article description',
20 publication: 'at://did:plc:ia76kvnndjutgedggx2ibrem/pub.leaflet.publication/3lpyvgcwc722m',
21 publishedAt: '2025-05-25T14:44:37.870Z',
22 pages: [
23 {
24 $type: 'pub.leaflet.pages.linearDocument',
25 blocks: [
26 {
27 $type: 'pub.leaflet.pages.linearDocument#block',
28 block: {
29 $type: 'pub.leaflet.blocks.text',
30 facets: [{ index: { byteEnd: 12, byteStart: 0 }, features: [] }],
31 plaintext: 'Hello world!',
32 },
33 },
34 {
35 $type: 'pub.leaflet.pages.linearDocument#block',
36 block: {
37 $type: 'pub.leaflet.blocks.text',
38 facets: [
39 {
40 index: { byteEnd: 9, byteStart: 0 },
41 features: [{ $type: 'pub.leaflet.richtext.facet#bold' }],
42 },
43 ],
44 plaintext: 'Bold text',
45 },
46 },
47 {
48 $type: 'pub.leaflet.pages.linearDocument#block',
49 block: {
50 $type: 'pub.leaflet.blocks.text',
51 facets: [
52 {
53 index: { byteEnd: 11, byteStart: 0 },
54 features: [{ $type: 'pub.leaflet.richtext.facet#italic' }],
55 },
56 ],
57 plaintext: 'Italic text',
58 },
59 },
60 {
61 $type: 'pub.leaflet.pages.linearDocument#block',
62 block: {
63 $type: 'pub.leaflet.blocks.text',
64 facets: [
65 {
66 index: { byteEnd: 16, byteStart: 0 },
67 features: [
68 { $type: 'pub.leaflet.richtext.facet#bold' },
69 { $type: 'pub.leaflet.richtext.facet#italic' },
70 ],
71 },
72 ],
73 plaintext: 'Bold italic text',
74 },
75 },
76 {
77 $type: 'pub.leaflet.pages.linearDocument#block',
78 block: { $type: 'pub.leaflet.blocks.text', facets: [], plaintext: '' },
79 },
80 ],
81 },
82 ],
83};
84
85is(PubLeafletDocument.mainSchema, document);
86// -> true
87```
88
89### with `@atcute/client`
90
91pick either one of these 3 options to register the ambient declarations
92
93```jsonc
94// tsconfig.json
95{
96 "compilerOptions": {
97 "types": ["@atcute/leaflet"],
98 },
99}
100```
101
102```ts
103// env.d.ts
104/// <reference types="@atcute/leaflet" />
105```
106
107```ts
108// index.ts
109import type {} from '@atcute/leaflet';
110```
111
112now all the XRPC operations should be visible in the client
113
114### with `@atcute/lex-cli`
115
116when building your own lexicons that reference Leaflet types, configure lex-cli to import from this
117package:
118
119```ts
120// file: lex.config.js
121import { defineLexiconConfig } from '@atcute/lex-cli';
122
123export default defineLexiconConfig({
124 files: ['lexicons/**/*.json'],
125 outdir: 'src/lexicons/',
126 imports: ['@atcute/leaflet'],
127});
128```