@abraca/junis 2.81.0 → 2.82.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/README.md CHANGED
@@ -8,15 +8,16 @@ visitor interaction — all driven by documents rather than code.
8
8
  Everything is a document, settings included. The site's configuration lives in a
9
9
  hidden document whose meta *is* the config and whose page is the settings UI.
10
10
 
11
- > **Status: pre-1.0, and honest about it.** Twenty-three of the twenty-four page
12
- > types render and are exercised on every boot by `pnpm parity` — **417 SSR
13
- > assertions**, from an empty database. The **globe** is the twenty-fourth: it is
14
- > ported but has **never been rendered**, because it needs a Mapbox token and
15
- > seeded waypoints. Treat it as unproven.
11
+ > **Status: pre-1.0, and honest about it.** All **23** page types render and are
12
+ > exercised on every boot by `pnpm parity` — **389 SSR assertions**, from an
13
+ > empty database. That now includes the **globe**, which had never once been
14
+ > rendered: it is on in the playground with a token and seeded waypoints, and it
15
+ > stays off by default in the module because enabling it pulls `mapbox-gl` into
16
+ > the bundle graph.
16
17
  >
17
- > `pnpm parity:nav` — the only check that catches broken client-side navigation —
18
- > **skips unless `puppeteer-core` is installed**, and it has never run here. A
19
- > green suite without it means the SSR payload is right, nothing more.
18
+ > `pnpm parity:nav` — the only check that catches broken client-side navigation
19
+ > — **now runs**: 52 assertions across every nav link, launching its own headless
20
+ > Chrome when there is no debuggable one to attach to.
20
21
  >
21
22
  > Remaining gaps are listed in `FOLLOW-UP.md`; every deliberate difference from
22
23
  > the reference implementation is in `PARITY-PLAN.md` §8. `CLAUDE.md` is the
@@ -103,7 +104,6 @@ default except `globe`.
103
104
  | `jun-mosaic` | A page composed of other pages — panes are documents, rendered by their own renderers. |
104
105
  | `jun-guestbook` | The one page visitors write to, over RPC. |
105
106
  | `jun-stats` | Live numbers over the document tree. |
106
- | `jun-window` | A pretend app — the presence vocabulary, all at once. |
107
107
  | `jun-redirect` | A document whose `meta.url` is a destination. Emits a real 301. |
108
108
  | `jun-home` | A composed front page — sections assembled from the tree. |
109
109
  | `jun-config` | The site's own settings. Owner-only, enforced. |
@@ -147,6 +147,17 @@ canonical one, so documents keep rendering without a migration:
147
147
  jun: { pageTypeAliases: { 'janis-journal': 'jun-journal' } }
