website-xp-phone 2.3.0 → 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 (77) hide show
  1. package/build/blogDirsPlugin.ts +100 -0
  2. package/package.json +9 -6
  3. package/public/blog/archive/eighth-post-lost-in-the-sauce.json +36 -0
  4. package/public/blog/archive/noise/eleventh-post-discussion-java-gist.md +5 -0
  5. package/public/blog/archive/noise/fifteenth-post-very-rare-windows-funny.md +8 -0
  6. package/public/blog/archive/noise/fourth-post-meta-blog.md +3 -0
  7. package/public/blog/archive/noise/sixteenth-post-meta-fantasy-blog.md +4 -0
  8. package/public/blog/archive/noise/tenth-post-meta-funny-redacted-and-timetravelled.md +3 -0
  9. package/public/blog/archive/noise/twelfth-post-mixing-phase-technique-audio-music.md +48 -0
  10. package/public/blog/archive/noise/welcome-back-ramble-meta.md +6 -0
  11. package/public/blog/archive/noise/welcome-to-my-blog-meta-blog-welcome-to-my-website.md +7 -0
  12. package/public/blog/archive/seventh-post-lie-theory-na2000.json +22 -0
  13. package/public/blog/archive/sophus-lie.json +36 -0
  14. package/public/blog/hlwm_and_herbstutil.md +11 -0
  15. package/public/blog/writing/hot-action-under-a-cold-moon.json +9 -0
  16. package/public/checksums.txt +90 -66
  17. package/public/documents/drift-report.json +13 -1
  18. package/scripts/refresh-soundcloud.mjs +54 -8
  19. package/src/content/blog.json +16 -363
  20. package/src/content/blogDirs.ts +196 -0
  21. package/src/content/configs.json +1 -1
  22. package/src/content/contacts.json +2 -2
  23. package/src/content/includes/make-recipes.md +18 -0
  24. package/src/content/index.ts +156 -57
  25. package/src/content/music-ext.json +1 -1
  26. package/src/content/projects/doftiles.json +88 -4
  27. package/src/content/projects/herbctl.json +58 -0
  28. package/src/content/projects/herbstutil.json +50 -20
  29. package/src/content/projects/on-deploy.json +57 -0
  30. package/src/content/projects/polyframes.json +83 -0
  31. package/src/content/schema.ts +7 -4
  32. package/src/content/sections.json +11 -10
  33. package/src/content/soundcloud.json +61 -13
  34. package/src/lib/clippy.ts +29 -8
  35. package/src/lib/history.ts +152 -0
  36. package/src/lib/markdown.tsx +11 -1
  37. package/src/lib/scrollTo.ts +45 -0
  38. package/src/lib/signals.tsx +271 -0
  39. package/src/main.tsx +20 -4
  40. package/src/pages/BlogDirPage.tsx +36 -0
  41. package/src/pages/BlogPostPage.tsx +76 -3
  42. package/src/pages/ProjectPage.tsx +9 -3
  43. package/src/pages/WowPage.tsx +8 -3
  44. package/src/pages/index.ts +2 -0
  45. package/src/shell/App.tsx +14 -8
  46. package/src/shell/Clippy.tsx +13 -3
  47. package/src/shell/MenuBar.tsx +7 -4
  48. package/src/shell/resolveRoute.ts +41 -2
  49. package/src/shell/routerSignals.ts +34 -0
  50. package/src/styles/extras.css +20 -0
  51. package/src/styles/layout.css +2 -2
  52. package/src/styles/menu.css +1 -1
  53. package/src/styles/window.css +9 -2
  54. package/src/themes/pageSlide/index.ts +120 -42
  55. package/src/themes/pageSlide/pageSlide.css +20 -9
  56. package/src/virtual.d.ts +14 -0
  57. package/src/window/MaximizedWindow.tsx +97 -64
  58. package/src/window/OkButton.tsx +42 -25
  59. package/src/window/PageWindows.tsx +7 -0
  60. package/src/window/TitleBar.tsx +3 -1
  61. package/src/window/Window.tsx +132 -87
  62. package/src/window/closeSounds.ts +27 -0
  63. package/src/window/model.ts +11 -0
  64. package/src/window/state.tsx +290 -50
  65. package/src/window/themes.ts +23 -2
  66. package/test/content.test.js +15 -10
  67. package/test/deploy-pipeline.test.js +11 -11
  68. package/test/markdown-tables.test.js +96 -0
  69. package/test/soundcloud-refresh.test.js +68 -0
  70. package/tsconfig.node.tsbuildinfo +1 -1
  71. package/tsconfig.tsbuildinfo +1 -1
  72. package/vite.config.ts +7 -1
  73. package/public/blog/4th.md +0 -28
  74. package/public/blog/wsl.1.md +0 -40
  75. package/src/window/hidden.ts +0 -22
  76. /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
  77. /package/src/content/{characters.json → includes/characters.json} +0 -0
