@ewanc26/svelte-standard-site 0.2.2 → 0.2.4

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 (69) hide show
  1. package/dist/components/ActionBar.svelte +85 -0
  2. package/dist/components/ActionBar.svelte.d.ts +13 -0
  3. package/dist/components/Avatar.svelte +104 -0
  4. package/dist/components/Avatar.svelte.d.ts +19 -0
  5. package/dist/components/Comment.svelte +172 -0
  6. package/dist/components/Comment.svelte.d.ts +22 -0
  7. package/dist/components/CommentsSection.svelte +89 -0
  8. package/dist/components/DocumentCard.svelte +126 -56
  9. package/dist/components/DocumentCard.svelte.d.ts +51 -0
  10. package/dist/components/Footnotes.svelte +72 -0
  11. package/dist/components/Footnotes.svelte.d.ts +13 -0
  12. package/dist/components/RecommendButton.svelte +153 -0
  13. package/dist/components/RecommendButton.svelte.d.ts +17 -0
  14. package/dist/components/ThemeProvider.svelte +92 -0
  15. package/dist/components/ThemeProvider.svelte.d.ts +13 -0
  16. package/dist/components/Toast.svelte +177 -0
  17. package/dist/components/Toast.svelte.d.ts +32 -0
  18. package/dist/components/Watermark.svelte +100 -0
  19. package/dist/components/Watermark.svelte.d.ts +17 -0
  20. package/dist/components/common/ThemedCard.svelte +15 -15
  21. package/dist/components/common/ThemedCard.svelte.d.ts +5 -0
  22. package/dist/components/document/BlockRenderer.svelte +3 -0
  23. package/dist/components/document/DocumentRenderer.svelte +41 -1
  24. package/dist/components/document/RichText.svelte +87 -2
  25. package/dist/components/document/RichText.svelte.d.ts +2 -0
  26. package/dist/components/document/blocks/OrderedListBlock.svelte +152 -0
  27. package/dist/components/document/blocks/UnorderedListBlock.svelte +1 -1
  28. package/dist/components/index.d.ts +28 -0
  29. package/dist/components/index.js +30 -0
  30. package/dist/index.d.ts +5 -4
  31. package/dist/index.js +6 -4
  32. package/dist/publisher.d.ts +73 -0
  33. package/dist/publisher.js +185 -0
  34. package/dist/schemas.d.ts +1162 -2
  35. package/dist/schemas.js +316 -0
  36. package/dist/types.d.ts +393 -2
  37. package/dist/types.js +1 -1
  38. package/dist/utils/native-comments.d.ts +68 -0
  39. package/dist/utils/native-comments.js +149 -0
  40. package/dist/utils/theme-helpers.d.ts +41 -1
  41. package/dist/utils/theme-helpers.js +98 -1
  42. package/dist/utils/theme.d.ts +48 -1
  43. package/dist/utils/theme.js +158 -0
  44. package/package.json +62 -65
  45. package/src/lib/components/ActionBar.svelte +85 -0
  46. package/src/lib/components/Avatar.svelte +104 -0
  47. package/src/lib/components/Comment.svelte +172 -0
  48. package/src/lib/components/CommentsSection.svelte +89 -0
  49. package/src/lib/components/DocumentCard.svelte +126 -56
  50. package/src/lib/components/Footnotes.svelte +72 -0
  51. package/src/lib/components/RecommendButton.svelte +153 -0
  52. package/src/lib/components/ThemeProvider.svelte +92 -0
  53. package/src/lib/components/Toast.svelte +177 -0
  54. package/src/lib/components/Watermark.svelte +100 -0
  55. package/src/lib/components/common/ThemedCard.svelte +15 -15
  56. package/src/lib/components/document/BlockRenderer.svelte +3 -0
  57. package/src/lib/components/document/DocumentRenderer.svelte +41 -1
  58. package/src/lib/components/document/RichText.svelte +87 -2
  59. package/src/lib/components/document/blocks/OrderedListBlock.svelte +152 -0
  60. package/src/lib/components/document/blocks/UnorderedListBlock.svelte +1 -1
  61. package/src/lib/components/index.ts +32 -0
  62. package/src/lib/index.ts +119 -5
  63. package/src/lib/publisher.ts +251 -0
  64. package/src/lib/schemas.ts +411 -0
  65. package/src/lib/types.ts +506 -2
  66. package/src/lib/utils/native-comments.ts +197 -0
  67. package/src/lib/utils/theme-helpers.ts +136 -3
  68. package/src/lib/utils/theme.ts +189 -1
  69. package/dist/components/document/blocks/UnorderedListBlock.svelte.d.ts +0 -9
