@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.
Files changed (109) hide show
  1. package/dist/module.d.mts +43 -4
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +121 -6
  4. package/dist/runtime/assets/css/jun.css +2 -2
  5. package/dist/runtime/components/JunDocSurface.d.vue.ts +20 -2
  6. package/dist/runtime/components/JunDocSurface.vue +27 -2
  7. package/dist/runtime/components/JunDocSurface.vue.d.ts +20 -2
  8. package/dist/runtime/components/JunHead.vue +16 -4
  9. package/dist/runtime/components/JunNavDock.d.vue.ts +15 -0
  10. package/dist/runtime/components/JunNavDock.vue +94 -0
  11. package/dist/runtime/components/JunNavDock.vue.d.ts +15 -0
  12. package/dist/runtime/components/JunNavMenu.client.d.vue.ts +15 -0
  13. package/dist/runtime/components/JunNavMenu.client.vue +501 -0
  14. package/dist/runtime/components/JunNavMenu.client.vue.d.ts +15 -0
  15. package/dist/runtime/components/JunNavPreview.d.vue.ts +17 -0
  16. package/dist/runtime/components/JunNavPreview.vue +169 -0
  17. package/dist/runtime/components/JunNavPreview.vue.d.ts +17 -0
  18. package/dist/runtime/components/JunNavigation.d.vue.ts +4 -11
  19. package/dist/runtime/components/JunNavigation.vue +813 -138
  20. package/dist/runtime/components/JunNavigation.vue.d.ts +4 -11
  21. package/dist/runtime/components/JunNoteLinks.vue +1 -1
  22. package/dist/runtime/components/JunOfflinePanel.client.d.vue.ts +3 -0
  23. package/dist/runtime/components/JunOfflinePanel.client.vue +293 -0
  24. package/dist/runtime/components/JunOfflinePanel.client.vue.d.ts +3 -0
  25. package/dist/runtime/components/JunPageHero.vue +3 -3
  26. package/dist/runtime/components/JunSectionBar.d.vue.ts +41 -0
  27. package/dist/runtime/components/JunSectionBar.vue +144 -0
  28. package/dist/runtime/components/JunSectionBar.vue.d.ts +41 -0
  29. package/dist/runtime/components/renderers/JunConfigRenderer.vue +618 -6
  30. package/dist/runtime/components/renderers/JunEntryRenderer.vue +48 -0
  31. package/dist/runtime/composables/useJunCommands.d.ts +1 -1
  32. package/dist/runtime/composables/useJunCommands.js +14 -1
  33. package/dist/runtime/composables/useJunCreatePage.js +7 -1
  34. package/dist/runtime/composables/useJunDocPage.d.ts +28 -0
  35. package/dist/runtime/composables/useJunDocPage.js +111 -20
  36. package/dist/runtime/composables/useJunGarden.d.ts +1 -1
  37. package/dist/runtime/composables/useJunGarden.js +3 -2
  38. package/dist/runtime/composables/useJunGestures.d.ts +53 -0
  39. package/dist/runtime/composables/useJunGestures.js +89 -0
  40. package/dist/runtime/composables/useJunMenuState.d.ts +4 -0
  41. package/dist/runtime/composables/useJunMenuState.js +5 -0
  42. package/dist/runtime/composables/useJunNavItems.d.ts +50 -0
  43. package/dist/runtime/composables/useJunNavItems.js +188 -0
  44. package/dist/runtime/composables/useJunNavSettings.d.ts +58 -1
  45. package/dist/runtime/composables/useJunNavSettings.js +110 -8
  46. package/dist/runtime/composables/useJunOffline.d.ts +109 -0
  47. package/dist/runtime/composables/useJunOffline.js +294 -0
  48. package/dist/runtime/composables/useJunOptions.d.ts +1 -0
  49. package/dist/runtime/composables/useJunSettings.d.ts +1 -1
  50. package/dist/runtime/composables/useJunSettings.js +2 -0
  51. package/dist/runtime/composables/useJunSiblings.d.ts +30 -0
  52. package/dist/runtime/composables/useJunSiblings.js +38 -0
  53. package/dist/runtime/composables/useJunSiteConfig.d.ts +70 -3
  54. package/dist/runtime/composables/useJunTheme.js +4 -1
  55. package/dist/runtime/composables/useJunViewingAccent.js +10 -0
  56. package/dist/runtime/layouts/jun.vue +32 -2
  57. package/dist/runtime/pages/doc.vue +2 -0
  58. package/dist/runtime/pages/index.vue +2 -0
  59. package/dist/runtime/server/api/health.get.d.ts +15 -0
  60. package/dist/runtime/server/api/health.get.js +7 -2
  61. package/dist/runtime/server/api/links.get.js +27 -3
  62. package/dist/runtime/server/api/offline.get.d.ts +10 -0
  63. package/dist/runtime/server/api/offline.get.js +13 -0
  64. package/dist/runtime/server/api/resolve/[...slug].get.d.ts +20 -0
  65. package/dist/runtime/server/api/resolve/[...slug].get.js +31 -0
  66. package/dist/runtime/server/api/search.get.d.ts +1 -1
  67. package/dist/runtime/server/api/search.get.js +42 -39
  68. package/dist/runtime/server/api/tree.get.js +3 -1
  69. package/dist/runtime/server/janitor/junJanitorChores.d.ts +14 -7
  70. package/dist/runtime/server/janitor/junJanitorChores.js +21 -3
  71. package/dist/runtime/server/janitor/junJanitorMachine.js +36 -4
  72. package/dist/runtime/server/janitor/junJanitorPerform.d.ts +15 -1
  73. package/dist/runtime/server/janitor/junJanitorPerform.js +13 -5
  74. package/dist/runtime/server/janitor/junJanitorYText.d.ts +40 -3
  75. package/dist/runtime/server/janitor/junJanitorYText.js +60 -14
  76. package/dist/runtime/server/plugins/jun-compress.d.ts +2 -0
  77. package/dist/runtime/server/plugins/jun-compress.js +76 -0
  78. package/dist/runtime/server/plugins/jun-janitor.js +132 -81
  79. package/dist/runtime/server/routes/jun-card.png.get.d.ts +2 -0
  80. package/dist/runtime/server/routes/jun-card.png.get.js +40 -0
  81. package/dist/runtime/server/routes/jun-sw.js.get.js +66 -13
  82. package/dist/runtime/server/routes/sitemap.xml.get.js +5 -18
  83. package/dist/runtime/server/utils/junCard.d.ts +39 -0
  84. package/dist/runtime/server/utils/junCard.js +159 -0
  85. package/dist/runtime/server/utils/junIcon.d.ts +27 -2
  86. package/dist/runtime/server/utils/junIcon.js +5 -5
  87. package/dist/runtime/server/utils/junJanitorStatus.d.ts +59 -0
  88. package/dist/runtime/server/utils/junJanitorStatus.js +27 -0
  89. package/dist/runtime/server/utils/junPages.d.ts +51 -0
  90. package/dist/runtime/server/utils/junPages.js +70 -0
  91. package/dist/runtime/types.d.ts +295 -0
  92. package/dist/runtime/utils/junAdopt.d.ts +43 -0
  93. package/dist/runtime/utils/junAdopt.js +7 -0
  94. package/dist/runtime/utils/junGesture.d.ts +84 -0
  95. package/dist/runtime/utils/junGesture.js +40 -0
  96. package/dist/runtime/utils/junLetters.d.ts +86 -0
  97. package/dist/runtime/utils/junLetters.js +173 -0
  98. package/dist/runtime/utils/junNavValue.d.ts +56 -0
  99. package/dist/runtime/utils/junNavValue.js +36 -0
  100. package/dist/runtime/utils/junOffline.d.ts +138 -0
  101. package/dist/runtime/utils/junOffline.js +73 -0
  102. package/dist/runtime/utils/junSearchRank.d.ts +79 -0
  103. package/dist/runtime/utils/junSearchRank.js +73 -0
  104. package/dist/runtime/utils/junSocial.d.ts +59 -0
  105. package/dist/runtime/utils/junSocial.js +56 -0
  106. package/dist/runtime/utils/junViewSpecs.d.ts +39 -1
  107. package/dist/runtime/utils/junViewSpecs.js +92 -1
  108. package/dist/types.d.mts +1 -1
  109. package/package.json +13 -9
