website-xp-phone 2.2.12 → 2.4.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 (94) hide show
  1. package/.github/workflows/ci.yml +2 -2
  2. package/README.md +17 -3
  3. package/build/blogDirsPlugin.ts +100 -0
  4. package/build/env.ts +4 -1
  5. package/build/routeSkeletonsPlugin.ts +44 -2
  6. package/package.json +14 -10
  7. package/public/blog/archive/eighth-post-lost-in-the-sauce.json +36 -0
  8. package/public/blog/archive/noise/eleventh-post-discussion-java-gist.md +5 -0
  9. package/public/blog/archive/noise/fifteenth-post-very-rare-windows-funny.md +8 -0
  10. package/public/blog/archive/noise/fourth-post-meta-blog.md +3 -0
  11. package/public/blog/archive/noise/sixteenth-post-meta-fantasy-blog.md +4 -0
  12. package/public/blog/archive/noise/tenth-post-meta-funny-redacted-and-timetravelled.md +3 -0
  13. package/public/blog/archive/noise/twelfth-post-mixing-phase-technique-audio-music.md +48 -0
  14. package/public/blog/archive/noise/welcome-back-ramble-meta.md +6 -0
  15. package/public/blog/archive/noise/welcome-to-my-blog-meta-blog-welcome-to-my-website.md +7 -0
  16. package/public/blog/archive/seventh-post-lie-theory-na2000.json +22 -0
  17. package/public/blog/archive/sophus-lie.json +36 -0
  18. package/public/blog/hlwm_and_herbstutil.md +11 -0
  19. package/public/blog/random/hlwm.md +8 -0
  20. package/public/blog/writing/hot-action-under-a-cold-moon.json +9 -0
  21. package/public/checksums.txt +91 -66
  22. package/public/documents/drift-report.json +42 -28
  23. package/render.yaml +11 -1
  24. package/scripts/mutable-assets.mjs +13 -22
  25. package/scripts/refresh-content.mjs +53 -32
  26. package/scripts/refresh-soundcloud.mjs +221 -136
  27. package/scripts/write-dist-checksums.mjs +48 -4
  28. package/src/content/blog.json +16 -363
  29. package/src/content/blogDirs.ts +196 -0
  30. package/src/content/configs.json +1 -1
  31. package/src/content/contacts.json +2 -2
  32. package/src/content/includes/make-recipes.md +18 -0
  33. package/src/content/index.ts +156 -57
  34. package/src/content/music-ext.json +1 -1
  35. package/src/content/projects/doftiles.json +88 -4
  36. package/src/content/projects/herbctl.json +58 -0
  37. package/src/content/projects/herbstutil.json +50 -20
  38. package/src/content/projects/on-deploy.json +57 -0
  39. package/src/content/projects/polyframes.json +83 -0
  40. package/src/content/schema.ts +7 -4
  41. package/src/content/sections.json +11 -10
  42. package/src/content/soundcloud.json +95 -47
  43. package/src/lib/clippy.ts +29 -8
  44. package/src/lib/embeds.ts +43 -24
  45. package/src/lib/history.ts +152 -0
  46. package/src/lib/markdown.tsx +19 -22
  47. package/src/lib/rehypeYoutubeEmbed.ts +65 -0
  48. package/src/lib/sanitizeSchema.ts +32 -0
  49. package/src/lib/scrollTo.ts +45 -0
  50. package/src/lib/signals.tsx +271 -0
  51. package/src/main.tsx +20 -4
  52. package/src/pages/BlogDirPage.tsx +36 -0
  53. package/src/pages/BlogPostPage.tsx +76 -3
  54. package/src/pages/ProjectPage.tsx +9 -3
  55. package/src/pages/WowPage.tsx +8 -3
  56. package/src/pages/index.ts +2 -0
  57. package/src/shell/App.tsx +14 -8
  58. package/src/shell/Clippy.tsx +13 -3
  59. package/src/shell/MenuBar.tsx +7 -4
  60. package/src/shell/resolveRoute.ts +41 -2
  61. package/src/shell/routerSignals.ts +34 -0
  62. package/src/styles/extras.css +27 -0
  63. package/src/styles/layout.css +2 -2
  64. package/src/styles/menu.css +1 -1
  65. package/src/styles/window.css +19 -9
  66. package/src/themes/pageSlide/index.ts +120 -42
  67. package/src/themes/pageSlide/pageSlide.css +20 -9
  68. package/src/virtual.d.ts +14 -0
  69. package/src/window/MaximizedWindow.tsx +97 -64
  70. package/src/window/OkButton.tsx +42 -25
  71. package/src/window/PageWindows.tsx +7 -0
  72. package/src/window/TitleBar.tsx +3 -1
  73. package/src/window/Window.tsx +132 -87
  74. package/src/window/closeSounds.ts +27 -0
  75. package/src/window/model.ts +11 -0
  76. package/src/window/state.tsx +290 -50
  77. package/src/window/themes.ts +23 -2
  78. package/test/content.test.js +15 -10
  79. package/test/deploy-pipeline.test.js +73 -0
  80. package/test/embeds.test.js +89 -0
  81. package/test/markdown-tables.test.js +96 -0
  82. package/test/mutable-assets.test.js +16 -4
  83. package/test/route-skeletons.test.js +38 -0
  84. package/test/soundcloud-refresh.test.js +68 -0
  85. package/test/youtubeEmbed.test.js +157 -0
  86. package/tsconfig.node.tsbuildinfo +1 -1
  87. package/tsconfig.tsbuildinfo +1 -1
  88. package/vite.config.ts +7 -1
  89. package/.opencode/cache/index.akinevz.html +0 -54
  90. package/public/blog/4th.md +0 -28
  91. package/public/blog/wsl.1.md +0 -40
  92. package/src/window/hidden.ts +0 -22
  93. /package/public/blog/{ → archive/noise/}/321/200/321/203/320/275/320/270/321/201/321/207-/320/263/320/273/320/276/321/201/321/201/320/260/321/200/320/270/320/271.md" +0 -0
  94. /package/src/content/{characters.json → includes/characters.json} +0 -0
