some cleanup

nulfrost b3305bf8 828cda5b

+2 -1
.gitignore
··· 1 node_modules 2 - dist
··· 1 node_modules 2 + dist 3 + *.tgz
+9 -18
lib/leaflet-live-loader.ts
··· 12 getLeafletDocuments, 13 getSingleLeafletDocument, 14 leafletDocumentRecordToView, 15 resolveMiniDoc, 16 uriToRkey, 17 } 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 29 export function leafletLiveLoader( 30 options: LeafletLoaderOptions, ··· 86 } 87 }, 88 loadEntry: async ({ filter }) => { 89 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 const pds_url = await resolveMiniDoc(repo); 99 const agent = new Agent({ service: pds_url }); 100 const document = await getSingleLeafletDocument({
··· 12 getLeafletDocuments, 13 getSingleLeafletDocument, 14 leafletDocumentRecordToView, 15 + LiveLoaderError, 16 resolveMiniDoc, 17 uriToRkey, 18 } from "./utils.js"; 19 20 export function leafletLiveLoader( 21 options: LeafletLoaderOptions, ··· 77 } 78 }, 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 + } 88 try { 89 const pds_url = await resolveMiniDoc(repo); 90 const agent = new Agent({ service: pds_url }); 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 import { is } from "@atcute/lexicons"; 2 import { AtUri, UnicodeString } from "@atproto/api"; 3 import sanitizeHTML from "sanitize-html"; 4 - import { LiveLoaderError } from "./leaflet-live-loader.js"; 5 import { 6 PubLeafletBlocksHeader, 7 PubLeafletBlocksText, ··· 18 RichTextSegment, 19 } from "./types.js"; 20 21 export function uriToRkey(uri: string): string { 22 const u = AtUri.make(uri); 23 if (!u.rkey) { ··· 62 63 if (response.success === false) { 64 throw new LiveLoaderError( 65 - "Could not fetch leaflet documents", 66 - "FETCH_FAILED", 67 ); 68 } 69 ··· 83 84 if (response.success === false) { 85 throw new LiveLoaderError( 86 - "error fetching document", 87 "DOCUMENT_FETCH_ERROR", 88 ); 89 }
··· 1 import { is } from "@atcute/lexicons"; 2 import { AtUri, UnicodeString } from "@atproto/api"; 3 import sanitizeHTML from "sanitize-html"; 4 import { 5 PubLeafletBlocksHeader, 6 PubLeafletBlocksText, ··· 17 RichTextSegment, 18 } from "./types.js"; 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 + 30 export function uriToRkey(uri: string): string { 31 const u = AtUri.make(uri); 32 if (!u.rkey) { ··· 71 72 if (response.success === false) { 73 throw new LiveLoaderError( 74 + "error fetching leaflet documents", 75 + "DOCUMENT_FETCH_ERROR", 76 ); 77 } 78 ··· 92 93 if (response.success === false) { 94 throw new LiveLoaderError( 95 + "error fetching single document", 96 "DOCUMENT_FETCH_ERROR", 97 ); 98 }
+2 -1
package.json
··· 23 "lex": "lex-cli generate -c ./lex.config.js", 24 "test": "vitest --run", 25 "typecheck": "tsc", 26 - "build": "rm -rf dist && tsup" 27 }, 28 "license": "MIT", 29 "files": [
··· 23 "lex": "lex-cli generate -c ./lex.config.js", 24 "test": "vitest --run", 25 "typecheck": "tsc", 26 + "build": "rm -rf dist && tsup", 27 + "pack": "pnpm build && pnpm pack" 28 }, 29 "license": "MIT", 30 "files": [