@@ -1,19 +1,12 @@
1
- interface NavigationItem {
2
- id?: string;
3
- name: string;
4
- href: string;
5
- type?: string;
6
- icon?: string;
7
- current: boolean;
8
- }
1
+ import { type JunNavigationItem as NavigationItem } from '../composables/useJunNavItems.js';
9
2
  type __VLS_Props = {
10
3
  navigation: NavigationItem[];
11
4
  };
12
- declare var __VLS_9: {}, __VLS_83: {};
5
+ declare var __VLS_14: {}, __VLS_118: {};
13
6
  type __VLS_Slots = {} & {
14
- logo?: (props: typeof __VLS_9) => any;
7
+ logo?: (props: typeof __VLS_14) => any;
15
8
  } & {
16
- actions?: (props: typeof __VLS_83) => any;
9
+ actions?: (props: typeof __VLS_118) => any;
17
10
  };
18
11
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
12
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
@@ -6,7 +6,7 @@ const props = defineProps({
6
6
  });
7
7
  const { typeIdFor } = useJunPageType();
8
8
  const gardenOn = computed(() => !!typeIdFor("garden"));
9
- const { graph } = useJunLinkGraph();
9
+ const { graph } = useJunLinkGraph(props.docId);
10
10
  const { entries } = useDocTree();
