a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(leaflet): initial commit

Mary 27aad10d 8c2af409

+957
+1
lexdocs/leaflet/README.md
··· 1 + https://github.com/hyperlink-academy/leaflet/tree/f76b379dfd8d0f853c24a95f9cae4166646d774f/lexicons/pub/leaflet/
+27
lexdocs/leaflet/blocks/header.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.blocks.header", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "required": ["plaintext"], 8 + "properties": { 9 + "level": { 10 + "type": "integer", 11 + "minimum": 1, 12 + "maximum": 6 13 + }, 14 + "plaintext": { 15 + "type": "string" 16 + }, 17 + "facets": { 18 + "type": "array", 19 + "items": { 20 + "type": "ref", 21 + "ref": "pub.leaflet.richtext.facet" 22 + } 23 + } 24 + } 25 + } 26 + } 27 + }
+37
lexdocs/leaflet/blocks/image.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.blocks.image", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "required": ["image", "aspectRatio"], 8 + "properties": { 9 + "image": { 10 + "type": "blob", 11 + "accept": ["image/*"], 12 + "maxSize": 1000000 13 + }, 14 + "alt": { 15 + "type": "string", 16 + "description": "Alt text description of the image, for accessibility." 17 + }, 18 + "aspectRatio": { 19 + "type": "ref", 20 + "ref": "#aspectRatio" 21 + } 22 + } 23 + }, 24 + "aspectRatio": { 25 + "type": "object", 26 + "required": ["width", "height"], 27 + "properties": { 28 + "width": { 29 + "type": "integer" 30 + }, 31 + "height": { 32 + "type": "integer" 33 + } 34 + } 35 + } 36 + } 37 + }
+22
lexdocs/leaflet/blocks/text.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.blocks.text", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "required": ["plaintext"], 8 + "properties": { 9 + "plaintext": { 10 + "type": "string" 11 + }, 12 + "facets": { 13 + "type": "array", 14 + "items": { 15 + "type": "ref", 16 + "ref": "pub.leaflet.richtext.facet" 17 + } 18 + } 19 + } 20 + } 21 + } 22 + }
+36
lexdocs/leaflet/blocks/unorderedList.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.blocks.unorderedList", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "required": ["children"], 8 + "properties": { 9 + "children": { 10 + "type": "array", 11 + "items": { 12 + "type": "ref", 13 + "ref": "#listItem" 14 + } 15 + } 16 + } 17 + }, 18 + "listItem": { 19 + "type": "object", 20 + "required": ["content"], 21 + "properties": { 22 + "content": { 23 + "type": "union", 24 + "refs": ["pub.leaflet.blocks.text", "pub.leaflet.blocks.header", "pub.leaflet.blocks.image"] 25 + }, 26 + "children": { 27 + "type": "array", 28 + "items": { 29 + "type": "ref", 30 + "ref": "#listItem" 31 + } 32 + } 33 + } 34 + } 35 + } 36 + }
+48
lexdocs/leaflet/document.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.document", 4 + "revision": 1, 5 + "description": "A lexicon for long form rich media documents", 6 + "defs": { 7 + "main": { 8 + "type": "record", 9 + "key": "tid", 10 + "description": "Record containing a document", 11 + "record": { 12 + "type": "object", 13 + "required": ["pages", "author", "title", "publication"], 14 + "properties": { 15 + "title": { 16 + "type": "string", 17 + "maxLength": 1280, 18 + "maxGraphemes": 128 19 + }, 20 + "description": { 21 + "type": "string", 22 + "maxLength": 3000, 23 + "maxGraphemes": 300 24 + }, 25 + "publishedAt": { 26 + "type": "string", 27 + "format": "datetime" 28 + }, 29 + "publication": { 30 + "type": "string", 31 + "format": "at-uri" 32 + }, 33 + "author": { 34 + "type": "string", 35 + "format": "at-identifier" 36 + }, 37 + "pages": { 38 + "type": "array", 39 + "items": { 40 + "type": "union", 41 + "refs": ["pub.leaflet.pages.linearDocument"] 42 + } 43 + } 44 + } 45 + } 46 + } 47 + } 48 + }
+46
lexdocs/leaflet/pages/linearDocument.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.pages.linearDocument", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "properties": { 8 + "blocks": { 9 + "type": "array", 10 + "items": { 11 + "type": "ref", 12 + "ref": "#block" 13 + } 14 + } 15 + } 16 + }, 17 + "block": { 18 + "type": "object", 19 + "required": ["block"], 20 + "properties": { 21 + "block": { 22 + "type": "union", 23 + "refs": [ 24 + "pub.leaflet.blocks.text", 25 + "pub.leaflet.blocks.header", 26 + "pub.leaflet.blocks.image", 27 + "pub.leaflet.blocks.unorderedList" 28 + ] 29 + }, 30 + "alignment": { 31 + "type": "string", 32 + "knownValues": ["#textAlignLeft", "#textAlignCenter", "#textAlignRight"] 33 + } 34 + } 35 + }, 36 + "textAlignLeft": { 37 + "type": "token" 38 + }, 39 + "textAlignCenter": { 40 + "type": "token" 41 + }, 42 + "textAlignRight": { 43 + "type": "token" 44 + } 45 + } 46 + }
+34
lexdocs/leaflet/publication.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.publication", 4 + "defs": { 5 + "main": { 6 + "type": "record", 7 + "key": "tid", 8 + "description": "Record declaring a publication", 9 + "record": { 10 + "type": "object", 11 + "required": ["name"], 12 + "properties": { 13 + "name": { 14 + "type": "string", 15 + "maxLength": 2000 16 + }, 17 + "base_path": { 18 + "type": "string", 19 + "format": "uri" 20 + }, 21 + "description": { 22 + "type": "string", 23 + "maxLength": 2000 24 + }, 25 + "icon": { 26 + "type": "blob", 27 + "accept": ["image/*"], 28 + "maxSize": 1000000 29 + } 30 + } 31 + } 32 + } 33 + } 34 + }
+80
lexdocs/leaflet/richtext/facet.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "pub.leaflet.richtext.facet", 4 + "defs": { 5 + "main": { 6 + "type": "object", 7 + "description": "Annotation of a sub-string within rich text.", 8 + "required": ["index", "features"], 9 + "properties": { 10 + "index": { 11 + "type": "ref", 12 + "ref": "#byteSlice" 13 + }, 14 + "features": { 15 + "type": "array", 16 + "items": { 17 + "type": "union", 18 + "refs": ["#link", "#highlight", "#underline", "#strikethrough", "#bold", "#italic"] 19 + } 20 + } 21 + } 22 + }, 23 + "byteSlice": { 24 + "type": "object", 25 + "description": "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.", 26 + "required": ["byteStart", "byteEnd"], 27 + "properties": { 28 + "byteStart": { 29 + "type": "integer", 30 + "minimum": 0 31 + }, 32 + "byteEnd": { 33 + "type": "integer", 34 + "minimum": 0 35 + } 36 + } 37 + }, 38 + "link": { 39 + "type": "object", 40 + "description": "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.", 41 + "required": ["uri"], 42 + "properties": { 43 + "uri": { 44 + "type": "string", 45 + "format": "uri" 46 + } 47 + } 48 + }, 49 + "highlight": { 50 + "type": "object", 51 + "description": "Facet feature for highlighted text.", 52 + "required": [], 53 + "properties": {} 54 + }, 55 + "underline": { 56 + "type": "object", 57 + "description": "Facet feature for underline markup", 58 + "required": [], 59 + "properties": {} 60 + }, 61 + "strikethrough": { 62 + "type": "object", 63 + "description": "Facet feature for strikethrough markup", 64 + "required": [], 65 + "properties": {} 66 + }, 67 + "bold": { 68 + "type": "object", 69 + "description": "Facet feature for bold text", 70 + "required": [], 71 + "properties": {} 72 + }, 73 + "italic": { 74 + "type": "object", 75 + "description": "Facet feature for italic text", 76 + "required": [], 77 + "properties": {} 78 + } 79 + } 80 + }
+1
package.json
··· 5 5 "pull": "node ./scripts/pull-lexicons.js", 6 6 "pull:bluemoji": "node ./scripts/pull-bluemoji-lexicons.js", 7 7 "pull:frontpage": "node ./scripts/pull-frontpage-lexicons.js", 8 + "pull:leaflet": "node ./scripts/pull-leaflet-lexicons.js", 8 9 "pull:lexcom": "node ./scripts/pull-lexcom-lexicons.js", 9 10 "pull:tangled": "node ./scripts/pull-tangled-lexicons.js", 10 11 "pull:whtwnd": "node ./scripts/pull-whtwnd-lexicons.js",
+108
packages/definitions/leaflet/README.md
··· 1 + # @atcute/leaflet 2 + 3 + [Leaflet](https://leaflet.pub/) (pub.leaflet.\*) schema definitions 4 + 5 + ## usage 6 + 7 + ```ts 8 + import { PubLeafletDocument } from '@atcute/leaflet'; 9 + import { is } from '@atcute/lexicons'; 10 + 11 + const document: PubLeafletDocument.Main = { 12 + $type: 'pub.leaflet.document', 13 + title: 'Article title', 14 + author: 'did:plc:ia76kvnndjutgedggx2ibrem', 15 + description: 'Article description', 16 + publication: 'at://did:plc:ia76kvnndjutgedggx2ibrem/pub.leaflet.publication/3lpyvgcwc722m', 17 + publishedAt: '2025-05-25T14:44:37.870Z', 18 + pages: [ 19 + { 20 + $type: 'pub.leaflet.pages.linearDocument', 21 + blocks: [ 22 + { 23 + $type: 'pub.leaflet.pages.linearDocument#block', 24 + block: { 25 + $type: 'pub.leaflet.blocks.text', 26 + facets: [{ index: { byteEnd: 12, byteStart: 0 }, features: [] }], 27 + plaintext: 'Hello world!', 28 + }, 29 + }, 30 + { 31 + $type: 'pub.leaflet.pages.linearDocument#block', 32 + block: { 33 + $type: 'pub.leaflet.blocks.text', 34 + facets: [ 35 + { 36 + index: { byteEnd: 9, byteStart: 0 }, 37 + features: [{ $type: 'pub.leaflet.richtext.facet#bold' }], 38 + }, 39 + ], 40 + plaintext: 'Bold text', 41 + }, 42 + }, 43 + { 44 + $type: 'pub.leaflet.pages.linearDocument#block', 45 + block: { 46 + $type: 'pub.leaflet.blocks.text', 47 + facets: [ 48 + { 49 + index: { byteEnd: 11, byteStart: 0 }, 50 + features: [{ $type: 'pub.leaflet.richtext.facet#italic' }], 51 + }, 52 + ], 53 + plaintext: 'Italic text', 54 + }, 55 + }, 56 + { 57 + $type: 'pub.leaflet.pages.linearDocument#block', 58 + block: { 59 + $type: 'pub.leaflet.blocks.text', 60 + facets: [ 61 + { 62 + index: { byteEnd: 16, byteStart: 0 }, 63 + features: [ 64 + { $type: 'pub.leaflet.richtext.facet#bold' }, 65 + { $type: 'pub.leaflet.richtext.facet#italic' }, 66 + ], 67 + }, 68 + ], 69 + plaintext: 'Bold italic text', 70 + }, 71 + }, 72 + { 73 + $type: 'pub.leaflet.pages.linearDocument#block', 74 + block: { $type: 'pub.leaflet.blocks.text', facets: [], plaintext: '' }, 75 + }, 76 + ], 77 + }, 78 + ], 79 + }; 80 + 81 + is(PubLeafletDocument.mainSchema, document); 82 + // -> true 83 + ``` 84 + 85 + ### with `@atcute/client` 86 + 87 + pick either one of these 3 options to register the ambient declarations 88 + 89 + ```jsonc 90 + // tsconfig.json 91 + { 92 + "compilerOptions": { 93 + "types": ["@atcute/leaflet"], 94 + }, 95 + } 96 + ``` 97 + 98 + ```ts 99 + // env.d.ts 100 + /// <reference types="@atcute/leaflet" /> 101 + ``` 102 + 103 + ```ts 104 + // index.ts 105 + import type {} from '@atcute/leaflet'; 106 + ``` 107 + 108 + now all the XRPC operations should be visible in the client
+15
packages/definitions/leaflet/lex.config.js
··· 1 + import { defineLexiconConfig } from '@atcute/lex-cli'; 2 + 3 + export default defineLexiconConfig({ 4 + files: ['../../../lexdocs/leaflet/**/*.json'], 5 + outdir: 'lib/lexicons/', 6 + mappings: [ 7 + // { 8 + // nsid: ['com.atproto.*'], 9 + // imports: (nsid) => { 10 + // const specifier = nsid.slice('com.atproto.'.length).replaceAll('.', '/'); 11 + // return { type: 'namespace', from: `@atcute/atproto/types/${specifier}` }; 12 + // }, 13 + // }, 14 + ], 15 + });
+1
packages/definitions/leaflet/lib/index.ts
··· 1 + export * from './lexicons/index.js';
+8
packages/definitions/leaflet/lib/lexicons/index.ts
··· 1 + export * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header.js'; 2 + export * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image.js'; 3 + export * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text.js'; 4 + export * as PubLeafletBlocksUnorderedList from './types/pub/leaflet/blocks/unorderedList.js'; 5 + export * as PubLeafletDocument from './types/pub/leaflet/document.js'; 6 + export * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument.js'; 7 + export * as PubLeafletPublication from './types/pub/leaflet/publication.js'; 8 + export * as PubLeafletRichtextFacet from './types/pub/leaflet/richtext/facet.js';
+22
packages/definitions/leaflet/lib/lexicons/types/pub/leaflet/blocks/header.ts
··· 1 + import type {} from '@atcute/lexicons'; 2 + import * as v from '@atcute/lexicons/validations'; 3 + import * as PubLeafletRichtextFacet from '../richtext/facet.js'; 4 + 5 + const _mainSchema = /*#__PURE__*/ v.object({ 6 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.blocks.header')), 7 + get facets() { 8 + return /*#__PURE__*/ v.optional(/*#__PURE__*/ v.array(PubLeafletRichtextFacet.mainSchema)); 9 + }, 10 + level: /*#__PURE__*/ v.optional( 11 + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.integer(), [/*#__PURE__*/ v.integerRange(1, 6)]), 12 + ), 13 + plaintext: /*#__PURE__*/ v.string(), 14 + }); 15 + 16 + type main$schematype = typeof _mainSchema; 17 + 18 + export interface mainSchema extends main$schematype {} 19 + 20 + export const mainSchema = _mainSchema as mainSchema; 21 + 22 + export interface Main extends v.InferInput<typeof mainSchema> {}
+28
packages/definitions/leaflet/lib/lexicons/types/pub/leaflet/blocks/image.ts
··· 1 + import type {} from '@atcute/lexicons'; 2 + import * as v from '@atcute/lexicons/validations'; 3 + 4 + const _aspectRatioSchema = /*#__PURE__*/ v.object({ 5 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.blocks.image#aspectRatio')), 6 + height: /*#__PURE__*/ v.integer(), 7 + width: /*#__PURE__*/ v.integer(), 8 + }); 9 + const _mainSchema = /*#__PURE__*/ v.object({ 10 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.blocks.image')), 11 + alt: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.string()), 12 + get aspectRatio() { 13 + return aspectRatioSchema; 14 + }, 15 + image: /*#__PURE__*/ v.blob(), 16 + }); 17 + 18 + type aspectRatio$schematype = typeof _aspectRatioSchema; 19 + type main$schematype = typeof _mainSchema; 20 + 21 + export interface aspectRatioSchema extends aspectRatio$schematype {} 22 + export interface mainSchema extends main$schematype {} 23 + 24 + export const aspectRatioSchema = _aspectRatioSchema as aspectRatioSchema; 25 + export const mainSchema = _mainSchema as mainSchema; 26 + 27 + export interface AspectRatio extends v.InferInput<typeof aspectRatioSchema> {} 28 + export interface Main extends v.InferInput<typeof mainSchema> {}
+19
packages/definitions/leaflet/lib/lexicons/types/pub/leaflet/blocks/text.ts
··· 1 + import type {} from '@atcute/lexicons'; 2 + import * as v from '@atcute/lexicons/validations'; 3 + import * as PubLeafletRichtextFacet from '../richtext/facet.js'; 4 + 5 + const _mainSchema = /*#__PURE__*/ v.object({ 6 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.blocks.text')), 7 + get facets() { 8 + return /*#__PURE__*/ v.optional(/*#__PURE__*/ v.array(PubLeafletRichtextFacet.mainSchema)); 9 + }, 10 + plaintext: /*#__PURE__*/ v.string(), 11 + }); 12 + 13 + type main$schematype = typeof _mainSchema; 14 + 15 + export interface mainSchema extends main$schematype {} 16 + 17 + export const mainSchema = _mainSchema as mainSchema; 18 + 19 + export interface Main extends v.InferInput<typeof mainSchema> {}
+37
packages/definitions/leaflet/lib/lexicons/types/pub/leaflet/blocks/unorderedList.ts
··· 1 + import type {} from '@atcute/lexicons'; 2 + import * as v from '@atcute/lexicons/validations'; 3 + import * as PubLeafletBlocksHeader from './header.js'; 4 + import * as PubLeafletBlocksImage from './image.js'; 5 + import * as PubLeafletBlocksText from './text.js'; 6 + 7 + const _listItemSchema = /*#__PURE__*/ v.object({ 8 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.blocks.unorderedList#listItem')), 9 + get children() { 10 + return /*#__PURE__*/ v.optional(/*#__PURE__*/ v.array(listItemSchema)); 11 + }, 12 + get content() { 13 + return /*#__PURE__*/ v.variant([ 14 + PubLeafletBlocksHeader.mainSchema, 15 + PubLeafletBlocksImage.mainSchema, 16 + PubLeafletBlocksText.mainSchema, 17 + ]); 18 + }, 19 + }); 20 + const _mainSchema = /*#__PURE__*/ v.object({ 21 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.blocks.unorderedList')), 22 + get children() { 23 + return /*#__PURE__*/ v.array(listItemSchema); 24 + }, 25 + }); 26 + 27 + type listItem$schematype = typeof _listItemSchema; 28 + type main$schematype = typeof _mainSchema; 29 + 30 + export interface listItemSchema extends listItem$schematype {} 31 + export interface mainSchema extends main$schematype {} 32 + 33 + export const listItemSchema = _listItemSchema as listItemSchema; 34 + export const mainSchema = _mainSchema as mainSchema; 35 + 36 + export interface ListItem extends v.InferInput<typeof listItemSchema> {} 37 + export interface Main extends v.InferInput<typeof mainSchema> {}
+41
packages/definitions/leaflet/lib/lexicons/types/pub/leaflet/document.ts
··· 1 + import type {} from '@atcute/lexicons'; 2 + import * as v from '@atcute/lexicons/validations'; 3 + import type {} from '@atcute/lexicons/ambient'; 4 + import * as PubLeafletPagesLinearDocument from './pages/linearDocument.js'; 5 + 6 + const _mainSchema = /*#__PURE__*/ v.record( 7 + /*#__PURE__*/ v.tidString(), 8 + /*#__PURE__*/ v.object({ 9 + $type: /*#__PURE__*/ v.literal('pub.leaflet.document'), 10 + author: /*#__PURE__*/ v.actorIdentifierString(), 11 + description: /*#__PURE__*/ v.optional( 12 + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 13 + /*#__PURE__*/ v.stringLength(0, 3000), 14 + /*#__PURE__*/ v.stringGraphemes(0, 300), 15 + ]), 16 + ), 17 + get pages() { 18 + return /*#__PURE__*/ v.array(/*#__PURE__*/ v.variant([PubLeafletPagesLinearDocument.mainSchema])); 19 + }, 20 + publication: /*#__PURE__*/ v.resourceUriString(), 21 + publishedAt: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.datetimeString()), 22 + title: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [ 23 + /*#__PURE__*/ v.stringLength(0, 1280), 24 + /*#__PURE__*/ v.stringGraphemes(0, 128), 25 + ]), 26 + }), 27 + ); 28 + 29 + type main$schematype = typeof _mainSchema; 30 + 31 + export interface mainSchema extends main$schematype {} 32 + 33 + export const mainSchema = _mainSchema as mainSchema; 34 + 35 + export interface Main extends v.InferInput<typeof mainSchema> {} 36 + 37 + declare module '@atcute/lexicons/ambient' { 38 + interface Records { 39 + 'pub.leaflet.document': mainSchema; 40 + } 41 + }
+54
packages/definitions/leaflet/lib/lexicons/types/pub/leaflet/pages/linearDocument.ts
··· 1 + import type {} from '@atcute/lexicons'; 2 + import * as v from '@atcute/lexicons/validations'; 3 + import * as PubLeafletBlocksHeader from '../blocks/header.js'; 4 + import * as PubLeafletBlocksImage from '../blocks/image.js'; 5 + import * as PubLeafletBlocksText from '../blocks/text.js'; 6 + import * as PubLeafletBlocksUnorderedList from '../blocks/unorderedList.js'; 7 + 8 + const _blockSchema = /*#__PURE__*/ v.object({ 9 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.pages.linearDocument#block')), 10 + alignment: /*#__PURE__*/ v.optional( 11 + /*#__PURE__*/ v.string<'#textAlignCenter' | '#textAlignLeft' | '#textAlignRight' | (string & {})>(), 12 + ), 13 + get block() { 14 + return /*#__PURE__*/ v.variant([ 15 + PubLeafletBlocksHeader.mainSchema, 16 + PubLeafletBlocksImage.mainSchema, 17 + PubLeafletBlocksText.mainSchema, 18 + PubLeafletBlocksUnorderedList.mainSchema, 19 + ]); 20 + }, 21 + }); 22 + const _mainSchema = /*#__PURE__*/ v.object({ 23 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.pages.linearDocument')), 24 + get blocks() { 25 + return /*#__PURE__*/ v.optional(/*#__PURE__*/ v.array(blockSchema)); 26 + }, 27 + }); 28 + const _textAlignCenterSchema = /*#__PURE__*/ v.literal('pub.leaflet.pages.linearDocument#textAlignCenter'); 29 + const _textAlignLeftSchema = /*#__PURE__*/ v.literal('pub.leaflet.pages.linearDocument#textAlignLeft'); 30 + const _textAlignRightSchema = /*#__PURE__*/ v.literal('pub.leaflet.pages.linearDocument#textAlignRight'); 31 + 32 + type block$schematype = typeof _blockSchema; 33 + type main$schematype = typeof _mainSchema; 34 + type textAlignCenter$schematype = typeof _textAlignCenterSchema; 35 + type textAlignLeft$schematype = typeof _textAlignLeftSchema; 36 + type textAlignRight$schematype = typeof _textAlignRightSchema; 37 + 38 + export interface blockSchema extends block$schematype {} 39 + export interface mainSchema extends main$schematype {} 40 + export interface textAlignCenterSchema extends textAlignCenter$schematype {} 41 + export interface textAlignLeftSchema extends textAlignLeft$schematype {} 42 + export interface textAlignRightSchema extends textAlignRight$schematype {} 43 + 44 + export const blockSchema = _blockSchema as blockSchema; 45 + export const mainSchema = _mainSchema as mainSchema; 46 + export const textAlignCenterSchema = _textAlignCenterSchema as textAlignCenterSchema; 47 + export const textAlignLeftSchema = _textAlignLeftSchema as textAlignLeftSchema; 48 + export const textAlignRightSchema = _textAlignRightSchema as textAlignRightSchema; 49 + 50 + export interface Block extends v.InferInput<typeof blockSchema> {} 51 + export interface Main extends v.InferInput<typeof mainSchema> {} 52 + export type TextAlignCenter = v.InferInput<typeof textAlignCenterSchema>; 53 + export type TextAlignLeft = v.InferInput<typeof textAlignLeftSchema>; 54 + export type TextAlignRight = v.InferInput<typeof textAlignRightSchema>;
+30
packages/definitions/leaflet/lib/lexicons/types/pub/leaflet/publication.ts
··· 1 + import type {} from '@atcute/lexicons'; 2 + import * as v from '@atcute/lexicons/validations'; 3 + import type {} from '@atcute/lexicons/ambient'; 4 + 5 + const _mainSchema = /*#__PURE__*/ v.record( 6 + /*#__PURE__*/ v.tidString(), 7 + /*#__PURE__*/ v.object({ 8 + $type: /*#__PURE__*/ v.literal('pub.leaflet.publication'), 9 + base_path: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.genericUriString()), 10 + description: /*#__PURE__*/ v.optional( 11 + /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [/*#__PURE__*/ v.stringLength(0, 2000)]), 12 + ), 13 + icon: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.blob()), 14 + name: /*#__PURE__*/ v.constrain(/*#__PURE__*/ v.string(), [/*#__PURE__*/ v.stringLength(0, 2000)]), 15 + }), 16 + ); 17 + 18 + type main$schematype = typeof _mainSchema; 19 + 20 + export interface mainSchema extends main$schematype {} 21 + 22 + export const mainSchema = _mainSchema as mainSchema; 23 + 24 + export interface Main extends v.InferInput<typeof mainSchema> {} 25 + 26 + declare module '@atcute/lexicons/ambient' { 27 + interface Records { 28 + 'pub.leaflet.publication': mainSchema; 29 + } 30 + }
+81
packages/definitions/leaflet/lib/lexicons/types/pub/leaflet/richtext/facet.ts
··· 1 + import type {} from '@atcute/lexicons'; 2 + import * as v from '@atcute/lexicons/validations'; 3 + 4 + const _boldSchema = /*#__PURE__*/ v.object({ 5 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.richtext.facet#bold')), 6 + }); 7 + const _byteSliceSchema = /*#__PURE__*/ v.object({ 8 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.richtext.facet#byteSlice')), 9 + byteEnd: /*#__PURE__*/ v.integer(), 10 + byteStart: /*#__PURE__*/ v.integer(), 11 + }); 12 + const _highlightSchema = /*#__PURE__*/ v.object({ 13 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.richtext.facet#highlight')), 14 + }); 15 + const _italicSchema = /*#__PURE__*/ v.object({ 16 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.richtext.facet#italic')), 17 + }); 18 + const _linkSchema = /*#__PURE__*/ v.object({ 19 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.richtext.facet#link')), 20 + uri: /*#__PURE__*/ v.genericUriString(), 21 + }); 22 + const _mainSchema = /*#__PURE__*/ v.object({ 23 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.richtext.facet')), 24 + get features() { 25 + return /*#__PURE__*/ v.array( 26 + /*#__PURE__*/ v.variant([ 27 + boldSchema, 28 + highlightSchema, 29 + italicSchema, 30 + linkSchema, 31 + strikethroughSchema, 32 + underlineSchema, 33 + ]), 34 + ); 35 + }, 36 + get index() { 37 + return byteSliceSchema; 38 + }, 39 + }); 40 + const _strikethroughSchema = /*#__PURE__*/ v.object({ 41 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.richtext.facet#strikethrough')), 42 + }); 43 + const _underlineSchema = /*#__PURE__*/ v.object({ 44 + $type: /*#__PURE__*/ v.optional(/*#__PURE__*/ v.literal('pub.leaflet.richtext.facet#underline')), 45 + }); 46 + 47 + type bold$schematype = typeof _boldSchema; 48 + type byteSlice$schematype = typeof _byteSliceSchema; 49 + type highlight$schematype = typeof _highlightSchema; 50 + type italic$schematype = typeof _italicSchema; 51 + type link$schematype = typeof _linkSchema; 52 + type main$schematype = typeof _mainSchema; 53 + type strikethrough$schematype = typeof _strikethroughSchema; 54 + type underline$schematype = typeof _underlineSchema; 55 + 56 + export interface boldSchema extends bold$schematype {} 57 + export interface byteSliceSchema extends byteSlice$schematype {} 58 + export interface highlightSchema extends highlight$schematype {} 59 + export interface italicSchema extends italic$schematype {} 60 + export interface linkSchema extends link$schematype {} 61 + export interface mainSchema extends main$schematype {} 62 + export interface strikethroughSchema extends strikethrough$schematype {} 63 + export interface underlineSchema extends underline$schematype {} 64 + 65 + export const boldSchema = _boldSchema as boldSchema; 66 + export const byteSliceSchema = _byteSliceSchema as byteSliceSchema; 67 + export const highlightSchema = _highlightSchema as highlightSchema; 68 + export const italicSchema = _italicSchema as italicSchema; 69 + export const linkSchema = _linkSchema as linkSchema; 70 + export const mainSchema = _mainSchema as mainSchema; 71 + export const strikethroughSchema = _strikethroughSchema as strikethroughSchema; 72 + export const underlineSchema = _underlineSchema as underlineSchema; 73 + 74 + export interface Bold extends v.InferInput<typeof boldSchema> {} 75 + export interface ByteSlice extends v.InferInput<typeof byteSliceSchema> {} 76 + export interface Highlight extends v.InferInput<typeof highlightSchema> {} 77 + export interface Italic extends v.InferInput<typeof italicSchema> {} 78 + export interface Link extends v.InferInput<typeof linkSchema> {} 79 + export interface Main extends v.InferInput<typeof mainSchema> {} 80 + export interface Strikethrough extends v.InferInput<typeof strikethroughSchema> {} 81 + export interface Underline extends v.InferInput<typeof underlineSchema> {}
+40
packages/definitions/leaflet/package.json
··· 1 + { 2 + "type": "module", 3 + "name": "@atcute/leaflet", 4 + "version": "1.0.0", 5 + "description": "Leaflet (pub.leaflet.*) schema definitions", 6 + "keywords": [ 7 + "atcute", 8 + "atproto", 9 + "leaflet" 10 + ], 11 + "license": "MIT", 12 + "repository": { 13 + "url": "https://github.com/mary-ext/atcute", 14 + "directory": "packages/definitions/leaflet" 15 + }, 16 + "files": [ 17 + "dist/", 18 + "lib/", 19 + "!lib/**/*.bench.ts", 20 + "!lib/**/*.test.ts" 21 + ], 22 + "exports": { 23 + ".": "./dist/index.js", 24 + "./types/*": "./dist/lexicons/types/pub/leaflet/*.js" 25 + }, 26 + "scripts": { 27 + "build": "tsc", 28 + "test": "vitest", 29 + "generate": "rm -r ./lib/lexicons/; lex-cli generate -c ./lex.config.js", 30 + "prepublish": "rm -rf dist; pnpm run build" 31 + }, 32 + "dependencies": { 33 + "@atcute/lexicons": "workspace:^" 34 + }, 35 + "devDependencies": { 36 + "@atcute/leaflet": "file:", 37 + "@atcute/lex-cli": "workspace:^", 38 + "vitest": "^3.1.3" 39 + } 40 + }
+22
packages/definitions/leaflet/tsconfig.json
··· 1 + { 2 + "compilerOptions": { 3 + "outDir": "dist/", 4 + "esModuleInterop": true, 5 + "skipLibCheck": true, 6 + "target": "ESNext", 7 + "allowJs": true, 8 + "resolveJsonModule": true, 9 + "moduleDetection": "force", 10 + "isolatedModules": true, 11 + "verbatimModuleSyntax": true, 12 + "strict": true, 13 + "noImplicitOverride": true, 14 + "noUnusedLocals": true, 15 + "noUnusedParameters": true, 16 + "noFallthroughCasesInSwitch": true, 17 + "module": "NodeNext", 18 + "sourceMap": true, 19 + "declaration": true, 20 + }, 21 + "include": ["lib"], 22 + }
+23
pnpm-lock.yaml
··· 247 247 specifier: ^3.1.3 248 248 version: 3.1.3(@types/node@22.15.17) 249 249 250 + packages/definitions/leaflet: 251 + dependencies: 252 + '@atcute/lexicons': 253 + specifier: workspace:^ 254 + version: link:../../lexicons/lexicons 255 + devDependencies: 256 + '@atcute/leaflet': 257 + specifier: 'file:' 258 + version: file:packages/definitions/leaflet 259 + '@atcute/lex-cli': 260 + specifier: workspace:^ 261 + version: link:../../lexicons/lex-cli 262 + vitest: 263 + specifier: ^3.1.3 264 + version: 3.1.3(@types/node@22.15.17) 265 + 250 266 packages/definitions/lexicon-community: 251 267 dependencies: 252 268 '@atcute/atproto': ··· 636 652 637 653 '@atcute/frontpage@file:packages/definitions/frontpage': 638 654 resolution: {directory: packages/definitions/frontpage, type: directory} 655 + 656 + '@atcute/leaflet@file:packages/definitions/leaflet': 657 + resolution: {directory: packages/definitions/leaflet, type: directory} 639 658 640 659 '@atcute/lexicon-community@file:packages/definitions/lexicon-community': 641 660 resolution: {directory: packages/definitions/lexicon-community, type: directory} ··· 3373 3392 '@atcute/frontpage@file:packages/definitions/frontpage': 3374 3393 dependencies: 3375 3394 '@atcute/atproto': link:packages/definitions/atproto 3395 + '@atcute/lexicons': link:packages/lexicons/lexicons 3396 + 3397 + '@atcute/leaflet@file:packages/definitions/leaflet': 3398 + dependencies: 3376 3399 '@atcute/lexicons': link:packages/lexicons/lexicons 3377 3400 3378 3401 '@atcute/lexicon-community@file:packages/definitions/lexicon-community':
+96
scripts/pull-leaflet-lexicons.js
··· 1 + import * as path from 'node:path'; 2 + import * as fs from 'node:fs/promises'; 3 + 4 + import { untar } from '@mary/tar'; 5 + import prettier from 'prettier'; 6 + 7 + const config = { 8 + repo: `hyperlink-academy/leaflet`, 9 + path: `lexicons/pub/leaflet/`, 10 + out: `lexdocs/leaflet/`, 11 + }; 12 + 13 + async function main() { 14 + const prettierConfig = await prettier.resolveConfig(process.cwd() + '/foo', { editorconfig: true }); 15 + 16 + let sha; 17 + { 18 + console.log(`retrieving latest commit`); 19 + const response = await fetch(`https://api.github.com/repos/${config.repo}/commits?path=${config.path}/`); 20 + 21 + if (!response.ok) { 22 + console.log(` response error ${response.status}`); 23 + return; 24 + } 25 + 26 + const json = await response.json(); 27 + const latest = json[0]; 28 + 29 + if (!latest) { 30 + console.log(` latest commit missing?`); 31 + return; 32 + } 33 + 34 + sha = latest.sha; 35 + console.log(` got ${sha}`); 36 + } 37 + 38 + const tmpdir = `lexicons-tmp/`; 39 + 40 + { 41 + console.log(`retrieving zip file`); 42 + const response = await fetch(`https://github.com/${config.repo}/archive/${sha}.tar.gz`); 43 + 44 + if (!response.ok) { 45 + console.log(` response error ${response.status}`); 46 + return; 47 + } 48 + 49 + const reponame = config.repo.replace(/^.*?\//, ''); 50 + const basename = `${reponame}-${sha}/${config.path}`; 51 + 52 + const ds = new DecompressionStream('gzip'); 53 + const stream = response.body.pipeThrough(ds); 54 + 55 + const promises = []; 56 + 57 + console.log(` reading`); 58 + for await (const entry of untar(stream)) { 59 + if (entry.type === 'file' && entry.name.startsWith(basename) && entry.name.endsWith('.json')) { 60 + const name = entry.name.slice(basename.length); 61 + const basedir = tmpdir + path.dirname(name); 62 + 63 + const code = await entry.text(); 64 + 65 + const promise = (async () => { 66 + const formatted = await prettier.format(code, { ...prettierConfig, parser: 'json' }); 67 + 68 + await fs.mkdir(basedir, { recursive: true }); 69 + await fs.writeFile(tmpdir + name, formatted); 70 + })(); 71 + 72 + promises.push(promise); 73 + } 74 + } 75 + 76 + console.log(` flushing writes`); 77 + await Promise.all(promises); 78 + } 79 + 80 + { 81 + const source = `https://github.com/${config.repo}/tree/${sha}/${config.path}\n`; 82 + 83 + console.log(`writing readme file`); 84 + 85 + await fs.writeFile(tmpdir + `README.md`, source); 86 + } 87 + 88 + { 89 + console.log(`moving folder`); 90 + 91 + await fs.rm(config.out, { recursive: true, force: true }); 92 + await fs.rename(tmpdir, config.out); 93 + } 94 + } 95 + 96 + await main();