some cleanup

nulfrost b3305bf8 828cda5b

+2 -1
.gitignore
··· 1 1 node_modules 2 - dist 2 + dist 3 + *.tgz
+9 -18
lib/leaflet-live-loader.ts
··· 12 12 getLeafletDocuments, 13 13 getSingleLeafletDocument, 14 14 leafletDocumentRecordToView, 15 + LiveLoaderError, 15 16 resolveMiniDoc, 16 17 uriToRkey, 17 18 } from "./utils.js"; 18 - 19 - export class LiveLoaderError extends Error { 20 - constructor( 21 - message: string, 22 - public code?: string, 23 - ) { 24 - super(message); 25 - this.name = "LiveLoaderError"; 26 - } 27 - } 28 19 29 20 export function leafletLiveLoader( 30 21 options: LeafletLoaderOptions, ··· 86 77 } 87 78 }, 88 79 loadEntry: async ({ filter }) => { 80 + if (!filter.id) { 81 + return { 82 + error: new LiveLoaderError( 83 + "must provide an id for specific document", 84 + "MISSING_DOCUMENT_ID", 85 + ), 86 + }; 87 + } 89 88 try { 90 - if (!filter.id) { 91 - return { 92 - error: new LiveLoaderError( 93 - "must provide an id for specific document", 94 - "MISSING_DOCUMENT_ID", 95 - ), 96 - }; 97 - } 98 89 const pds_url = await resolveMiniDoc(repo); 99 90 const agent = new Agent({ service: pds_url }); 100 91 const document = await getSingleLeafletDocument({
lib/leaftlet-static-loader.ts

This is a binary file and will not be displayed.

+13 -4
lib/utils.ts
··· 1 1 import { is } from "@atcute/lexicons"; 2 2 import { AtUri, UnicodeString } from "@atproto/api"; 3 3 import sanitizeHTML from "sanitize-html"; 4 - import { LiveLoaderError } from "./leaflet-live-loader.js"; 5 4 import { 6 5 PubLeafletBlocksHeader, 7 6 PubLeafletBlocksText, ··· 18 17 RichTextSegment, 19 18 } from "./types.js"; 20 19 20 + export class LiveLoaderError extends Error { 21 + constructor( 22 + message: string, 23 + public code?: string, 24 + ) { 25 + super(message); 26 + this.name = "LiveLoaderError"; 27 + } 28 + } 29 + 21 30 export function uriToRkey(uri: string): string { 22 31 const u = AtUri.make(uri); 23 32 if (!u.rkey) { ··· 62 71 63 72 if (response.success === false) { 64 73 throw new LiveLoaderError( 65 - "Could not fetch leaflet documents", 66 - "FETCH_FAILED", 74 + "error fetching leaflet documents", 75 + "DOCUMENT_FETCH_ERROR", 67 76 ); 68 77 } 69 78 ··· 83 92 84 93 if (response.success === false) { 85 94 throw new LiveLoaderError( 86 - "error fetching document", 95 + "error fetching single document", 87 96 "DOCUMENT_FETCH_ERROR", 88 97 ); 89 98 }
+2 -1
package.json
··· 23 23 "lex": "lex-cli generate -c ./lex.config.js", 24 24 "test": "vitest --run", 25 25 "typecheck": "tsc", 26 - "build": "rm -rf dist && tsup" 26 + "build": "rm -rf dist && tsup", 27 + "pack": "pnpm build && pnpm pack" 27 28 }, 28 29 "license": "MIT", 29 30 "files": [