11
11
  const { getDocUrl } = useDocSlugs();
12
12
  const labelOf = computed(() => {
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,293 @@
1
+ <script setup>
2
+ import { computed, ref, watch } from "vue";
3
+ import { useJunOffline, useJunStudio } from "#imports";
4
+ import { junFormatBytes } from "../utils/junOffline";
5
+ const {
6
+ open,
7
+ mode,
8
+ media,
9
+ policy,
10
+ manifest,
11
+ usage,
12
+ receipt,
13
+ receiptStale,
14
+ saving,
15
+ savedCount,
16
+ savedTotal,
17
+ savedBytes,
18
+ progress,
19
+ lastError,
20
+ syncing,
21
+ syncedDocs,
22
+ syncTotal,
23
+ syncDocuments,
24
+ setMode,
25
+ setMedia,
26
+ loadManifest,
27
+ estimate,
28
+ save,
29
+ purge
30
+ } = useJunOffline();
31
+ const { canEdit } = useJunStudio();
32
+ const estimated = ref(null);
33
+ watch(open, async (isOpen) => {
34
+ if (!isOpen) return;
35
+ await loadManifest();
36
+ estimated.value = await estimate();
37
+ });
38
+ const TIERS = [
39
+ {
40
+ value: "off",
41
+ label: "Nothing",
42
+ hint: "Keep no part of this site on this device.",
43
+ icon: "i-lucide-cloud-off"
44
+ },
45
+ {
46
+ value: "visited",
47
+ label: "Pages you open",
48
+ hint: "The default. Nothing is downloaded on its own \u2014 pages you read are kept, so they are still there when the signal drops.",
49
+ icon: "i-lucide-history"
50
+ },
51
+ {
52
+ value: "site",
53
+ label: "The whole site",
54
+ hint: "Downloaded once, now, so every page works offline.",
55
+ icon: "i-lucide-hard-drive-download"
56
+ }
57
+ ];
58
+ async function pick(next) {
59
+ if (saving.value) return;
60
+ if (next === "site") {
61
+ await save();
62
+ return;
63
+ }
64
+ await setMode(next);
65
+ }
66
+ const tiers = computed(() => TIERS.filter((t) => t.value !== "site" || policy.value.fullSite));
67
+ const savedAgo = computed(() => {
68
+ const at = receipt.value?.at;
69
+ if (!at) return "";
70
+ const mins = Math.round((Date.now() - at) / 6e4);
71
+ if (mins < 1) return "just now";
72
+ if (mins < 60) return `${mins} minute${mins === 1 ? "" : "s"} ago`;
73
+ const hours = Math.round(mins / 60);
74
+ if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"} ago`;
75
+ const days = Math.round(hours / 24);
76
+ return `${days} day${days === 1 ? "" : "s"} ago`;
77
+ });
78
+ async function clear() {
79
+ await purge();
80
+ if (mode.value === "site") await setMode("visited");
81
+ }
82
+ </script>
83
+
84
+ <template>
85
+ <UModal
86
+ v-model:open="open"
87
+ :dismissible="true"
88
+ :ui="{
89
+ content: 'jun-blur-gradient max-w-lg rounded-xl divide-y-0 border-1 border-white/10 shadow-none ring-1 ring-black/5 dark:border-black/5 dark:ring-white/10',
90
+ overlay: 'bg-black/[0.06] dark:bg-black/35'
91
+ }"
92
+ >
93
+ <template #content>
94
+ <div class="flex min-h-0 flex-col overflow-hidden rounded-xl">
95
+ <div class="flex h-12 shrink-0 items-center gap-2 border-b border-black/5 px-3 dark:border-white/10">
96
+ <UIcon
97
+ name="i-lucide-cloud-download"
98
+ class="ml-1 size-4 shrink-0 opacity-60"
99
+ />
100
+ <span class="min-w-0 flex-1 truncate text-sm tracking-widest">Offline</span>
101
+ <button
102
+ type="button"
103
+ class="hidden shrink-0 opacity-60 transition-opacity hover:opacity-100 sm:inline-flex"
104
+ aria-label="Close"
105
+ @click="open = false"
106
+ >
107
+ <UKbd value="esc" />
108
+ </button>
109
+ </div>
110
+
111
+ <div class="min-h-0 flex-1 space-y-5 overflow-y-auto p-4 sm:p-5">
112
+ <p class="text-xs text-muted">
113
+ This site can keep itself on your device, so it still works with no
114
+ connection. Nothing is downloaded unless you ask for it here.
115
+ </p>
116
+
117
+ <!-- The tiers. Buttons rather than a radio group: picking "the whole
118
+ site" STARTS A DOWNLOAD, and a radio implies a setting that takes
119
+ effect quietly. -->
120
+ <div
121
+ class="space-y-2"
122
+ role="group"
123
+ aria-label="How much of this site to keep"
124
+ >
125
+ <button
126
+ v-for="tier in tiers"
127
+ :key="tier.value"
128
+ type="button"
129
+ :disabled="saving"
130
+ :aria-pressed="mode === tier.value"
131
+ class="flex w-full cursor-pointer items-start gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors disabled:cursor-wait disabled:opacity-60"
132
+ :class="mode === tier.value ? 'border-black/15 bg-black/[0.04] dark:border-white/20 dark:bg-white/[0.06]' : 'border-black/5 hover:bg-black/[0.02] dark:border-white/10 dark:hover:bg-white/[0.03]'"
133
+ @click="pick(tier.value)"
134
+ >
135
+ <UIcon
136
+ :name="tier.icon"
137
+ class="mt-0.5 size-4 shrink-0 opacity-70"
138
+ />
139
+ <span class="min-w-0 flex-1">
140
+ <span class="flex items-center gap-2">
141
+ <span class="text-sm font-medium">{{ tier.label }}</span>
142
+ <span
143
+ v-if="tier.value === 'site' && estimated"
144
+ class="rounded-full bg-black/5 px-1.5 py-0.5 text-[0.6875rem] opacity-70 dark:bg-white/10"
145
+ >about {{ junFormatBytes(estimated) }}</span>
146
+ </span>
147
+ <span class="mt-0.5 block text-[11px] text-muted">{{ tier.hint }}</span>
148
+ <span
149
+ v-if="tier.value === 'site' && manifest"
150
+ class="mt-0.5 block text-[11px] text-muted"
151
+ >{{ manifest.count }} pages across {{ manifest.sections.length }} sections</span>
152
+ </span>
153
+ <UIcon
154
+ v-if="mode === tier.value"
155
+ name="i-lucide-check"
156
+ class="mt-0.5 size-4 shrink-0"
157
+ />
158
+ </button>
159
+ </div>
160
+
161
+ <!-- Saving. A live byte count, because the estimate above is one. -->
162
+ <div
163
+ v-if="saving"
164
+ class="space-y-1.5"
165
+ aria-live="polite"
166
+ >
167
+ <div class="h-1 overflow-hidden rounded-full bg-black/10 dark:bg-white/10">
168
+ <div
169
+ class="h-full rounded-full bg-current transition-[width] duration-200"
170
+ :style="{ width: `${Math.round(progress * 100)}%` }"
171
+ />
172
+ </div>
173
+ <p class="text-[11px] text-muted">
174
+ Saving {{ savedCount }} of {{ savedTotal }} pages · {{ junFormatBytes(savedBytes) }}
175
+ </p>
176
+ </div>
177
+
178
+ <!-- Images. Off unless the owner allows it AND the reader asks: this
179
+ is the half whose size is a property of the content. -->
180
+ <JunConfigRow
181
+ v-if="policy.media"
182
+ label="Include images"
183
+ hint="Photographs are the heavy part of a copy. Without them, a saved page shows its words and not its pictures."
184
+ >
185
+ <USwitch
186
+ :model-value="media"
187
+ :disabled="saving"
188
+ @update:model-value="setMedia($event)"
189
+ />
190
+ </JunConfigRow>
191
+
192
+ <!-- What is actually stored. From the browser, not from our own sums. -->
193
+ <div class="space-y-1.5 border-t border-black/5 pt-4 dark:border-white/10">
194
+ <div
195
+ v-if="receipt && !receiptStale"
196
+ class="flex items-baseline justify-between gap-3 text-xs"
197
+ >
198
+ <span class="text-muted">Saved copy</span>
199
+ <span>{{ receipt.pages }} pages, {{ savedAgo }}</span>
200
+ </div>
201
+ <p
202
+ v-else-if="receiptStale"
203
+ class="text-[11px] text-muted"
204
+ >
205
+ A new version of this site was published, so the saved copy was
206
+ replaced. Save it again to have it offline.
207
+ </p>
208
+ <div
209
+ v-if="usage"
210
+ class="flex items-baseline justify-between gap-3 text-xs"
211
+ >
212
+ <span class="text-muted">This site is using</span>
213
+ <span>{{ junFormatBytes(usage.used) }}</span>
214
+ </div>
215
+ <p
216
+ v-if="receipt?.stopped === 'budget'"
217
+ class="text-[11px] text-muted"
218
+ >
219
+ The copy reached this site's size limit and stopped there. The
220
+ pages it did save still work offline.
221
+ </p>
222
+ <p
223
+ v-if="lastError"
224
+ class="text-[11px] text-muted"
225
+ >
226
+ {{ lastError }}
227
+ </p>
228
+ </div>
229
+
230
+ <div class="flex flex-wrap items-center gap-2">
231
+ <UButton
232
+ v-if="policy.fullSite"
233
+ size="xs"
234
+ color="neutral"
235
+ variant="soft"
236
+ icon="i-lucide-refresh-cw"
237
+ :loading="saving"
238
+ :disabled="saving"
239
+ @click="save()"
240
+ >
241
+ {{ receipt && !receiptStale ? "Update the copy" : "Save the whole site" }}
242
+ </UButton>
243
+ <UButton
244
+ size="xs"
245
+ color="neutral"
246
+ variant="ghost"
247
+ icon="i-lucide-trash-2"
248
+ :disabled="saving"
249
+ @click="clear()"
250
+ >
251
+ Clear what is stored
252
+ </UButton>
253
+ </div>
254
+
255
+ <!-- The CRDT half. Owner-only, and a BUTTON rather than a setting:
256
+ this is every document into IndexedDB, which is precisely the
257
+ download nobody asked for when it happens on its own. -->
258
+ <div
259
+ v-if="canEdit && policy.docSync"
260
+ class="space-y-2 border-t border-black/5 pt-4 dark:border-white/10"
261
+ >
262
+ <p class="text-xs font-medium">
263
+ Keep the documents too
264
+ </p>
265
+ <p class="text-[11px] text-muted">
266
+ The pages above are what a reader sees. This copies the documents
267
+ themselves onto this device, so you can edit with no connection —
268
+ a bigger download, and one nothing starts on its own.
269
+ </p>
270
+ <div class="flex items-center gap-2">
271
+ <UButton
272
+ size="xs"
273
+ color="neutral"
274
+ variant="soft"
275
+ icon="i-lucide-refresh-ccw-dot"
276
+ :loading="syncing"
277
+ :disabled="syncing"
278
+ @click="syncDocuments()"
279
+ >
280
+ Sync documents
281
+ </UButton>
282
+ <span
283
+ v-if="syncTotal"
284
+ class="text-[11px] text-muted"
285
+ aria-live="polite"
286
+ >{{ syncedDocs }} of {{ syncTotal }} documents</span>
287
+ </div>
288
+ </div>
289
+ </div>
290
+ </div>
291
+ </template>
292
+ </UModal>
293
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -50,14 +50,14 @@ const editableRing = "cursor-text rounded-md px-1 -mx-1 transition-shadow hover:
50
50
  initial: { opacity: 0, y: 12 },
51
51
  enter: { opacity: 1, y: 0, transition: { duration: 700 } }
52
52
  })"