@@ -1,13 +1,16 @@
1
- import { useLocation, useNavigate } from "react-router-dom";
1
+ import { useLocation } from "react-router-dom";
2
2
  import { projectPath, projects, type Item, type Section } from "@/content";
3
3
  import { normalizePath } from "@/shell/resolveRoute";
4
+ import { useSignals } from "@/lib/signals";
4
5
  import { PageWindows } from "@/window";
5
6
 
6
7
  const toItems = (content: Section["content"]): Item[] =>
7
8
  content === undefined ? [] : Array.isArray(content) ? content : [content];
8
9
 
9
10
  export const ProjectPage = () => {
10
- const navigate = useNavigate();
11
+ // Leaving the page is a command, not a router call — the shell owns
12
+ // the single router-aware "app:navigate" handler.
13
+ const { dispatch } = useSignals();
11
14
  const path = normalizePath(useLocation().pathname);
12
15
  const project = projects.find((p) => projectPath(p) === path);
13
16
  if (!project) return null;
@@ -17,6 +20,9 @@ export const ProjectPage = () => {
17
20
  content: toItems(project.content.content),
18
21
  };
19
22
  return (
20
- <PageWindows content={content} onLeave={() => navigate("/projects")} />
23
+ <PageWindows
24
+ content={content}
25
+ onLeave={() => dispatch("app:navigate", { to: "/projects" })}
26
+ />
21
27
  );
22
28
  };
@@ -1,6 +1,6 @@
1
1
  import { useMemo, useState, type FormEvent } from "react";
2
- import { useNavigate } from "react-router-dom";
3
2
  import { addons, characters } from "@/content";
3
+ import { useSignals } from "@/lib/signals";
4
4
  import { PageWindows } from "@/window";
5
5
 
6
6
  type Feedback = { kind: "error" | "success"; text: string } | null;
@@ -22,7 +22,9 @@ function download(href: string, name: string) {
22
22
  }
23
23
 
