@abraca/junis 2.84.0 → 2.86.0

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 (178) hide show
  1. package/dist/module.d.mts +17 -2
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +270 -22
  4. package/dist/runtime/assets/css/jun.css +1 -1
  5. package/dist/runtime/components/JunBlobBackdrop.client.vue +1 -1
  6. package/dist/runtime/components/JunCampfirePresence.client.vue +75 -10
  7. package/dist/runtime/components/JunCollectionIntro.d.vue.ts +11 -0
  8. package/dist/runtime/components/JunCollectionIntro.vue +45 -0
  9. package/dist/runtime/components/JunCollectionIntro.vue.d.ts +11 -0
  10. package/dist/runtime/components/JunConfigRow.d.vue.ts +43 -0
  11. package/dist/runtime/components/JunConfigRow.vue +34 -0
  12. package/dist/runtime/components/JunConfigRow.vue.d.ts +43 -0
  13. package/dist/runtime/components/JunFooter.vue +1 -1
  14. package/dist/runtime/components/JunHead.vue +37 -5
  15. package/dist/runtime/components/JunHorizontalTimeline.d.vue.ts +30 -0
  16. package/dist/runtime/components/JunHorizontalTimeline.vue.d.ts +30 -0
  17. package/dist/runtime/components/JunLinksRow.d.vue.ts +16 -1
  18. package/dist/runtime/components/JunLinksRow.vue +17 -7
  19. package/dist/runtime/components/JunLinksRow.vue.d.ts +16 -1
  20. package/dist/runtime/components/JunLogo.vue +10 -45
  21. package/dist/runtime/components/JunMedia.client.d.vue.ts +1 -1
  22. package/dist/runtime/components/JunMedia.client.vue.d.ts +1 -1
  23. package/dist/runtime/components/JunNavigation.vue +21 -4
  24. package/dist/runtime/components/JunNoteLinks.d.vue.ts +6 -0
  25. package/dist/runtime/components/JunNoteLinks.vue +57 -0
  26. package/dist/runtime/components/JunNoteLinks.vue.d.ts +6 -0
  27. package/dist/runtime/components/JunPageHero.d.vue.ts +8 -2
  28. package/dist/runtime/components/JunPageHero.vue +15 -3
  29. package/dist/runtime/components/JunPageHero.vue.d.ts +8 -2
  30. package/dist/runtime/components/JunPatternBackdrop.client.vue +1 -1
  31. package/dist/runtime/components/JunReaders.d.vue.ts +11 -0
  32. package/dist/runtime/components/JunReaders.vue +99 -0
  33. package/dist/runtime/components/JunReaders.vue.d.ts +11 -0
  34. package/dist/runtime/components/JunSearch.client.vue +2 -2
  35. package/dist/runtime/components/JunSectionPresence.client.d.vue.ts +17 -0
  36. package/dist/runtime/components/JunSectionPresence.client.vue +99 -0
  37. package/dist/runtime/components/JunSectionPresence.client.vue.d.ts +17 -0
  38. package/dist/runtime/components/JunShaderBackdrop.client.vue +1 -1
  39. package/dist/runtime/components/JunThreadComposer.d.vue.ts +37 -0
  40. package/dist/runtime/components/JunThreadComposer.vue +54 -0
  41. package/dist/runtime/components/JunThreadComposer.vue.d.ts +37 -0
  42. package/dist/runtime/components/JunTravellersChip.vue +35 -5
  43. package/dist/runtime/components/JunVideoEmbed.client.d.vue.ts +1 -1
  44. package/dist/runtime/components/JunVideoEmbed.client.vue.d.ts +1 -1
  45. package/dist/runtime/components/JunViewControl.d.vue.ts +29 -0
  46. package/dist/runtime/components/JunViewControl.vue +340 -0
  47. package/dist/runtime/components/JunViewControl.vue.d.ts +29 -0
  48. package/dist/runtime/components/JunViewControls.d.vue.ts +27 -0
  49. package/dist/runtime/components/JunViewControls.vue +94 -0
  50. package/dist/runtime/components/JunViewControls.vue.d.ts +27 -0
  51. package/dist/runtime/components/renderers/JunAppsRenderer.vue +45 -4
  52. package/dist/runtime/components/renderers/JunCinemaRenderer.vue +42 -4
  53. package/dist/runtime/components/renderers/JunConfigRenderer.vue +362 -239
  54. package/dist/runtime/components/renderers/JunCourseRenderer.d.vue.ts +10 -0
  55. package/dist/runtime/components/renderers/JunCourseRenderer.vue +229 -0
  56. package/dist/runtime/components/renderers/JunCourseRenderer.vue.d.ts +10 -0
  57. package/dist/runtime/components/renderers/JunCvRenderer.vue +44 -6
  58. package/dist/runtime/components/renderers/JunDeckRenderer.d.vue.ts +9 -0
  59. package/dist/runtime/components/renderers/JunDeckRenderer.vue +370 -0
  60. package/dist/runtime/components/renderers/JunDeckRenderer.vue.d.ts +9 -0
  61. package/dist/runtime/components/renderers/JunEntryRenderer.vue +157 -31
  62. package/dist/runtime/components/renderers/JunFestivalRenderer.vue +42 -5
  63. package/dist/runtime/components/renderers/JunGardenRenderer.d.vue.ts +10 -0
  64. package/dist/runtime/components/renderers/JunGardenRenderer.vue +280 -0
  65. package/dist/runtime/components/renderers/JunGardenRenderer.vue.d.ts +10 -0
  66. package/dist/runtime/components/renderers/JunGuestbookRenderer.vue +96 -14
  67. package/dist/runtime/components/renderers/JunHomeRenderer.vue +31 -132
  68. package/dist/runtime/components/renderers/JunItemRenderer.d.vue.ts +10 -0
  69. package/dist/runtime/components/renderers/JunItemRenderer.vue +398 -0
  70. package/dist/runtime/components/renderers/JunItemRenderer.vue.d.ts +10 -0
  71. package/dist/runtime/components/renderers/JunJournalRenderer.vue +141 -11
  72. package/dist/runtime/components/renderers/JunLibraryRenderer.vue +295 -12
  73. package/dist/runtime/components/renderers/JunLinksRenderer.vue +33 -1
  74. package/dist/runtime/components/renderers/JunLiveRenderer.vue +38 -2
  75. package/dist/runtime/components/renderers/JunMosaicRenderer.vue +3 -2
  76. package/dist/runtime/components/renderers/JunMovieRenderer.vue +32 -5
  77. package/dist/runtime/components/renderers/JunNowRenderer.vue +40 -7
  78. package/dist/runtime/components/renderers/JunPollRenderer.d.vue.ts +9 -0
  79. package/dist/runtime/components/renderers/JunPollRenderer.vue +231 -0
  80. package/dist/runtime/components/renderers/JunPollRenderer.vue.d.ts +9 -0
  81. package/dist/runtime/components/renderers/JunProjectRenderer.vue +74 -18
  82. package/dist/runtime/components/renderers/JunServicesRenderer.vue +40 -2
  83. package/dist/runtime/components/renderers/JunStatsRenderer.vue +37 -50
  84. package/dist/runtime/components/renderers/JunThreadRenderer.d.vue.ts +9 -0
  85. package/dist/runtime/components/renderers/JunThreadRenderer.vue +304 -0
  86. package/dist/runtime/components/renderers/JunThreadRenderer.vue.d.ts +9 -0
  87. package/dist/runtime/components/renderers/JunTrackRenderer.vue +32 -4
  88. package/dist/runtime/components/renderers/JunUsesRenderer.vue +57 -13
  89. package/dist/runtime/components/renderers/JunWallRenderer.vue +60 -5
  90. package/dist/runtime/composables/useJunDeck.d.ts +66 -0
  91. package/dist/runtime/composables/useJunDeck.js +61 -0
  92. package/dist/runtime/composables/useJunDocPage.d.ts +14 -11
  93. package/dist/runtime/composables/useJunDocPage.js +67 -3
  94. package/dist/runtime/composables/useJunFollow.d.ts +65 -9
  95. package/dist/runtime/composables/useJunFollow.js +237 -20
  96. package/dist/runtime/composables/useJunGarden.d.ts +67 -0
  97. package/dist/runtime/composables/useJunGarden.js +92 -0
  98. package/dist/runtime/composables/useJunOptions.d.ts +1 -0
  99. package/dist/runtime/composables/useJunPresence.d.ts +26 -0
  100. package/dist/runtime/composables/useJunPresence.js +9 -2
  101. package/dist/runtime/composables/useJunSections.d.ts +73 -0
  102. package/dist/runtime/composables/useJunSections.js +117 -0
  103. package/dist/runtime/composables/useJunSettings.d.ts +1 -1
  104. package/dist/runtime/composables/useJunSettings.js +5 -1
  105. package/dist/runtime/composables/useJunSiteConfig.d.ts +37 -0
  106. package/dist/runtime/composables/useJunTheme.js +49 -50
  107. package/dist/runtime/composables/useJunViewOptions.d.ts +85 -0
  108. package/dist/runtime/composables/useJunViewOptions.js +63 -0
  109. package/dist/runtime/pages/doc.vue +14 -8
  110. package/dist/runtime/plugins/jun-sw.client.d.ts +2 -0
  111. package/dist/runtime/plugins/jun-sw.client.js +36 -0
  112. package/dist/runtime/server/api/health.get.d.ts +19 -0
  113. package/dist/runtime/server/api/health.get.js +40 -0
  114. package/dist/runtime/server/api/links.get.d.ts +19 -0
  115. package/dist/runtime/server/api/links.get.js +37 -0
  116. package/dist/runtime/server/api/resolve/[...slug].get.d.ts +9 -0
  117. package/dist/runtime/server/api/resolve/[...slug].get.js +5 -0
  118. package/dist/runtime/server/api/stats.get.js +2 -1
  119. package/dist/runtime/server/janitor/junJanitorChores.js +8 -0
  120. package/dist/runtime/server/plugins/jun-bootstrap.js +103 -15
  121. package/dist/runtime/server/plugins/jun-doc-cache.js +42 -4
  122. package/dist/runtime/server/plugins/jun-janitor.js +9 -1
  123. package/dist/runtime/server/plugins/jun-rpc.js +293 -0
  124. package/dist/runtime/server/plugins/jun-watchdog.d.ts +2 -0
  125. package/dist/runtime/server/plugins/jun-watchdog.js +54 -0
  126. package/dist/runtime/server/routes/jun-icon.png.get.d.ts +2 -0
  127. package/dist/runtime/server/routes/jun-icon.png.get.js +25 -0
  128. package/dist/runtime/server/routes/jun-icon.svg.get.d.ts +2 -0
  129. package/dist/runtime/server/routes/jun-icon.svg.get.js +9 -0
  130. package/dist/runtime/server/routes/jun-splash.png.get.d.ts +2 -0
  131. package/dist/runtime/server/routes/jun-splash.png.get.js +37 -0
  132. package/dist/runtime/server/routes/jun-sw.js.get.d.ts +2 -0
  133. package/dist/runtime/server/routes/jun-sw.js.get.js +126 -0
  134. package/dist/runtime/server/routes/manifest.webmanifest.get.d.ts +24 -0
  135. package/dist/runtime/server/routes/manifest.webmanifest.get.js +51 -0
  136. package/dist/runtime/server/routes/sitemap.xml.get.js +2 -0
  137. package/dist/runtime/server/utils/junBoot.d.ts +1 -0
  138. package/dist/runtime/server/utils/junBoot.js +4 -0
  139. package/dist/runtime/server/utils/junBrand.d.ts +4 -0
  140. package/dist/runtime/server/utils/junBrand.js +9 -0
  141. package/dist/runtime/server/utils/junCache.d.ts +17 -0
  142. package/dist/runtime/server/utils/junCache.js +5 -0
  143. package/dist/runtime/server/utils/junIcon.d.ts +44 -0
  144. package/dist/runtime/server/utils/junIcon.js +374 -0
  145. package/dist/runtime/server/utils/junSeedGate.d.ts +68 -0
  146. package/dist/runtime/server/utils/junSeedGate.js +41 -0
  147. package/dist/runtime/types.d.ts +82 -3
  148. package/dist/runtime/utils/junCourse.d.ts +106 -0
  149. package/dist/runtime/utils/junCourse.js +65 -0
  150. package/dist/runtime/utils/junGarden.d.ts +193 -0
  151. package/dist/runtime/utils/junGarden.js +233 -0
  152. package/dist/runtime/utils/junIdentity.d.ts +121 -0
  153. package/dist/runtime/utils/junIdentity.js +115 -0
  154. package/dist/runtime/utils/junMark.d.ts +254 -0
  155. package/dist/runtime/utils/junMark.js +169 -0
  156. package/dist/runtime/utils/junMetaSchemas.js +8 -1
  157. package/dist/runtime/utils/junModeration.d.ts +67 -0
  158. package/dist/runtime/utils/junModeration.js +20 -0
  159. package/dist/runtime/utils/junMotion.d.ts +26 -0
  160. package/dist/runtime/utils/junMotion.js +31 -0
  161. package/dist/runtime/utils/junPeople.d.ts +43 -0
  162. package/dist/runtime/utils/junPeople.js +9 -0
  163. package/dist/runtime/utils/junPoll.d.ts +79 -0
  164. package/dist/runtime/utils/junPoll.js +82 -0
  165. package/dist/runtime/utils/junReadiness.d.ts +131 -0
  166. package/dist/runtime/utils/junReadiness.js +69 -0
  167. package/dist/runtime/utils/junSections.d.ts +115 -0
  168. package/dist/runtime/utils/junSections.js +45 -0
  169. package/dist/runtime/utils/junSlides.d.ts +66 -0
  170. package/dist/runtime/utils/junSlides.js +47 -0
  171. package/dist/runtime/utils/junThread.d.ts +81 -0
  172. package/dist/runtime/utils/junThread.js +75 -0
  173. package/dist/runtime/utils/junViewSpecs.d.ts +671 -0
  174. package/dist/runtime/utils/junViewSpecs.js +534 -0
  175. package/dist/runtime/utils/junViewValues.d.ts +125 -0
  176. package/dist/runtime/utils/junViewValues.js +104 -0
  177. package/dist/types.d.mts +1 -1
  178. package/package.json +5 -1