148
148
  ```
149
149
 
150
+ It is also how you survive a type being **retired**. `jun-window` — a pretend
151
+ application that showed the whole presence vocabulary at once — was removed in
152
+ 2.82.0. A document still carrying that type does not break: an unrecognised type
153
+ falls through to FLOWING and renders in the editor, which is the same tolerance
154
+ that makes "Page type ▸" a safe menu item. To point those pages somewhere
155
+ deliberate instead:
156
+
157
+ ```ts
158
+ jun: { pageTypeAliases: { 'jun-window': 'jun-mosaic' } }
159
+ ```
160
+
150
161
  ### The mosaic — an alternative to the home page
151
162
 
152
163
  `jun-home` composes a front page out of a fixed vocabulary of sections.
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "2.81.0",
7
+ "version": "2.82.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -139,12 +139,6 @@ const PAGE_TYPES = {
139
139
  renderer: "JunConfigRenderer",
140
140
  default: true
141
141
  },
142
- window: {
143
- label: "Window",
144
- icon: "i-lucide-app-window",
145
- renderer: "JunWindowRenderer",
146
- default: true
147
- },
148
142
  cinema: {
149
143
  label: "Cinema",
150
144
  icon: "i-lucide-clapperboard",
@@ -254,6 +248,10 @@ const BUILTIN_META_EXCLUDE_KEYS = [
254
248
  // Waveform peaks — an array of a few hundred floats. Same class of hazard as
255
249
  // `routeGeo`: a chip would stringify the lot on the main thread.
256
250
  "peaks",
251
+ // Which tiles the Pulse page shows, in order. An ARRAY of tile keys, written
252
+ // by ticking a menu — a chip for it is an editable string that can only be
253
+ // got wrong.
254
+ "statsTiles",
257
255
  // The mosaic's own composition. `paneSpan` is edited by dragging a corner,
258
256
  // `paneRect` is four numbers in grid units, and `mosaicLayout` is picked from
259
257
  // a card row — a chip for any of them is an editable string that can only be
@@ -449,6 +447,20 @@ const FONT_FAMILIES = [
449
447
  { name: "Space Grotesk", provider: "google", fallbacks: ["system-ui", "sans-serif"], weights: [300, 400, 500, 600, 700], styles: ["normal"], display: "swap" },
450
448
  { name: "JetBrains Mono", provider: "google", fallbacks: ["ui-monospace", "monospace"], weights: [400, 500, 600], styles: ["normal"], display: "swap" }
451
449
  ];
450
+ function nuxtOptionsRecord(nuxt) {
451
+ return nuxt.options;
452
+ }
453
+ function asRecord(value) {
454
+ return value && typeof value === "object" ? value : void 0;
455
+ }
456
+ function siblingOptions(nuxt, key) {
457
+ const all = nuxtOptionsRecord(nuxt);
458
+ const existing = all[key];
459
+ if (existing && typeof existing === "object") return existing;
460
+ const created = {};
461
+ all[key] = created;
462
+ return created;
463
+ }
452
464
  function resolveJanitor(options, featureOn) {
453
465
  const name = options?.name ?? "janitor";
454
466
  return {
@@ -554,7 +566,7 @@ const module$1 = defineNuxtModule({
554
566
  },
555
567
  async setup(options, nuxt) {
556
568
  const resolver = createResolver(import.meta.url);
557
- const iconOptions = nuxt.options.icon ??= {};
569
+ const iconOptions = siblingOptions(nuxt, "icon");
558
570
  iconOptions.cssLayer ??= "base";
559
571
  if (options.autoInstall !== false) {
560
572
  if (!hasNuxtModule("@nuxt/ui")) await installModule("@nuxt/ui");
@@ -610,7 +622,6 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
610
622
  "redirect",
611
623
  "guestbook",
612
624
  "stats",
613
- "window",
614
625
  "movie",
615
626
  "track"
616
627
  ),
@@ -728,11 +739,12 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
728
739
  githubToken: options.githubToken ?? ""
729
740
  }
730
741
  );
731
- const abra = nuxt.options.abracadabra ??= {};
742
+ const abra = siblingOptions(nuxt, "abracadabra");
732
743
  abra.guestName ??= runtime.guestNames;
733
744
  if (options.fonts !== false) {
734
- const fonts = nuxt.options.fonts ??= {};
735
- fonts.families = [...fonts.families ?? [], ...FONT_FAMILIES];
745
+ const fonts = siblingOptions(nuxt, "fonts");
746
+ const families = Array.isArray(fonts.families) ? fonts.families : [];
747
+ fonts.families = [...families, ...FONT_FAMILIES];
736
748
  }
737
749
  nuxt.options.appConfig.ui = defu(nuxt.options.appConfig.ui ?? {}, {
738
750
  colors: { primary: "stone", neutral: "stone" },
@@ -876,6 +888,13 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
876
888
  }
877
889
  if (runtime.features.docCache) {
878
890
  addServerPlugin(resolver.resolve("./runtime/server/plugins/jun-doc-cache"));
891
+ nuxt.options.nitro.experimental = defu(nuxt.options.nitro.experimental, { tasks: true });
892
+ nuxt.options.nitro.tasks = defu(nuxt.options.nitro.tasks, {
893
+ "jun:register-tree": {
894
+ handler: resolver.resolve("./runtime/server/tasks/jun-register-tree"),
895
+ description: "REST-register yjs-only tree documents so the permission cascade sees them"
896
+ }
897
+ });
879
898
  }
880
899
  if (runtime.features.rpc) {
881
900
  addServerPlugin(resolver.resolve("./runtime/server/plugins/jun-rpc"));
@@ -890,8 +909,8 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
890
909
  inline: ["happy-dom"]
891
910
  });
892
911
  if (options.pwa !== false && hasNuxtModule("@vite-pwa/nuxt")) {
893
- const nuxtAny = nuxt.options;
894
- nuxtAny.pwa = defu(nuxtAny.pwa, {
912
+ const all = nuxtOptionsRecord(nuxt);
913
+ all.pwa = defu(asRecord(all.pwa), {
895
914
  registerType: "autoUpdate",
896
915
  manifest: {
897
916
  id: "/",
@@ -932,15 +951,20 @@ Switch them off with \`jun.pageTypes: { ${missing.map((e) => `${e.key}: false`).
932
951
  });
933
952
  }
934
953
  if (options.imageDomains?.length) {
935
- const image = nuxt.options.image ??= {};
936
- image.domains = [...image.domains ?? [], ...options.imageDomains];
954
+ const image = siblingOptions(nuxt, "image");
955
+ const domains = Array.isArray(image.domains) ? image.domains : [];
956
+ image.domains = [...domains, ...options.imageDomains];
937
957
  }
938
958
  if (hasNuxtModule("nuxt-og-image")) {
939
- const nuxtAny = nuxt.options;
940
- nuxtAny.ogImage = defu(nuxtAny.ogImage, { zeroRuntime: true });
959
+ const all = nuxtOptionsRecord(nuxt);
960
+ all.ogImage = defu(asRecord(all.ogImage), { zeroRuntime: true });
941
961
  }
942
962
  nuxt.options.nitro.devStorage = defu(nuxt.options.nitro.devStorage, {
943
- "cache:nuxt:payload": { driver: "memory" }
963
+ "cache:nuxt:payload": { driver: "memory" },
964
+ "jun": { driver: "fs", base: "./.data/jun" }
965
+ });
966
+ nuxt.options.nitro.storage = defu(nuxt.options.nitro.storage, {
967
+ jun: { driver: "fs", base: "./.data/jun" }
944
968
  });
945
969
  if (runtime.features.backdrop === "shader") {
946
970
  nuxt.hook("vite:extendConfig", (config) => {
@@ -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,30 +270,43 @@ 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 class="jun-card mb-6 flex items-center gap-3 rounded-2xl px-5 py-4">
274
+ <span
275
+ class="relative flex size-2.5 flex-none"
276
+ aria-hidden="true"
277
+ >
278
+ <span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-30" />
279
+ <span class="relative inline-flex size-2.5 rounded-full bg-current opacity-70" />
280
+ </span>
281
+ <p class="text-sm text-toned">
282
+ <span class="font-semibold tabular-nums">{{ readingNow }}</span>
283
+ {{ readingNow === 1 ? "person is" : "people are" }} reading right now
155
284
  <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>
285
+ v-if="readingNow === 1"
286
+ class="text-dimmed"
287
+ >(that's you)</span>
288
+ </p>
289
+
290
+ <UDropdownMenu
291
+ v-if="editing"
292
+ :items="tileMenuItems"
293
+ :content="{ align: 'end' }"
294
+ class="ml-auto"
295
+ >
296
+ <UButton
297
+ icon="i-lucide-layout-grid"
298
+ color="neutral"
299
+ variant="ghost"
300
+ size="xs"
301
+ label="Tiles"
302
+ />
303
+ </UDropdownMenu>
304
+ </div>
172
305
 
173
306
  <div class="grid grid-cols-2 gap-3 sm:grid-cols-4">
174
307
  <div
175
308
  v-for="(tile, i) in tiles"
176
- :key="tile.label"
309
+ :key="tile.key"
177
310
  v-motion="junMotion(junStagger(i, { delayMs: 40 }))"
178
311
  class="jun-card rounded-2xl p-4"
179
312
  >
@@ -188,43 +321,116 @@ const tiles = computed(() => {
188
321
  <p class="mt-0.5 text-[11px] tracking-wider text-dimmed uppercase">
189
322
  {{ tile.label }}
190
323
  </p>
324
+ <p
325
+ v-if="tile.delta"
326
+ class="mt-1 text-[11px] text-muted tabular-nums"
327
+ >
328
+ {{ tile.delta }}
329
+ </p>
191
330
  </div>
192
331
  </div>
193
332
 
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"
333
+ <!-- Activity. Server-only and a HISTORY: the tree cannot answer it. -->
334
+ <div class="jun-card mt-3 rounded-2xl p-5">
335
+ <div class="mb-3 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1">
336
+ <p class="text-[11px] tracking-wider text-dimmed uppercase">
337
+ Activity · last 30 days
338
+ </p>
339
+ <p class="text-[11px] text-dimmed">
340
+ <template v-if="hoveredPoint">
341
+ <span class="text-toned">{{ dayLabel(hoveredPoint.date) }}</span>
342
+ · {{ hoveredPoint.edits }} {{ hoveredPoint.edits === 1 ? "edit" : "edits" }}
343
+ <template v-if="hoveredPoint.words">
344
+ · {{ hoveredPoint.words > 0 ? "+" : "" }}{{ fmt(hoveredPoint.words) }} words
345
+ </template>
346
+ </template>
347
+ <template v-else-if="activityReady">
348
+ {{ editsThisWeek }} in the last 7 days
349
+ </template>
350
+ <template v-else>
351
+ still measuring
352
+ </template>
353
+ </p>
354
+ </div>
355
+
356
+ <svg
357
+ v-if="activityReady"
358
+ viewBox="0 0 300 48"
359
+ class="h-12 w-full text-black/60 dark:text-white/60"
360
+ preserveAspectRatio="none"
361
+ role="img"
362
+ aria-label="Documents edited per day over the last 30 days"
363
+ @pointerleave="hovered = null"
364
+ >
365
+ <g
366
+ v-for="(point, i) in activity"
367
+ :key="point.date"
368
+ @pointerenter="hovered = i"
210
369
  >
370
+ <!-- A full-height hit target: a 2px bar is not something anyone can
371
+ point at, and the readout is the only place the exact figure and
372
+ the date appear. -->
373
+ <rect
374
+ :x="i * 10"
375
+ y="0"
376
+ width="10"
377
+ height="48"
378
+ fill="transparent"
379
+ />
211
380
  <rect
212
- v-for="(v, i) in sparkBuckets"
213
- :key="i"
214
381
  :x="i * 10 + 2"
215
- :y="48 - v / sparkMax * 44 - 2"
382
+ :y="48 - point.edits / activityMax * 44 - 2"
216
383
  width="6"
217
- :height="Math.max(2, v / sparkMax * 44)"
384
+ :height="Math.max(2, point.edits / activityMax * 44)"
218
385
  rx="1.5"
219
386
  fill="currentColor"
220
- :opacity="v ? 0.9 : 0.15"
387
+ :opacity="hovered === i ? 1 : point.edits ? 0.9 : 0.15"
221
388
  />
222
- </svg>
223
- </div>
224
- </ClientOnly>
389
+ </g>
390
+ </svg>
391
+ <p
392
+ v-else
393
+ class="py-3 text-[11px] text-dimmed"
394
+ >
395
+ The ledger takes its baseline shortly after the server starts, then books
396
+ one point per sweep. History appears from the next sweep onwards.
397
+ </p>
398
+
399
+ <p class="mt-3 text-[11px] leading-relaxed text-dimmed">
400
+ A bar counts documents whose text CHANGED between two checks of the
401
+ site's cache — near enough an editing session, and not a count of
402
+ keystrokes.
403
+ </p>
404
+ </div>
405
+
406
+ <!-- What the site is MADE of. Live: the tree can answer this one. -->
407
+ <div
408
+ v-if="typeBreakdown.length > 1"
409
+ class="jun-card mt-3 rounded-2xl p-5"
410
+ >
411
+ <p class="mb-3 text-[11px] tracking-wider text-dimmed uppercase">
412
+ Pages by type
413
+ </p>
414
+ <ul class="space-y-1.5">
415
+ <li
416
+ v-for="row in typeBreakdown"
417
+ :key="row.type"
418
+ class="flex items-center gap-3"
419
+ >
420
+ <span class="w-28 flex-none truncate text-xs text-toned">{{ row.label }}</span>
421
+ <span class="h-1.5 flex-1 overflow-hidden rounded-full bg-black/5 dark:bg-white/10">
422
+ <span
423
+ class="block h-full rounded-full bg-current opacity-50"
424
+ :style="{ width: `${row.count / typeMax * 100}%` }"
425
+ />
426
+ </span>
427
+ <span class="w-8 flex-none text-right text-xs text-dimmed tabular-nums">{{ row.count }}</span>
428
+ </li>
429
+ </ul>
430
+ </div>
225
431
 
226
432
  <p class="mt-6 text-center text-[11px] text-dimmed">
227
- Every number here is a live view over this site's document tree.
433
+ Every count here is a live view over this site's document tree.
228
434
  </p>
229
435
  </div>
230
436
  </template>
@@ -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
  }