24
24
  function DownloadForm() {
25
- const navigate = useNavigate();
25
+ // Cancelling is a command, not a router call — the shell owns the one
26
+ // router-aware "app:navigate" handler.
27
+ const { dispatch } = useSignals();
26
28
  const [username, setUsername] = useState("");
27
29
  const [date, setDate] = useState("");
28
30
  const [feedback, setFeedback] = useState<Feedback>(null);
@@ -85,7 +87,10 @@ function DownloadForm() {
85
87
  </div>
86
88
  <div className="form-actions">
87
89
  <button type="submit">Verify &amp; Download</button>
88
- <button type="button" onClick={() => navigate("/")}>
90
+ <button
91
+ type="button"
92
+ onClick={() => dispatch("app:navigate", { to: "/" })}
93
+ >
89
94
  Cancel
90
95
  </button>
91
96
  </div>
@@ -1,5 +1,6 @@
1
1
  import type { ComponentType } from "react";
2
2
  import { AddonsPage } from "./AddonsPage";
3
+ import { BlogDirPage } from "./BlogDirPage";
3
4
  import { BlogPage } from "./BlogPage";
4
5
  import { BlogPostPage } from "./BlogPostPage";
5
6
  import { ContactPage } from "./ContactPage";
@@ -16,6 +17,7 @@ import { WowPage } from "./WowPage";
16
17
  /** Maps the `page` names in content/pages.json to components. */
17
18
  export const pageRegistry: Record<string, ComponentType> = {
18
19
  AddonsPage,
20
+ BlogDirPage,
19
21
  BlogPage,
20
22
  BlogPostPage,
21
23
  ConfigsPage,
package/src/shell/App.tsx CHANGED
@@ -1,9 +1,10 @@
1
1
  import { useEffect } from "react";
2
- import { Navigate, useLocation } from "react-router-dom";
2
+ import { Navigate, useLocation, useNavigate } from "react-router-dom";
3
3
  import { ToastContainer } from "react-toastify";
4
4
  import { pageRegistry } from "@/pages";
5
5
  import { NotFoundPage } from "@/pages/NotFoundPage";
6
6
  import { applyStoredTheme } from "@/lib/theme";
7
+ import { bindNavigate } from "./routerSignals";
7
8
  import { Clippy } from "./Clippy";
8
9
  import { MenuBar } from "./MenuBar";
9
10
  import { resolveRoute } from "./resolveRoute";
@@ -16,6 +17,13 @@ export function App() {
16
17
  const { pathname, hash } = useLocation();
17
18
  const route = resolveRoute(pathname);
18
19
  const Page = pageRegistry[route.page] ?? NotFoundPage;
20
+ const navigate = useNavigate();
21
+ // The shell keeps only the router awareness: the app:navigate handler
22
+ // attached at boot (routerSignals) performs dispatches with THIS
23
+ // navigate, bound here against the router context. Page-load
24
+ // monitoring is the attached handlers' business too — the boot route
25
+ // is announced there, transitions by the pageSlide theme.
26
+ bindNavigate(navigate);
19
27
 
20
28
  const blank = pathname === "/" && hash.toLowerCase() === FEEF69_HASH;
21
29
 
@@ -34,13 +42,11 @@ export function App() {
34
42
  return (
35
43
  <>
36
44
  <MenuBar />
37
- <main>
38
- <section
39
- className={`page${route.path === "/configs" ? " page-configs" : ""}`}
40
- key={route.path}
41
- >
42
- <Page />
43
- </section>
45
+ {/* main IS the page: one element carries the scroll container and the
46
+ page styling — an extra <section.page> inside it only added a
47
+ nesting level. Pages differ in content, never in shell structure. */}
48
+ <main className="page" key={route.path}>
49
+ <Page />
44
50
  </main>
45
51
  <Clippy />
46
52
  <ToastContainer position="bottom-right" />
@@ -6,7 +6,7 @@ import {
6
6
  subscribeClippy,
7
7
  toggleClippyList,
8
8
  } from "@/lib/clippy";
9
- import { getHidden, subscribeHidden } from "@/window/hidden";
9
+ import { useSignalValue } from "@/lib/signals";
10
10
 
11
11
  type Corner = "tl" | "tr" | "bl" | "br";
12
12
 
@@ -20,11 +20,14 @@ const ARRIVE_MS = 600;
20
20
 
21
21
  /** Hidden mascot; summoning logic lives in lib/clippy. Draggable & snappy. */
22
22
  export function Clippy() {
23
- const { visible, bubble, saysNo, listOpen } = useSyncExternalStore(
23
+ const { visible, bubble, saysNo, offering, listOpen } = useSyncExternalStore(
24
24
  subscribeClippy,
25
25
  getClippyState,
26
26
  );
27
- const hidden = useSyncExternalStore(subscribeHidden, getHidden);
27
+ // The parked-window roster is a retained signal: Clippy reads its
28
+ // snapshot at render time (the bus keeps the last one) and manages
29
+ // no bridge of its own.
30
+ const hidden = useSignalValue("window:hidden");
28
31
  useEffect(attachClippy, []);
29
32
 
30
33
  const containerRef = useRef<HTMLDivElement>(null);
@@ -199,9 +202,16 @@ export function Clippy() {
199
202
  </div>
200
203
  )}
201
204
  {!listOpen && bubble && (
205
+ // ONE bubble at a time, by construction: every lib/clippy state
206
+ // transition clears its sibling flags in the SAME committed set()
207
+ // (offer clears saysNo, the veto clears nothing else, the hint
208
+ // clears offering, the list masks the bubble outright) — so the
209
+ // precedence here never renders two texts side by side.
202
210
  <div className="clippy-bubble" role="status">
203
211
  {saysNo ? (
204
212
  "haha it said no"
213
+ ) : offering ? (
214
+ "oh where did that go?.."
205
215
  ) : (
206
216
  <>
207
217
  It looks like you're trying to close something. Try clicking one
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useMemo } from "react";
2
- import { Link, useLocation, useNavigate } from "react-router-dom";
2
+ import { Link, useLocation } from "react-router-dom";
3
3
  import { getCookie } from "@/lib/cookies";
4
+ import { useSignals } from "@/lib/signals";
4
5
  import { visibleMenuItems } from "./menu";
5
6
 
6
7
  const isTyping = (target: EventTarget | null) =>
@@ -10,7 +11,9 @@ const isTyping = (target: EventTarget | null) =>
10
11
 
11
12
  export function MenuBar() {
12
13
  const { pathname } = useLocation();
13
- const navigate = useNavigate();
14
+ // Hotkeys command navigation, so they dispatch: the shell owns the
15
+ // router-aware handler. The <Link> elements below stay real anchors.
16
+ const { dispatch } = useSignals();
14
17
  const items = useMemo(
15
18
  () => visibleMenuItems(pathname, getCookie("admin") === "akinevz"),
16
19
  [pathname],
@@ -30,11 +33,11 @@ export function MenuBar() {
30
33
  const item = items.find((i) => i.label[0]?.toLowerCase() === key);
31
34
  if (!item) return;
32
35
  event.preventDefault();
33
- navigate(item.href);
36
+ dispatch("app:navigate", { to: item.href });
34
37
  };
35
38
  document.addEventListener("keydown", onKey);
36
39
  return () => document.removeEventListener("keydown", onKey);
37
- }, [items, navigate]);
40
+ }, [items, dispatch]);
38
41
 
39
42
  return (
40
43
  <nav className="menu-bar">
@@ -1,4 +1,10 @@
1
- import { routes, type Route } from "@/content";
1
+ import {
2
+ blogDirFiles,
3
+ blogDirListed,
4
+ findBlogDir,
5
+ routes,
6
+ type Route,
7
+ } from "@/content";
2
8
 
3
9
  export const NOT_FOUND = routes.find((r) => r.path === "/404") as Route;
4
10
 
@@ -38,7 +44,40 @@ function blogDocumentRoute(pathname: string): Route {
38
44
  }
39
45
 
40
46
  export function resolveRoute(pathname: string): Route {
41
- if (BLOG_PAGE.test(pathname)) return blogDocumentRoute(pathname);
47
+ if (BLOG_PAGE.test(pathname)) {
48
+ // Every /blog/** address resolves against the filesystem walk
49
+ // (build/blogDirsPlugin.ts), in order:
50
+ // 1. a directory → its listing page (or 404 when opted out);
51
+ // 2. a file (<base>.md or <base>.json) → its post page;
52
+ // 3. neither → 404. The old fallback embedded "<path>.md" blindly,
53
+ // so removed files AND removed directories rendered whatever the
54
+ // server's SPA fallback handed back — the site inside itself.
55
+ const path = normalizePath(pathname);
56
+ const blogDir = findBlogDir(path);
57
+ if (blogDir) {
58
+ if (!blogDirListed(blogDir.path)) return NOT_FOUND;
59
+ const name =
60
+ blogDir.path.split("/").filter(Boolean).pop() ?? blogDir.path;
61
+ return {
62
+ path: pathname,
63
+ title: `${name} | blog of kine`,
64
+ description: `${name} — the files in this blog directory.`,
65
+ page: "BlogDirPage",
66
+ hidden: true,
67
+ };
68
+ }
69
+ const parent = path.replace(/\/+$/, "").replace(/\/[^/]*$/, "") || "/";
70
+ const base = path.split("/").pop() ?? "";
71
+ const files = blogDirFiles(parent);
72
+ // The parent of any /blog/** address is /blog or a walk-known
73
+ // subdirectory; an unknown parent means a missing ancestor — 404.
74
+ if (
75
+ !files ||
76
+ (!files.includes(`${base}.md`) && !files.includes(`${base}.json`))
77
+ )
78
+ return NOT_FOUND;
79
+ return blogDocumentRoute(pathname);
80
+ }
42
81
  const path = normalizePath(pathname);
43
82
  const route = routes.find((r) => r.path === path);
44
83
  return route ?? NOT_FOUND;
@@ -0,0 +1,34 @@
1
+ import { dispatchSignal, onSignal } from "@/lib/signals";
2
+
3
+ /** The shell's router-aware signal behaviours. Handlers live OUT of the
4
+ * components: components only ever dispatch, and the behaviours they
5
+ * trigger are attached once at boot (main.tsx) — no per-component
6
+ * subscription effects. */
7
+
8
+ /** The route-change performer. Until the router binds its navigate,
9
+ * the honest fallback is a full document assign. */
10
+ let go: (to: string) => void = (to) => window.location.assign(to);
11
+
12
+ /** Hands the bus the router's navigate implementation. App binds it
13
+ * while rendering against the router context: an idempotent reference
14
+ * swap of a stable framework function, nothing more. */
15
+ export function bindNavigate(impl: (to: string) => void): void {
16
+ go = impl;
17
+ }
18
+
19
+ /** Attaches the shell's handlers and announces the boot route. The
20
+ * handler is app-lifetime; the unsubscribe return is for symmetry —
21
+ * main.tsx calls this once at boot and never detaches. */
22
+ export function attachRouterSignals(): () => void {
23
+ // The navigation command: dispatching arrives from anywhere (menu
24
+ // hotkeys, OK buttons, page Cancel buttons) and lands HERE, then the
25
+ // pageSlide choreography rides the pushState it triggers, exactly as
26
+ // a direct navigate() would.
27
+ const offNavigate = onSignal("app:navigate", ({ to }) => go(to));
28
+ // The boot announcement: the first route is live as soon as the
29
+ // shell attaches — before the first paint, no post-render effect.
30
+ // Every route change from here on arrives as the theme's
31
+ // "page:navigated" (the authoritative commit point it owns).
32
+ dispatchSignal("page:loaded", { path: location.pathname });
33
+ return offNavigate;
34
+ }
@@ -405,3 +405,23 @@ main.feef69-page {
405
405
  .window-body iframe:not(.embed) {
406
406
  max-width: 100%;
407
407
  }
408
+
409
+ /* Content tables: GFM pipe tables via remark-gfm (added to the Md
410
+ pipeline) — content files stay plain markdown. td/th are missing from
411
+ window.css's color list — color inherits fine, but UA styles leave the
412
+ cells plain (and th centered): give them terminal-style rules and
413
+ even, padded cells. */
414
+ .window-body table {
415
+ border-collapse: collapse;
416
+ width: 100%;
417
+ margin: var(--gap-size) 0;
418
+ font-size: inherit;
419
+ }
420
+
421
+ .window-body th,
422
+ .window-body td {
423
+ border: 1px solid var(--text-color);
424
+ padding: 0.25em 0.5em;
425
+ text-align: left;
426
+ vertical-align: top;
427
+ }
@@ -97,7 +97,7 @@ body:has([data-debug-bar]) .page {
97
97
 
98
98
  .menu-bar menu a {
99
99
  padding: 6px 12px;
100
- font-size: 14px;
100
+ font-size: 16px;
101
101
  white-space: nowrap;
102
102
  }
103
103
 
@@ -170,7 +170,7 @@ body:has([data-debug-bar]) .page {
170
170
 
171
171
  .minimized-menu-button {
172
172
  top: var(--menu-bar-height);
173
- font-size: 14px !important;
173
+ font-size: 16px !important;
174
174
  text-align: center;
175
175
  z-index: 98;
176
176
  }
@@ -29,7 +29,7 @@
29
29
  padding: 4px 8px;
30
30
  text-decoration: none;
31
31
  color: #000 !important;
32
- font-size: 16px;
32
+ font-size: 18px;
33
33
  font-family: "Tahoma", "MS Sans Serif", sans-serif;
34
34
  white-space: nowrap;
35
35
  transition: background-color 0.1s ease;
@@ -19,13 +19,13 @@
19
19
  the last row of content. */
20
20
  --debug-bar-height: 2.5em;
21
21
  --clippy-border-flash-color: transparent;
22
- font-size: 16px;
22
+ font-size: 18px;
23
23
  }
24
24
  /* Force title bar text to dark gray for readability */
25
25
  .title-bar-text,
26
26
  .title-bar-text a {
27
27
  color: #eee !important;
28
- font-size: 0.85rem;
28
+ font-size: 1rem;
29
29
  }
30
30
 
31
31
  :root.theme-border-flash .window,
@@ -422,6 +422,13 @@ form#form > label {
422
422
  word-break: break-word;
423
423
  }
424
424
 
425
+ /* 98.css pins window text to its Win98 chrome size: .window{font-size:11px}.
426
+ Content windows read like documents — body text follows the root size,
427
+ the same 1rem the pre blocks above (98.css) already render at. */
428
+ .window-body {
429
+ font-size: 0.78rem;
430
+ }
431
+
425
432
  /* xp.css sets very large heading sizes; keep markdown headings readable in content windows. */
426
433
  .window-body h1 {
427
434
  font-size: 1.2rem !important;
@@ -5,6 +5,9 @@ import {
5
5
  type ThemeDefinition,
6
6
  } from "lightdni-jssas-toggle";
7
7
  import { playMinimizeClick } from "@/lib/audio";
8
+ import { windowBookmark } from "@/lib/history";
9
+ import { dispatchSignal } from "@/lib/signals";
10
+ import { scrollToId } from "@/lib/scrollTo";
8
11
  import { resolveDirection, type Direction } from "./direction";
9
12
  import "./pageSlide.css";
10
13
 
@@ -47,7 +50,7 @@ const themes: Record<Direction | "parked", ThemeDefinition> = {
47
50
  /** Initial load ONTO a hyperlinked window target: the slide theme is
48
51
  * fully installed (its class drives minimize folds and the navigation
49
52
  * hooks) but with a zero-distance entrance — nothing visibly moves
50
- * while the maximized overlay is the page's first paint. */
53
+ * while the reveal scrolls to the linked section. */
51
54
  parked: slide("parked", "0", "0"),
52
55
  };
53
56
 
@@ -88,8 +91,12 @@ function leaveGhost(): void {
88
91
  height: `${rect.height}px`,
89
92
  minHeight: "0",
90
93
  });
91
- const pageEl = main.querySelector<HTMLElement>(".page");
92
- const ghostPage = ghost.querySelector<HTMLElement>(".page");
94
+ const pageEl = main.matches(".page")
95
+ ? main
96
+ : main.querySelector<HTMLElement>(".page");
97
+ const ghostPage = ghost.matches(".page")
98
+ ? ghost
99
+ : ghost.querySelector<HTMLElement>(".page");
93
100
  if (pageEl && ghostPage) {
94
101
  // Page padding can depend on elements (debug bar) that unmount with the
95
102
  // route: freeze it on the ghost and ease the new page away from it.
@@ -153,7 +160,7 @@ function leaveGhost(): void {
153
160
  const leaving = bar.cloneNode(true) as HTMLElement;
154
161
  leaving.classList.add("page-slide-bar");
155
162
  // Layout rules key off this attribute; the clone must not keep them alive.
156
- leaving.removeAttribute("data-debug-bar");
163
+ delete leaving.dataset.debugBar;
157
164
  document.body.appendChild(leaving);
158
165
  // The live bar yields to the clone in the same frame — visibility,
159
166
  // not display, so the body padding rules keep reserving its row —
@@ -184,8 +191,10 @@ function leaveGhost(): void {
184
191
 
185
192
  let current = "";
186
193
  let originalPushState: History["pushState"] | null = null;
187
- /** Mutes the next transition's fold click: a window ✕ that navigates
188
- * closes with its own crunchy kick — no Click.ogg on top of it. */
194
+ let originalReplaceState: History["replaceState"] | null = null;
195
+ /** Mutes the next transition's fold click: the navigating window ✕
196
+ * declares its own Click.ogg through the bus (closeSounds) — no second
197
+ * click on top of the navigation fold. */
189
198
  let clickSuppressed = false;
190
199
 
191
200
  export function suppressNextSlideClick(): void {
@@ -199,6 +208,9 @@ const isMobileLayout = () => window.matchMedia("(max-width: 768px)").matches;
199
208
 
200
209
  function transition(to: string, hash: string): void {
201
210
  if (to === current) return;
211
+ // The committed navigation rides the signal bus as a notice —
212
+ // monitoring handlers subscribe; the choreography itself stays here.
213
+ dispatchSignal("page:navigated", { from: current, to });
202
214
  if (clickSuppressed) clickSuppressed = false;
203
215
  else playMinimizeClick();
204
216
  const direction = isMobileLayout()
@@ -219,48 +231,52 @@ function restartArrival(): void {
219
231
  const main = document.querySelector("main");
220
232
  if (!main) return;
221
233
  main.style.animation = "none";
222
- void main.offsetWidth;
234
+ // void main.offsetWidth;
223
235
  main.style.animation = "";
224
- const pageEl = main.querySelector<HTMLElement>(".page");
225
- if (pageEl) {
226
- pageEl.style.animation = "none";
227
- void pageEl.offsetWidth;
228
- pageEl.style.animation = "";
236
+ // The page element is main itself in the normalized shell (main.page):
237
+ // a nested .page resets separately, in whatever shape the document has.
238
+ const page = main.matches(".page")
239
+ ? null
240
+ : main.querySelector<HTMLElement>(".page");
241
+ if (page) {
242
+ page.style.animation = "none";
243
+ // void page.offsetWidth;
244
+ page.style.animation = "";
229
245
  }
230
246
  }
231
247
 
232
248
  const onPopState = () => {
249
+ const arrival = { path: location.pathname, hash: location.hash };
233
250
  if (location.pathname === current) {
234
- // Same-page history traversal only moves the hash: bring the
235
- // hyperlinked element into view (inside its scrolling window).
251
+ // Same-page history traversal only moves the shape of the URL:
252
+ // bring the hyperlinked element into view (inside its scrolling
253
+ // window) — and announce the RETURN, so holders of pre-departure
254
+ // state (the window store, same-path traversals never remount) can
255
+ // repair themselves.
236
256
  if (location.hash) scrollToHash(location.hash);
257
+ // A hash-free bookmarked destination names its section in STATE:
258
+ // the same landing rule.
259
+ else scrollToId(windowBookmark() ?? "");
260
+ dispatchSignal("page:returned", arrival);
237
261
  return;
238
262
  }
239
263
  transition(location.pathname, location.hash);
264
+ if (location.hash) scrollToHash(location.hash);
265
+ // A hash-free bookmarked return (the window departures' form — the
266
+ // entry names its section in STATE alone): land on it like any hash
267
+ // target. The reveal is the store's; the landing scroll is ours.
268
+ else scrollToId(windowBookmark() ?? "");
269
+ // History traversal onto another page keeps the same rule: a hashed
270
+ // window target lands on its element (the reveal is the store's),
271
+ // and the traversal is announced as a return.
272
+ dispatchSignal("page:returned", arrival);
240
273
  };
241
274
 
242
- /** Scrolls the hash element into view — inside its scrolling window
243
- * (a maximized window scrolls its own revealed content) or the page.
244
- * The element can mount after the route commit (lazy pages), hence the
245
- * deferred retries. */
275
+ /** Scrolls the hash element into view — the aim implementation lives in
276
+ * @/lib/scrollTo, shared with the window system's dismissal landings. */
246
277
  function scrollToHash(hash: string, attempts = 12): void {
247
278
  const id = decodeURIComponent(hash.slice(1));
248
- if (!id) return;
249
- const tick = () => {
250
- const el = document.getElementById(id);
251
- if (el) {
252
- // Maximized windows are viewport-fixed overlays; scrolling the page
253
- // behind them just resets the background while the overlay hides
254
- // it. The restored window scrolls itself to the hash element on
255
- // dismissal instead.
256
- if (!el.closest(".maximized-backdrop")) {
257
- el.scrollIntoView({ behavior: "smooth", block: "start" });
258
- }
259
- return;
260
- }
261
- if (attempts > 0) window.setTimeout(tick, 100);
262
- };
263
- tick();
279
+ scrollToId(id, attempts);
264
280
  }
265
281
 
266
282
  /**
@@ -273,28 +289,88 @@ export function enablePageSlide(): void {
273
289
  if (originalPushState || typeof document === "undefined") return;
274
290
  current = location.pathname;
275
291
  // Initial load ONTO a hyperlinked window target (#hash or a blog
276
- // ?post= the route maximizes): install the theme "parked" so the
277
- // entrance slide plays from nowhere — the maximized overlay is the
278
- // only visible first paint, and minimize folds / navigation hooks
279
- // stay functional. Plain loads slide in from the top as before.
292
+ // ?post= the route reveals): install the theme "parked" so the
293
+ // entrance slide plays from nowhere, then land the page on the target
294
+ // — the return-to-page choreography (the reveal is the window store's,
295
+ // the landing scroll is this theme's, like every hash navigation).
296
+ // Minimize folds / navigation hooks stay functional. Plain loads slide
297
+ // in from the top as before.
280
298
  const linkedWindowTarget =
281
- !!location.hash || new URLSearchParams(location.search).has("post");
299
+ !!location.hash ||
300
+ new URLSearchParams(location.search).has("post") ||
301
+ // A returned-to entry may name its section in STATE alone (the
302
+ // off-site bookmark is hash-free by design): that arrival is a
303
+ // landing on a target too — parked, reveal + scroll, nothing moves.
304
+ !!windowBookmark();
282
305
  applyDirection(linkedWindowTarget ? "parked" : "down");
306
+ if (linkedWindowTarget) {
307
+ if (location.hash) scrollToHash(location.hash);
308
+ // A hash-free bookmarked target (the off-site return's form): the
309
+ // entry names its section in STATE alone — land on it the same way
310
+ // the hash form lands.
311
+ else scrollToId(windowBookmark() ?? "");
312
+ }
283
313
 
284
314
  const original = history.pushState.bind(history);
285
315
  originalPushState = history.pushState;
316
+ /** Set inside the pushState wrapper when a same-path commit
317
+ * re-addresses the content: the announcement dispatches only after
318
+ * the original pushState has committed, so repair handlers read the
319
+ * NEW address. */
320
+ let samePathReaddress = false;
286
321
  history.pushState = (data, unused, url) => {
287
322
  if (url != null) {
288
323
  const target = new URL(url, location.href);
289
324
  if (target.pathname !== current) {
290
325
  transition(target.pathname, target.hash);
291
326
  if (target.hash) scrollToHash(target.hash);
292
- } else if (target.hash && target.hash !== location.hash) {
293
- // Same pathname, new hash: no page transition — scroll instead.
294
- scrollToHash(target.hash);
327
+ } else if (
328
+ (data as { window?: unknown } | null)?.window == null &&
329
+ (target.search !== location.search || target.hash !== location.hash)
330
+ ) {
331
+ // Same-path CONTENT re-address: the router pushed a query or
332
+ // hash that names a new target (?post=, #id) — announced AFTER
333
+ // the commit below, so the repair reads the new address. The
334
+ // window system's own anchor pushes carry the state bookmark
335
+ // and stay silent (they are UI entries, not content addresses).
336
+ samePathReaddress = true;
295
337
  }
338
+ // Pure same-path pushes without a re-address stay silent: they
339
+ // are UI history entries, NOT page arrivals — no landing scroll
340
+ // exists for them. Hash landings for real arrivals come from the
341
+ // boot branch, the popstate branches and hashchange.
296
342
  }
297
343
  original(data, unused, url);
344
+ if (samePathReaddress) {
345
+ samePathReaddress = false;
346
+ dispatchSignal("page:addressed", {
347
+ path: location.pathname,
348
+ hash: location.hash,
349
+ });
350
+ }
351
+ };
352
+ // The ALIAS re-land: a shorthand path (/addons) boots as its own
353
+ // document and the router commits the destination (<Navigate
354
+ // to="/wow#addons" replace>) with a replaceState — the only
355
+ // path-changing commit the pushState wrapper cannot see. It is not a
356
+ // traversal (nothing announces it; the fresh-arrival gate decides the
357
+ // store's landing by the referrer alone) — but the page must still be
358
+ // LANDED on the destination's hash element like every boot: aim the
359
+ // scroll at it (the retrying scrollToId absorbs the remount delay),
360
+ // and take over `current` so later pushes compare against the true
361
+ // destination path. Same-path replaceStates (the window system's
362
+ // bookmark writes) stay silent.
363
+ const originalReplaceState = history.replaceState.bind(history);
364
+ history.replaceState = (data, unused, url) => {
365
+ if (url != null) {
366
+ const target = new URL(url, location.href);
367
+ if (target.pathname !== current) {
368
+ current = target.pathname;
369
+ if (target.hash) scrollToHash(target.hash);
370
+ else scrollToId(windowBookmark() ?? "");
371
+ }
372
+ }
373
+ originalReplaceState(data, unused, url);
298
374
  };
299
375
  // Same-page hyperlinks to hash elements change the hash natively.
300
376
  window.addEventListener("hashchange", (event) =>
@@ -308,6 +384,8 @@ export function disablePageSlide(): void {
308
384
  if (!originalPushState) return;
309
385
  history.pushState = originalPushState;
310
386
  originalPushState = null;
387
+ if (originalReplaceState) history.replaceState = originalReplaceState;
388
+ originalReplaceState = null;
311
389
  window.removeEventListener("popstate", onPopState);
312
390
  applyTheme({}, { previousClassNames: [CLASS] });
313
391
  clearThemeVariables(VARIABLES);