@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
@@ -0,0 +1,117 @@
1
+ import { computed, onBeforeUnmount, onMounted, ref } from "vue";
2
+ import { useAAEphemeral } from "#imports";
3
+ import {
4
+ JUN_READING_LINE,
5
+ junCurrentSectionIndex,
6
+ junSectionLabel,
7
+ junSlugSection
8
+ } from "../utils/junSections.js";
9
+ export const JUN_SECTION_FIELD = "junSection";
10
+ const HEADING_SELECTOR = "h1, h2, h3";
11
+ export function useJunSectionMarks() {
12
+ const { peers: raw, setLocal } = useAAEphemeral(JUN_SECTION_FIELD);
13
+ const peers = computed(() => {
14
+ const out = [];
15
+ for (const peer of raw.value) {
16
+ const mark = peer.value;
17
+ if (!mark || typeof mark.d !== "string" || typeof mark.i !== "number") continue;
18
+ out.push({
19
+ clientId: peer.clientId,
20
+ name: peer.user?.name || "Traveller",
21
+ color: peer.user?.color || "var(--ui-text-muted)",
22
+ publicKey: typeof peer.user?.publicKey === "string" ? peer.user.publicKey : null,
23
+ mark: { d: mark.d, i: mark.i, t: typeof mark.t === "string" ? mark.t : "" }
24
+ });
25
+ }
26
+ return out;
27
+ });
28
+ function markFor(clientId) {
29
+ if (clientId == null) return null;
30
+ return peers.value.find((p) => p.clientId === clientId)?.mark ?? null;
31
+ }
32
+ return { peers, markFor, setLocal };
33
+ }
34
+ export function useJunSectionScan(container) {
35
+ const headings = ref([]);
36
+ const currentIndex = ref(-1);
37
+ if (import.meta.server) return { headings, currentIndex, measure: () => {
38
+ } };
39
+ let frame = null;
40
+ let mutations = null;
41
+ let resizes = null;
42
+ function scan() {
43
+ const root = container.value;
44
+ if (!root) {
45
+ headings.value = [];
46
+ return;
47
+ }
48
+ const rootTop = root.getBoundingClientRect().top;
49
+ const found = [];
50
+ let index = 0;
51
+ for (const el of root.querySelectorAll(HEADING_SELECTOR)) {
52
+ const text = (el.textContent ?? "").replace(/\s+/g, " ").trim();
53
+ if (!text) continue;
54
+ const rect = el.getBoundingClientRect();
55
+ if (rect.width === 0 && rect.height === 0) continue;
56
+ found.push({
57
+ index: index++,
58
+ level: Number(el.tagName.slice(1)) || 2,
59
+ text,
60
+ slug: junSlugSection(text),
61
+ offset: Math.round(el.getBoundingClientRect().top - rootTop)
62
+ });
63
+ }
64
+ headings.value = found;
65
+ }
66
+ function locate() {
67
+ const root = container.value;
68
+ if (!root || !headings.value.length) {
69
+ currentIndex.value = -1;
70
+ return;
71
+ }
72
+ const rootTop = root.getBoundingClientRect().top;
73
+ const line = window.innerHeight * JUN_READING_LINE;
74
+ currentIndex.value = junCurrentSectionIndex(
75
+ headings.value.map((h) => rootTop + h.offset),
76
+ line
77
+ );
78
+ }
79
+ function schedule(rescan) {
80
+ if (frame != null) return;
81
+ frame = requestAnimationFrame(() => {
82
+ frame = null;
83
+ if (rescan) scan();
84
+ locate();
85
+ });
86
+ }
87
+ const onScroll = () => schedule(false);
88
+ const onResize = () => schedule(true);
89
+ function measure() {
90
+ scan();
91
+ locate();
92
+ }
93
+ onMounted(() => {
94
+ measure();
95
+ window.addEventListener("scroll", onScroll, { passive: true });
96
+ window.addEventListener("resize", onResize, { passive: true });
97
+ const root = container.value;
98
+ if (root) {
99
+ mutations = new MutationObserver(() => schedule(true));
100
+ mutations.observe(root, { childList: true, subtree: true, characterData: true });
101
+ resizes = new ResizeObserver(() => schedule(true));
102
+ resizes.observe(root);
103
+ }
104
+ });
105
+ onBeforeUnmount(() => {
106
+ if (frame != null) cancelAnimationFrame(frame);
107
+ window.removeEventListener("scroll", onScroll);
108
+ window.removeEventListener("resize", onResize);
109
+ mutations?.disconnect();
110
+ resizes?.disconnect();
111
+ });
112
+ return { headings, currentIndex, measure };
113
+ }
114
+ export function junSectionText(mark, max) {
115
+ if (!mark?.t) return "";
116
+ return junSectionLabel(mark.t, max);
117
+ }
@@ -1,4 +1,4 @@
1
- export type JunSettingsSection = 'identity' | 'navigation' | 'mark' | 'theme' | 'announcement' | 'campfire' | 'footer' | 'visitors';
1
+ export type JunSettingsSection = 'identity' | 'navigation' | 'mark' | 'theme' | 'announcement' | 'campfire' | 'footer' | 'visitors' | 'renderers';
2
2
  export interface JunSettingsSectionDef {
3
3
  id: JunSettingsSection;
4
4
  label: string;
@@ -7,7 +7,11 @@ export const JUN_SETTINGS_SECTIONS = [
7
7
  { id: "announcement", label: "Announcement", icon: "i-lucide-megaphone", hint: "The ribbon across the top" },
8
8
  { id: "campfire", label: "User center", icon: "i-lucide-flame", hint: "Chat, presence, reactions" },
9
9
  { id: "footer", label: "Footer", icon: "i-lucide-panel-bottom", hint: "The line at the bottom" },
10
- { id: "visitors", label: "Visitors", icon: "i-lucide-users", hint: "Guestbook, feeds, people" }
10
+ { id: "visitors", label: "Visitors", icon: "i-lucide-users", hint: "Guestbook, feeds, people" },
11
+ // Last, because it is the only section that configures CONTENT rather than
12
+ // chrome — and the only one whose controls are generated from the renderers'
13
+ // own specs rather than written out here.
14
+ { id: "renderers", label: "Page types", icon: "i-lucide-sliders-horizontal", hint: "How each kind of page looks, site-wide" }
11
15
  ];
12
16
  const DEFAULT_SECTION = "identity";
13
17
  const open = ref(false);
@@ -181,6 +181,43 @@ export interface JunSiteConfig {
181
181
  authorName?: string;
182
182
  /** Custom copy on the themed 404 page. */
183
183
  notFoundText?: string;
184
+ /**
185
+ * The site's HOUSE STYLE for its renderers — `{ library: { variant: 'shelf' } }`.
186
+ *
187
+ * The middle layer of `useJunViewOptions`, and until now the only layer an owner
188
+ * could not reach: it was `jun.renderers` in `nuxt.config`, evaluated when the
189
+ * app is BUILT. So "every library on this site uses the shelf" meant editing
190
+ * source and redeploying, which is the opposite of how everything else here
191
+ * works. The build-time value stays as the deploy's default; this wins over it,
192
+ * per key, per type.
193
+ */
194
+ renderers?: Record<string, Record<string, unknown>>;
195
+ /**
196
+ * How big the site reads. A percentage on the ROOT font size, so it scales the
197
+ * type and every rem-based measurement with it — which is what makes it a
198
+ * scale rather than a font-size override that leaves the spacing behind.
199
+ */
200
+ typeScale?: 'small' | 'normal' | 'large';
201
+ /**
202
+ * How airy the reading column is: line height and the space between
203
+ * paragraphs. Separate from the type scale on purpose — a site can read large
204
+ * and tight, or small and generous, and those are different requests.
205
+ */
206
+ density?: 'tight' | 'normal' | 'airy';
207
+ /**
208
+ * How much the site MOVES. `prefers-reduced-motion` is the floor, never the
209
+ * ceiling: a visitor who asked their system for less always gets less, whatever
210
+ * this says. See `utils/junMotion.ts`.
211
+ */
212
+ motion?: 'full' | 'reduced' | 'none';
213
+ /**
214
+ * A different accent per PAGE TYPE — a journal that is warm and a globe that is
215
+ * cold. Keyed by page-type KEY (`journal`), one hex, applied to both schemes.
216
+ *
217
+ * A key rather than a resolved type id, the same choice `renderers` makes: a
218
+ * site that remaps a type keeps its colour.
219
+ */
220
+ accentByType?: Record<string, string>;
184
221
  [k: string]: unknown;
185
222
  }
186
223
  /** The one meta key on the space document that holds the whole configuration. */
@@ -1,6 +1,8 @@
1
- import { computed } from "vue";
1
+ import { computed, watchEffect } from "vue";
2
2
  import { useHead, useNuxtData } from "#app";
3
3
  import { useJunSiteConfig } from "./useJunSiteConfig.js";
4
+ import { JUN_ACCENTS, junShade, junSunColors } from "../utils/junMark.js";
5
+ import { junSetMotionFloor, junSetMotionLevel } from "../utils/junMotion.js";
4
6
  const RADIUS = {
5
7
  none: "0px",
6
8
  xs: "0.125rem",
@@ -9,27 +11,22 @@ const RADIUS = {
9
11
  lg: "0.625rem",
10
12
  xl: "1rem"
11
13
  };
12
- const ACCENT = {
13
- sun: {
14
- light: "#e08a00",
15
- dark: "#ffb800",
16
- orb: {
17
- light: { from: "#ffb800", to: "#ff9f00", glow: "#ff9f00", core: "#ffffff" },
18
- dark: { from: "#ffb800", to: "#ff9f00", glow: "#ff9f00", core: "#ffffff" }
19
- }
20
- },
21
- blue: { light: "#2563eb", dark: "#60a5fa" },
22
- emerald: { light: "#059669", dark: "#34d399" },
23
- violet: { light: "#7c3aed", dark: "#a78bfa" },
24
- amber: { light: "#d97706", dark: "#fbbf24" },
25
- rose: { light: "#e11d48", dark: "#fb7185" },
26
- teal: { light: "#0d9488", dark: "#2dd4bf" }
27
- };
14
+ const ACCENT = JUN_ACCENTS;
28
15
  const NEUTRAL = {
29
16
  slate: ["#f8fafc", "#f1f5f9", "#e2e8f0", "#cbd5e1", "#94a3b8", "#64748b", "#475569", "#334155", "#1e293b", "#0f172a", "#020617"],
30
17
  zinc: ["#fafafa", "#f4f4f5", "#e4e4e7", "#d4d4d8", "#a1a1aa", "#71717a", "#52525b", "#3f3f46", "#27272a", "#18181b", "#09090b"],
31
18
  stone: ["#fafaf9", "#f5f5f4", "#e7e5e4", "#d6d3d1", "#a8a29e", "#78716c", "#57534e", "#44403c", "#292524", "#1c1917", "#0c0a09"]
32
19
  };
20
+ const TYPE_SCALE = {
21
+ small: "94%",
22
+ normal: "",
23
+ large: "108%"
24
+ };
25
+ const DENSITY = {
26
+ tight: "0.86",
27
+ normal: "",
28
+ airy: "1.18"
29
+ };
33
30
  const NEUTRAL_STEPS = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"];
34
31
  const BLOBS = {
35
32
  off: "0",
@@ -49,46 +46,21 @@ const SURFACE_CLASS = {
49
46
  solid: "jun-surface-solid"
50
47
  };
51
48
  const HEX_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
52
- function shade(hex, amount) {
53
- const h = hex.replace("#", "");
54
- const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
55
- const n = Number.parseInt(full, 16);
56
- const to = amount > 0 ? 255 : 0;
57
- const t = Math.abs(amount);
58
- const mix = (v) => Math.round(v + (to - v) * t);
59
- const r = mix(n >> 16 & 255);
60
- const g = mix(n >> 8 & 255);
61
- const b = mix(n & 255);
62
- return `#${[r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("")}`;
63
- }
64
- function luminance(hex) {
65
- const h = hex.replace("#", "");
66
- const full = h.length === 3 ? h.split("").map((c) => c + c).join("") : h;
67
- const n = Number.parseInt(full, 16);
68
- return ((n >> 16 & 255) * 0.299 + (n >> 8 & 255) * 0.587 + (n & 255) * 0.114) / 255;
69
- }
70
49
  function sunVars(hex, orb) {
71
- if (orb) {
72
- return [
73
- `--jun-sun-from:${orb.from}`,
74
- `--jun-sun-to:${orb.to}`,
75
- `--jun-sun-core:${orb.core ?? (luminance(orb.from) > 0.62 ? "#101013" : "#ffffff")}`,
76
- `--jun-sun-glow:${orb.glow}`
77
- ];
78
- }
79
- if (!hex) return [];
50
+ const sun = junSunColors(hex, orb);
51
+ if (!sun) return [];
80
52
  return [
81
- `--jun-sun-from:${shade(hex, 0.12)}`,
82
- `--jun-sun-to:${shade(hex, -0.08)}`,
83
- `--jun-sun-core:${luminance(hex) > 0.62 ? "#101013" : "#ffffff"}`,
84
- `--jun-sun-glow:${hex}`
53
+ `--jun-sun-from:${sun.from}`,
54
+ `--jun-sun-to:${sun.to}`,
55
+ `--jun-sun-core:${sun.core}`,
56
+ `--jun-sun-glow:${sun.glow}`
85
57
  ];
86
58
  }
87
59
  function emberVars(hex) {
88
60
  if (!hex) return [];
89
61
  return [
90
62
  `--jun-ember:${hex}`,
91
- `--jun-ember-glow:${shade(hex, 0.12)}`
63
+ `--jun-ember-glow:${junShade(hex, 0.12)}`
92
64
  ];
93
65
  }
94
66
  export function junFontClass(cfg) {
@@ -125,9 +97,21 @@ export function junThemeCss(cfg) {
125
97
  const blobs = cfg.themeBlobs;
126
98
  const blobVal = blobs ? BLOBS[blobs] : null;
127
99
  if (blobVal !== null && blobVal !== void 0) root.push(`--jun-blob-opacity:${blobVal}`);
100
+ const typeScale = TYPE_SCALE[String(cfg.typeScale ?? "normal")];
101
+ if (typeScale) root.push(`font-size:${typeScale}`);
102
+ const density = DENSITY[String(cfg.density ?? "normal")];
103
+ if (density) root.push(`--jun-density:${density}`);
128
104
  let css = "";
129
105
  if (root.length) css += `html:root{${root.join(";")}}`;
130
106
  if (dark.length) css += `html:root.dark{${dark.join(";")}}`;
107
+ const byType = cfg.accentByType;
108
+ if (byType && typeof byType === "object") {
109
+ for (const [key, hex] of Object.entries(byType)) {
110
+ if (typeof hex !== "string" || !HEX_RE.test(hex)) continue;
111
+ if (!/^[a-z][a-z0-9-]*$/i.test(key)) continue;
112
+ css += `html:root[data-jun-type="${key}"]{--ui-primary:${hex};${sunVars(hex).join(";")};${emberVars(hex).join(";")}}`;
113
+ }
114
+ }
131
115
  return css;
132
116
  }
133
117
  export function useJunThemeApply() {
@@ -136,12 +120,27 @@ export function useJunThemeApply() {
136
120
  const merged = computed(
137
121
  () => Object.keys(config.value).length ? config.value : ssrCfg.value ?? {}
138
122
  );
123
+ if (import.meta.client) {
124
+ const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
125
+ junSetMotionFloor(mq.matches);
126
+ mq.addEventListener("change", (e) => junSetMotionFloor(e.matches));
127
+ }
128
+ watchEffect(() => junSetMotionLevel(merged.value.motion));
139
129
  useHead({
140
130
  style: [{ key: "jun-theme", textContent: computed(() => junThemeCss(merged.value)) }],
131
+ // `data-jun-motion` / `data-jun-density` are ATTRIBUTES rather than emitted
132
+ // rules: `jun.css` needs to key several dozen selectors off them, and a sheet
133
+ // rebuilt on every config change is the wrong place for that.
141
134
  // The font preset class is SSR-stamped on <html>, so the first paint
142
135
  // already uses the configured face — the faces themselves are static
143
136
  // @font-face rules in jun.css, which is what lets @nuxt/fonts self-host
144
137
  // them. A runtime-injected sheet would be invisible to it.
145
- htmlAttrs: { class: computed(() => junFontClass(merged.value)) }
138
+ htmlAttrs: {
139
+ "class": computed(() => junFontClass(merged.value)),
140
+ "data-jun-motion": computed(() => {
141
+ const level = merged.value.motion;
142
+ return level === "reduced" || level === "none" ? level : void 0;
143
+ })
144
+ }
146
145
  });
147
146
  }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * useJunViewOptions — a renderer's display settings, stored on its document.
3
+ *
4
+ * Every renderer but one used to hard-code how it looks. A site's Library was a
5
+ * list, its Wall was a masonry grid and its Cinema was a poster shelf, always,
6
+ * on every site, for every owner — while the module's configuration surface
7
+ * (features, navigation, campfire, brand, site config) was enormous and stopped
8
+ * dead at the page content.
9
+ *
10
+ * The one exception was `JunHomeRenderer`, which stores `meta.homeLayout` and
11
+ * `meta.homeSections` on its own document and hand-rolled everything around it:
12
+ * the meta read, the default-clearing write, the validity filter against a
13
+ * newer build's section ids, and ninety lines of panel markup. This is that
14
+ * mechanism, generalised — so a renderer adds an option by adding a line to a
15
+ * spec, and `<JunViewControls>` renders the control for it. Home now uses it
16
+ * too, keeping its own storage keys through `metaKey`.
17
+ *
18
+ * ── Where a value comes from, in order ───────────────────────────────────────
19
+ *
20
+ * 1. `meta.junView[key]` on the DOCUMENT — this owner, this page. (Or
21
+ * `meta.<metaKey>`, for a setting that predates this system.)
22
+ * 2. the SITE's house style — `config.renderers[typeKey][key]` on the space
23
+ * document (set from the studio, *Renderers*), over
24
+ * `jun.renderers[typeKey][key]` from `nuxt.config` (the deploy's default).
25
+ * Merged per key, so setting one option in the studio does not discard what
26
+ * the deploy chose for the others.
27
+ * 3. the spec's own `default` — what the module thinks the type should be.
28
+ *
29
+ * The arithmetic — coercion, that resolution, and the default-clearing write —
30
+ * lives in `utils/junViewValues.ts` with zero imports, so it can be unit-tested
31
+ * outside a Nuxt app. This file is the reactive wrapper and the CRDT write.
32
+ *
33
+ * ── Two rules it inherits, and both are load-bearing ─────────────────────────
34
+ *
35
+ * **Choosing the default CLEARS the key.** A site that stored its default and a
36
+ * site that never touched the setting must be indistinguishable, or changing a
37
+ * default later is silently overridden by copies of the old one on every
38
+ * document that ever opened the panel. Same rule as the Site Config document.
39
+ *
40
+ * **An unknown value is ignored, never rendered.** A value written by a NEWER
41
+ * build — a variant this version does not have — must fall back to the default
42
+ * rather than render as an empty page.
43
+ *
44
+ * `junView` is ONE namespaced object rather than a key per setting: it keeps
45
+ * display settings from colliding with content meta, and it is a single entry in
46
+ * `metaExcludeKeys` instead of one per option added forever.
47
+ */
48
+ import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
49
+ import { type JunViewOption, type JunViewValue } from '../utils/junViewValues.js';
50
+ export type { JunViewChoice, JunViewOption, JunViewOptionKind, JunViewValue, } from '../utils/junViewValues.js';
51
+ export interface JunViewSpec {
52
+ /**
53
+ * The page-type KEY (`'library'`), not a resolved type id. It names the
54
+ * `jun.renderers` block that carries the site's defaults for this renderer —
55
+ * and a key rather than an id so a site that remaps a type keeps its
56
+ * settings.
57
+ */
58
+ typeKey: string;
59
+ /**
60
+ * The options this renderer offers. A plain array for a fixed set, or a
61
+ * GETTER when the choices depend on the page.
62
+ *
63
+ * The Pulse page needs the second form and is the reason it exists: which
64
+ * tiles a site COULD show depends on which page types it has, so its choices
65
+ * — and therefore its default, "all of them" — are computed from live data.
66
+ * A static array could not describe that, and the alternative was leaving one
67
+ * renderer outside the system for the rest of time.
68
+ */
69
+ options: MaybeRefOrGetter<JunViewOption[]>;
70
+ }
71
+ export interface JunViewOptionsApi {
72
+ /** Resolved values, by key. Every key in the spec is present. */
73
+ view: ComputedRef<Record<string, JunViewValue>>;
74
+ /** Write one option. Passing the resolved default clears the stored key. */
75
+ set: (key: string, value: JunViewValue) => void;
76
+ /** Back to the site's defaults — removes everything this spec owns. */
77
+ reset: () => void;
78
+ /** Nothing stored: the page is showing exactly what the site chose. */
79
+ isDefault: ComputedRef<boolean>;
80
+ /** The spec's options, resolved — hand straight to `<JunViewControls>`. */
81
+ options: ComputedRef<JunViewOption[]>;
82
+ }
83
+ export declare function useJunViewOptions(docId: string, spec: JunViewSpec,
84
+ /** The SSR meta, for the first paint before the live tree arrives. */
85
+ fallbackMeta?: MaybeRefOrGetter<Record<string, unknown> | undefined>): JunViewOptionsApi;
@@ -0,0 +1,63 @@
1
+ import { computed, toValue } from "vue";
2
+ import { useAbracadabra, useChildTree, useDocTree, useJunOptions, useJunSiteConfig } from "#imports";
3
+ import {
4
+ junNextViewObject,
5
+ junResolveViewValue,
6
+ junViewUnsetValue,
7
+ junViewValuesEqual
8
+ } from "../utils/junViewValues.js";
9
+ export function useJunViewOptions(docId, spec, fallbackMeta) {
10
+ const abra = useAbracadabra();
11
+ const tree = useChildTree(abra.doc, docId);
12
+ const { getEntry } = useDocTree();
13
+ const { renderers } = useJunOptions();
14
+ const { config } = useJunSiteConfig();
15
+ const siteDefaults = computed(() => ({
16
+ ...renderers[spec.typeKey] ?? {},
17
+ ...config.value.renderers?.[spec.typeKey] ?? {}
18
+ }));
19
+ const meta = computed(
20
+ () => getEntry(docId)?.meta ?? toValue(fallbackMeta) ?? {}
21
+ );
22
+ const stored = computed(() => {
23
+ const v = meta.value.junView;
24
+ return v && typeof v === "object" && !Array.isArray(v) ? v : {};
25
+ });
26
+ const options = computed(() => toValue(spec.options));
27
+ const view = computed(() => {
28
+ const out = {};
29
+ for (const option of options.value) {
30
+ out[option.key] = junResolveViewValue(option, stored.value, siteDefaults.value, meta.value);
31
+ }
32
+ return out;
33
+ });
34
+ const escaped = computed(() => options.value.filter((o) => o.metaKey));
35
+ const isDefault = computed(
36
+ () => Object.keys(stored.value).length === 0 && escaped.value.every((o) => meta.value[o.metaKey] === void 0)
37
+ );
38
+ function set(key, value) {
39
+ const option = options.value.find((o) => o.key === key);
40
+ if (!option) return;
41
+ if (option.metaKey) {
42
+ const clean = junResolveViewValue(
43
+ { ...option, metaKey: void 0 },
44
+ { [option.key]: value },
45
+ {}
46
+ );
47
+ const unset = junViewUnsetValue(option, siteDefaults.value);
48
+ tree.updateMeta(docId, {
49
+ [option.metaKey]: junViewValuesEqual(clean, unset) ? void 0 : clean
50
+ });
51
+ return;
52
+ }
53
+ tree.updateMeta(docId, {
54
+ junView: junNextViewObject(option, stored.value, siteDefaults.value, value)
55
+ });
56
+ }
57
+ function reset() {
58
+ const patch = { junView: void 0 };
59
+ for (const option of escaped.value) patch[option.metaKey] = void 0;
60
+ tree.updateMeta(docId, patch);
61
+ }
62
+ return { view, set, reset, isDefault, options };
63
+ }
@@ -93,15 +93,21 @@ const cachedHtml = computed(() => hidden.value ? "" : resolved.value?.html ?? ""
93
93
  </script>
94
94
 
95
95
  <template>
96
- <!-- A real ELEMENT root, and it is load-bearing.
97
- `<ClientOnly>` renders a fragment (a comment node before mount), and the
98
- `jun-fade` page transition wraps this component in a `<Transition>`. A
99
- Transition cannot animate a non-element root: it has nothing to attach
100
- to, so the fade never runs and — under the `out-in` this codebase is not
101
- allowed to use — the incoming page never paints at all. Nuxt warns about
102
- exactly this ("does not have a single root node and will cause errors
103
- when navigating between routes"). Do not remove this wrapper. -->
104
96
  <div class="jun-doc-root">
97
+ <!-- A real ELEMENT root, and it is load-bearing.
98
+ `<ClientOnly>` renders a fragment (a comment node before mount), and the
99
+ `jun-fade` page transition wraps this component in a `<Transition>`. A
100
+ Transition cannot animate a non-element root: it has nothing to attach
101
+ to, so the fade never runs and — under the `out-in` this codebase is not
102
+ allowed to use — the incoming page never paints at all. Do not remove
103
+ this wrapper.
104
+
105
+ The comment lives INSIDE it, and that is not tidying: Nuxt counts a
106
+ top-level comment as a second root node, so describing the wrapper from
107
+ above it made every page log the very warning the wrapper exists to
108
+ prevent — "does not have a single root node and will cause errors when
109
+ navigating between routes" — while navigation was in fact fine. A
110
+ warning that cries wolf on every page load is worse than no warning. -->
105
111
  <ClientOnly>
106
112
  <!-- Rendered ON THE SERVER and held until mount: this is what a crawler
107
113
  indexes and what a cold visitor sees first. The same HTML goes into
@@ -0,0 +1,2 @@
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,36 @@
1
+ import { defineNuxtPlugin, useRuntimeConfig } from "#imports";
2
+ export default defineNuxtPlugin({
3
+ name: "jun:service-worker",
4
+ setup() {
5
+ if (import.meta.server) return;
6
+ if (!("serviceWorker" in navigator)) return;
7
+ const jun = useRuntimeConfig().public.jun;
8
+ if (jun?.pwa === false) return;
9
+ if (import.meta.dev) {
10
+ void (async () => {
11
+ try {
12
+ const regs = await navigator.serviceWorker.getRegistrations();
13
+ const ours = regs.filter((r) => (r.active?.scriptURL ?? r.installing?.scriptURL ?? "").includes("jun-sw"));
14
+ if (!ours.length) return;
15
+ await Promise.all(ours.map((r) => r.update().catch(() => {
16
+ })));
17
+ await Promise.all(ours.map((r) => r.unregister()));
18
+ const names = await caches.keys();
19
+ await Promise.all(names.filter((n) => n.startsWith("jun-")).map((n) => caches.delete(n)));
20
+ console.info(
21
+ `[jun] clearing ${ours.length} service worker(s) left over from a production build on this origin. They answer navigations from a cache and make a dev server look frozen.`
22
+ );
23
+ } catch {
24
+ }
25
+ })();
26
+ return;
27
+ }
28
+ const register = () => {
29
+ navigator.serviceWorker.register("/jun-sw.js", { scope: "/" }).catch((err) => {
30
+ console.warn("[jun] service worker registration failed:", err);
31
+ });
32
+ };
33
+ if (document.readyState === "complete") register();
34
+ else window.addEventListener("load", register, { once: true });
35
+ }
36
+ });
@@ -0,0 +1,19 @@
1
+ import { type JunReadinessState } from '../../utils/junReadiness.js';
2
+ export interface JunHealthReport {
3
+ state: JunReadinessState;
4
+ healthy: boolean;
5
+ reason: string;
6
+ hint?: string;
7
+ /** The numbers the verdict was made from — so a reader need not guess. */
8
+ cache: {
9
+ tree: number;
10
+ slugs: number;
11
+ bodies: number;
12
+ };
13
+ /** Milliseconds since the doc-cache runner last swept IN THIS PROCESS. */
14
+ sweptMsAgo: number | null;
15
+ rootDocId: string;
16
+ ageMs: number;
17
+ }
18
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<JunHealthReport>>;
19
+ export default _default;
@@ -0,0 +1,40 @@
1
+ import { defineEventHandler, setResponseStatus } from "h3";
2
+ import { useRuntimeConfig, useStorage } from "nitropack/runtime";
3
+ import { junDocTree, junHeartbeat, junRootDocId, junSlugMap } from "../utils/junCache.js";
4
+ import { junBootedAt } from "../utils/junBoot.js";
5
+ import { junReadiness } from "../../utils/junReadiness.js";
6
+ export default defineEventHandler(async (event) => {
7
+ const storage = useStorage();
8
+ const [tree, slugs, bodyKeys, beat] = await Promise.all([
9
+ junDocTree(),
10
+ junSlugMap(),
11
+ storage.getKeys("doc-cache:html"),
12
+ junHeartbeat()
13
+ ]);
14
+ const ageMs = Date.now() - junBootedAt();
15
+ const sweptMsAgo = beat && beat.at >= junBootedAt() ? Date.now() - beat.at : null;
16
+ const features = (useRuntimeConfig().public.jun ?? {}).features ?? {};
17
+ const verdict = junReadiness({
18
+ treeSize: Object.keys(tree).length,
19
+ slugCount: Object.keys(slugs).length,
20
+ bodyCount: bodyKeys.length,
21
+ ageMs,
22
+ heartbeatAgeMs: sweptMsAgo,
23
+ expectHeartbeat: features.docCache !== false
24
+ });
25
+ if (!verdict.healthy) setResponseStatus(event, 503);
26
+ return {
27
+ state: verdict.state,
28
+ healthy: verdict.healthy,
29
+ reason: verdict.reason,
30
+ ...verdict.hint ? { hint: verdict.hint } : {},
31
+ cache: {
32
+ tree: Object.keys(tree).length,
33
+ slugs: Object.keys(slugs).length,
34
+ bodies: bodyKeys.length
35
+ },
36
+ sweptMsAgo,
37
+ rootDocId: junRootDocId(),
38
+ ageMs
39
+ };
40
+ });
@@ -0,0 +1,19 @@
1
+ import { type JunGardenEdge } from '../../utils/junGarden.js';
2
+ export interface JunLinkNode {
3
+ id: string;
4
+ label: string;
5
+ href: string;
6
+ type: string;
7
+ parentId?: string | null;
8
+ updatedAt: number;
9
+ maturity: string | null;
10
+ }
11
+ export interface JunLinkGraph {
12
+ nodes: JunLinkNode[];
13
+ edges: JunGardenEdge[];
14
+ /** How many bodies the cache had. Zero means "not warm yet", not "no links". */
15
+ scanned: number;
16
+ generatedAt: number;
17
+ }
18
+ declare const _default: import("h3").EventHandler<Omit<import("h3").EventHandlerRequest, "body">, Promise<JunLinkGraph>>;
19
+ export default _default;