53
- class="mb-8 flex items-end justify-between gap-4 sm:mb-10 sm:gap-6"
53
+ class="jun-page-hero mb-8 flex items-end justify-between gap-4 sm:mb-10 sm:gap-6"
54
54
  >
55
- <div class="min-w-0">
55
+ <div class="jun-hero-lines min-w-0">
56
56
  <h1
57
57
  ref="h1El"
58
58
  :contenteditable="editable ? 'plaintext-only' : void 0"
59
59
  spellcheck="false"
60
- class="text-3xl leading-[1.05] font-semibold tracking-tight text-highlighted
60
+ class="jun-hero-title text-3xl leading-[1.05] font-semibold tracking-tight text-highlighted
61
61
  outline-none sm:text-4xl lg:text-5xl"
62
62
  :class="editable ? editableRing : ''"
63
63
  @blur="editable && commit()"
@@ -0,0 +1,41 @@
1
+ /** One entry, in the shape the resolve endpoint sends. */
2
+ export interface JunSectionItem {
3
+ id: string;
4
+ title: string;
5
+ slug: string | null;
6
+ icon?: string;
7
+ }
8
+ type __VLS_Props = {
9
+ docId: string;
10
+ /**
11
+ * A column for the bar to sit in.
12
+ *
13
+ * The surface only constrains the page for types that do NOT pad themselves;
14
+ * a journal entry and every feed page carry their own column, so the wrapper
15
+ * around them is full width and a bar inside it would run edge to edge while
16
+ * the prose sat in the middle. The page passes the column when it is the one
17
+ * that knows there isn't one.
18
+ */
19
+ column?: string;
20
+ /**
21
+ * The SSR trail, so the marking is in the SERVED HTML too.
22
+ *
23
+ * On a deep page the item that lights up is an ANCESTOR rather than the page,
24
+ * and the live tree cannot say which one until it has synced.
25
+ */
26
+ ssrTrail?: {
27
+ id: string;
28
+ title: string;
29
+ slug: string | null;
30
+ }[];
31
+ /** The SSR payload's section, used until the live tree has synced. */
32
+ ssrSection?: {
33
+ parentId: string;
34
+ parentTitle: string;
35
+ parentSlug: string | null;
36
+ items: JunSectionItem[];
37
+ } | null;
38
+ };
39
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
40
+ declare const _default: typeof __VLS_export;
41
+ export default _default;
@@ -0,0 +1,144 @@
1
+ <script setup>
2
+ import { computed, onMounted, ref } from "vue";
3
+ import { useDocSlugs, useDocTree, useJunDocIcon, useRoute } from "#imports";
4
+ import { useJunNavSettings } from "../composables/useJunNavSettings";
5
+ const props = defineProps({
6
+ docId: { type: String, required: true },
7
+ column: { type: String, required: false },
8
+ ssrTrail: { type: Array, required: false },
9
+ ssrSection: { type: [Object, null], required: false }
10
+ });
11
+ const SECTION_MAX = 40;
12
+ const mounted = ref(false);
13
+ onMounted(() => {
14
+ mounted.value = true;
15
+ });
16
+ const route = useRoute();
17
+ const nav = useJunNavSettings();
18
+ const { entries, getEntry } = useDocTree();
19
+ const { getDocUrl } = useDocSlugs();
20
+ const docIcon = useJunDocIcon();
21
+ const branchId = computed(() => {
22
+ const live = mounted.value ? getEntry(props.docId) : void 0;
23
+ if (!live) return props.ssrSection?.parentId ?? null;
24
+ const seen = /* @__PURE__ */ new Set();
25
+ let cursor = props.docId;
26
+ let last = null;
27
+ while (cursor && !seen.has(cursor)) {
28
+ seen.add(cursor);
29
+ const entry = getEntry(cursor);
30
+ if (!entry) break;
31
+ const parent = entry.parentId ?? null;
32
+ if (!parent || !getEntry(parent)) return last ?? cursor;
33
+ last = cursor;
34
+ cursor = parent;
35
+ }
36
+ return last;
37
+ });
38
+ const items = computed(() => {
39
+ const branch = branchId.value;
40
+ if (!branch) return [];
41
+ if (!mounted.value) return props.ssrSection?.items ?? [];
42
+ const live = entries.value.filter(
43
+ (entry) => entry.parentId === branch && entry.id !== branch && !entry.trashed && !!entry.label && entry.meta?.hidden !== true && entry.meta?.draft !== true && entry.meta?.ownerOnly !== true && !entry.meta?.signerId && entry.meta?.replyTo == null && entry.meta?.t == null
44
+ );
45
+ if (!live.length) return props.ssrSection?.items ?? [];
46
+ return [...live].sort((a, b) => (a.order ?? 0) - (b.order ?? 0)).slice(0, SECTION_MAX).map((entry) => ({
47
+ id: entry.id,
48
+ title: entry.label ?? "",
49
+ slug: null,
50
+ icon: docIcon(entry.type, entry.meta?.icon)
51
+ }));
52
+ });
53
+ const branchTitle = computed(() => {
54
+ const branch = mounted.value ? branchId.value : null;
55
+ return (branch ? getEntry(branch)?.label : null) ?? props.ssrSection?.parentTitle ?? "";
56
+ });
57
+ const branchHref = computed(() => {
58
+ const branch = branchId.value;
59
+ if (!branch) return null;
60
+ return getDocUrl(branch) ?? (props.ssrSection?.parentSlug ? `/${props.ssrSection.parentSlug}` : null);
61
+ });
62
+ function hrefFor(item) {
63
+ if (!mounted.value) return item.slug ? `/${item.slug}` : `/${item.id}`;
64
+ return getDocUrl(item.id) ?? (item.slug ? `/${item.slug}` : `/${item.id}`);
65
+ }
66
+ const mode = computed(() => nav.section.value);
67
+ const show = computed(() => mode.value !== "off" && items.value.length > 1);
68
+ const activeIds = computed(() => {
69
+ const ids = /* @__PURE__ */ new Set([props.docId]);
70
+ const seen = /* @__PURE__ */ new Set();
71
+ let cursor = mounted.value ? props.docId : null;
72
+ while (cursor && !seen.has(cursor)) {
73
+ seen.add(cursor);
74
+ ids.add(cursor);
75
+ cursor = getEntry(cursor)?.parentId ?? null;
76
+ }
77
+ for (const step of props.ssrTrail ?? []) ids.add(step.id);
78
+ return ids;
79
+ });
80
+ const isCurrent = (item) => hrefFor(item) === route.path || item.id === props.docId;
81
+ const isAncestor = (item) => !isCurrent(item) && activeIds.value.has(item.id);
82
+ const ITEM_CLASS = {
83
+ row: {
84
+ base: "rounded-lg px-2.5 py-1.5 text-sm transition-colors",
85
+ on: "bg-black/5 font-medium text-highlighted dark:bg-white/10",
86
+ off: "text-muted hover:bg-black/5 hover:text-default dark:hover:bg-white/5"
87
+ },
88
+ segmented: {
89
+ base: "rounded-full px-3 py-1.5 text-sm transition-colors",
90
+ on: "bg-black/8 font-medium text-highlighted dark:bg-white/15",
91
+ off: "text-muted hover:bg-black/5 hover:text-default dark:hover:bg-white/5"
92
+ },
93
+ tabs: {
94
+ base: "border-b-2 px-1.5 pb-2 pt-1 text-sm transition-colors",
95
+ on: "border-current font-medium text-highlighted",
96
+ off: "border-transparent text-muted hover:text-default"
97
+ }
98
+ };
99
+ const itemClass = computed(() => ITEM_CLASS[mode.value] ?? ITEM_CLASS.row);
100
+ </script>
101
+
102
+ <template>
103
+ <nav
104
+ v-if="show"
105
+ class="jun-section-bar jun-blur sticky z-20 mb-4 flex items-center gap-1 overflow-x-auto py-2"
106
+ :class="[
107
+ props.column,
108
+ mode === 'segmented' ? 'gap-1.5' : mode === 'tabs' ? 'gap-4 border-b border-default' : ''
109
+ ]"
110
+ :aria-label="branchTitle ? `${branchTitle} section` : 'Section'"
111
+ data-swipe-ignore
112
+ >
113
+ <NuxtLink
114
+ v-if="branchHref && mode !== 'segmented'"
115
+ :to="branchHref"
116
+ class="mr-1 flex-none truncate text-[11px] font-medium tracking-[0.18em] text-dimmed uppercase transition-colors hover:text-muted"
117
+ >
118
+ {{ branchTitle }}
119
+ </NuxtLink>
120
+ <NuxtLink
121
+ v-for="item in items"
122
+ :key="item.id"
123
+ :to="hrefFor(item)"
124
+ class="flex flex-none items-center gap-1.5 whitespace-nowrap"
125
+ :class="[
126
+ itemClass.base,
127
+ isCurrent(item) || isAncestor(item) ? itemClass.on : itemClass.off,
128
+ isAncestor(item) ? 'opacity-80' : ''
129
+ ]"
130
+ :aria-current="isCurrent(item) ? 'page' : isAncestor(item) ? 'true' : void 0"
131
+ >
132
+ <UIcon
133
+ v-if="item.icon && mode !== 'tabs'"
134
+ :name="item.icon"
135
+ class="size-3.5 flex-none opacity-70"
136
+ />
137
+ {{ item.title }}
138
+ </NuxtLink>
139
+ </nav>
140
+ </template>
141
+
142
+ <style scoped>
143
+ .jun-section-bar{top:calc(var(--jun-nav-offset, 0px) + .25rem)}html[data-jun-nav=bottom] .jun-section-bar,html[data-jun-nav^=rail] .jun-section-bar{top:.5rem}.jun-section-bar{-webkit-mask-image:linear-gradient(180deg,#000 0,#000 82%,transparent);mask-image:linear-gradient(180deg,#000 0,#000 82%,transparent);overscroll-behavior-x:contain;padding-bottom:.35rem;scrollbar-width:none;touch-action:pan-x pan-y}.jun-section-bar::-webkit-scrollbar{display:none}
144
+ </style>
@@ -0,0 +1,41 @@
1
+ /** One entry, in the shape the resolve endpoint sends. */
2
+ export interface JunSectionItem {
3
+ id: string;
4
+ title: string;
5
+ slug: string | null;
6
+ icon?: string;
7
+ }
8
+ type __VLS_Props = {
9
+ docId: string;
10
+ /**
11
+ * A column for the bar to sit in.
12
+ *
13
+ * The surface only constrains the page for types that do NOT pad themselves;
14
+ * a journal entry and every feed page carry their own column, so the wrapper
15
+ * around them is full width and a bar inside it would run edge to edge while
16
+ * the prose sat in the middle. The page passes the column when it is the one
17
+ * that knows there isn't one.
18
+ */
19
+ column?: string;
20
+ /**
21
+ * The SSR trail, so the marking is in the SERVED HTML too.
22
+ *
23
+ * On a deep page the item that lights up is an ANCESTOR rather than the page,
24
+ * and the live tree cannot say which one until it has synced.
25
+ */
26
+ ssrTrail?: {
27
+ id: string;
28
+ title: string;
29
+ slug: string | null;
30
+ }[];
31
+ /** The SSR payload's section, used until the live tree has synced. */
32
+ ssrSection?: {
33
+ parentId: string;
34
+ parentTitle: string;
35
+ parentSlug: string | null;
36
+ items: JunSectionItem[];
37
+ } | null;
38
+ };
39
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
40
+ declare const _default: typeof __VLS_export;
41
+ export default _default;