@@ -16,7 +16,7 @@
16
16
  * - DETAIL pages are the children of a list page and render one document.
17
17
  * - SYSTEM pages are singletons that configure or describe the site itself.
18
18
  */
19
- export type JunPageTypeKey = 'apps' | 'journal' | 'live' | 'links' | 'cv' | 'wall' | 'uses' | 'library' | 'guestbook' | 'cinema' | 'festival' | 'services' | 'app' | 'entry' | 'now' | 'movie' | 'track' | 'globe' | 'mosaic' | 'config' | 'redirect' | 'stats' | 'home';
19
+ export type JunPageTypeKey = 'apps' | 'journal' | 'live' | 'links' | 'cv' | 'wall' | 'uses' | 'library' | 'guestbook' | 'cinema' | 'festival' | 'services' | 'poll' | 'thread' | 'garden' | 'course' | 'app' | 'entry' | 'now' | 'movie' | 'track' | 'globe' | 'mosaic' | 'deck' | 'config' | 'redirect' | 'stats' | 'home';
20
20
  /** Per-page-type overrides. `true` keeps every default; `false` never registers it. */
21
21
  export interface JunPageTypeOverride {
22
22
  /** Display name in pickers, breadcrumbs and the type switcher. */
@@ -585,10 +585,25 @@ export interface JunBrand {
585
585
  logoVariant?: JunLogoVariant;
586
586
  /** PWA / browser theme colour. */
587
587
  themeColor?: string;
588
+ /**
589
+ * The tile the app icon is drawn on — the home-screen square, before iOS
590
+ * rounds it and Android crops it. Defaults to `themeColor`.
591
+ *
592
+ * It is ONE colour rather than a per-scheme pair, and that is not an
593
+ * omission: a home-screen icon sits on whatever wallpaper the person chose
594
+ * and never follows the site's colour mode. The mark is drawn in its DARK
595
+ * colours on it, because the default tile is near-black and the light mark's
596
+ * ink is near-black too.
597
+ */
598
+ iconBackground?: string;
588
599
  /**
589
600
  * PWA manifest icons. Public paths, since the manifest is fetched by the
590
- * browser rather than bundled. Omit and no manifest icons are declared —
591
- * which is better than pointing at files a site does not have.
601
+ * browser rather than bundled.
602
+ *
603
+ * Only needed to OVERRIDE the module's own: `/jun-icon.png?size=…` renders
604
+ * the site's configured mark in its configured accent, at any size, so a site
605
+ * that has not drawn its own artwork still installs with a real icon rather
606
+ * than with a screenshot of its front page.
592
607
  */
593
608
  icons?: {
594
609
  src: string;
@@ -785,6 +800,21 @@ export interface JunMosaicOptions {
785
800
  */
786
801
  maxDepth?: number;
787
802
  }
803
+ /**
804
+ * The site's house style for its renderers — page-type KEY → option key →
805
+ * value, e.g. `{ library: { variant: 'grid', covers: true } }`.
806
+ *
807
+ * Read by `useJunViewOptions`, which resolves a page's display settings in three
808
+ * steps: the document's own `meta.junView`, then this, then the renderer's own
809
+ * default. A document that stores nothing follows whatever is set here, so
810
+ * changing a value later reaches every page that never disagreed with it.
811
+ *
812
+ * Deliberately loose: each renderer declares its own option keys next to the
813
+ * layout they drive, so a union of every valid key would have to be maintained
814
+ * here as well and would be wrong the moment a renderer gained an option.
815
+ * Unknown keys and out-of-range values are ignored rather than rendered.
816
+ */
817
+ export type JunRendererDefaults = Record<string, Record<string, string | boolean | number>>;
788
818
  /** Which external-service adapters the `services` page type may call. */
789
819
  export interface JunServicesOptions {
790
820
  /**
@@ -808,6 +838,8 @@ export interface JunRuntimeOptions {
808
838
  logoMark: JunLogoMark;
809
839
  logoVariant: JunLogoVariant;
810
840
  themeColor: string;
841
+ /** The app-icon tile. Defaults to `themeColor`; see `JunBrand`. */
842
+ iconBackground: string;
811
843
  schemaType: JunBrand['schemaType'];
812
844
  };
813
845
  features: Required<JunFeatures>;
@@ -849,6 +881,12 @@ export interface JunRuntimeOptions {
849
881
  paletteMap: Record<string, string>;
850
882
  /** Where the module's own API routes live. Change only to avoid a collision. */
851
883
  apiBase: string;
884
+ /**
885
+ * Whether the module contributes app identity — manifest, icons, launch
886
+ * screens and a service worker. Read at RUNTIME by the service-worker
887
+ * plugin, which cannot see module options.
888
+ */
889
+ pwa: boolean;
852
890
  /** Mapbox token for the globe. Empty unless the site sets one. */
853
891
  mapboxToken: string;
854
892
  /** Third-party media policy. See `JunEmbedOptions`. */
@@ -857,6 +895,11 @@ export interface JunRuntimeOptions {
857
895
  mosaic: Required<JunMosaicOptions>;
858
896
  /** Enabled service adapters + their cache TTL. See `JunServicesOptions`. */
859
897
  services: Required<JunServicesOptions>;
898
+ /**
899
+ * Per-page-type display defaults — the site's house style, resolved under
900
+ * each document's own `meta.junView`. See `JunRendererDefaults`.
901
+ */
902
+ renderers: JunRendererDefaults;
860
903
  /** Clicking a node in a renderer: navigate to its page, or open the slideover. */
861
904
  nodePanel: 'navigate' | 'slideover';
862
905
  /** Which context-menu items exist. Resolved — every key filled. */
@@ -876,4 +919,40 @@ export interface JunRuntimeOptions {
876
919
  * client-only and never runs for them.
877
920
  */
878
921
  jsonLd: Record<string, JunJsonLdSpec>;
922
+ /**
923
+ * COLLECTION type id → how its unclaimed children present as pages.
924
+ *
925
+ * A Library row, a gear item, a CV station and a links row are all
926
+ * `type: 'doc'` children of a typed parent. They are reachable — every
927
+ * collection renderer links each row to its own page — and until this
928
+ * existed they rendered as a bare editor: no cover, no author, no rating,
929
+ * nothing the shelf above them displays.
930
+ *
931
+ * The presentation is derived from the PARENT rather than from a type on
932
+ * the child, and that is the whole design. Children are `doc` on every site
933
+ * that already exists, so a child-side type would have improved nothing
934
+ * without a migration — and it would have fought the rule that makes page
935
+ * types convertible in the first place: a collection renders every child,
936
+ * including one it did not create.
937
+ *
938
+ * A child with its OWN registered type (an `entry` under a journal, a
939
+ * `movie` under a cinema) is never overridden — it has a renderer already.
940
+ */
941
+ itemParents: Record<string, JunItemPresentation>;
942
+ /**
943
+ * The registered type id the item renderer is mounted under. Internal: it
944
+ * is not a `JunPageTypeKey`, never appears in the type switcher, and is
945
+ * never written to a document — pages are handed it as a synthetic type at
946
+ * render time.
947
+ */
948
+ itemType: string;
949
+ }
950
+ /** How one collection's unclaimed children render as their own pages. */
951
+ export interface JunItemPresentation {
952
+ /** Singular noun for the back-link and the type line — "Book", "Tool". */
953
+ label: string;
954
+ /** Lucide icon for the item, when the document has none of its own. */
955
+ icon: string;
956
+ /** Structured data for the item, built from the server cache like every other. */
957
+ jsonLd?: JunJsonLdSpec;
879
958
  }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * The arithmetic behind `jun-course` — a page you get THROUGH.
3
+ *
4
+ * No Vue, no `#imports`, **no imports at all**: the server validates a step and
5
+ * writes progress, the page draws two progress figures from the same data, and a
6
+ * test runs both without a Nuxt app. The server and the page must never disagree
7
+ * about how far somebody is.
8
+ *
9
+ * ── Progress is per PERSON, and the server writes it ─────────────────────────
10
+ *
11
+ * A visitor has no CRDT write access, so ticking a step goes through RPC v1 and
12
+ * lands under the identity the SERVER stamped (`meta.courseProgress[from]`). The
13
+ * same rule as the poll's ballots, for a stronger reason: progress is a claim
14
+ * about a person, so a second tab, a reload and a reconnect are one learner.
15
+ *
16
+ * ── Two numbers, and they answer different questions ─────────────────────────
17
+ *
18
+ * **How far YOU are** is the one a learner came for. **How far the ROOM is** is
19
+ * the one only a live document can offer — "nine people have finished this, you
20
+ * are on step three" is a fact about a shared page, not a progress bar.
21
+ *
22
+ * ── What it must not do ──────────────────────────────────────────────────────
23
+ *
24
+ * **No gating.** `junNextStep` says where to go next; nothing here says a step may
25
+ * not be opened. The steps are pages with their own URLs on a public website, so a
26
+ * lock a reader walks around by typing a path is theatre — and a lock that worked
27
+ * would mean hiding documents from the tree, which breaks search, the feed and the
28
+ * sitemap.
29
+ */
30
+ /** How many people's progress one course may hold. */
31
+ export declare const JUN_COURSE_MAX_PEOPLE = 5000;
32
+ /** How many steps one person's progress may name. */
33
+ export declare const JUN_COURSE_MAX_STEPS = 200;
34
+ export interface JunCourseStepInput {
35
+ id: string;
36
+ label?: string;
37
+ order?: number;
38
+ trashed?: boolean;
39
+ meta?: Record<string, unknown> | null;
40
+ }
41
+ export interface JunCourseStep {
42
+ id: string;
43
+ label: string;
44
+ /** 1-based, for display — a step called "0" reads as an error. */
45
+ number: number;
46
+ done: boolean;
47
+ /** How many people have finished this one. */
48
+ finishedBy: number;
49
+ }
50
+ /**
51
+ * The steps, in the owner's order.
52
+ *
53
+ * Trashed children drop out; a child with no label is still a step (an owner mid
54
+ * -typing must not see the list renumber itself), and hidden ones stay, because
55
+ * `meta.hidden` means "not in navigation" and never "not there".
56
+ */
57
+ export declare function junCourseSteps(children: JunCourseStepInput[]): JunCourseStepInput[];
58
+ /**
59
+ * `meta.courseProgress`, validated.
60
+ *
61
+ * Every layer is checked because this is stored data a newer build may have
62
+ * written: a non-object, a non-array value, a non-string step id and a step that
63
+ * is not in this course are all dropped rather than counted. An uncounted step
64
+ * would inflate somebody's progress past 100%.
65
+ */
66
+ export declare function junCourseProgress(meta: Record<string, unknown> | null | undefined, stepIds: string[]): Record<string, string[]>;
67
+ export interface JunCourseView {
68
+ steps: JunCourseStep[];
69
+ /** Steps this person has finished. */
70
+ done: number;
71
+ total: number;
72
+ /** 0–100, rounded. 100 only when every step is done. */
73
+ percent: number;
74
+ /** The first unfinished step, or `null` when there are none left. */
75
+ next: JunCourseStep | null;
76
+ /** People who have finished at least one step. */
77
+ people: number;
78
+ /** People who have finished every step. */
79
+ finished: number;
80
+ }
81
+ /**
82
+ * Everything a course page draws, from the steps and the stored progress.
83
+ *
84
+ * One function rather than six, because the figures have to be consistent with
85
+ * each other: a bar at 100% beside a "continue" button pointing at step three is
86
+ * the failure this shape makes impossible.
87
+ */
88
+ export declare function junCourseView(children: JunCourseStepInput[], meta: Record<string, unknown> | null | undefined, selfId: string | null | undefined): JunCourseView;
89
+ /**
90
+ * One person's next progress list after ticking a step.
91
+ *
92
+ * Returns `null` to REFUSE — an unknown step id, which is the server's check as
93
+ * well as the page's. Ticking is a toggle: a learner who marked a step by mistake
94
+ * must be able to unmark it, and a course that only counts up is a course people
95
+ * stop trusting.
96
+ */
97
+ export declare function junNextProgress(current: string[] | undefined, stepIds: string[], stepId: string): string[] | null;
98
+ /**
99
+ * Cap the number of PEOPLE a course remembers.
100
+ *
101
+ * Unbounded growth in one document's meta is the hazard the poll's ballots have
102
+ * too: every visitor's progress lives in the course's own entry, which every
103
+ * client syncs. Past the cap, new people are not recorded — their progress still
104
+ * works for the session, and the alternative (dropping somebody else's) is worse.
105
+ */
106
+ export declare function junCapProgress(progress: Record<string, string[]>, person: string, max?: number): boolean;
@@ -0,0 +1,65 @@
1
+ export const JUN_COURSE_MAX_PEOPLE = 5e3;
2
+ export const JUN_COURSE_MAX_STEPS = 200;
3
+ export function junCourseSteps(children) {
4
+ return children.filter((child) => !!child?.id && !child.trashed).slice().sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
5
+ }
6
+ export function junCourseProgress(meta, stepIds) {
7
+ const raw = meta?.courseProgress;
8
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
9
+ const known = new Set(stepIds);
10
+ const out = {};
11
+ for (const [person, value] of Object.entries(raw)) {
12
+ if (!person || !Array.isArray(value)) continue;
13
+ const seen = /* @__PURE__ */ new Set();
14
+ for (const id of value) {
15
+ if (typeof id !== "string" || !known.has(id) || seen.has(id)) continue;
16
+ seen.add(id);
17
+ if (seen.size >= JUN_COURSE_MAX_STEPS) break;
18
+ }
19
+ if (seen.size) out[person] = [...seen];
20
+ }
21
+ return out;
22
+ }
23
+ export function junCourseView(children, meta, selfId) {
24
+ const ordered = junCourseSteps(children);
25
+ const ids = ordered.map((step) => step.id);
26
+ const progress = junCourseProgress(meta, ids);
27
+ const mine = new Set(selfId ? progress[selfId] ?? [] : []);
28
+ const finishedBy = /* @__PURE__ */ new Map();
29
+ let finished = 0;
30
+ for (const list of Object.values(progress)) {
31
+ for (const id of list) finishedBy.set(id, (finishedBy.get(id) ?? 0) + 1);
32
+ if (ids.length > 0 && list.length === ids.length) finished++;
33
+ }
34
+ const steps = ordered.map((step, i) => ({
35
+ id: step.id,
36
+ label: (step.label ?? "").trim() || `Step ${i + 1}`,
37
+ number: i + 1,
38
+ done: mine.has(step.id),
39
+ finishedBy: finishedBy.get(step.id) ?? 0
40
+ }));
41
+ const done = steps.filter((step) => step.done).length;
42
+ const total = steps.length;
43
+ return {
44
+ steps,
45
+ done,
46
+ total,
47
+ // Rounded, but never 99 for a finished course and never 100 for an unfinished
48
+ // one: `Math.round` alone would report 100% at 199 of 200 steps.
49
+ percent: total === 0 ? 0 : done === total ? 100 : Math.min(99, Math.round(done / total * 100)),
50
+ next: steps.find((step) => !step.done) ?? null,
51
+ people: Object.keys(progress).length,
52
+ finished
53
+ };
54
+ }
55
+ export function junNextProgress(current, stepIds, stepId) {
56
+ if (!stepIds.includes(stepId)) return null;
57
+ const seen = new Set((current ?? []).filter((id) => stepIds.includes(id)));
58
+ if (seen.has(stepId)) seen.delete(stepId);
59
+ else if (seen.size >= JUN_COURSE_MAX_STEPS) return null;
60
+ else seen.add(stepId);
61
+ return stepIds.filter((id) => seen.has(id));
62
+ }
63
+ export function junCapProgress(progress, person, max = JUN_COURSE_MAX_PEOPLE) {
64
+ return person in progress || Object.keys(progress).length < max;
65
+ }
@@ -0,0 +1,193 @@
1
+ /**
2
+ * The arithmetic behind `jun-garden` — a document tree read as a graph.
3
+ *
4
+ * No Vue, no `#imports`, **no imports at all**: the endpoint builds the edges in
5
+ * Nitro, the renderer draws them in a browser, and a test runs both without a
6
+ * Nuxt app anywhere. Three things live here.
7
+ *
8
+ * ── 1. Two kinds of link, and the second one is the common case ──────────────
9
+ *
10
+ * The platform has a wiki-style reference: `[[doc]]` in the editor becomes a link
11
+ * to `/doc/<id>` (or a `docLink` / `docEmbed` node carrying `data-doc-id`). That
12
+ * is the one a graph view is obviously supposed to follow.
13
+ *
14
+ * It is not the one people write. Somebody linking one note to another usually
15
+ * writes an ordinary link to the other page's PATH, because that is what a link
16
+ * is. A garden that understood only its own syntax would show an empty graph on a
17
+ * site full of cross-references — so a path resolves too, through the slug map
18
+ * the site already keeps for routing.
19
+ *
20
+ * An external link is not an edge, and neither is a path this site does not have:
21
+ * a graph must not invent a node for `/notes/something-i-never-wrote`.
22
+ *
23
+ * ── 2. Maturity is a claim, and an unstated one is not `seedling` ────────────
24
+ *
25
+ * `junMaturityOf` returns **null** for a note whose author never said. Defaulting
26
+ * to `seedling` would print a judgement on every page that predates the setting —
27
+ * the site would appear to claim that a decade of tended writing is rough drafts.
28
+ *
29
+ * ── 3. The layout has to be deterministic ────────────────────────────────────
30
+ *
31
+ * The same graph is drawn during SSR and again after hydration. A force layout
32
+ * seeded from `Math.random()` is therefore a hydration mismatch BY CONSTRUCTION —
33
+ * every node in a different place on the client than the server sent. So: fixed
34
+ * starting positions, a fixed iteration count, no randomness anywhere, and the
35
+ * same input gives the same picture on both sides and in a test.
36
+ */
37
+ export type JunMaturity = 'seedling' | 'budding' | 'evergreen';
38
+ /**
39
+ * The three states, in growing order — the ONE copy. The leaf page's `select`
40
+ * control, the garden's badges and its filter all read this list, and a fourth
41
+ * state added in two of the three places is how a note becomes unfilterable.
42
+ */
43
+ export declare const JUN_MATURITIES: readonly [{
44
+ readonly value: "seedling";
45
+ readonly label: "Seedling";
46
+ readonly icon: "i-lucide-sprout";
47
+ readonly hint: "Rough, and says so";
48
+ }, {
49
+ readonly value: "budding";
50
+ readonly label: "Budding";
51
+ readonly icon: "i-lucide-flower-2";
52
+ readonly hint: "Taking shape";
53
+ }, {
54
+ readonly value: "evergreen";
55
+ readonly label: "Evergreen";
56
+ readonly icon: "i-lucide-trees";
57
+ readonly hint: "Tended, and holds up";
58
+ }];
59
+ /**
60
+ * A note's stated maturity, or `null` when its author never stated one.
61
+ *
62
+ * An unknown value — written by a newer build with a fourth state — reads as
63
+ * unstated rather than rendering a badge with no label, the same rule every view
64
+ * option here follows.
65
+ */
66
+ export declare function junMaturityOf(meta: Record<string, unknown> | undefined | null): JunMaturity | null;
67
+ /**
68
+ * Every link target in a rendered body, in document order, duplicates included.
69
+ *
70
+ * Both shapes: an `<a href>` (which is what a `[[doc]]` reference and an ordinary
71
+ * internal link both become) and a `data-doc-id` attribute (which is what an
72
+ * embed node renders as). Duplicates are kept — how MANY times one note points at
73
+ * another is a real quantity, and de-duplication is the edge builder's job.
74
+ */
75
+ export declare function junScanLinkTargets(html: string | null | undefined): string[];
76
+ /**
77
+ * Resolve one link target to a document id in THIS site, or `null`.
78
+ *
79
+ * `null` covers four separate cases on purpose, because all four mean "not an
80
+ * edge": an external URL, an in-page anchor, a `/doc/<id>` for a document this
81
+ * site does not have, and a path that resolves to nothing. A graph that guessed
82
+ * on any of them would draw a node for a page that does not exist.
83
+ */
84
+ export declare function junResolveLinkTarget(target: string, slugToId: Record<string, string>, knownIds: ReadonlySet<string>): string | null;
85
+ export interface JunGardenEdge {
86
+ source: string;
87
+ target: string;
88
+ /** How many links point that way. A note cited three times is not cited once. */
89
+ weight: number;
90
+ }
91
+ export interface JunGardenSource {
92
+ id: string;
93
+ /** The rendered body, as the doc cache holds it. */
94
+ html?: string | null;
95
+ /** Already-scanned targets, for a caller that has them (the live client). */
96
+ targets?: string[];
97
+ }
98
+ /**
99
+ * Every edge in the site, deduplicated and weighted.
100
+ *
101
+ * A self-link is dropped: a note that mentions its own path is not connected to
102
+ * itself, and drawing that would put a loop on the busiest node on every site
103
+ * with a "back to the top" link.
104
+ */
105
+ export declare function junGardenEdges(sources: JunGardenSource[], slugToId: Record<string, string>, knownIds: ReadonlySet<string>): JunGardenEdge[];
106
+ export interface JunGardenEntryInput {
107
+ id: string;
108
+ label?: string;
109
+ href?: string;
110
+ type?: string;
111
+ updatedAt?: number;
112
+ createdAt?: number;
113
+ meta?: Record<string, unknown> | null;
114
+ }
115
+ export interface JunGardenRef {
116
+ id: string;
117
+ label: string;
118
+ href?: string;
119
+ weight: number;
120
+ }
121
+ export interface JunGardenNote {
122
+ id: string;
123
+ label: string;
124
+ href?: string;
125
+ type?: string;
126
+ maturity: JunMaturity | null;
127
+ updatedAt: number;
128
+ /** What points HERE — the thing a garden owner opens the page for. */
129
+ inbound: JunGardenRef[];
130
+ /** What this note points at. */
131
+ outbound: JunGardenRef[];
132
+ /** Both directions, which is what the graph draws a node's size from. */
133
+ degree: number;
134
+ }
135
+ /**
136
+ * Shape the graph into notes.
137
+ *
138
+ * `scope` is which documents the garden OWNS — its own notes. Inbound links are
139
+ * resolved against every entry in the site, because a note being cited from
140
+ * outside the garden is still a citation, and a garden that only counted its own
141
+ * children would call a widely-linked note an orphan.
142
+ */
143
+ export declare function junGardenNotes(entries: JunGardenEntryInput[], edges: JunGardenEdge[], scope: ReadonlySet<string>): JunGardenNote[];
144
+ /**
145
+ * The notes nothing points at.
146
+ *
147
+ * Outbound links do not save a note from this list — a page that links out and is
148
+ * never linked to is exactly the page an owner has lost track of, which is the
149
+ * one question a garden exists to answer.
150
+ */
151
+ export declare function junGardenOrphans(notes: JunGardenNote[]): JunGardenNote[];
152
+ export type JunGardenSort = 'links' | 'recent' | 'alpha';
153
+ /** Order the notes. Ties break on the label, so the list never shuffles. */
154
+ export declare function junGardenSort(notes: JunGardenNote[], key: JunGardenSort): JunGardenNote[];
155
+ /** The one-line summary above the graph. */
156
+ export declare function junGardenCounts(notes: JunGardenNote[]): {
157
+ notes: number;
158
+ links: number;
159
+ orphans: number;
160
+ evergreen: number;
161
+ };
162
+ export interface JunGardenPoint {
163
+ id: string;
164
+ x: number;
165
+ y: number;
166
+ }
167
+ export interface JunGardenLayoutOptions {
168
+ width?: number;
169
+ height?: number;
170
+ /** Ideal edge length, as a multiple of the natural spacing. */
171
+ spread?: number;
172
+ /** Fixed, and part of the contract: the count is what makes this repeatable. */
173
+ iterations?: number;
174
+ padding?: number;
175
+ }
176
+ /**
177
+ * A force-directed layout, hand-rolled and deterministic.
178
+ *
179
+ * Fruchterman-Reingold: every pair of nodes repels, every edge attracts, and a
180
+ * cooling schedule stops the whole thing oscillating. ~60 lines, which is why
181
+ * this is written here rather than taken as a dependency — `d3-force` is a
182
+ * playground dependency and must stay one, the same way this repo writes its own
183
+ * rasteriser and its own TOML reader.
184
+ *
185
+ * **Nothing random.** Starting positions come off a golden-angle spiral (an even
186
+ * spread with no clumps to unstick) and the iteration count is fixed, so the
187
+ * server and the client draw the same picture and a test can assert positions.
188
+ *
189
+ * Coincident nodes are nudged apart by a value derived from their INDEX rather
190
+ * than a random jitter: two nodes at the same point produce a zero-length vector,
191
+ * and dividing by it is how a layout fills with `NaN` and paints nothing.
192
+ */
193
+ export declare function junGardenLayout(ids: string[], edges: JunGardenEdge[], options?: JunGardenLayoutOptions): JunGardenPoint[];