@abraca/junis 2.81.0 → 2.83.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 (59) hide show
  1. package/README.md +31 -15
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +49 -18
  4. package/dist/runtime/assets/css/jun.css +1 -1
  5. package/dist/runtime/components/JunCampfireChat.vue +1 -1
  6. package/dist/runtime/components/JunCampfirePanel.vue +12 -12
  7. package/dist/runtime/components/JunCampfirePresence.client.vue +8 -8
  8. package/dist/runtime/components/JunCampfireRoster.vue +13 -13
  9. package/dist/runtime/components/JunCampfireYou.vue +9 -9
  10. package/dist/runtime/components/JunGlobeEditor.client.vue +396 -183
  11. package/dist/runtime/components/JunGlobeMap.client.vue +1 -0
  12. package/dist/runtime/components/JunHorizontalTimeline.vue +41 -4
  13. package/dist/runtime/components/JunImagePopup.client.vue +1 -1
  14. package/dist/runtime/components/renderers/JunAppsRenderer.vue +5 -5
  15. package/dist/runtime/components/renderers/JunCvRenderer.vue +1 -1
  16. package/dist/runtime/components/renderers/JunEntryRenderer.vue +1 -1
  17. package/dist/runtime/components/renderers/JunGuestbookRenderer.vue +2 -0
  18. package/dist/runtime/components/renderers/JunHomeRenderer.vue +2 -2
  19. package/dist/runtime/components/renderers/JunJournalRenderer.vue +6 -6
  20. package/dist/runtime/components/renderers/JunLiveRenderer.vue +2 -1
  21. package/dist/runtime/components/renderers/JunMovieRenderer.vue +1 -1
  22. package/dist/runtime/components/renderers/JunNowRenderer.vue +39 -0
  23. package/dist/runtime/components/renderers/JunProjectRenderer.vue +2 -2
  24. package/dist/runtime/components/renderers/JunStatsRenderer.vue +293 -74
  25. package/dist/runtime/components/renderers/JunTrackRenderer.vue +44 -0
  26. package/dist/runtime/components/renderers/JunWallRenderer.vue +1 -0
  27. package/dist/runtime/composables/useJunChrome.js +11 -2
  28. package/dist/runtime/composables/useJunTheme.js +9 -0
  29. package/dist/runtime/composables/useJunViewingAccent.d.ts +0 -1
  30. package/dist/runtime/composables/useJunViewingAccent.js +1 -1
  31. package/dist/runtime/plugins/jun-fresh-server.client.d.ts +2 -0
  32. package/dist/runtime/plugins/jun-fresh-server.client.js +42 -0
  33. package/dist/runtime/server/api/stats.get.d.ts +27 -0
  34. package/dist/runtime/server/api/stats.get.js +35 -8
  35. package/dist/runtime/server/janitor/junJanitorChores.d.ts +23 -2
  36. package/dist/runtime/server/janitor/junJanitorChores.js +74 -8
  37. package/dist/runtime/server/janitor/junJanitorMachine.js +16 -2
  38. package/dist/runtime/server/janitor/junJanitorStore.d.ts +35 -1
  39. package/dist/runtime/server/janitor/junJanitorStore.js +62 -4
  40. package/dist/runtime/server/plugins/jun-bootstrap.js +128 -15
  41. package/dist/runtime/server/plugins/jun-doc-cache.js +44 -3
  42. package/dist/runtime/server/tasks/jun-register-tree.d.ts +16 -0
  43. package/dist/runtime/server/tasks/jun-register-tree.js +22 -0
  44. package/dist/runtime/server/utils/junActivity.d.ts +15 -0
  45. package/dist/runtime/server/utils/junActivity.js +71 -0
  46. package/dist/runtime/server/utils/junActivityMath.d.ts +61 -0
  47. package/dist/runtime/server/utils/junActivityMath.js +31 -0
  48. package/dist/runtime/server/utils/junCache.d.ts +15 -0
  49. package/dist/runtime/server/utils/junCache.js +9 -0
  50. package/dist/runtime/server/utils/junRegisterTree.d.ts +59 -0
  51. package/dist/runtime/server/utils/junRegisterTree.js +76 -0
  52. package/dist/runtime/server/utils/junServiceFetch.js +1 -1
  53. package/dist/runtime/server/utils/junVisibility.js +2 -0
  54. package/dist/runtime/types.d.ts +1 -1
  55. package/dist/runtime/utils/junVisibility.js +2 -0
  56. package/package.json +5 -2
  57. package/dist/runtime/components/renderers/JunWindowRenderer.d.vue.ts +0 -10
  58. package/dist/runtime/components/renderers/JunWindowRenderer.vue +0 -516
  59. package/dist/runtime/components/renderers/JunWindowRenderer.vue.d.ts +0 -10