@@ -6,8 +6,15 @@ import {
6
6
  useReducer,
7
7
  type ReactNode,
8
8
  } from "react";
9
- import { clearHidden, publishHidden } from "./hidden";
10
9
  import { descendantIds, flatten, lineage, type WindowNode } from "./model";
10
+ import { freshArrival, windowBookmark } from "@/lib/history";
11
+ import { CLIPPY_LINK } from "@/lib/clippy";
12
+ import {
13
+ useRetained,
14
+ useSignalHandler,
15
+ useSignals,
16
+ type SignalManifest,
17
+ } from "@/lib/signals";
11
18
 
12
19
  export type PermalinkMode = "hash" | "post";
13
20
 
@@ -39,7 +46,7 @@ type WindowStore = {
39
46
  permalinkMode: PermalinkMode;
40
47
  /** Replaces close/minimise of top-level windows (e.g. "go back"). */
41
48
  onLeave: (() => void) | undefined;
42
- /** Records the window in the URL so returning to the page reopens it. */
49
+ /** Records the window in the URL so returning to the page reveals it. */
43
50
  remember: (id: string) => void;
44
51
  flagsOf: (id: string) => WindowFlags;
45
52
  patch: (id: string, flags: WindowFlags) => void;
@@ -51,21 +58,57 @@ type WindowStore = {
51
58
 
52
59
  const Ctx = createContext<WindowStore | null>(null);
53
60
 
54
- /** Seeds the store synchronously from the URL: if the location names a
55
- * target window (?post=slug / #tree-index), it starts maximized with the
56
- * whole subtree expanded on the FIRST render. usePermalinkTarget's
57
- * post-paint effect normally applies these flags a frame later, but then
58
- * the page first paints the un-maximized main DOM and scrolls — the
59
- * maximized element pops into view over a polluted first frame. Rendering
60
- * the flags from the start shows the maximized overlay immediately, with
61
- * nothing below it ever committed. */
61
+ /** Seeds the store synchronously from the URL: if the location (or the
62
+ * history entry's off-site bookmark — windowBookmark) names a target
63
+ * window (?post=slug / #tree-index), it starts REVEALED — expanded
64
+ * inline, never maximized — with its whole subtree expanded on the FIRST
65
+ * render. Revealing inline needs every ancestor expanded too (a collapsed
66
+ * parent never mounts the target, leaving nothing to scroll to), hence
67
+ * the lineage. usePermalinkTarget's post-paint effect re-applies the
68
+ * identical flags a frame later, and the pageSlide theme lands the page
69
+ * on the element; seeding first keeps that first paint already expanded
70
+ * instead of popping the section open after the fact. */
62
71
  function initialFlags(roots: WindowNode[]): State {
63
72
  const windows = flatten(roots);
64
73
  const target = findTarget(windows);
65
74
  if (!target) return {};
66
- const state: State = {
67
- [target.id]: { maximized: true, minimized: false, expanded: true },
68
- };
75
+ const state: State = {};
76
+ // A FRESH permalink (a new tab from the Permalink button, typed,
77
+ // shared): the landing IS the maximized view — the maximized view is
78
+ // the section's own page. Seeded on the very first render, so no
79
+ // un-maximized frame flashes. The view is a FRAMING, not a reveal:
80
+ // no lineage seeding, no subtree seeding.
81
+ if (freshArrival() && namedByUrl(target)) {
82
+ // The maximized view IS the landing — but a nested section's
83
+ // collapsed ancestors never mount it (a collapsed parent never
84
+ // mounts its target), so the lineage opens with it: every ancestor
85
+ // expanded, the target itself maximized. Without the lineage the
86
+ // landing is an empty page for any target below the roots.
87
+ for (const id of lineage(target.id)) {
88
+ state[id] =
89
+ id === target.id
90
+ ? { maximized: true, minimized: false }
91
+ : { expanded: true, minimized: false };
92
+ }
93
+ return state;
94
+ }
95
+ // A maximize push popped back (or forward) onto — its state bookmark
96
+ // and URL name the same window: the framing return. Only the
97
+ // target's lineage (self + ancestors) opens; the maximized view kept
98
+ // the inner sections' flags and so does the landing (fixes the
99
+ // configs Gallery: returning from the OK link does not unfold the
100
+ // section's whole subtree).
101
+ if (windowBookmark() === target.id && namedByUrl(target)) {
102
+ for (const id of lineage(target.id))
103
+ state[id] = { expanded: true, minimized: false };
104
+ return state;
105
+ }
106
+ // The plain permalink / hash-free off-site return: the section comes
107
+ // back with its whole subtree expanded (revealing inline needs every
108
+ // ancestor expanded too — a collapsed parent never mounts the target).
109
+ for (const id of lineage(target.id)) {
110
+ state[id] = { expanded: true, minimized: false };
111
+ }
69
112
  for (const id of descendantIds(windows, target.id)) {
70
113
  state[id] = { expanded: true, minimized: false };
71
114
  }
@@ -83,8 +126,11 @@ export function WindowProvider({
83
126
  onLeave?: (() => void) | undefined;
84
127
  children: ReactNode;
85
128
  }) {
86
- const [state, dispatch] = useReducer(reducer, [], () => initialFlags(roots));
129
+ const [state, dispatchReducer] = useReducer(reducer, [], () =>
130
+ initialFlags(roots),
131
+ );
87
132
  const windows = useMemo(() => flatten(roots), [roots]);
133
+ const { dispatch } = useSignals();
88
134
 
89
135
  const store = useMemo<WindowStore>(() => {
90
136
  const flagsOf = (id: string) => state[id] ?? {};
@@ -93,36 +139,58 @@ export function WindowProvider({
93
139
  permalinkMode,
94
140
  onLeave,
95
141
  remember: (id) => {
142
+ // Any .window[id] on the page may bookmark its departure — not
143
+ // only model nodes. Page-specific hand-rolled windows (the wow
144
+ // download form) live OUTSIDE PageWindows' tree: their id is
145
+ // nowhere in the model, but the browser back that returns to
146
+ // this entry must still land on them (the pageSlide theme's
147
+ // landing scroll resolves ANY id). Model nodes keep their
148
+ // permalink URL form (?post= on the blog); unknown ones take
149
+ // the current address hash-free.
96
150
  const node = windows.find((w) => w.id === id);
97
- if (node)
98
- history.replaceState(
99
- history.state,
100
- "",
101
- permalinkFor(node, permalinkMode),
102
- );
151
+ dispatch("history:remember", {
152
+ id,
153
+ url: node
154
+ ? bookmarkUrlFor(node, permalinkMode)
155
+ : location.pathname + location.search,
156
+ });
103
157
  },
104
158
  flagsOf,
105
- patch: (id, flags) => dispatch({ type: "patch", ids: [id], flags }),
159
+ patch: (id, flags) =>
160
+ dispatchReducer({ type: "patch", ids: [id], flags }),
106
161
  expand: (id) =>
107
- dispatch({
162
+ // Revealed content shows inline: a stale minimized flag on the
163
+ // lineage (a window parked earlier by the minimize dismissal)
164
+ // would leave the revealed target on its OK-row body — the
165
+ // reveal un-minimizes what it expands.
166
+ dispatchReducer({
108
167
  type: "patch",
109
168
  ids: lineage(id),
110
- flags: { expanded: true },
169
+ flags: { expanded: true, minimized: false },
111
170
  }),
112
- restore: (id) => dispatch({ type: "restore", ids: lineage(id) }),
171
+ restore: (id) => dispatchReducer({ type: "restore", ids: lineage(id) }),
113
172
  parked: windows.filter((w) => {
114
173
  return state[w.id]?.closed;
115
174
  }),
116
175
  };
117
- }, [state, windows, permalinkMode, onLeave]);
176
+ }, [state, windows, permalinkMode, onLeave, dispatch]);
118
177
 
119
- useEffect(() => {
120
- publishHidden({
178
+ // The parked-window roster is broadcast as a retained signal, not
179
+ // held in a store: the publisher just DECLARES the snapshot it
180
+ // currently holds — the library commits it post-render and restores
181
+ // the seed on unmount — so Clippy's readers hold no state of their
182
+ // own and this component manages no effect of its own. The snapshot
183
+ // is memo'd on the store: a fresh object per flag change keeps the
184
+ // refire frequency of the old whole-republish contract, and nothing
185
+ // higher up the tree can disturb it.
186
+ const roster = useMemo<SignalManifest["window:hidden"]>(
187
+ () => ({
121
188
  items: store.parked.map((w) => ({ id: w.id, label: w.heading ?? w.id })),
122
189
  restore: store.restore,
123
- });
124
- }, [store]);
125
- useEffect(() => clearHidden, []);
190
+ }),
191
+ [store],
192
+ );
193
+ useRetained("window:hidden", roster);
126
194
 
127
195
  return <Ctx.Provider value={store}>{children}</Ctx.Provider>;
128
196
  }
@@ -152,10 +220,27 @@ export function permalinkFor(node: WindowNode, mode: PermalinkMode): string {
152
220
  return `${origin}${pathname}#${node.id}`;
153
221
  }
154
222
 
155
- /** The window named by the URL. BOTH link shapes land on any page:
156
- * ?post=slug (the blog's permalink mode) addresses a post by heading, and
157
- * #tree-index addresses any window by id. ?post wins when both are set
158
- * (they could name different windows); the hash is the fallback. */
223
+ /** The OFF-SITE bookmark's URL form: the page's own address WITHOUT a
224
+ * per-section hash — the blog keeps its ?post= slug (that form IS the
225
+ * section's permalink; no hash is involved), every other page keeps the
226
+ * bare path with its query. The section id rides the entry's state
227
+ * payload (history:remember's handler), so the departure the back
228
+ * button returns to stays hash-free while still naming the window. */
229
+ function bookmarkUrlFor(node: WindowNode, mode: PermalinkMode): string {
230
+ if (mode === "post" && node.depth > 0 && node.heading) {
231
+ return `${location.pathname}?post=${encodeURIComponent(toSlug(node.heading))}`;
232
+ }
233
+ return location.pathname + location.search;
234
+ }
235
+
236
+ /** The window named by the URL — or by the history entry's BOOKMARK:
237
+ * ?post=slug (the blog's permalink mode) addresses a post by heading,
238
+ * #tree-index addresses any window by id, and the ?post/hash lookup
239
+ * loses to nothing — the bookmark answers only when the URL names no
240
+ * window at all, which is exactly the off-site departure's form (the
241
+ * entry went out hash-free, its state carries the window that left).
242
+ * ?post wins when both a slug and a hash are set (they could name
243
+ * different windows); the hash is the fallback over the bookmark. */
159
244
  function findTarget(windows: WindowNode[]) {
160
245
  const slug = new URLSearchParams(location.search).get("post");
161
246
  if (slug) {
@@ -165,39 +250,194 @@ function findTarget(windows: WindowNode[]) {
165
250
  if (post) return post;
166
251
  }
167
252
  const hash = location.hash.slice(1);
168
- return windows.find((w) => w.id === hash);
253
+ if (hash) return windows.find((w) => w.id === hash);
254
+ return windows.find((w) => w.id === windowBookmark());
169
255
  }
170
256
 
257
+ /** Whether the URL itself names the window (the hash or the blog's
258
+ * ?post= slug) — as opposed to the off-site form, where ONLY the
259
+ * entry's state bookmark carries the id. Used to tell the three
260
+ * landing shapes apart: a fresh permalink, a maximize push popped
261
+ * back/forward onto, and the hash-free off-site return. */
262
+ const namedByUrl = (target: WindowNode): boolean => {
263
+ const slug = new URLSearchParams(location.search).get("post");
264
+ if (slug && target.depth > 0 && target.heading)
265
+ return toSlug(target.heading) === slug;
266
+ return decodeURIComponent(location.hash.slice(1)) === target.id;
267
+ };
268
+
171
269
  /** Confirms the window named by the URL, once per page load. The store is
172
- * already seeded synchronously with the target maximized (initialFlags)
173
- * so the FIRST paint shows the fullscreen view with no inline flash;
174
- * this effect only re-applies the identical, idempotent patches. Both
175
- * link shapes arrive the same way: the target opens maximized in the
176
- * foreground with its whole subtree expanded. */
270
+ * already seeded synchronously with the target revealed (initialFlags) so
271
+ * the FIRST paint shows it expanded with no late pop-open; this effect
272
+ * only re-applies the identical confirmation through the reveal signal
273
+ * (the store's handler performs the expansion — see useReveal). The
274
+ * landing splits three ways, mirroring initialFlags's seeding:
275
+ *
276
+ * - Fresh permalink (the Permalink button's new tab, typed, shared) on
277
+ * a URL that names the window: the store already holds maximized:true
278
+ * — no reveal, no scroll (the maximized view IS the landing), and the
279
+ * arrival entry is ANCHORED to the permalink (mode "replace") so the
280
+ * mount carries the bookmark key: dismissals settle on it
281
+ * (stillOwnsEntry) and a refresh stays maximized.
282
+ * - A maximize push popped back/forward/reload onto (its entry's state
283
+ * bookmark and the URL name the same window): the framing confirm —
284
+ * reveal "none", only the target's lineage was seeded, collapsed
285
+ * sections stay collapsed (the configs Gallery fix).
286
+ * - The plain permalink / hash-free off-site return: the whole-subtree
287
+ * reveal (descendants "all"). */
177
288
  export function usePermalinkTarget() {
178
- const { windows, expand, patch } = useWindowStore();
289
+ const { windows, permalinkMode } = useWindowStore();
290
+ const { dispatch } = useSignals();
179
291
  useEffect(() => {
180
292
  const target = findTarget(windows);
181
293
  if (!target) return;
182
- expand(target.id);
183
- // Arriving at a permalink reveals the target's whole subtree, not
184
- // just its own section (descendants expand, stale minimized flags
185
- // clear; closed/parked windows stay parked), then lifts it.
186
- for (const id of descendantIds(windows, target.id)) {
187
- patch(id, { expanded: true, minimized: false });
294
+ if (freshArrival() && namedByUrl(target)) {
295
+ dispatch("history:anchor", {
296
+ id: target.id,
297
+ url: permalinkFor(target, permalinkMode),
298
+ mode: "replace",
299
+ });
300
+ return;
188
301
  }
189
- patch(target.id, { maximized: true, minimized: false });
302
+ if (windowBookmark() === target.id && namedByUrl(target)) {
303
+ // Framing only: the target itself, never its descendants.
304
+ dispatch("window:reveal", { id: target.id, descendants: "none" });
305
+ if (location.hash) return;
306
+ const el = document.getElementById(target.id);
307
+ if (el)
308
+ window.scrollTo({
309
+ top: el.getBoundingClientRect().top + window.scrollY,
310
+ });
311
+ return;
312
+ }
313
+ // The reveal (lineage + whole subtree) rides the signal bus: nothing
314
+ // lifts and nothing scrolls here for hash arrivals — the pageSlide
315
+ // theme lands the page.
316
+ dispatch("window:reveal", { id: target.id, descendants: "all" });
317
+ if (location.hash) return;
318
+ // Plain instant scroll: hash arrivals ride the theme's smooth
319
+ // landing; query-only ones land here, retail-instant.
320
+ const el = document.getElementById(target.id);
321
+ if (el)
322
+ window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY });
190
323
  }, []);
191
324
  }
192
325
 
193
- /** Same-tab links out of the site remember the window they were clicked in. */
326
+ /** The reveal COMMAND's store handler. Announced for any flow that opens
327
+ * a window's content without lifting it — permalink confirms, same-path
328
+ * returns, maximized-rail dismissals — this expands the target's lineage
329
+ * first (a collapsed parent never mounts its target) and then either its
330
+ * direct children or the whole subtree. It never touches maximized
331
+ * flags: revealing is a framing-free expansion. Must subscribe BEFORE
332
+ * any mount-time dispatcher (order inside Roots), so a confirm dispatch
333
+ * is not missed on the first render. */
334
+ export function useReveal() {
335
+ const { windows, expand, patch } = useWindowStore();
336
+ useSignalHandler("window:reveal", ({ id, descendants }) => {
337
+ expand(id);
338
+ const node = windows.find((w) => w.id === id);
339
+ const revealed =
340
+ !node || descendants === "none"
341
+ ? []
342
+ : descendants === "all"
343
+ ? descendantIds(windows, id)
344
+ : node.children.flatMap((c) =>
345
+ c.kind === "window" ? [c.node.id] : [],
346
+ );
347
+ for (const child of revealed)
348
+ patch(child, { expanded: true, minimized: false });
349
+ });
350
+ }
351
+
352
+ /** REPAIRS the same-path history return. Traversals that keep the route
353
+ * (same pathname, hash/query-only entries — the blog's ?post= form)
354
+ * never remount the page: the store still holds the flags it left with.
355
+ * Every maximized window the traversal LEFT (its maximize push was
356
+ * popped — the URL hash no longer names it) gets the minimize
357
+ * dismissal through window:minimize: the browser back button out of the
358
+ * maximized view plays the minimize click, slides the window off and
359
+ * parks it — back out of a maximized section IS minimizing it. One
360
+ * whose id the URL still names keeps the foreground (a stacked
361
+ * window's entry is active again, or forward onto its push). The
362
+ * URL's target — hash, ?post= slug or the off-site bookmark —
363
+ * re-expands with its subtree, landing on the section instead of
364
+ * re-showing the lifted window. The query-only landing happens here
365
+ * too (only the store resolves ?post= to its element); hash landings
366
+ * stay the pageSlide theme's scrollToHash. Cross-page returns (a
367
+ * REMOUNTED route) don't need this — their fresh store confirms via
368
+ * usePermalinkTarget. */
369
+ export function usePageReturn() {
370
+ const { windows, flagsOf } = useWindowStore();
371
+ const { dispatch } = useSignals();
372
+ // The repair: maximized windows the address no longer names get the
373
+ // minimize choreography; the URL's target — hash, ?post= slug or the
374
+ // off-site bookmark — re-expands, landing on the section. The
375
+ // query-only landing happens here too (only the store resolves
376
+ // ?post= to its element); hash landings stay the pageSlide theme's
377
+ // scrollToHash. Cross-page returns (a REMOUNTED route) don't need
378
+ // this — their fresh store confirms via usePermalinkTarget.
379
+ const repair = () => {
380
+ const named = location.hash.slice(1);
381
+ for (const w of windows) {
382
+ if (!flagsOf(w.id).maximized || w.id === named) continue;
383
+ dispatch("window:minimize", { id: w.id });
384
+ }
385
+ const target = findTarget(windows);
386
+ if (!target) return;
387
+ // The return landing mirrors the remount's: back onto a maximize
388
+ // push (bookmark + URL name the same window) is a FRAMING — the
389
+ // inner sections keep their flags, no subtree cascade (the configs
390
+ // Gallery fix); every other return reveals the whole subtree.
391
+ if (windowBookmark() === target.id && namedByUrl(target))
392
+ dispatch("window:reveal", { id: target.id, descendants: "none" });
393
+ else dispatch("window:reveal", { id: target.id, descendants: "all" });
394
+ if (location.hash) return;
395
+ const el = document.getElementById(target.id);
396
+ if (el)
397
+ window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY });
398
+ };
399
+ // History traversals AND same-path re-addresses (an in-site link
400
+ // click pushing ?post= or #id without remounting the page) both
401
+ // repair: the page holds the flags it left with either way.
402
+ useSignalHandler("page:returned", repair);
403
+ useSignalHandler("page:addressed", repair);
404
+ }
405
+
406
+ /** Links clicked inside a window remember it. An off-site same-tab
407
+ * departure (a full document navigation) and an internal same-tab one
408
+ * (the router's SPA push — "job search" → /resume) BOTH bookmark the
409
+ * window into the entry they LEAVE, so the browser back lands on the
410
+ * section revealed and scrolled to. The listener is capture-phase at
411
+ * document level, so it runs BEFORE the <Link>'s own handler: the
412
+ * bookmark is written while the current entry is still the page being
413
+ * left — anything later (the router's pushState) has already made the
414
+ * DESTINATION entry current. Modifier clicks and target=_blank leave
415
+ * nothing behind (the leaving tab never leaves), and the Clippy
416
+ * trigger link departs nowhere at all. */
194
417
  export function useRememberLeave() {
195
418
  const { remember } = useWindowStore();
196
419
  useEffect(() => {
197
420
  const onClick = (event: MouseEvent) => {
421
+ if (
422
+ event.defaultPrevented ||
423
+ event.button !== 0 ||
424
+ event.metaKey ||
425
+ event.ctrlKey ||
426
+ event.shiftKey ||
427
+ event.altKey
428
+ )
429
+ return;
198
430
  const anchor = (event.target as Element).closest?.("a[href]");
199
431
  if (!(anchor instanceof HTMLAnchorElement)) return;
200
- if (anchor.origin === location.origin || anchor.target === "_blank")
432
+ // New tabs leave nothing behind and the Clippy trigger link
433
+ // departs nowhere: a _blank tab restores the session entry's
434
+ // state as it stands (a bookmark would double-apply), and the
435
+ // Clippy link navigates to nowhere — its bookmark would be stale
436
+ // on an entry that never left.
437
+ if (
438
+ anchor.target === "_blank" ||
439
+ anchor.getAttribute("href") === CLIPPY_LINK
440
+ )
201
441
  return;
202
442
  const id = anchor.closest<HTMLElement>(".window[id]")?.id;
203
443
  if (id) remember(id);
@@ -1,8 +1,29 @@
1
1
  import type { WindowNode } from "./model";
2
2
  import { hasTheme } from "./model";
3
+ import type { SignalManifest } from "@/lib/signals";
3
4
 
4
- export const dataTheme = (node: WindowNode): string | undefined =>
5
- node.themes.length ? node.themes.join(" ") : undefined;
5
+ /** TEMP STUB: the "experimental" theme is switched off — its wobble and
6
+ * flash animations are noise while the OK/maximize choreography is being
7
+ * reworked. Filtering it here disables every effect at once (all CSS keys
8
+ * on [data-theme~="experimental"] and nothing in TS reads the theme)
9
+ * without touching content files or stylesheets. Restore by deleting the
10
+ * filter. */
11
+ export const dataTheme = (node: WindowNode): string | undefined => {
12
+ const themes = node.themes.filter((theme) => theme !== "experimental");
13
+ return themes.length ? themes.join(" ") : undefined;
14
+ };
15
+
16
+ /** The ✕ close's sound, declared. The crunchy kick backs every ✕ press
17
+ * that STAYS on the page — refusals (Clippy veto, "funny" windows),
18
+ * local collapses, Clippy parks, maximized restores — while the
19
+ * Click.ogg is reserved for the ✕ that navigates away to a new page
20
+ * (that gesture's pageSlide fold click is muted in closeSounds.ts, so
21
+ * the navigation gets exactly one click). The sound's name is owned by
22
+ * the window:closed manifest entry; this policy maps a press to it. */
23
+ export type CloseSound = SignalManifest["window:closed"]["sound"];
24
+
25
+ export const closeSound = (navigates: boolean): CloseSound =>
26
+ navigates ? "click" : "kick";
6
27
 
7
28
  /** `open` windows are always expanded and have no OK button. */
8
29
  export const forcesExpanded = (node: WindowNode): boolean =>
@@ -36,11 +36,12 @@ test("page aliases target an existing route (+optional section anchor)", () => {
36
36
  }
37
37
  });
38
38
 
39
- test("include directives target a registered content file", async () => {
39
+ test("include directives target a file under src/content/includes/", async () => {
40
40
  const { readdirSync } = await import("node:fs");
41
- const indexTs = readFileSync("src/content/index.ts", "utf8");
42
- const jsonFiles = readdirSync("src/content").filter((f) =>
43
- f.endsWith(".json"),
41
+ // Every content JSON anywhere in src/content/ may carry directives —
42
+ // page content files and project pages alike.
43
+ const jsonFiles = readdirSync("src/content", { recursive: true }).filter(
44
+ (f) => f.endsWith(".json") && !f.startsWith("includes/"),
44
45
  );
45
46
  const directives = jsonFiles.flatMap(
46
47
  (file) =>
@@ -48,18 +49,22 @@ test("include directives target a registered content file", async () => {
48
49
  /"include"\s*:\s*"([^"]+)"/g,
49
50
  ) ?? [],
50
51
  );
52
+ assert.ok(directives.length > 0, "the repo carries at least one directive");
51
53
  for (const directive of directives) {
54
+ // The directive carries the FULL FILE NAME (extension included); the
55
+ // resolver looks bare file names up in glob-built maps, so a name
56
+ // with directory parts cannot escape includes/.
52
57
  const name = directive.match(/"include"\s*:\s*"([^"]+)"/)[1];
53
- const target = `src/content/${name}.json`;
58
+ assert.match(
59
+ name,
60
+ /^[a-z0-9][a-z0-9._-]*\.(json|md)$/i,
61
+ `${directive}: full file name with an includable extension`,
62
+ );
63
+ const target = `src/content/includes/${name}`;
54
64
  assert.ok(
55
65
  readFileSync(target, "utf8").length > 0,
56
66
  `include target ${target} exists`,
57
67
  );
58
- assert.match(
59
- indexTs,
60
- new RegExp(`\\b${name}\\b`),
61
- `${name} registered in includeRegistry`,
62
- );
63
68
  }
64
69
  });
65
70
 
@@ -0,0 +1,73 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFileSync } from "node:fs";
3
+ import { test } from "node:test";
4
+
5
+ const pkg = JSON.parse(readFileSync("package.json", "utf8"));
6
+ const scripts = pkg.scripts;
7
+ const renderYaml = readFileSync("render.yaml", "utf8");
8
+ const ciYml = readFileSync(".github/workflows/ci.yml", "utf8");
9
+
10
+ /**
11
+ * The deploy end (Render) must stay cheap and side-effect-free: it builds
12
+ * the committed tree and statically gates on the committed drift report.
13
+ * Everything expensive or stateful — content refresh, checksums, live
14
+ * baseline fetches — belongs to `build:gated` (CI, build:local) only.
15
+ */
16
+ test("the deploy build neither regenerates content nor runs the checksums pipeline", () => {
17
+ const build = scripts.build;
18
+ assert.match(build, /vite build/);
19
+ assert.doesNotMatch(build, /checksums/);
20
+ assert.doesNotMatch(build, /refresh/);
21
+ });
22
+
23
+ test("build:gated is the full pipeline: build + checksums", () => {
24
+ assert.equal(scripts["build:gated"], "npm run build && npm run checksums");
25
+ });
26
+
27
+ test("build:local refreshes soundcloud, then gated build, then the gate", () => {
28
+ const local = scripts["build:local"];
29
+ assert.match(local, /refresh:content/);
30
+ assert.match(local, /refresh:soundcloud/);
31
+ const refreshAt = local.indexOf("refresh:soundcloud");
32
+ const gatedAt = local.indexOf("build:gated");
33
+ const gateAt = local.indexOf("verify:policy");
34
+ assert.ok(refreshAt !== -1 && gatedAt !== -1 && gateAt !== -1);
35
+ assert.ok(refreshAt < gatedAt, "content refresh must precede the build");
36
+ assert.ok(gatedAt < gateAt, "the gate must consume the fresh drift report");
37
+ });
38
+
39
+ test("check:ci mirrors the CI subset with the gated build", () => {
40
+ assert.match(scripts["check:ci"], /build:gated/);
41
+ assert.match(scripts["check:ci"], /verify:policy/);
42
+ });
43
+
44
+ test("build:local serves regardless of the repo's git state", () => {
45
+ // The dev server must come up on any working tree — dirty, staged,
46
+ // mid-rebase. check:lockfile is a git-diff gate, so it stays a CI
47
+ // concern (check:ci); `git add -A` is the commit flow's job
48
+ // (build:ready), not a precondition of serving.
49
+ const local = scripts["build:local"];
50
+ assert.doesNotMatch(local, /\bgit\b/);
51
+ assert.doesNotMatch(local, /check:lockfile/);
52
+ assert.match(local, /npm run dev$/);
53
+ });
54
+
55
+ test("CI runs the gated build so the drift report is recomputed there", () => {
56
+ assert.match(ciYml, /npm run build:gated/);
57
+ });
58
+
59
+ test("Render statically gates on the uploaded report before any install", () => {
60
+ const commandLine = renderYaml
61
+ .split("\n")
62
+ .find((line) => line.trim().startsWith("buildCommand:"));
63
+ assert.ok(commandLine, "render.yaml must declare a buildCommand");
64
+ // The static gate runs before npm install: a failing report aborts the
65
+ // deploy before spending any real compute.
66
+ const gateAt = commandLine.indexOf("npm run verify:policy");
67
+ const installAt = commandLine.indexOf("npm install");
68
+ assert.ok(gateAt !== -1, "deploy must statically check the drift report");
69
+ assert.ok(installAt !== -1 && gateAt < installAt);
70
+ // And it must not re-run the pipeline it gated.
71
+ assert.doesNotMatch(commandLine, /checksums/);
72
+ assert.doesNotMatch(commandLine, /refresh/);
73
+ });