@@ -21,6 +21,31 @@ export const RGBColorSchema = z.object({
21
21
  b: z.number().int().min(0).max(255)
22
22
  });
23
23
 
24
+ /**
25
+ * RGBA Color schema (with alpha)
26
+ */
27
+ export const RGBAColorSchema = z.object({
28
+ r: z.number().int().min(0).max(255),
29
+ g: z.number().int().min(0).max(255),
30
+ b: z.number().int().min(0).max(255),
31
+ a: z.number().int().min(0).max(100)
32
+ });
33
+
34
+ /**
35
+ * Color union (RGB or RGBA)
36
+ */
37
+ export const ColorSchema = z.union([RGBColorSchema, RGBAColorSchema]);
38
+
39
+ /**
40
+ * Background Image schema
41
+ */
42
+ export const BackgroundImageSchema = z.object({
43
+ $type: z.literal('pub.leaflet.theme.backgroundImage').optional(),
44
+ url: z.string(),
45
+ opacity: z.number().min(0).max(1).optional(),
46
+ blur: z.number().min(0).optional()
47
+ });
48
+
24
49
  /**
25
50
  * Basic Theme schema
26
51
  */
@@ -32,6 +57,23 @@ export const BasicThemeSchema = z.object({
32
57
  accentForeground: RGBColorSchema
33
58
  });
34
59
 
60
+ /**
61
+ * Extended Theme schema (pub.leaflet.publication#theme)
62
+ */
63
+ export const ExtendedThemeSchema = z.object({
64
+ $type: z.literal('pub.leaflet.theme').optional(),
65
+ backgroundColor: ColorSchema.optional(),
66
+ pageBackground: ColorSchema.optional(),
67
+ showPageBackground: z.boolean().optional(),
68
+ primary: ColorSchema.optional(),
69
+ accentBackground: ColorSchema.optional(),
70
+ accentText: ColorSchema.optional(),
71
+ headingFont: z.string().max(100).optional(),
72
+ bodyFont: z.string().max(100).optional(),
73
+ pageWidth: z.number().int().min(0).max(1600).optional(),
74
+ backgroundImage: BackgroundImageSchema.optional()
75
+ });
76
+
35
77
  /**
36
78
  * Publication Preferences schema
37
79
  */
@@ -124,9 +166,335 @@ export const LoaderConfigSchema = z.object({
124
166
  service: z.string().url().default('https://public.api.bsky.app')
125
167
  });
126
168
 
