@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.
- package/dist/module.d.mts +17 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +270 -22
- package/dist/runtime/assets/css/jun.css +1 -1
- package/dist/runtime/components/JunBlobBackdrop.client.vue +1 -1
- package/dist/runtime/components/JunCampfirePresence.client.vue +75 -10
- package/dist/runtime/components/JunCollectionIntro.d.vue.ts +11 -0
- package/dist/runtime/components/JunCollectionIntro.vue +45 -0
- package/dist/runtime/components/JunCollectionIntro.vue.d.ts +11 -0
- package/dist/runtime/components/JunConfigRow.d.vue.ts +43 -0
- package/dist/runtime/components/JunConfigRow.vue +34 -0
- package/dist/runtime/components/JunConfigRow.vue.d.ts +43 -0
- package/dist/runtime/components/JunFooter.vue +1 -1
- package/dist/runtime/components/JunHead.vue +37 -5
- package/dist/runtime/components/JunHorizontalTimeline.d.vue.ts +30 -0
- package/dist/runtime/components/JunHorizontalTimeline.vue.d.ts +30 -0
- package/dist/runtime/components/JunLinksRow.d.vue.ts +16 -1
- package/dist/runtime/components/JunLinksRow.vue +17 -7
- package/dist/runtime/components/JunLinksRow.vue.d.ts +16 -1
- package/dist/runtime/components/JunLogo.vue +10 -45
- package/dist/runtime/components/JunMedia.client.d.vue.ts +1 -1
- package/dist/runtime/components/JunMedia.client.vue.d.ts +1 -1
- package/dist/runtime/components/JunNavigation.vue +21 -4
- package/dist/runtime/components/JunNoteLinks.d.vue.ts +6 -0
- package/dist/runtime/components/JunNoteLinks.vue +57 -0
- package/dist/runtime/components/JunNoteLinks.vue.d.ts +6 -0
- package/dist/runtime/components/JunPageHero.d.vue.ts +8 -2
- package/dist/runtime/components/JunPageHero.vue +15 -3
- package/dist/runtime/components/JunPageHero.vue.d.ts +8 -2
- package/dist/runtime/components/JunPatternBackdrop.client.vue +1 -1
- package/dist/runtime/components/JunReaders.d.vue.ts +11 -0
- package/dist/runtime/components/JunReaders.vue +99 -0
- package/dist/runtime/components/JunReaders.vue.d.ts +11 -0
- package/dist/runtime/components/JunSearch.client.vue +2 -2
- package/dist/runtime/components/JunSectionPresence.client.d.vue.ts +17 -0
- package/dist/runtime/components/JunSectionPresence.client.vue +99 -0
- package/dist/runtime/components/JunSectionPresence.client.vue.d.ts +17 -0
- package/dist/runtime/components/JunShaderBackdrop.client.vue +1 -1
- package/dist/runtime/components/JunThreadComposer.d.vue.ts +37 -0
- package/dist/runtime/components/JunThreadComposer.vue +54 -0
- package/dist/runtime/components/JunThreadComposer.vue.d.ts +37 -0
- package/dist/runtime/components/JunTravellersChip.vue +35 -5
- package/dist/runtime/components/JunVideoEmbed.client.d.vue.ts +1 -1
- package/dist/runtime/components/JunVideoEmbed.client.vue.d.ts +1 -1
- package/dist/runtime/components/JunViewControl.d.vue.ts +29 -0
- package/dist/runtime/components/JunViewControl.vue +340 -0
- package/dist/runtime/components/JunViewControl.vue.d.ts +29 -0
- package/dist/runtime/components/JunViewControls.d.vue.ts +27 -0
- package/dist/runtime/components/JunViewControls.vue +94 -0
- package/dist/runtime/components/JunViewControls.vue.d.ts +27 -0
- package/dist/runtime/components/renderers/JunAppsRenderer.vue +45 -4
- package/dist/runtime/components/renderers/JunCinemaRenderer.vue +42 -4
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +362 -239
- package/dist/runtime/components/renderers/JunCourseRenderer.d.vue.ts +10 -0
- package/dist/runtime/components/renderers/JunCourseRenderer.vue +229 -0
- package/dist/runtime/components/renderers/JunCourseRenderer.vue.d.ts +10 -0
- package/dist/runtime/components/renderers/JunCvRenderer.vue +44 -6
- package/dist/runtime/components/renderers/JunDeckRenderer.d.vue.ts +9 -0
- package/dist/runtime/components/renderers/JunDeckRenderer.vue +370 -0
- package/dist/runtime/components/renderers/JunDeckRenderer.vue.d.ts +9 -0
- package/dist/runtime/components/renderers/JunEntryRenderer.vue +157 -31
- package/dist/runtime/components/renderers/JunFestivalRenderer.vue +42 -5
- package/dist/runtime/components/renderers/JunGardenRenderer.d.vue.ts +10 -0
- package/dist/runtime/components/renderers/JunGardenRenderer.vue +280 -0
- package/dist/runtime/components/renderers/JunGardenRenderer.vue.d.ts +10 -0
- package/dist/runtime/components/renderers/JunGuestbookRenderer.vue +96 -14
- package/dist/runtime/components/renderers/JunHomeRenderer.vue +31 -132
- package/dist/runtime/components/renderers/JunItemRenderer.d.vue.ts +10 -0
- package/dist/runtime/components/renderers/JunItemRenderer.vue +398 -0
- package/dist/runtime/components/renderers/JunItemRenderer.vue.d.ts +10 -0
- package/dist/runtime/components/renderers/JunJournalRenderer.vue +141 -11
- package/dist/runtime/components/renderers/JunLibraryRenderer.vue +295 -12
- package/dist/runtime/components/renderers/JunLinksRenderer.vue +33 -1
- package/dist/runtime/components/renderers/JunLiveRenderer.vue +38 -2
- package/dist/runtime/components/renderers/JunMosaicRenderer.vue +3 -2
- package/dist/runtime/components/renderers/JunMovieRenderer.vue +32 -5
- package/dist/runtime/components/renderers/JunNowRenderer.vue +40 -7
- package/dist/runtime/components/renderers/JunPollRenderer.d.vue.ts +9 -0
- package/dist/runtime/components/renderers/JunPollRenderer.vue +231 -0
- package/dist/runtime/components/renderers/JunPollRenderer.vue.d.ts +9 -0
- package/dist/runtime/components/renderers/JunProjectRenderer.vue +74 -18
- package/dist/runtime/components/renderers/JunServicesRenderer.vue +40 -2
- package/dist/runtime/components/renderers/JunStatsRenderer.vue +37 -50
- package/dist/runtime/components/renderers/JunThreadRenderer.d.vue.ts +9 -0
- package/dist/runtime/components/renderers/JunThreadRenderer.vue +304 -0
- package/dist/runtime/components/renderers/JunThreadRenderer.vue.d.ts +9 -0
- package/dist/runtime/components/renderers/JunTrackRenderer.vue +32 -4
- package/dist/runtime/components/renderers/JunUsesRenderer.vue +57 -13
- package/dist/runtime/components/renderers/JunWallRenderer.vue +60 -5
- package/dist/runtime/composables/useJunDeck.d.ts +66 -0
- package/dist/runtime/composables/useJunDeck.js +61 -0
- package/dist/runtime/composables/useJunDocPage.d.ts +14 -11
- package/dist/runtime/composables/useJunDocPage.js +67 -3
- package/dist/runtime/composables/useJunFollow.d.ts +65 -9
- package/dist/runtime/composables/useJunFollow.js +237 -20
- package/dist/runtime/composables/useJunGarden.d.ts +67 -0
- package/dist/runtime/composables/useJunGarden.js +92 -0
- package/dist/runtime/composables/useJunOptions.d.ts +1 -0
- package/dist/runtime/composables/useJunPresence.d.ts +26 -0
- package/dist/runtime/composables/useJunPresence.js +9 -2
- package/dist/runtime/composables/useJunSections.d.ts +73 -0
- package/dist/runtime/composables/useJunSections.js +117 -0
- package/dist/runtime/composables/useJunSettings.d.ts +1 -1
- package/dist/runtime/composables/useJunSettings.js +5 -1
- package/dist/runtime/composables/useJunSiteConfig.d.ts +37 -0
- package/dist/runtime/composables/useJunTheme.js +49 -50
- package/dist/runtime/composables/useJunViewOptions.d.ts +85 -0
- package/dist/runtime/composables/useJunViewOptions.js +63 -0
- package/dist/runtime/pages/doc.vue +14 -8
- package/dist/runtime/plugins/jun-sw.client.d.ts +2 -0
- package/dist/runtime/plugins/jun-sw.client.js +36 -0
- package/dist/runtime/server/api/health.get.d.ts +19 -0
- package/dist/runtime/server/api/health.get.js +40 -0
- package/dist/runtime/server/api/links.get.d.ts +19 -0
- package/dist/runtime/server/api/links.get.js +37 -0
- package/dist/runtime/server/api/resolve/[...slug].get.d.ts +9 -0
- package/dist/runtime/server/api/resolve/[...slug].get.js +5 -0
- package/dist/runtime/server/api/stats.get.js +2 -1
- package/dist/runtime/server/janitor/junJanitorChores.js +8 -0
- package/dist/runtime/server/plugins/jun-bootstrap.js +103 -15
- package/dist/runtime/server/plugins/jun-doc-cache.js +42 -4
- package/dist/runtime/server/plugins/jun-janitor.js +9 -1
- package/dist/runtime/server/plugins/jun-rpc.js +293 -0
- package/dist/runtime/server/plugins/jun-watchdog.d.ts +2 -0
- package/dist/runtime/server/plugins/jun-watchdog.js +54 -0
- package/dist/runtime/server/routes/jun-icon.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-icon.png.get.js +25 -0
- package/dist/runtime/server/routes/jun-icon.svg.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-icon.svg.get.js +9 -0
- package/dist/runtime/server/routes/jun-splash.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-splash.png.get.js +37 -0
- package/dist/runtime/server/routes/jun-sw.js.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-sw.js.get.js +126 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.d.ts +24 -0
- package/dist/runtime/server/routes/manifest.webmanifest.get.js +51 -0
- package/dist/runtime/server/routes/sitemap.xml.get.js +2 -0
- package/dist/runtime/server/utils/junBoot.d.ts +1 -0
- package/dist/runtime/server/utils/junBoot.js +4 -0
- package/dist/runtime/server/utils/junBrand.d.ts +4 -0
- package/dist/runtime/server/utils/junBrand.js +9 -0
- package/dist/runtime/server/utils/junCache.d.ts +17 -0
- package/dist/runtime/server/utils/junCache.js +5 -0
- package/dist/runtime/server/utils/junIcon.d.ts +44 -0
- package/dist/runtime/server/utils/junIcon.js +374 -0
- package/dist/runtime/server/utils/junSeedGate.d.ts +68 -0
- package/dist/runtime/server/utils/junSeedGate.js +41 -0
- package/dist/runtime/types.d.ts +82 -3
- package/dist/runtime/utils/junCourse.d.ts +106 -0
- package/dist/runtime/utils/junCourse.js +65 -0
- package/dist/runtime/utils/junGarden.d.ts +193 -0
- package/dist/runtime/utils/junGarden.js +233 -0
- package/dist/runtime/utils/junIdentity.d.ts +121 -0
- package/dist/runtime/utils/junIdentity.js +115 -0
- package/dist/runtime/utils/junMark.d.ts +254 -0
- package/dist/runtime/utils/junMark.js +169 -0
- package/dist/runtime/utils/junMetaSchemas.js +8 -1
- package/dist/runtime/utils/junModeration.d.ts +67 -0
- package/dist/runtime/utils/junModeration.js +20 -0
- package/dist/runtime/utils/junMotion.d.ts +26 -0
- package/dist/runtime/utils/junMotion.js +31 -0
- package/dist/runtime/utils/junPeople.d.ts +43 -0
- package/dist/runtime/utils/junPeople.js +9 -0
- package/dist/runtime/utils/junPoll.d.ts +79 -0
- package/dist/runtime/utils/junPoll.js +82 -0
- package/dist/runtime/utils/junReadiness.d.ts +131 -0
- package/dist/runtime/utils/junReadiness.js +69 -0
- package/dist/runtime/utils/junSections.d.ts +115 -0
- package/dist/runtime/utils/junSections.js +45 -0
- package/dist/runtime/utils/junSlides.d.ts +66 -0
- package/dist/runtime/utils/junSlides.js +47 -0
- package/dist/runtime/utils/junThread.d.ts +81 -0
- package/dist/runtime/utils/junThread.js +75 -0
- package/dist/runtime/utils/junViewSpecs.d.ts +671 -0
- package/dist/runtime/utils/junViewSpecs.js +534 -0
- package/dist/runtime/utils/junViewValues.d.ts +125 -0
- package/dist/runtime/utils/junViewValues.js +104 -0
- package/dist/types.d.mts +1 -1
- 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
|
-
|
|
72
|
-
|
|
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:${
|
|
82
|
-
`--jun-sun-to:${
|
|
83
|
-
`--jun-sun-core:${
|
|
84
|
-
`--jun-sun-glow:${
|
|
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:${
|
|
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: {
|
|
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,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;
|