@@ -7,6 +7,7 @@ import {
7
7
  useChildTree,
8
8
  useDocTree,
9
9
  useJunOptions,
10
+ useJunPageType,
10
11
  useJunRename,
11
12
  useJunStudio,
12
13
  useJunTravellers
@@ -26,11 +27,14 @@ const { entries, getEntry } = useDocTree();
26
27
  const { editing } = useJunStudio();
27
28
  const { renameDoc } = useJunRename();
28
29
  const { travellers } = useJunTravellers();
30
+ const { labelForType } = useJunPageType();
29
31
  const types = computed(() => opts.typeIds);
30
32
  const pageTitle = computed(() => getEntry(props.docId)?.label ?? props.docLabel ?? "Pulse");
33
+ const pageMeta = computed(
34
+ () => getEntry(props.docId)?.meta ?? props.docMeta ?? {}
35
+ );
31
36
  const subtitle = computed(() => {
32
- const meta = getEntry(props.docId)?.meta;
33
- const ex = meta?.excerpt ?? props.docMeta?.excerpt;
37
+ const ex = pageMeta.value.excerpt;
34
38
  return typeof ex === "string" && ex.trim() ? ex : void 0;
35
39
  });
36
40
  function renamePage(t) {
@@ -54,9 +58,11 @@ const treeLive = computed(() => liveEntries.value.length > 0);
54
58
  const byId = computed(() => new Map(
55
59
  (entries.value ?? []).map((e) => [e.id, e])
56
60
  ));
61
+ const WEEK = 7 * 864e5;
57
62
  const live = computed(() => {
58
63
  if (!treeLive.value) return null;
59
64
  const t = types.value;
65
+ const weekAgo = Date.now() - WEEK;
60
66
  let pages = 0;
61
67
  let journalEntries = 0;
62
68
  let livePosts = 0;
@@ -64,10 +70,14 @@ const live = computed(() => {
64
70
  let signatures = 0;
65
71
  let appreciations = 0;
66
72
  let newestEdit = 0;
73
+ let oldestPage = 0;
74
+ let pagesThisWeek = 0;
75
+ const byType = {};
67
76
  for (const e of liveEntries.value) {
68
77
  pages++;
69
78
  if (t.entry && e.type === t.entry) journalEntries++;
70
79
  if (t.now && e.type === t.now) livePosts++;
80
+ if (e.type) byType[e.type] = (byType[e.type] ?? 0) + 1;
71
81
  const parent = e.parentId ? byId.value.get(e.parentId) : void 0;
72
82
  if (t.wall && parent?.type === t.wall && e.meta?.coverUploadId) photos++;
73
83
  if (t.guestbook && parent?.type === t.guestbook && typeof e.meta?.message === "string") {
@@ -75,8 +85,22 @@ const live = computed(() => {
75
85
  }
76
86
  if (Array.isArray(e.meta?.appreciatedBy)) appreciations += e.meta.appreciatedBy.length;
77
87
  if ((e.updatedAt ?? 0) > newestEdit) newestEdit = e.updatedAt ?? 0;
88
+ const created = e.createdAt ?? 0;
89
+ if (created > 0 && (oldestPage === 0 || created < oldestPage)) oldestPage = created;
90
+ if (created > weekAgo) pagesThisWeek++;
78
91
  }
79
- return { pages, journalEntries, livePosts, photos, signatures, appreciations, newestEdit };
92
+ return {
93
+ pages,
94
+ journalEntries,
95
+ livePosts,
96
+ photos,
97
+ signatures,
98
+ appreciations,
99
+ newestEdit,
100
+ oldestPage,
101
+ pagesThisWeek,
102
+ byType
103
+ };
80
104
  });
81
105
  const stats = computed(() => ({
82
106
  pages: live.value?.pages ?? ssrStats.value?.pages ?? 0,
@@ -86,10 +110,11 @@ const stats = computed(() => ({
86
110
  signatures: live.value?.signatures ?? ssrStats.value?.signatures ?? 0,
87
111
  appreciations: live.value?.appreciations ?? ssrStats.value?.appreciations ?? 0,
88
112
  words: ssrStats.value?.words ?? 0,
89
- newestEdit: live.value?.newestEdit ?? ssrStats.value?.newestEdit ?? 0
113
+ newestEdit: live.value?.newestEdit ?? ssrStats.value?.newestEdit ?? 0,
114
+ oldestPage: live.value?.oldestPage ?? ssrStats.value?.oldestPage ?? 0,
115
+ pagesThisWeek: live.value?.pagesThisWeek ?? 0
90
116
  }));
91
117
  const readingNow = computed(() => travellers.value.length + 1);
92
- const DAY = 864e5;
93
118
  const now = ref(Date.now());
94
119
  let tick = null;
95
120
  onMounted(() => {
@@ -100,44 +125,139 @@ onMounted(() => {
100
125
  onUnmounted(() => {
101
126
  if (tick) clearInterval(tick);
102
127
  });
103
- const sparkBuckets = computed(() => {
104
- const buckets = Array.from({ length: 30 }, () => 0);
105
- if (!treeLive.value) return buckets;
106
- for (const e of liveEntries.value) {
107
- const t = e.updatedAt ?? 0;
108
- if (!t) continue;
109
- const idx = 29 - Math.floor((now.value - t) / DAY);
110
- if (idx >= 0 && idx < 30) buckets[idx]++;
111
- }
112
- return buckets;
113
- });
114
- const sparkMax = computed(() => Math.max(1, ...sparkBuckets.value));
115
128
  const nf = new Intl.NumberFormat(void 0);
116
129
  const rtf = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" });
130
+ const df = new Intl.DateTimeFormat(void 0, { month: "short", day: "numeric" });
117
131
  const fmt = (n) => nf.format(n);
118
- const lastEditLabel = computed(() => {
119
- if (!stats.value.newestEdit) return "\u2014";
120
- const min = Math.floor(Math.max(0, now.value - stats.value.newestEdit) / 6e4);
132
+ function relative(ts) {
133
+ const min = Math.floor(Math.max(0, now.value - ts) / 6e4);
121
134
  if (min < 1) return "just now";
122
135
  if (min < 60) return rtf.format(-min, "minute");
123
136
  const h = Math.floor(min / 60);
124
137
  if (h < 24) return rtf.format(-h, "hour");
125
- return rtf.format(-Math.floor(h / 24), "day");
138
+ const d = Math.floor(h / 24);
139
+ if (d < 30) return rtf.format(-d, "day");
140
+ const mo = Math.floor(d / 30);
141
+ if (mo < 12) return rtf.format(-mo, "month");
142
+ return rtf.format(-Math.floor(mo / 12), "year");
143
+ }
144
+ const lastEditAt = computed(
145
+ () => Math.max(stats.value.newestEdit, ssrStats.value?.lastActivityAt ?? 0)
146
+ );
147
+ const lastEditLabel = computed(
148
+ () => lastEditAt.value ? relative(lastEditAt.value) : "\u2014"
149
+ );
150
+ const ageLabel = computed(() => {
151
+ if (!stats.value.oldestPage) return "\u2014";
152
+ const days = Math.floor((now.value - stats.value.oldestPage) / 864e5);
153
+ if (days < 1) return "today";
154
+ if (days < 60) return `${days} days`;
155
+ const months = Math.floor(days / 30);
156
+ if (months < 24) return `${months} months`;
157
+ return `${Math.floor(days / 365)} years`;
126
158
  });
127
- const tiles = computed(() => {
159
+ const activity = computed(() => ssrStats.value?.activity ?? []);
160
+ const activityReady = computed(() => ssrStats.value?.activityReady === true);
161
+ const activityMax = computed(() => Math.max(1, ...activity.value.map((p) => p.edits)));
162
+ const editsThisWeek = computed(
163
+ () => activity.value.slice(-7).reduce((n, p) => n + p.edits, 0)
164
+ );
165
+ const wordsThisWeek = computed(
166
+ () => activity.value.slice(-7).reduce((n, p) => n + p.words, 0)
167
+ );
168
+ const hovered = ref(null);
169
+ const hoveredPoint = computed(
170
+ () => hovered.value === null ? null : activity.value[hovered.value] ?? null
171
+ );
172
+ function dayLabel(iso) {
173
+ return df.format(/* @__PURE__ */ new Date(`${iso}T12:00:00Z`));
174
+ }
175
+ const typeBreakdown = computed(() => {
176
+ const source = live.value?.byType ?? ssrStats.value?.byType ?? {};
177
+ const rows = Object.entries(source).map(([type, count]) => ({
178
+ type,
179
+ count,
180
+ // A type the site does not register still gets a row — a corpus being
181
+ // adopted is full of them, and dropping them would make the totals
182
+ // disagree with the "Pages" tile for no visible reason.
183
+ label: labelForType(type) ?? type
184
+ })).sort((a, b) => b.count - a.count || a.label.localeCompare(b.label));
185
+ return rows.slice(0, 8);
186
+ });
187
+ const typeMax = computed(() => Math.max(1, ...typeBreakdown.value.map((r) => r.count)));
188
+ const allTiles = computed(() => {
128
189
  const t = types.value;
129
190
  const out = [
130
- { label: "Pages", value: fmt(stats.value.pages), icon: "i-lucide-file-text" },
131
- { label: "Words written", value: fmt(stats.value.words), icon: "i-lucide-type" }
191
+ {
192
+ key: "pages",
193
+ label: "Pages",
194
+ value: fmt(stats.value.pages),
195
+ icon: "i-lucide-file-text",
196
+ delta: stats.value.pagesThisWeek ? `+${stats.value.pagesThisWeek} this week` : void 0
197
+ },
198
+ {
199
+ key: "words",
200
+ label: "Words written",
201
+ value: fmt(stats.value.words),
202
+ icon: "i-lucide-type",
203
+ delta: wordsThisWeek.value ? `${wordsThisWeek.value > 0 ? "+" : ""}${fmt(wordsThisWeek.value)} this week` : void 0,
204
+ snapshot: true
205
+ }
132
206
  ];
133
- if (t.entry) out.push({ label: "Entries", value: fmt(stats.value.journalEntries), icon: "i-lucide-feather" });
134
- if (t.now) out.push({ label: "Posts", value: fmt(stats.value.livePosts), icon: "i-lucide-radio" });
135
- if (t.wall) out.push({ label: "Photos", value: fmt(stats.value.photos), icon: "i-lucide-images" });
136
- if (t.guestbook) out.push({ label: "Signatures", value: fmt(stats.value.signatures), icon: "i-lucide-pen-line" });
137
- out.push({ label: "Appreciations", value: fmt(stats.value.appreciations), icon: "i-lucide-heart" });
138
- out.push({ label: "Last edit", value: lastEditLabel.value, icon: "i-lucide-history" });
207
+ if (t.entry) out.push({ key: "entries", label: "Entries", value: fmt(stats.value.journalEntries), icon: "i-lucide-feather" });
208
+ if (t.now) out.push({ key: "posts", label: "Posts", value: fmt(stats.value.livePosts), icon: "i-lucide-radio" });
209
+ if (t.wall) out.push({ key: "photos", label: "Photos", value: fmt(stats.value.photos), icon: "i-lucide-images" });
210
+ if (t.guestbook) out.push({ key: "signatures", label: "Signatures", value: fmt(stats.value.signatures), icon: "i-lucide-pen-line" });
211
+ out.push({ key: "appreciations", label: "Appreciations", value: fmt(stats.value.appreciations), icon: "i-lucide-heart" });
212
+ out.push({
213
+ key: "lastEdit",
214
+ label: "Last edit",
215
+ value: lastEditLabel.value,
216
+ icon: "i-lucide-history"
217
+ });
218
+ out.push({ key: "age", label: "Site age", value: ageLabel.value, icon: "i-lucide-calendar-days" });
139
219
  return out;
140
220
  });
221
+ const chosenKeys = computed(() => {
222
+ const raw = pageMeta.value.statsTiles;
223
+ if (!Array.isArray(raw)) return null;
224
+ const keys = raw.filter((k) => typeof k === "string");
225
+ return keys.length ? keys : [];
226
+ });
227
+ const tiles = computed(() => {
228
+ const chosen = chosenKeys.value;
229
+ if (!chosen) return allTiles.value;
230
+ const byKey = new Map(allTiles.value.map((t) => [t.key, t]));
231
+ return chosen.map((k) => byKey.get(k)).filter((t) => !!t);
232
+ });
233
+ function toggleTile(key) {
234
+ const current = chosenKeys.value ?? allTiles.value.map((t) => t.key);
235
+ const next = current.includes(key) ? current.filter((k) => k !== key) : [...current, key];
236
+ tree.updateMeta(props.docId, { statsTiles: next });
237
+ }
238
+ function resetTiles() {
239
+ tree.updateMeta(props.docId, { statsTiles: void 0 });
240
+ }
241
+ const tileMenuItems = computed(() => {
242
+ const shown = new Set(tiles.value.map((t) => t.key));
243
+ return [
244
+ allTiles.value.map((t) => ({
245
+ label: t.label,
246
+ icon: t.icon,
247
+ type: "checkbox",
248
+ checked: shown.has(t.key),
249
+ onSelect: (e) => {
250
+ e.preventDefault();
251
+ toggleTile(t.key);
252
+ }
253
+ })),
254
+ [{
255
+ label: "Show all",
256
+ icon: "i-lucide-rotate-ccw",
257
+ onSelect: () => resetTiles()
258
+ }]
259
+ ];
260
+ });
141
261
  </script>
142
262
 
143
263
  <template>
@@ -150,31 +270,53 @@ const tiles = computed(() => {
150
270
  @rename-subtitle="renameSubtitle"
151
271
  />
152
272
 
153
- <ClientOnly>
154
- <div class="jun-card mb-6 flex items-center gap-3 rounded-2xl px-5 py-4">
273
+ <div
274
+ data-jun-anchor="stat:summary"
275
+ class="jun-card mb-6 flex items-center gap-3 rounded-2xl px-5 py-4"
276
+ >
277
+ <span
278
+ class="relative flex size-2.5 flex-none"
279
+ aria-hidden="true"
280
+ >
281
+ <span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-30" />
282
+ <span class="relative inline-flex size-2.5 rounded-full bg-current opacity-70" />
283
+ </span>
284
+ <p class="text-sm text-toned">
285
+ <span class="font-semibold tabular-nums">{{ readingNow }}</span>
286
+ {{ readingNow === 1 ? "person is" : "people are" }} reading right now
155
287
  <span
156
- class="relative flex size-2.5 flex-none"
157
- aria-hidden="true"
158
- >
159
- <span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-30" />
160
- <span class="relative inline-flex size-2.5 rounded-full bg-current opacity-70" />
161
- </span>
162
- <p class="text-sm text-toned">
163
- <span class="font-semibold tabular-nums">{{ readingNow }}</span>
164
- {{ readingNow === 1 ? "person is" : "people are" }} reading right now
165
- <span
166
- v-if="readingNow === 1"
167
- class="text-dimmed"
168
- >(that's you)</span>
169
- </p>
170
- </div>
171
- </ClientOnly>
288
+ v-if="readingNow === 1"
289
+ class="text-dimmed"
290
+ >(that's you)</span>
291
+ </p>
292
+
293
+ <UDropdownMenu
294
+ v-if="editing"
295
+ :items="tileMenuItems"
296
+ :content="{ align: 'end' }"
297
+ class="ml-auto"
298
+ >
299
+ <UButton
300
+ icon="i-lucide-layout-grid"
301
+ color="neutral"
302
+ variant="ghost"
303
+ size="xs"
304
+ label="Tiles"
305
+ />
306
+ </UDropdownMenu>
307
+ </div>
172
308
 
173
309
  <div class="grid grid-cols-2 gap-3 sm:grid-cols-4">
310
+ <!-- `stat:` and not `doc:` — a tile is a derived figure, not a document,
311
+ so there is no id to key it on. `tile.key` is stable across peers
312
+ (it comes from the tile definition, not from render order) and the
313
+ owner's `statsTiles` selection only ever changes which tiles are
314
+ present, never what a given one is called. -->
174
315
  <div
175
316
  v-for="(tile, i) in tiles"
176
- :key="tile.label"
317
+ :key="tile.key"
177
318
  v-motion="junMotion(junStagger(i, { delayMs: 40 }))"
319
+ :data-jun-anchor="`stat:${tile.key}`"
178
320
  class="jun-card rounded-2xl p-4"
179
321
  >
180
322
  <UIcon
@@ -188,43 +330,120 @@ const tiles = computed(() => {
188
330
  <p class="mt-0.5 text-[11px] tracking-wider text-dimmed uppercase">
189
331
  {{ tile.label }}
190
332
  </p>
333
+ <p
334
+ v-if="tile.delta"
335
+ class="mt-1 text-[11px] text-muted tabular-nums"
336
+ >
337
+ {{ tile.delta }}
338
+ </p>
191
339
  </div>
192
340
  </div>
193
341
 
194
- <ClientOnly>
195
- <div class="jun-card mt-3 rounded-2xl p-5">
196
- <div class="mb-3 flex items-baseline justify-between">
197
- <p class="text-[11px] tracking-wider text-dimmed uppercase">
198
- Edits · last 30 days
199
- </p>
200
- <p class="text-[11px] text-dimmed">
201
- pages touched per day
202
- </p>
203
- </div>
204
- <svg
205
- viewBox="0 0 300 48"
206
- class="h-12 w-full text-black/60 dark:text-white/60"
207
- preserveAspectRatio="none"
208
- role="img"
209
- aria-label="Pages edited per day over the last 30 days"
342
+ <!-- Activity. Server-only and a HISTORY: the tree cannot answer it. -->
343
+ <div
344
+ data-jun-anchor="stat:activity"
345
+ class="jun-card mt-3 rounded-2xl p-5"
346
+ >
347
+ <div class="mb-3 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1">
348
+ <p class="text-[11px] tracking-wider text-dimmed uppercase">
349
+ Activity · last 30 days
350
+ </p>
351
+ <p class="text-[11px] text-dimmed">
352
+ <template v-if="hoveredPoint">
353
+ <span class="text-toned">{{ dayLabel(hoveredPoint.date) }}</span>
354
+ · {{ hoveredPoint.edits }} {{ hoveredPoint.edits === 1 ? "edit" : "edits" }}
355
+ <template v-if="hoveredPoint.words">
356
+ · {{ hoveredPoint.words > 0 ? "+" : "" }}{{ fmt(hoveredPoint.words) }} words
357
+ </template>
358
+ </template>
359
+ <template v-else-if="activityReady">
360
+ {{ editsThisWeek }} in the last 7 days
361
+ </template>
362
+ <template v-else>
363
+ still measuring
364
+ </template>
365
+ </p>
366
+ </div>
367
+
368
+ <svg
369
+ v-if="activityReady"
370
+ viewBox="0 0 300 48"
371
+ class="h-12 w-full text-black/60 dark:text-white/60"
372
+ preserveAspectRatio="none"
373
+ role="img"
374
+ aria-label="Documents edited per day over the last 30 days"
375
+ @pointerleave="hovered = null"
376
+ >
377
+ <g
378
+ v-for="(point, i) in activity"
379
+ :key="point.date"
380
+ @pointerenter="hovered = i"
210
381
  >
382
+ <!-- A full-height hit target: a 2px bar is not something anyone can
383
+ point at, and the readout is the only place the exact figure and
384
+ the date appear. -->
385
+ <rect
386
+ :x="i * 10"
387
+ y="0"
388
+ width="10"
389
+ height="48"
390
+ fill="transparent"
391
+ />
211
392
  <rect
212
- v-for="(v, i) in sparkBuckets"
213
- :key="i"
214
393
  :x="i * 10 + 2"
215
- :y="48 - v / sparkMax * 44 - 2"
394
+ :y="48 - point.edits / activityMax * 44 - 2"
216
395
  width="6"
217
- :height="Math.max(2, v / sparkMax * 44)"
396
+ :height="Math.max(2, point.edits / activityMax * 44)"
218
397
  rx="1.5"
219
398
  fill="currentColor"
220
- :opacity="v ? 0.9 : 0.15"
399
+ :opacity="hovered === i ? 1 : point.edits ? 0.9 : 0.15"
221
400
  />
222
- </svg>
223
- </div>
224
- </ClientOnly>
401
+ </g>
402
+ </svg>
403
+ <p
404
+ v-else
405
+ class="py-3 text-[11px] text-dimmed"
406
+ >
407
+ The ledger takes its baseline shortly after the server starts, then books
408
+ one point per sweep. History appears from the next sweep onwards.
409
+ </p>
410
+
411
+ <p class="mt-3 text-[11px] leading-relaxed text-dimmed">
412
+ A bar counts documents whose text CHANGED between two checks of the
413
+ site's cache — near enough an editing session, and not a count of
414
+ keystrokes.
415
+ </p>
416
+ </div>
417
+
418
+ <!-- What the site is MADE of. Live: the tree can answer this one. -->
419
+ <div
420
+ v-if="typeBreakdown.length > 1"
421
+ data-jun-anchor="stat:by-type"
422
+ class="jun-card mt-3 rounded-2xl p-5"
423
+ >
424
+ <p class="mb-3 text-[11px] tracking-wider text-dimmed uppercase">
425
+ Pages by type
426
+ </p>
427
+ <ul class="space-y-1.5">
428
+ <li
429
+ v-for="row in typeBreakdown"
430
+ :key="row.type"
431
+ class="flex items-center gap-3"
432
+ >
433
+ <span class="w-28 flex-none truncate text-xs text-toned">{{ row.label }}</span>
434
+ <span class="h-1.5 flex-1 overflow-hidden rounded-full bg-black/5 dark:bg-white/10">
435
+ <span
436
+ class="block h-full rounded-full bg-current opacity-50"
437
+ :style="{ width: `${row.count / typeMax * 100}%` }"
438
+ />
439
+ </span>
440
+ <span class="w-8 flex-none text-right text-xs text-dimmed tabular-nums">{{ row.count }}</span>
441
+ </li>
442
+ </ul>
443
+ </div>
225
444
 
226
445
  <p class="mt-6 text-center text-[11px] text-dimmed">
227
- Every number here is a live view over this site's document tree.
446
+ Every count here is a live view over this site's document tree.
228
447
  </p>
229
448
  </div>
230
449
  </template>
@@ -26,6 +26,9 @@ const abra = useAbracadabra();
26
26
  const tree = useChildTree(abra.doc, props.docId);
27
27
  const { entries, getEntry } = useDocTree();
28
28
  const { getDocUrl } = useDocSlugs();
29
+ const otherChildren = computed(
30
+ () => (tree.childrenOf(null) ?? []).filter((e) => !!e.label)
31
+ );
29
32
  const { editing } = useJunStudio();
30
33
  const { renameDoc } = useJunRename();
31
34
  const { uploadTo, imageFiles } = useJunUpload();
@@ -357,6 +360,47 @@ const factLine = computed(
357
360
  </ul>
358
361
  </section>
359
362
 
363
+ <!-- Children, listed rather than dropped.
364
+
365
+ This renderer read none of them. Every other renderer in the module
366
+ tolerates a child created under a different page type — "never silently
367
+ drop a child" is what makes `Page type ▸` a safe context-menu item
368
+ rather than a data-loss button — and a track was the one page where
369
+ converting a document with children made them invisible. Same shape the
370
+ movie renderer uses, because a track and a film are the same kind of
371
+ leaf. -->
372
+ <section
373
+ v-if="otherChildren.length"
374
+ class="mt-8"
375
+ >
376
+ <div class="mb-3 flex items-baseline gap-3">
377
+ <h2 class="text-xs font-medium tracking-[0.22em] text-dimmed uppercase">
378
+ More
379
+ </h2>
380
+ <div class="h-px flex-1 bg-black/10 dark:bg-white/10" />
381
+ </div>
382
+ <ul class="flex flex-wrap gap-2">
383
+ <li
384
+ v-for="child in otherChildren"
385
+ :key="child.id"
386
+ >
387
+ <JunItemMenu
388
+ :entry="child"
389
+ :tree="tree"
390
+ >
391
+ <UButton
392
+ :to="getDocUrl(child.id)"
393
+ icon="i-lucide-file-text"
394
+ color="neutral"
395
+ variant="soft"
396
+ size="xs"
397
+ :label="child.label"
398
+ />
399
+ </JunItemMenu>
400
+ </li>
401
+ </ul>
402
+ </section>
403
+
360
404
  <hr class="my-8 border-default">
361
405
 
362
406
  <div class="jun-track-body">
@@ -196,6 +196,7 @@ function commitCaption(p, e) {
196
196
  v-for="(p, i) in orderedItems"
197
197
  :key="p.id"
198
198
  v-motion="junMotion(junStagger(Math.min(i, 8), { delayMs: 50 }))"
199
+ :data-jun-anchor="`doc:${p.id}`"
199
200
  class="mb-3 break-inside-avoid sm:mb-4"
200
201
  :data-dnd-id="p.id"
201
202
  :draggable="editing ? true : void 0"
@@ -13,6 +13,9 @@ const ALIGN = ["x-left", "x-right", "y-top", "y-bottom"];
13
13
  const SETTLE_MS = 260;
14
14
  const GAP = 16;
15
15
  const PLAYER_SIDE_ROOM = 220;
16
+ const SHARE_RADIUS_MIN = 4;
17
+ let radiusMax = 0;
18
+ let radiusFor = null;
16
19
  const published = {
17
20
  edges: { "top": 0, "bottom": 0, "left-top": 0, "left-bottom": 0, "right-top": 0, "right-bottom": 0 },
18
21
  align: { "x-left": GAP, "x-right": GAP, "y-top": GAP, "y-bottom": GAP },
@@ -64,8 +67,14 @@ function measure() {
64
67
  else out.align["y-top"] = Math.max(GAP, r.top);
65
68
  }
66
69
  if (!docked) {
67
- const rad = getComputedStyle(nav).borderTopLeftRadius;
68
- if (rad && Number.parseFloat(rad) > 0) out.radius = rad;
70
+ const px = Number.parseFloat(getComputedStyle(nav).borderTopLeftRadius);
71
+ const round = Number.isFinite(px) ? Math.round(px) : 0;
72
+ if (placement !== radiusFor) {
73
+ radiusFor = placement;
74
+ radiusMax = 0;
75
+ }
76
+ if (round > radiusMax) radiusMax = round;
77
+ out.radius = radiusMax >= SHARE_RADIUS_MIN ? `${radiusMax}px` : null;
69
78
  }
70
79
  }
71
80
  }
@@ -84,6 +84,13 @@ function sunVars(hex, orb) {
84
84
  `--jun-sun-glow:${hex}`
85
85
  ];
86
86
  }
87
+ function emberVars(hex) {
88
+ if (!hex) return [];
89
+ return [
90
+ `--jun-ember:${hex}`,
91
+ `--jun-ember-glow:${shade(hex, 0.12)}`
92
+ ];
93
+ }
87
94
  export function junFontClass(cfg) {
88
95
  const font = cfg.themeFont;
89
96
  const surface = cfg.themeSurface ?? "soft";
@@ -107,6 +114,8 @@ export function junThemeCss(cfg) {
107
114
  if (darkHex) dark.push(`--ui-primary:${darkHex}`);
108
115
  root.push(...sunVars(lightHex, customLight ? void 0 : preset?.orb?.light));
109
116
  dark.push(...sunVars(darkHex, customDark ? void 0 : preset?.orb?.dark));
117
+ root.push(...emberVars(lightHex));
118
+ dark.push(...emberVars(darkHex));
110
119
  const neutral = cfg.themeNeutral ?? "stone";
111
120
  const ramp = NEUTRAL[neutral] ?? NEUTRAL.stone;
112
121
  ramp.forEach((hex, i) => {
@@ -1,5 +1,4 @@
1
1
  export declare function useJunViewingAccent(): {
2
- getViewers: (itemId: string | undefined | null) => import("#imports").PresenceUser[];
3
2
  accentStyle: (id: string | undefined | null) => Record<string, string> | undefined;
4
3
  accentInsetStyle: (id: string | undefined | null) => Record<string, string> | undefined;
5
4
  accentTitle: (id: string | undefined | null) => string | undefined;
@@ -24,5 +24,5 @@ export function useJunViewingAccent() {
24
24
  const others = viewers.length - 1;
25
25
  return `${first} and ${others} ${others === 1 ? "other" : "others"} are reading this`;
26
26
  }
27
- return { getViewers, accentStyle, accentInsetStyle, accentTitle };
27
+ return { accentStyle, accentInsetStyle, accentTitle };
28
28
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,42 @@
1
+ import { dropCachesIfServerReplaced } from "@abraca/dabra";
2
+ import { defineNuxtPlugin, useRuntimeConfig } from "#imports";
3
+ export default defineNuxtPlugin({
4
+ name: "jun:fresh-server",
5
+ enforce: "pre",
6
+ async setup() {
7
+ if (import.meta.server) return;
8
+ const config = useRuntimeConfig().public;
9
+ const url = config.abracadabra?.url ?? config.jun?.serverUrl;
10
+ if (!url) return;
11
+ let origin;
12
+ let host;
13
+ try {
14
+ const parsed = new URL(url, window.location.origin);
15
+ origin = parsed.origin;
16
+ host = parsed.host;
17
+ } catch {
18
+ return;
19
+ }
20
+ try {
21
+ const controller = new AbortController();
22
+ const timer = setTimeout(() => controller.abort(), 4e3);
23
+ const info = await fetch(`${origin}/info`, { signal: controller.signal }).finally(() => clearTimeout(timer));
24
+ if (!info.ok) return;
25
+ const serverId = (await info.json())?.server_id;
26
+ if (typeof serverId !== "string" || !serverId) return;
27
+ const outcome = await dropCachesIfServerReplaced(host, serverId);
28
+ if (!outcome) return;
29
+ const moved = `${outcome.previousServerId?.slice(0, 8)} \u2192 ${serverId.slice(0, 8)}`;
30
+ if (outcome.blocked.length) {
31
+ console.warn(
32
+ `[jun] ${origin} has a new database (${moved}), but ${outcome.blocked.length} cache(s) could not be cleared \u2014 something already had them open, so this tab may re-push a tree that no longer exists. Reload it. Blocked: ${outcome.blocked.join(", ")}`
33
+ );
34
+ } else {
35
+ console.info(
36
+ `[jun] ${origin} has a new database (${moved}); cleared ${outcome.cleared.length} local cache(s) so this tab does not re-push a tree that no longer exists.`
37
+ );
38
+ }
39
+ } catch {
40
+ }
41
+ }
42
+ });