169
+ // ============================================
170
+ // Rich Text Facet Schemas (pub.leaflet.richtext.facet)
171
+ // ============================================
172
+
173
+ /**
174
+ * Byte slice for facet index
175
+ */
176
+ export const ByteSliceSchema = z.object({
177
+ byteStart: z.number().int().min(0),
178
+ byteEnd: z.number().int().min(0)
179
+ });
180
+
181
+ /**
182
+ * Link facet feature
183
+ */
184
+ export const LinkFeatureSchema = z.object({
185
+ $type: z.literal('pub.leaflet.richtext.facet#link'),
186
+ uri: z.string()
187
+ });
188
+
189
+ /**
190
+ * DID Mention facet feature
191
+ */
192
+ export const DidMentionFeatureSchema = z.object({
193
+ $type: z.literal('pub.leaflet.richtext.facet#didMention'),
194
+ did: z.string()
195
+ });
196
+
197
+ /**
198
+ * AT URI Mention facet feature
199
+ */
200
+ export const AtMentionFeatureSchema = z.object({
201
+ $type: z.literal('pub.leaflet.richtext.facet#atMention'),
202
+ atURI: z.string()
203
+ });
204
+
205
+ /**
206
+ * Code facet feature (inline code)
207
+ */
208
+ export const CodeFeatureSchema = z.object({
209
+ $type: z.literal('pub.leaflet.richtext.facet#code')
210
+ });
211
+
212
+ /**
213
+ * Highlight facet feature
214
+ */
215
+ export const HighlightFeatureSchema = z.object({
216
+ $type: z.literal('pub.leaflet.richtext.facet#highlight')
217
+ });
218
+
219
+ /**
220
+ * Underline facet feature
221
+ */
222
+ export const UnderlineFeatureSchema = z.object({
223
+ $type: z.literal('pub.leaflet.richtext.facet#underline')
224
+ });
225
+
226
+ /**
227
+ * Strikethrough facet feature
228
+ */
229
+ export const StrikethroughFeatureSchema = z.object({
230
+ $type: z.literal('pub.leaflet.richtext.facet#strikethrough')
231
+ });
232
+
233
+ /**
234
+ * Bold facet feature
235
+ */
236
+ export const BoldFeatureSchema = z.object({
237
+ $type: z.literal('pub.leaflet.richtext.facet#bold')
238
+ });
239
+
240
+ /**
241
+ * Italic facet feature
242
+ */
243
+ export const ItalicFeatureSchema = z.object({
244
+ $type: z.literal('pub.leaflet.richtext.facet#italic')
245
+ });
246
+
247
+ /**
248
+ * ID facet feature (for anchor links)
249
+ */
250
+ export const IdFeatureSchema = z.object({
251
+ $type: z.literal('pub.leaflet.richtext.facet#id'),
252
+ id: z.string()
253
+ });
254
+
255
+ /**
256
+ * Footnote facet feature
257
+ */
258
+ export const FootnoteFeatureSchema: z.ZodType<any> = z.object({
259
+ $type: z.literal('pub.leaflet.richtext.facet#footnote'),
260
+ footnoteId: z.string(),
261
+ contentPlaintext: z.string(),
262
+ contentFacets: z.array(z.lazy(() => FacetSchema)).optional()
263
+ });
264
+
265
+ /**
266
+ * Facet feature union
267
+ */
268
+ export const FacetFeatureSchema: z.ZodType<any> = z.union([
269
+ LinkFeatureSchema,
270
+ DidMentionFeatureSchema,
271
+ AtMentionFeatureSchema,
272
+ CodeFeatureSchema,
273
+ HighlightFeatureSchema,
274
+ UnderlineFeatureSchema,
275
+ StrikethroughFeatureSchema,
276
+ BoldFeatureSchema,
277
+ ItalicFeatureSchema,
278
+ IdFeatureSchema,
279
+ FootnoteFeatureSchema
280
+ ]);
281
+
282
+ /**
283
+ * Rich Text Facet schema
284
+ */
285
+ export const FacetSchema: z.ZodType<any> = z.object({
286
+ index: ByteSliceSchema,
287
+ features: z.array(FacetFeatureSchema)
288
+ });
289
+
290
+ // ============================================
291
+ // Block Schemas (pub.leaflet.blocks.*)
292
+ // ============================================
293
+
294
+ /**
295
+ * Text Block schema
296
+ */
297
+ export const TextBlockSchema = z.object({
298
+ $type: z.literal('pub.leaflet.blocks.text'),
299
+ plaintext: z.string(),
300
+ textSize: z.enum(['default', 'small', 'large']).optional(),
301
+ facets: z.array(FacetSchema).optional()
302
+ });
303
+
304
+ /**
305
+ * Header Block schema
306
+ */
307
+ export const HeaderBlockSchema = z.object({
308
+ $type: z.literal('pub.leaflet.blocks.header'),
309
+ plaintext: z.string(),
310
+ level: z.number().int().min(1).max(6).optional(),
311
+ facets: z.array(FacetSchema).optional()
312
+ });
313
+
314
+ /**
315
+ * Ordered List Item schema
316
+ */
317
+ export const OrderedListItemSchema: z.ZodType<any> = z.lazy(() =>
318
+ z.object({
319
+ content: z.union([TextBlockSchema, HeaderBlockSchema, z.any()]).optional(),
320
+ checked: z.boolean().optional(),
321
+ children: z.array(OrderedListItemSchema).optional(),
322
+ unorderedListChildren: z.any().optional()
323
+ })
324
+ );
325
+
326
+ /**
327
+ * Ordered List Block schema
328
+ */
329
+ export const OrderedListBlockSchema = z.object({
330
+ $type: z.literal('pub.leaflet.blocks.orderedList'),
331
+ children: z.array(OrderedListItemSchema),
332
+ startIndex: z.number().int().optional()
333
+ });
334
+
335
+ /**
336
+ * Unordered List Item schema
337
+ */
338
+ export const UnorderedListItemSchema: z.ZodType<any> = z.lazy(() =>
339
+ z.object({
340
+ content: z.union([TextBlockSchema, HeaderBlockSchema, z.any()]).optional(),
341
+ children: z.array(UnorderedListItemSchema).optional()
342
+ })
343
+ );
344
+
345
+ /**
346
+ * Unordered List Block schema
347
+ */
348
+ export const UnorderedListBlockSchema = z.object({
349
+ $type: z.literal('pub.leaflet.blocks.unorderedList'),
350
+ children: z.array(UnorderedListItemSchema)
351
+ });
352
+
353
+ // ============================================
354
+ // Comment Schemas (pub.leaflet.comment)
355
+ // ============================================
356
+
357
+ /**
358
+ * Linear Document Quote schema (for comment attachments)
359
+ */
360
+ export const LinearDocumentQuoteSchema = z.object({
361
+ $type: z.literal('pub.leaflet.comment#linearDocumentQuote').optional(),
362
+ document: z.string(),
363
+ quote: z.object({
364
+ start: z.object({
365
+ block: z.array(z.number().int()),
366
+ offset: z.number().int()
367
+ }),
368
+ end: z.object({
369
+ block: z.array(z.number().int()),
370
+ offset: z.number().int()
371
+ })
372
+ }).optional()
373
+ });
374
+
375
+ /**
376
+ * Comment Reply Reference schema
377
+ */
378
+ export const CommentReplyRefSchema = z.object({
379
+ $type: z.literal('pub.leaflet.comment#replyRef').optional(),
380
+ parent: z.string()
381
+ });
382
+
383
+ /**
384
+ * Comment schema
385
+ */
386
+ export const CommentSchema = z.object({
387
+ $type: z.literal('pub.leaflet.comment'),
388
+ subject: z.string(),
389
+ plaintext: z.string(),
390
+ createdAt: z.string().datetime(),
391
+ reply: CommentReplyRefSchema.optional(),
392
+ facets: z.array(FacetSchema).optional(),
393
+ onPage: z.string().optional(),
394
+ attachment: LinearDocumentQuoteSchema.optional()
395
+ });
396
+
397
+ // ============================================
398
+ // Interactions Schemas (pub.leaflet.interactions.*)
399
+ // ============================================
400
+
401
+ /**
402
+ * Recommend schema
403
+ */
404
+ export const RecommendSchema = z.object({
405
+ $type: z.literal('pub.leaflet.interactions.recommend'),
406
+ subject: z.string(),
407
+ createdAt: z.string().datetime()
408
+ });
409
+
410
+ // ============================================
411
+ // Graph Schemas (site.standard.graph.*, pub.leaflet.graph.*)
412
+ // ============================================
413
+
414
+ /**
415
+ * Subscription schema (site.standard.graph.subscription)
416
+ */
417
+ export const SubscriptionSchema = z.object({
418
+ $type: z.literal('site.standard.graph.subscription'),
419
+ publication: z.string()
420
+ });
421
+
422
+ /**
423
+ * Leaflet Subscription schema (pub.leaflet.graph.subscription)
424
+ */
425
+ export const LeafletSubscriptionSchema = z.object({
426
+ $type: z.literal('pub.leaflet.graph.subscription'),
427
+ publication: z.string()
428
+ });
429
+
430
+ // ============================================
431
+ // Content Schemas (pub.leaflet.content)
432
+ // ============================================
433
+
434
+ /**
435
+ * Position schema for quotes
436
+ */
437
+ export const PositionSchema = z.object({
438
+ block: z.array(z.number().int()),
439
+ offset: z.number().int()
440
+ });
441
+
442
+ /**
443
+ * Quote schema
444
+ */
445
+ export const QuoteSchema = z.object({
446
+ start: PositionSchema,
447
+ end: PositionSchema
448
+ });
449
+
450
+ /**
451
+ * Linear Document Page schema
452
+ */
453
+ export const LinearDocumentPageSchema = z.object({
454
+ $type: z.literal('pub.leaflet.pages.linearDocument'),
455
+ id: z.string().optional(),
456
+ blocks: z.array(z.object({
457
+ $type: z.literal('pub.leaflet.pages.linearDocument#block'),
458
+ block: z.any(),
459
+ alignment: z.enum(['#textAlignLeft', '#textAlignCenter', '#textAlignRight', '#textAlignJustify']).optional()
460
+ }))
461
+ });
462
+
463
+ /**
464
+ * Canvas Page schema
465
+ */
466
+ export const CanvasPageSchema = z.object({
467
+ $type: z.literal('pub.leaflet.pages.canvas'),
468
+ id: z.string().optional(),
469
+ blocks: z.array(z.object({
470
+ $type: z.literal('pub.leaflet.pages.canvas#block'),
471
+ block: z.any(),
472
+ x: z.number().int(),
473
+ y: z.number().int(),
474
+ width: z.number().int(),
475
+ height: z.number().int().optional(),
476
+ rotation: z.number().int().optional()
477
+ }))
478
+ });
479
+
480
+ /**
481
+ * Content schema (pub.leaflet.content)
482
+ */
483
+ export const ContentSchema = z.object({
484
+ $type: z.literal('pub.leaflet.content'),
485
+ pages: z.array(z.union([LinearDocumentPageSchema, CanvasPageSchema]))
486
+ });
487
+
488
+ // ============================================
127
489
  // Type exports
