@abraca/junis 2.87.0 → 2.90.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 +43 -4
- package/dist/module.json +1 -1
- package/dist/module.mjs +121 -6
- package/dist/runtime/assets/css/jun.css +2 -2
- package/dist/runtime/components/JunDocSurface.d.vue.ts +20 -2
- package/dist/runtime/components/JunDocSurface.vue +27 -2
- package/dist/runtime/components/JunDocSurface.vue.d.ts +20 -2
- package/dist/runtime/components/JunHead.vue +16 -4
- package/dist/runtime/components/JunNavDock.d.vue.ts +15 -0
- package/dist/runtime/components/JunNavDock.vue +94 -0
- package/dist/runtime/components/JunNavDock.vue.d.ts +15 -0
- package/dist/runtime/components/JunNavMenu.client.d.vue.ts +15 -0
- package/dist/runtime/components/JunNavMenu.client.vue +501 -0
- package/dist/runtime/components/JunNavMenu.client.vue.d.ts +15 -0
- package/dist/runtime/components/JunNavPreview.d.vue.ts +17 -0
- package/dist/runtime/components/JunNavPreview.vue +169 -0
- package/dist/runtime/components/JunNavPreview.vue.d.ts +17 -0
- package/dist/runtime/components/JunNavigation.d.vue.ts +4 -11
- package/dist/runtime/components/JunNavigation.vue +813 -138
- package/dist/runtime/components/JunNavigation.vue.d.ts +4 -11
- package/dist/runtime/components/JunNoteLinks.vue +1 -1
- package/dist/runtime/components/JunOfflinePanel.client.d.vue.ts +3 -0
- package/dist/runtime/components/JunOfflinePanel.client.vue +293 -0
- package/dist/runtime/components/JunOfflinePanel.client.vue.d.ts +3 -0
- package/dist/runtime/components/JunPageHero.vue +3 -3
- package/dist/runtime/components/JunSectionBar.d.vue.ts +41 -0
- package/dist/runtime/components/JunSectionBar.vue +144 -0
- package/dist/runtime/components/JunSectionBar.vue.d.ts +41 -0
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +618 -6
- package/dist/runtime/components/renderers/JunEntryRenderer.vue +48 -0
- package/dist/runtime/composables/useJunCommands.d.ts +1 -1
- package/dist/runtime/composables/useJunCommands.js +14 -1
- package/dist/runtime/composables/useJunCreatePage.js +7 -1
- package/dist/runtime/composables/useJunDocPage.d.ts +28 -0
- package/dist/runtime/composables/useJunDocPage.js +111 -20
- package/dist/runtime/composables/useJunGarden.d.ts +1 -1
- package/dist/runtime/composables/useJunGarden.js +3 -2
- package/dist/runtime/composables/useJunGestures.d.ts +53 -0
- package/dist/runtime/composables/useJunGestures.js +89 -0
- package/dist/runtime/composables/useJunMenuState.d.ts +4 -0
- package/dist/runtime/composables/useJunMenuState.js +5 -0
- package/dist/runtime/composables/useJunNavItems.d.ts +50 -0
- package/dist/runtime/composables/useJunNavItems.js +188 -0
- package/dist/runtime/composables/useJunNavSettings.d.ts +58 -1
- package/dist/runtime/composables/useJunNavSettings.js +110 -8
- package/dist/runtime/composables/useJunOffline.d.ts +109 -0
- package/dist/runtime/composables/useJunOffline.js +294 -0
- package/dist/runtime/composables/useJunOptions.d.ts +1 -0
- package/dist/runtime/composables/useJunSettings.d.ts +1 -1
- package/dist/runtime/composables/useJunSettings.js +2 -0
- package/dist/runtime/composables/useJunSiblings.d.ts +30 -0
- package/dist/runtime/composables/useJunSiblings.js +38 -0
- package/dist/runtime/composables/useJunSiteConfig.d.ts +70 -3
- package/dist/runtime/composables/useJunTheme.js +4 -1
- package/dist/runtime/composables/useJunViewingAccent.js +10 -0
- package/dist/runtime/layouts/jun.vue +32 -2
- package/dist/runtime/pages/doc.vue +2 -0
- package/dist/runtime/pages/index.vue +2 -0
- package/dist/runtime/server/api/health.get.d.ts +15 -0
- package/dist/runtime/server/api/health.get.js +7 -2
- package/dist/runtime/server/api/links.get.js +27 -3
- package/dist/runtime/server/api/offline.get.d.ts +10 -0
- package/dist/runtime/server/api/offline.get.js +13 -0
- package/dist/runtime/server/api/resolve/[...slug].get.d.ts +20 -0
- package/dist/runtime/server/api/resolve/[...slug].get.js +31 -0
- package/dist/runtime/server/api/search.get.d.ts +1 -1
- package/dist/runtime/server/api/search.get.js +42 -39
- package/dist/runtime/server/api/tree.get.js +3 -1
- package/dist/runtime/server/janitor/junJanitorChores.d.ts +14 -7
- package/dist/runtime/server/janitor/junJanitorChores.js +21 -3
- package/dist/runtime/server/janitor/junJanitorMachine.js +36 -4
- package/dist/runtime/server/janitor/junJanitorPerform.d.ts +15 -1
- package/dist/runtime/server/janitor/junJanitorPerform.js +13 -5
- package/dist/runtime/server/janitor/junJanitorYText.d.ts +40 -3
- package/dist/runtime/server/janitor/junJanitorYText.js +60 -14
- package/dist/runtime/server/plugins/jun-compress.d.ts +2 -0
- package/dist/runtime/server/plugins/jun-compress.js +76 -0
- package/dist/runtime/server/plugins/jun-janitor.js +132 -81
- package/dist/runtime/server/routes/jun-card.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-card.png.get.js +40 -0
- package/dist/runtime/server/routes/jun-sw.js.get.js +66 -13
- package/dist/runtime/server/routes/sitemap.xml.get.js +5 -18
- package/dist/runtime/server/utils/junCard.d.ts +39 -0
- package/dist/runtime/server/utils/junCard.js +159 -0
- package/dist/runtime/server/utils/junIcon.d.ts +27 -2
- package/dist/runtime/server/utils/junIcon.js +5 -5
- package/dist/runtime/server/utils/junJanitorStatus.d.ts +59 -0
- package/dist/runtime/server/utils/junJanitorStatus.js +27 -0
- package/dist/runtime/server/utils/junPages.d.ts +51 -0
- package/dist/runtime/server/utils/junPages.js +70 -0
- package/dist/runtime/types.d.ts +295 -0
- package/dist/runtime/utils/junAdopt.d.ts +43 -0
- package/dist/runtime/utils/junAdopt.js +7 -0
- package/dist/runtime/utils/junGesture.d.ts +84 -0
- package/dist/runtime/utils/junGesture.js +40 -0
- package/dist/runtime/utils/junLetters.d.ts +86 -0
- package/dist/runtime/utils/junLetters.js +173 -0
- package/dist/runtime/utils/junNavValue.d.ts +56 -0
- package/dist/runtime/utils/junNavValue.js +36 -0
- package/dist/runtime/utils/junOffline.d.ts +138 -0
- package/dist/runtime/utils/junOffline.js +73 -0
- package/dist/runtime/utils/junSearchRank.d.ts +79 -0
- package/dist/runtime/utils/junSearchRank.js +73 -0
- package/dist/runtime/utils/junSocial.d.ts +59 -0
- package/dist/runtime/utils/junSocial.js +56 -0
- package/dist/runtime/utils/junViewSpecs.d.ts +39 -1
- package/dist/runtime/utils/junViewSpecs.js +92 -1
- package/dist/types.d.mts +1 -1
- package/package.json +13 -9
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { computed, onMounted, ref, watch } from "vue";
|
|
2
|
+
import {
|
|
3
|
+
useAbracadabra,
|
|
4
|
+
useDocSlugs,
|
|
5
|
+
useDocTree,
|
|
6
|
+
useRoute,
|
|
7
|
+
useSlugRoute
|
|
8
|
+
} from "#imports";
|
|
9
|
+
import { useJunDocIcon, useJunOptions, useJunPageType } from "./useJunOptions.js";
|
|
10
|
+
import { useJunNavSettings } from "./useJunNavSettings.js";
|
|
11
|
+
import { junDedupeTravellers, useJunTravellers } from "./useJunPresence.js";
|
|
12
|
+
const SEEN_KEY = "jun_seen_v1";
|
|
13
|
+
export function useJunNavItems(items, options = {}) {
|
|
14
|
+
const route = useRoute();
|
|
15
|
+
const abra = useAbracadabra();
|
|
16
|
+
const { typeIds } = useJunOptions();
|
|
17
|
+
const { resolveType } = useJunPageType();
|
|
18
|
+
const { entries: treeEntries, getEntry } = useDocTree();
|
|
19
|
+
const { getDocUrl } = useDocSlugs();
|
|
20
|
+
const { docId } = useSlugRoute();
|
|
21
|
+
const { travellers } = useJunTravellers();
|
|
22
|
+
const nav = useJunNavSettings();
|
|
23
|
+
const docIcon = useJunDocIcon();
|
|
24
|
+
const iconFor = (item) => item.icon ?? docIcon(item.type);
|
|
25
|
+
function navLabelFor(item) {
|
|
26
|
+
if (!item.id) return item.name;
|
|
27
|
+
const nl = getEntry(item.id)?.meta?.navLabel;
|
|
28
|
+
return typeof nl === "string" && nl.trim() ? nl.trim() : item.name;
|
|
29
|
+
}
|
|
30
|
+
function redirectTargetFor(item) {
|
|
31
|
+
if (!typeIds.redirect || resolveType(item.type) !== typeIds.redirect || !item.id) return null;
|
|
32
|
+
const u = getEntry(item.id)?.meta?.url;
|
|
33
|
+
return typeof u === "string" && u.trim() ? u.trim() : null;
|
|
34
|
+
}
|
|
35
|
+
const isExternalTarget = (u) => !!u && /^https?:\/\//i.test(u);
|
|
36
|
+
const childrenByParent = computed(() => {
|
|
37
|
+
const map = /* @__PURE__ */ new Map();
|
|
38
|
+
for (const e of treeEntries.value) {
|
|
39
|
+
const arr = map.get(e.parentId ?? null) ?? [];
|
|
40
|
+
arr.push({ id: e.id, updatedAt: e.updatedAt });
|
|
41
|
+
map.set(e.parentId ?? null, arr);
|
|
42
|
+
}
|
|
43
|
+
return map;
|
|
44
|
+
});
|
|
45
|
+
function childrenOf(id) {
|
|
46
|
+
if (!id) return [];
|
|
47
|
+
return treeEntries.value.filter((e) => e.parentId === id && !e.trashed && e.meta?.hidden !== true).sort((a, b) => (a.order ?? 0) - (b.order ?? 0)).map((e) => ({
|
|
48
|
+
id: e.id,
|
|
49
|
+
name: e.label || "Untitled",
|
|
50
|
+
href: getDocUrl(e.id),
|
|
51
|
+
icon: e.meta?.icon,
|
|
52
|
+
type: e.type
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
const seenMap = ref({});
|
|
56
|
+
function persistSeen() {
|
|
57
|
+
try {
|
|
58
|
+
localStorage.setItem(SEEN_KEY, JSON.stringify(seenMap.value));
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
onMounted(() => {
|
|
63
|
+
try {
|
|
64
|
+
seenMap.value = JSON.parse(localStorage.getItem(SEEN_KEY) || "null") ?? {};
|
|
65
|
+
} catch {
|
|
66
|
+
seenMap.value = {};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const subtreeMaxById = computed(() => {
|
|
70
|
+
const m = /* @__PURE__ */ new Map();
|
|
71
|
+
for (const item of items.value) {
|
|
72
|
+
if (!item.id) continue;
|
|
73
|
+
let max = getEntry(item.id)?.updatedAt ?? 0;
|
|
74
|
+
const queue = [...childrenByParent.value.get(item.id) ?? []];
|
|
75
|
+
while (queue.length) {
|
|
76
|
+
const cur = queue.pop();
|
|
77
|
+
if ((cur.updatedAt ?? 0) > max) max = cur.updatedAt ?? 0;
|
|
78
|
+
for (const c of childrenByParent.value.get(cur.id) ?? []) queue.push(c);
|
|
79
|
+
}
|
|
80
|
+
m.set(item.id, max);
|
|
81
|
+
}
|
|
82
|
+
return m;
|
|
83
|
+
});
|
|
84
|
+
const countById = computed(() => {
|
|
85
|
+
const out = /* @__PURE__ */ new Map();
|
|
86
|
+
const mode = nav.counts.value;
|
|
87
|
+
if (mode === "off") return out;
|
|
88
|
+
for (const item of items.value) {
|
|
89
|
+
if (!item.id) continue;
|
|
90
|
+
if (mode === "children") {
|
|
91
|
+
const n2 = (childrenByParent.value.get(item.id) ?? []).length;
|
|
92
|
+
if (n2 > 0) out.set(item.id, n2);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const seen = seenMap.value[item.id];
|
|
96
|
+
if (!seen || item.current) continue;
|
|
97
|
+
let n = 0;
|
|
98
|
+
const queue = [...childrenByParent.value.get(item.id) ?? []];
|
|
99
|
+
while (queue.length) {
|
|
100
|
+
const cur = queue.pop();
|
|
101
|
+
if ((cur.updatedAt ?? 0) > seen + 2e3) n++;
|
|
102
|
+
for (const child of childrenByParent.value.get(cur.id) ?? []) queue.push(child);
|
|
103
|
+
}
|
|
104
|
+
if (n > 0) out.set(item.id, n);
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
});
|
|
108
|
+
function countFor(item) {
|
|
109
|
+
return (item.id ? countById.value.get(item.id) : void 0) ?? null;
|
|
110
|
+
}
|
|
111
|
+
function freshFor(item) {
|
|
112
|
+
if (!nav.freshnessDots.value || !item.id || item.current) return false;
|
|
113
|
+
const seen = seenMap.value[item.id];
|
|
114
|
+
if (!seen) return false;
|
|
115
|
+
return (subtreeMaxById.value.get(item.id) ?? 0) > seen + 2e3;
|
|
116
|
+
}
|
|
117
|
+
function activeTrail() {
|
|
118
|
+
const trail = [];
|
|
119
|
+
let cursor = docId.value ?? null;
|
|
120
|
+
for (let depth = 0; cursor && depth < 32; depth++) {
|
|
121
|
+
const entry = getEntry(cursor);
|
|
122
|
+
if (!entry) break;
|
|
123
|
+
trail.unshift(cursor);
|
|
124
|
+
const parent = entry.parentId ?? null;
|
|
125
|
+
if (!parent || parent === abra.spaceDocId.value) break;
|
|
126
|
+
cursor = parent;
|
|
127
|
+
}
|
|
128
|
+
return trail;
|
|
129
|
+
}
|
|
130
|
+
function labelOf(id) {
|
|
131
|
+
const entry = getEntry(id);
|
|
132
|
+
const nl = entry?.meta?.navLabel;
|
|
133
|
+
if (typeof nl === "string" && nl.trim()) return nl.trim();
|
|
134
|
+
return entry?.label || "Untitled";
|
|
135
|
+
}
|
|
136
|
+
function topAncestorOf(id) {
|
|
137
|
+
let cursor = id;
|
|
138
|
+
for (let depth = 0; cursor && depth < 32; depth++) {
|
|
139
|
+
const entry = getEntry(cursor);
|
|
140
|
+
if (!entry) return null;
|
|
141
|
+
const parent = entry.parentId ?? null;
|
|
142
|
+
if (!parent || parent === abra.spaceDocId.value) return cursor;
|
|
143
|
+
cursor = parent;
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const presenceByNavId = computed(() => {
|
|
148
|
+
const map = /* @__PURE__ */ new Map();
|
|
149
|
+
for (const t of travellers.value) {
|
|
150
|
+
if (!t.docId) continue;
|
|
151
|
+
const top = topAncestorOf(t.docId);
|
|
152
|
+
if (!top) continue;
|
|
153
|
+
const list = map.get(top) ?? [];
|
|
154
|
+
list.push(t);
|
|
155
|
+
map.set(top, list);
|
|
156
|
+
}
|
|
157
|
+
for (const [id, list] of map) map.set(id, junDedupeTravellers(list));
|
|
158
|
+
return map;
|
|
159
|
+
});
|
|
160
|
+
const presenceFor = (id) => id ? presenceByNavId.value.get(id) ?? [] : [];
|
|
161
|
+
if (options.trackSeen) {
|
|
162
|
+
watch(
|
|
163
|
+
[() => route.path, docId, subtreeMaxById],
|
|
164
|
+
() => {
|
|
165
|
+
if (!import.meta.client) return;
|
|
166
|
+
const top = docId.value ? topAncestorOf(docId.value) : null;
|
|
167
|
+
if (!top) return;
|
|
168
|
+
seenMap.value = { ...seenMap.value, [top]: Date.now() };
|
|
169
|
+
persistSeen();
|
|
170
|
+
},
|
|
171
|
+
{ immediate: true }
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
activeTrail,
|
|
176
|
+
labelOf,
|
|
177
|
+
iconFor,
|
|
178
|
+
navLabelFor,
|
|
179
|
+
redirectTargetFor,
|
|
180
|
+
isExternalTarget,
|
|
181
|
+
childrenOf,
|
|
182
|
+
freshFor,
|
|
183
|
+
countFor,
|
|
184
|
+
presenceFor,
|
|
185
|
+
topAncestorOf,
|
|
186
|
+
subtreeMaxById
|
|
187
|
+
};
|
|
188
|
+
}
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
import type { JunNavActiveStyle, JunNavItemMode, JunNavLogoAction, JunNavPlacement, JunNavShape, JunNavSize } from '../types.js';
|
|
1
|
+
import type { JunNavActiveStyle, JunNavAlign, JunNavBreakpoint, JunNavChildrenMode, JunNavItemMode, JunNavLogoAction, JunNavMenuIcon, JunNavMenuSide, JunNavMobileItemMode, JunNavMobileMode, JunNavMobilePlacement, JunNavOverflow, JunNavPlacement, JunNavRailBreakpoint, JunNavCountMode, JunNavSectionMode, JunNavShape, JunNavSize, JunNavWidth } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The pixel width of each breakpoint, for the ONE consumer that cannot use a
|
|
4
|
+
* Tailwind class: `useMediaQuery`. Everything that can express the switch in
|
|
5
|
+
* CSS does, because a media query resolved in JavaScript is `false` on the
|
|
6
|
+
* server — the trap the rail fallback carries a paragraph about.
|
|
7
|
+
*/
|
|
8
|
+
export declare const JUN_NAV_BREAKPOINT_PX: Record<string, number>;
|
|
2
9
|
export declare function useJunNavSettings(): {
|
|
3
10
|
placement: import("vue").ComputedRef<JunNavPlacement>;
|
|
4
11
|
shape: import("vue").ComputedRef<JunNavShape>;
|
|
5
12
|
size: import("vue").ComputedRef<JunNavSize>;
|
|
6
13
|
itemMode: import("vue").ComputedRef<JunNavItemMode>;
|
|
7
14
|
activeStyle: import("vue").ComputedRef<JunNavActiveStyle>;
|
|
15
|
+
/** The section bar's shape — `off` unless a site asked for one. */
|
|
16
|
+
section: import("vue").ComputedRef<JunNavSectionMode>;
|
|
17
|
+
/** What a nav item's badge counts — `off` unless a site asked for one. */
|
|
18
|
+
counts: import("vue").ComputedRef<JunNavCountMode>;
|
|
19
|
+
/**
|
|
20
|
+
* …and the document may answer this one too, as `on` / `off` rather than a
|
|
21
|
+
* boolean: `junView` values are the strings a `select` stores, and a
|
|
22
|
+
* boolean has no way to spell "no opinion".
|
|
23
|
+
*/
|
|
8
24
|
autoHide: import("vue").ComputedRef<boolean>;
|
|
9
25
|
blur: import("vue").ComputedRef<boolean>;
|
|
10
26
|
homeItem: import("vue").ComputedRef<boolean>;
|
|
@@ -45,6 +61,36 @@ export declare function useJunNavSettings(): {
|
|
|
45
61
|
logoVariant: import("vue").ComputedRef<import("../types.js").JunLogoVariant>;
|
|
46
62
|
/** True for the two vertical placements — the track then stacks. */
|
|
47
63
|
isRail: import("vue").ComputedRef<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* The phone presentation. `track` — today's scrolling row — is the default
|
|
66
|
+
* and the only one that renders no trigger at all.
|
|
67
|
+
*/
|
|
68
|
+
mobileMode: import("vue").ComputedRef<JunNavMobileMode>;
|
|
69
|
+
mobilePlacement: import("vue").ComputedRef<JunNavMobilePlacement>;
|
|
70
|
+
breakpoint: import("vue").ComputedRef<JunNavBreakpoint>;
|
|
71
|
+
railBreakpoint: import("vue").ComputedRef<JunNavRailBreakpoint>;
|
|
72
|
+
menuIcon: import("vue").ComputedRef<JunNavMenuIcon>;
|
|
73
|
+
menuSide: import("vue").ComputedRef<JunNavMenuSide>;
|
|
74
|
+
/**
|
|
75
|
+
* Item rendering inside the menu, with `inherit` already resolved — no
|
|
76
|
+
* consumer should have to know that `inherit` means "ask `itemMode`", and
|
|
77
|
+
* `icon-focus` is silently downgraded because a phone has no hover to
|
|
78
|
+
* reveal the label with.
|
|
79
|
+
*/
|
|
80
|
+
menuItemMode: import("vue").ComputedRef<JunNavItemMode>;
|
|
81
|
+
menuChildren: import("vue").ComputedRef<boolean>;
|
|
82
|
+
menuExtras: import("vue").ComputedRef<boolean>;
|
|
83
|
+
desktopMenu: import("vue").ComputedRef<boolean>;
|
|
84
|
+
/** True when SOME viewport gets a menu — i.e. the trigger has to exist. */
|
|
85
|
+
menuEnabled: import("vue").ComputedRef<boolean>;
|
|
86
|
+
overflow: import("vue").ComputedRef<JunNavOverflow>;
|
|
87
|
+
children: import("vue").ComputedRef<JunNavChildrenMode>;
|
|
88
|
+
align: import("vue").ComputedRef<JunNavAlign>;
|
|
89
|
+
width: import("vue").ComputedRef<JunNavWidth>;
|
|
90
|
+
separators: import("vue").ComputedRef<boolean>;
|
|
91
|
+
scrollArrows: import("vue").ComputedRef<boolean>;
|
|
92
|
+
edgeFade: import("vue").ComputedRef<boolean>;
|
|
93
|
+
snap: import("vue").ComputedRef<boolean>;
|
|
48
94
|
/** The vocabularies, so the settings page never keeps a second copy. */
|
|
49
95
|
vocab: {
|
|
50
96
|
PLACEMENTS: JunNavPlacement[];
|
|
@@ -53,5 +99,16 @@ export declare function useJunNavSettings(): {
|
|
|
53
99
|
ITEM_MODES: JunNavItemMode[];
|
|
54
100
|
ACTIVE_STYLES: JunNavActiveStyle[];
|
|
55
101
|
LOGO_ACTIONS: JunNavLogoAction[];
|
|
102
|
+
MOBILE_MODES: JunNavMobileMode[];
|
|
103
|
+
MOBILE_PLACEMENTS: JunNavMobilePlacement[];
|
|
104
|
+
BREAKPOINTS: JunNavBreakpoint[];
|
|
105
|
+
RAIL_BREAKPOINTS: JunNavRailBreakpoint[];
|
|
106
|
+
MENU_ICONS: JunNavMenuIcon[];
|
|
107
|
+
MENU_SIDES: JunNavMenuSide[];
|
|
108
|
+
MOBILE_ITEM_MODES: JunNavMobileItemMode[];
|
|
109
|
+
OVERFLOWS: JunNavOverflow[];
|
|
110
|
+
CHILDREN_MODES: JunNavChildrenMode[];
|
|
111
|
+
ALIGNS: JunNavAlign[];
|
|
112
|
+
WIDTHS: JunNavWidth[];
|
|
56
113
|
};
|
|
57
114
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
|
+
import { useAbracadabra, useDocTree, useRoute, useSlugRoute } from "#imports";
|
|
3
|
+
import { junNavFlag, junNavPick, junNavPreview } from "../utils/junNavValue.js";
|
|
2
4
|
import { useJunOptions } from "./useJunOptions.js";
|
|
3
5
|
import { useJunEffectiveConfig } from "./useJunSiteConfig.js";
|
|
4
6
|
const PLACEMENTS = ["top", "top-bar", "bottom", "rail-left", "rail-right"];
|
|
@@ -8,27 +10,69 @@ const ITEM_MODES = ["text", "icon", "icon-focus", "icon-text", "icon-stack"];
|
|
|
8
10
|
const ACTIVE_STYLES = ["underline", "pill", "dot", "bold", "glow", "box", "bracket"];
|
|
9
11
|
const LOGO_VARIANTS = ["mark", "lockup", "wordmark"];
|
|
10
12
|
const LOGO_ACTIONS = ["home", "palette"];
|
|
13
|
+
const COUNT_MODES = ["off", "children", "new"];
|
|
14
|
+
const SECTION_MODES = ["off", "row", "segmented", "tabs"];
|
|
15
|
+
const MOBILE_MODES = ["track", "sheet", "drawer-left", "drawer-right", "fullscreen", "grid", "dock"];
|
|
16
|
+
const MOBILE_PLACEMENTS = ["inherit", "top", "top-bar", "bottom"];
|
|
17
|
+
const BREAKPOINTS = ["sm", "md", "lg"];
|
|
18
|
+
const RAIL_BREAKPOINTS = ["lg", "md", "xl"];
|
|
19
|
+
const MENU_ICONS = ["menu", "grid", "dots", "chevron"];
|
|
20
|
+
const MENU_SIDES = ["right", "left"];
|
|
21
|
+
const MOBILE_ITEM_MODES = ["inherit", ...ITEM_MODES];
|
|
22
|
+
const OVERFLOWS = ["scroll", "wrap", "more", "shrink"];
|
|
23
|
+
const CHILDREN_MODES = ["none", "hover", "click", "mega"];
|
|
24
|
+
const ALIGNS = ["center", "start", "end", "spread"];
|
|
25
|
+
const WIDTHS = ["contained", "narrow", "wide", "full"];
|
|
26
|
+
export const JUN_NAV_BREAKPOINT_PX = {
|
|
27
|
+
sm: 640,
|
|
28
|
+
md: 768,
|
|
29
|
+
lg: 1024,
|
|
30
|
+
xl: 1280
|
|
31
|
+
};
|
|
11
32
|
export function useJunNavSettings() {
|
|
12
33
|
const { navigation, brand } = useJunOptions();
|
|
34
|
+
const route = useRoute();
|
|
35
|
+
const abra = useAbracadabra();
|
|
36
|
+
const { getEntry } = useDocTree();
|
|
37
|
+
const { docId } = useSlugRoute();
|
|
38
|
+
const docNav = computed(() => {
|
|
39
|
+
const id = docId.value ?? (route.path === "/" ? abra.spaceDocId.value : null);
|
|
40
|
+
if (!id) return {};
|
|
41
|
+
const view = getEntry(id)?.meta?.junView;
|
|
42
|
+
const stored = view && typeof view === "object" ? view : {};
|
|
43
|
+
return { ...stored, ...junNavPreview(route.query["jun-nav"]) };
|
|
44
|
+
});
|
|
13
45
|
const config = useJunEffectiveConfig();
|
|
14
|
-
function pick(stored, allowed, fallback) {
|
|
15
|
-
return
|
|
46
|
+
function pick(stored, allowed, fallback, doc) {
|
|
47
|
+
return junNavPick({ doc, site: stored, build: fallback }, allowed);
|
|
16
48
|
}
|
|
17
|
-
function flag(stored, fallback) {
|
|
18
|
-
return
|
|
49
|
+
function flag(stored, fallback, doc) {
|
|
50
|
+
return junNavFlag({ doc, site: stored, build: fallback });
|
|
19
51
|
}
|
|
20
|
-
const placement = computed(() => pick(config.value.navPlacement, PLACEMENTS, navigation.placement));
|
|
52
|
+
const placement = computed(() => pick(config.value.navPlacement, PLACEMENTS, navigation.placement, docNav.value.navPlacement));
|
|
21
53
|
const shape = computed(() => pick(config.value.navShape, SHAPES, navigation.shape));
|
|
22
54
|
const size = computed(() => pick(config.value.navSize, SIZES, navigation.size));
|
|
23
|
-
const itemMode = computed(() => pick(config.value.navItemMode, ITEM_MODES, navigation.itemMode));
|
|
55
|
+
const itemMode = computed(() => pick(config.value.navItemMode, ITEM_MODES, navigation.itemMode, docNav.value.navItemMode));
|
|
24
56
|
const activeStyle = computed(() => pick(config.value.navActiveStyle, ACTIVE_STYLES, navigation.activeStyle));
|
|
57
|
+
const section = computed(() => pick(config.value.navSection, SECTION_MODES, navigation.section, docNav.value.navSection));
|
|
58
|
+
const counts = computed(() => pick(config.value.navCounts, COUNT_MODES, navigation.counts));
|
|
59
|
+
const mobileMode = computed(() => pick(config.value.navMobileMode, MOBILE_MODES, navigation.mobileMode, docNav.value.navMobileMode));
|
|
25
60
|
return {
|
|
26
61
|
placement,
|
|
27
62
|
shape,
|
|
28
63
|
size,
|
|
29
64
|
itemMode,
|
|
30
65
|
activeStyle,
|
|
31
|
-
|
|
66
|
+
/** The section bar's shape — `off` unless a site asked for one. */
|
|
67
|
+
section,
|
|
68
|
+
/** What a nav item's badge counts — `off` unless a site asked for one. */
|
|
69
|
+
counts,
|
|
70
|
+
/**
|
|
71
|
+
* …and the document may answer this one too, as `on` / `off` rather than a
|
|
72
|
+
* boolean: `junView` values are the strings a `select` stores, and a
|
|
73
|
+
* boolean has no way to spell "no opinion".
|
|
74
|
+
*/
|
|
75
|
+
autoHide: computed(() => flag(config.value.navAutoHide, navigation.autoHide, docNav.value.navAutoHide)),
|
|
32
76
|
blur: computed(() => flag(config.value.navBlur, navigation.blur)),
|
|
33
77
|
homeItem: computed(() => flag(config.value.navHomeItem, navigation.homeItem)),
|
|
34
78
|
showLogo: computed(() => flag(config.value.navShowLogo, navigation.showLogo)),
|
|
@@ -68,7 +112,65 @@ export function useJunNavSettings() {
|
|
|
68
112
|
logoVariant: computed(() => pick(config.value.brandLogoVariant, LOGO_VARIANTS, brand.logoVariant)),
|
|
69
113
|
/** True for the two vertical placements — the track then stacks. */
|
|
70
114
|
isRail: computed(() => placement.value === "rail-left" || placement.value === "rail-right"),
|
|
115
|
+
// ── Mobile ───────────────────────────────────────────────────────────────
|
|
116
|
+
/**
|
|
117
|
+
* The phone presentation. `track` — today's scrolling row — is the default
|
|
118
|
+
* and the only one that renders no trigger at all.
|
|
119
|
+
*/
|
|
120
|
+
mobileMode,
|
|
121
|
+
mobilePlacement: computed(() => pick(config.value.navMobilePlacement, MOBILE_PLACEMENTS, navigation.mobilePlacement)),
|
|
122
|
+
breakpoint: computed(() => pick(config.value.navBreakpoint, BREAKPOINTS, navigation.breakpoint)),
|
|
123
|
+
railBreakpoint: computed(() => pick(config.value.navRailBreakpoint, RAIL_BREAKPOINTS, navigation.railBreakpoint)),
|
|
124
|
+
menuIcon: computed(() => pick(config.value.navMenuIcon, MENU_ICONS, navigation.menuIcon)),
|
|
125
|
+
menuSide: computed(() => pick(config.value.navMenuSide, MENU_SIDES, navigation.menuSide)),
|
|
126
|
+
/**
|
|
127
|
+
* Item rendering inside the menu, with `inherit` already resolved — no
|
|
128
|
+
* consumer should have to know that `inherit` means "ask `itemMode`", and
|
|
129
|
+
* `icon-focus` is silently downgraded because a phone has no hover to
|
|
130
|
+
* reveal the label with.
|
|
131
|
+
*/
|
|
132
|
+
menuItemMode: computed(() => {
|
|
133
|
+
const stored = pick(
|
|
134
|
+
config.value.navMobileItemMode,
|
|
135
|
+
MOBILE_ITEM_MODES,
|
|
136
|
+
navigation.mobileItemMode
|
|
137
|
+
);
|
|
138
|
+
const resolved = stored === "inherit" ? itemMode.value : stored;
|
|
139
|
+
return resolved === "icon-focus" ? "icon-text" : resolved;
|
|
140
|
+
}),
|
|
141
|
+
menuChildren: computed(() => flag(config.value.navMenuChildren, navigation.menuChildren)),
|
|
142
|
+
menuExtras: computed(() => flag(config.value.navMenuExtras, navigation.menuExtras)),
|
|
143
|
+
desktopMenu: computed(() => flag(config.value.navDesktopMenu, navigation.desktopMenu)),
|
|
144
|
+
/** True when SOME viewport gets a menu — i.e. the trigger has to exist. */
|
|
145
|
+
menuEnabled: computed(() => mobileMode.value !== "track" || flag(config.value.navDesktopMenu, navigation.desktopMenu)),
|
|
146
|
+
// ── Track layout ─────────────────────────────────────────────────────────
|
|
147
|
+
overflow: computed(() => pick(config.value.navOverflow, OVERFLOWS, navigation.overflow)),
|
|
148
|
+
children: computed(() => pick(config.value.navChildren, CHILDREN_MODES, navigation.children)),
|
|
149
|
+
align: computed(() => pick(config.value.navAlign, ALIGNS, navigation.align)),
|
|
150
|
+
width: computed(() => pick(config.value.navWidth, WIDTHS, navigation.width)),
|
|
151
|
+
separators: computed(() => flag(config.value.navSeparators, navigation.separators)),
|
|
152
|
+
scrollArrows: computed(() => flag(config.value.navScrollArrows, navigation.scrollArrows)),
|
|
153
|
+
edgeFade: computed(() => flag(config.value.navEdgeFade, navigation.edgeFade)),
|
|
154
|
+
snap: computed(() => flag(config.value.navSnap, navigation.snap)),
|
|
71
155
|
/** The vocabularies, so the settings page never keeps a second copy. */
|
|
72
|
-
vocab: {
|
|
156
|
+
vocab: {
|
|
157
|
+
PLACEMENTS,
|
|
158
|
+
SHAPES,
|
|
159
|
+
SIZES,
|
|
160
|
+
ITEM_MODES,
|
|
161
|
+
ACTIVE_STYLES,
|
|
162
|
+
LOGO_ACTIONS,
|
|
163
|
+
MOBILE_MODES,
|
|
164
|
+
MOBILE_PLACEMENTS,
|
|
165
|
+
BREAKPOINTS,
|
|
166
|
+
RAIL_BREAKPOINTS,
|
|
167
|
+
MENU_ICONS,
|
|
168
|
+
MENU_SIDES,
|
|
169
|
+
MOBILE_ITEM_MODES,
|
|
170
|
+
OVERFLOWS,
|
|
171
|
+
CHILDREN_MODES,
|
|
172
|
+
ALIGNS,
|
|
173
|
+
WIDTHS
|
|
174
|
+
}
|
|
73
175
|
};
|
|
74
176
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type JunOfflineMode, type JunOfflineSection } from '../utils/junOffline.js';
|
|
2
|
+
/** What the last save actually stored, kept so the panel can say how old it is. */
|
|
3
|
+
export interface JunOfflineReceipt {
|
|
4
|
+
at: number;
|
|
5
|
+
pages: number;
|
|
6
|
+
assets: number;
|
|
7
|
+
bytes: number;
|
|
8
|
+
/**
|
|
9
|
+
* The build the copy was made from.
|
|
10
|
+
*
|
|
11
|
+
* The cache is named after the build, so a DEPLOY orphans a saved copy and
|
|
12
|
+
* the worker's `activate` deletes it. That is correct — a copy of pages whose
|
|
13
|
+
* assets no longer exist is not a copy — but it is invisible, and a visitor
|
|
14
|
+
* whose saved site quietly evaporated deserves to be told rather than to find
|
|
15
|
+
* out in a tunnel.
|
|
16
|
+
*/
|
|
17
|
+
build: string;
|
|
18
|
+
/** Set when the save stopped early: `'budget'`. */
|
|
19
|
+
stopped?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface JunOfflineManifest {
|
|
22
|
+
pages: string[];
|
|
23
|
+
sections: JunOfflineSection[];
|
|
24
|
+
count: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function useJunOffline(): {
|
|
27
|
+
open: import("vue").Ref<boolean, boolean>;
|
|
28
|
+
openOffline: () => void;
|
|
29
|
+
/** Deferred to mount — every reader below is client-only state. */
|
|
30
|
+
mounted: import("vue").Ref<boolean, boolean>;
|
|
31
|
+
mode: import("vue").Ref<JunOfflineMode, JunOfflineMode>;
|
|
32
|
+
media: import("vue").Ref<boolean, boolean>;
|
|
33
|
+
policy: import("vue").ComputedRef<{
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
fullSite: boolean;
|
|
36
|
+
media: boolean;
|
|
37
|
+
docSync: boolean;
|
|
38
|
+
budgetBytes: number;
|
|
39
|
+
defaultMode: JunOfflineMode;
|
|
40
|
+
}>;
|
|
41
|
+
manifest: import("vue").Ref<{
|
|
42
|
+
pages: string[];
|
|
43
|
+
sections: {
|
|
44
|
+
path: string;
|
|
45
|
+
label: string;
|
|
46
|
+
pages: {
|
|
47
|
+
path: string;
|
|
48
|
+
label: string;
|
|
49
|
+
section: string;
|
|
50
|
+
}[];
|
|
51
|
+
}[];
|
|
52
|
+
count: number;
|
|
53
|
+
} | null, JunOfflineManifest | {
|
|
54
|
+
pages: string[];
|
|
55
|
+
sections: {
|
|
56
|
+
path: string;
|
|
57
|
+
label: string;
|
|
58
|
+
pages: {
|
|
59
|
+
path: string;
|
|
60
|
+
label: string;
|
|
61
|
+
section: string;
|
|
62
|
+
}[];
|
|
63
|
+
}[];
|
|
64
|
+
count: number;
|
|
65
|
+
} | null>;
|
|
66
|
+
usage: import("vue").Ref<{
|
|
67
|
+
used: number;
|
|
68
|
+
quota: number;
|
|
69
|
+
} | null, {
|
|
70
|
+
used: number;
|
|
71
|
+
quota: number;
|
|
72
|
+
} | {
|
|
73
|
+
used: number;
|
|
74
|
+
quota: number;
|
|
75
|
+
} | null>;
|
|
76
|
+
receipt: import("vue").Ref<{
|
|
77
|
+
at: number;
|
|
78
|
+
pages: number;
|
|
79
|
+
assets: number;
|
|
80
|
+
bytes: number;
|
|
81
|
+
build: string;
|
|
82
|
+
stopped?: string | undefined;
|
|
83
|
+
} | null, JunOfflineReceipt | {
|
|
84
|
+
at: number;
|
|
85
|
+
pages: number;
|
|
86
|
+
assets: number;
|
|
87
|
+
bytes: number;
|
|
88
|
+
build: string;
|
|
89
|
+
stopped?: string | undefined;
|
|
90
|
+
} | null>;
|
|
91
|
+
receiptStale: import("vue").ComputedRef<boolean>;
|
|
92
|
+
saving: import("vue").Ref<boolean, boolean>;
|
|
93
|
+
savedCount: import("vue").Ref<number, number>;
|
|
94
|
+
savedTotal: import("vue").Ref<number, number>;
|
|
95
|
+
savedBytes: import("vue").Ref<number, number>;
|
|
96
|
+
progress: import("vue").ComputedRef<number>;
|
|
97
|
+
lastError: import("vue").Ref<string | null, string | null>;
|
|
98
|
+
syncing: import("vue").Ref<boolean, boolean>;
|
|
99
|
+
syncedDocs: import("vue").Ref<number, number>;
|
|
100
|
+
syncTotal: import("vue").Ref<number, number>;
|
|
101
|
+
syncDocuments: () => Promise<void>;
|
|
102
|
+
setMode: (next: JunOfflineMode) => Promise<void>;
|
|
103
|
+
setMedia: (next: boolean) => Promise<void>;
|
|
104
|
+
loadManifest: () => Promise<JunOfflineManifest | null>;
|
|
105
|
+
estimate: () => Promise<number>;
|
|
106
|
+
save: (paths?: string[]) => Promise<JunOfflineReceipt | null>;
|
|
107
|
+
purge: () => Promise<void>;
|
|
108
|
+
refreshUsage: () => Promise<void>;
|
|
109
|
+
};
|