490
+ // ============================================
491
+
128
492
  export type RGBColor = z.infer<typeof RGBColorSchema>;
493
+ export type RGBAColor = z.infer<typeof RGBAColorSchema>;
494
+ export type Color = z.infer<typeof ColorSchema>;
495
+ export type BackgroundImage = z.infer<typeof BackgroundImageSchema>;
129
496
  export type BasicTheme = z.infer<typeof BasicThemeSchema>;
497
+ export type ExtendedTheme = z.infer<typeof ExtendedThemeSchema>;
130
498
  export type PublicationPreferences = z.infer<typeof PublicationPreferencesSchema>;
131
499
  export type AtProtoBlob = z.infer<typeof AtProtoBlobSchema>;
132
500
  export type StrongRef = z.infer<typeof StrongRefSchema>;
@@ -135,3 +503,46 @@ export type Document = z.infer<typeof DocumentSchema>;
135
503
  export type PublisherConfig = z.infer<typeof PublisherConfigSchema>;
136
504
  export type ReaderConfig = z.infer<typeof ReaderConfigSchema>;
137
505
  export type LoaderConfig = z.infer<typeof LoaderConfigSchema>;
506
+
507
+ // Rich text types
508
+ export type ByteSlice = z.infer<typeof ByteSliceSchema>;
509
+ export type LinkFeature = z.infer<typeof LinkFeatureSchema>;
510
+ export type DidMentionFeature = z.infer<typeof DidMentionFeatureSchema>;
511
+ export type AtMentionFeature = z.infer<typeof AtMentionFeatureSchema>;
512
+ export type CodeFeature = z.infer<typeof CodeFeatureSchema>;
513
+ export type HighlightFeature = z.infer<typeof HighlightFeatureSchema>;
514
+ export type UnderlineFeature = z.infer<typeof UnderlineFeatureSchema>;
515
+ export type StrikethroughFeature = z.infer<typeof StrikethroughFeatureSchema>;
516
+ export type BoldFeature = z.infer<typeof BoldFeatureSchema>;
517
+ export type ItalicFeature = z.infer<typeof ItalicFeatureSchema>;
518
+ export type IdFeature = z.infer<typeof IdFeatureSchema>;
519
+ export type FootnoteFeature = z.infer<typeof FootnoteFeatureSchema>;
520
+ export type FacetFeature = z.infer<typeof FacetFeatureSchema>;
521
+ export type Facet = z.infer<typeof FacetSchema>;
522
+
523
+ // Block types
524
+ export type TextBlock = z.infer<typeof TextBlockSchema>;
525
+ export type HeaderBlock = z.infer<typeof HeaderBlockSchema>;
526
+ export type OrderedListItem = z.infer<typeof OrderedListItemSchema>;
527
+ export type OrderedListBlock = z.infer<typeof OrderedListBlockSchema>;
528
+ export type UnorderedListItem = z.infer<typeof UnorderedListItemSchema>;
529
+ export type UnorderedListBlock = z.infer<typeof UnorderedListBlockSchema>;
530
+
531
+ // Comment types
532
+ export type LinearDocumentQuote = z.infer<typeof LinearDocumentQuoteSchema>;
533
+ export type CommentReplyRef = z.infer<typeof CommentReplyRefSchema>;
534
+ export type Comment = z.infer<typeof CommentSchema>;
535
+
536
+ // Interaction types
537
+ export type Recommend = z.infer<typeof RecommendSchema>;
538
+
539
+ // Graph types
540
+ export type Subscription = z.infer<typeof SubscriptionSchema>;
541
+ export type LeafletSubscription = z.infer<typeof LeafletSubscriptionSchema>;
542
+
543
+ // Content types
544
+ export type Position = z.infer<typeof PositionSchema>;
545
+ export type Quote = z.infer<typeof QuoteSchema>;
546
+ export type LinearDocumentPage = z.infer<typeof LinearDocumentPageSchema>;
547
+ export type CanvasPage = z.infer<typeof CanvasPageSchema>;
548
+ export type Content = z.infer<typeof ContentSchema>;