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.
- package/build/blogDirsPlugin.ts +100 -0
- package/package.json +9 -6
- package/public/blog/archive/eighth-post-lost-in-the-sauce.json +36 -0
- package/public/blog/archive/noise/eleventh-post-discussion-java-gist.md +5 -0
- package/public/blog/archive/noise/fifteenth-post-very-rare-windows-funny.md +8 -0
- package/public/blog/archive/noise/fourth-post-meta-blog.md +3 -0
- package/public/blog/archive/noise/sixteenth-post-meta-fantasy-blog.md +4 -0
- package/public/blog/archive/noise/tenth-post-meta-funny-redacted-and-timetravelled.md +3 -0
- package/public/blog/archive/noise/twelfth-post-mixing-phase-technique-audio-music.md +48 -0
- package/public/blog/archive/noise/welcome-back-ramble-meta.md +6 -0
- package/public/blog/archive/noise/welcome-to-my-blog-meta-blog-welcome-to-my-website.md +7 -0
- package/public/blog/archive/seventh-post-lie-theory-na2000.json +22 -0
- package/public/blog/archive/sophus-lie.json +36 -0
- package/public/blog/hlwm_and_herbstutil.md +11 -0
- package/public/blog/writing/hot-action-under-a-cold-moon.json +9 -0
- package/public/checksums.txt +90 -66
- package/public/documents/drift-report.json +13 -1
- package/scripts/refresh-soundcloud.mjs +54 -8
- package/src/content/blog.json +16 -363
- package/src/content/blogDirs.ts +196 -0
- package/src/content/configs.json +1 -1
- package/src/content/contacts.json +2 -2
- package/src/content/includes/make-recipes.md +18 -0
- package/src/content/index.ts +156 -57
- package/src/content/music-ext.json +1 -1
- package/src/content/projects/doftiles.json +88 -4
- package/src/content/projects/herbctl.json +58 -0
- package/src/content/projects/herbstutil.json +50 -20
- package/src/content/projects/on-deploy.json +57 -0
- package/src/content/projects/polyframes.json +83 -0
- package/src/content/schema.ts +7 -4
- package/src/content/sections.json +11 -10
- package/src/content/soundcloud.json +61 -13
- package/src/lib/clippy.ts +29 -8
- package/src/lib/history.ts +152 -0
- package/src/lib/markdown.tsx +11 -1
- package/src/lib/scrollTo.ts +45 -0
- package/src/lib/signals.tsx +271 -0
- package/src/main.tsx +20 -4
- package/src/pages/BlogDirPage.tsx +36 -0
- package/src/pages/BlogPostPage.tsx +76 -3
- package/src/pages/ProjectPage.tsx +9 -3
- package/src/pages/WowPage.tsx +8 -3
- package/src/pages/index.ts +2 -0
- package/src/shell/App.tsx +14 -8
- package/src/shell/Clippy.tsx +13 -3
- package/src/shell/MenuBar.tsx +7 -4
- package/src/shell/resolveRoute.ts +41 -2
- package/src/shell/routerSignals.ts +34 -0
- package/src/styles/extras.css +20 -0
- package/src/styles/layout.css +2 -2
- package/src/styles/menu.css +1 -1
- package/src/styles/window.css +9 -2
- package/src/themes/pageSlide/index.ts +120 -42
- package/src/themes/pageSlide/pageSlide.css +20 -9
- package/src/virtual.d.ts +14 -0
- package/src/window/MaximizedWindow.tsx +97 -64
- package/src/window/OkButton.tsx +42 -25
- package/src/window/PageWindows.tsx +7 -0
- package/src/window/TitleBar.tsx +3 -1
- package/src/window/Window.tsx +132 -87
- package/src/window/closeSounds.ts +27 -0
- package/src/window/model.ts +11 -0
- package/src/window/state.tsx +290 -50
- package/src/window/themes.ts +23 -2
- package/test/content.test.js +15 -10
- package/test/deploy-pipeline.test.js +11 -11
- package/test/markdown-tables.test.js +96 -0
- package/test/soundcloud-refresh.test.js +68 -0
- package/tsconfig.node.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/vite.config.ts +7 -1
- package/public/blog/4th.md +0 -28
- package/public/blog/wsl.1.md +0 -40
- package/src/window/hidden.ts +0 -22
- /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
- /package/src/content/{characters.json → includes/characters.json} +0 -0
package/src/window/state.tsx
CHANGED
|
@@ -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
|
|
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
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* the
|
|
61
|
-
*
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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) =>
|
|
159
|
+
patch: (id, flags) =>
|
|
160
|
+
dispatchReducer({ type: "patch", ids: [id], flags }),
|
|
106
161
|
expand: (id) =>
|
|
107
|
-
|
|
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) =>
|
|
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
|
-
|
|
120
|
-
|
|
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
|
-
|
|
125
|
-
|
|
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
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
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
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
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,
|
|
289
|
+
const { windows, permalinkMode } = useWindowStore();
|
|
290
|
+
const { dispatch } = useSignals();
|
|
179
291
|
useEffect(() => {
|
|
180
292
|
const target = findTarget(windows);
|
|
181
293
|
if (!target) return;
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
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
|
-
/**
|
|
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
|
-
|
|
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);
|
package/src/window/themes.ts
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
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 =>
|
package/test/content.test.js
CHANGED
|
@@ -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
|
|
39
|
+
test("include directives target a file under src/content/includes/", async () => {
|
|
40
40
|
const { readdirSync } = await import("node:fs");
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -36,22 +36,22 @@ test("build:local refreshes soundcloud, then gated build, then the gate", () =>
|
|
|
36
36
|
assert.ok(gatedAt < gateAt, "the gate must consume the fresh drift report");
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
test("build:local commits the refreshed snapshot before the dev preview", () => {
|
|
40
|
-
// npm run dev blocks forever; if it ran before `git add -A && git commit`
|
|
41
|
-
// the refreshed snapshots (soundcloud.json, checksums, drift report)
|
|
42
|
-
// would never be committed and the deployed site would trail releases.
|
|
43
|
-
const local = scripts["build:local"];
|
|
44
|
-
const commitAt = local.indexOf("git commit");
|
|
45
|
-
const devAt = local.indexOf("npm run dev");
|
|
46
|
-
assert.ok(commitAt !== -1 && devAt !== -1);
|
|
47
|
-
assert.ok(commitAt < devAt, "commit must precede the blocking dev server");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
39
|
test("check:ci mirrors the CI subset with the gated build", () => {
|
|
51
40
|
assert.match(scripts["check:ci"], /build:gated/);
|
|
52
41
|
assert.match(scripts["check:ci"], /verify:policy/);
|
|
53
42
|
});
|
|
54
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
55
|
test("CI runs the gated build so the drift report is recomputed there", () => {
|
|
56
56
|
assert.match(ciYml, /npm run build:gated/);
|
|
57
57
|
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { unified } from "unified";
|
|
4
|
+
import remarkParse from "remark-parse";
|
|
5
|
+
import remarkBreaks from "remark-breaks";
|
|
6
|
+
import remarkGfm from "remark-gfm";
|
|
7
|
+
import remarkRehype from "remark-rehype";
|
|
8
|
+
import rehypeRaw from "rehype-raw";
|
|
9
|
+
import rehypeSanitize from "rehype-sanitize";
|
|
10
|
+
// The exact schema the real pipeline uses (src/lib/markdown.tsx) — no
|
|
11
|
+
// local mirror that could drift from it.
|
|
12
|
+
import { sanitizeSchema } from "../src/lib/sanitizeSchema.ts";
|
|
13
|
+
|
|
14
|
+
const processor = unified()
|
|
15
|
+
.use(remarkParse)
|
|
16
|
+
.use(remarkBreaks)
|
|
17
|
+
.use(remarkGfm)
|
|
18
|
+
.use(remarkRehype, { allowDangerousHtml: true })
|
|
19
|
+
.use(rehypeRaw)
|
|
20
|
+
.use(rehypeSanitize, sanitizeSchema);
|
|
21
|
+
|
|
22
|
+
function process(md) {
|
|
23
|
+
return processor.runSync(processor.parse(md));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function collect(node, tagName, acc = []) {
|
|
27
|
+
if (!node || typeof node !== "object") return acc;
|
|
28
|
+
if (node.tagName === tagName) acc.push(node);
|
|
29
|
+
for (const child of node.children ?? []) collect(child, tagName, acc);
|
|
30
|
+
return acc;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function textOf(nodes) {
|
|
34
|
+
const walk = (node, acc = []) => {
|
|
35
|
+
if (node?.type === "text") acc.push(node.value);
|
|
36
|
+
for (const child of node?.children ?? []) walk(child, acc);
|
|
37
|
+
return acc.join("");
|
|
38
|
+
};
|
|
39
|
+
return nodes.map((node) => walk(node)).join(" | ");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
test("GFM pipe tables render through the Md pipeline", () => {
|
|
43
|
+
const md = [
|
|
44
|
+
"\n\n| Recipe | Effect |",
|
|
45
|
+
"|---|---|",
|
|
46
|
+
"| `install` | full host setup |",
|
|
47
|
+
"| `wm` -> `herbst` | stows `herbst` + `herbstclient reload` |",
|
|
48
|
+
"\n\n",
|
|
49
|
+
].join("\n");
|
|
50
|
+
const tree = process(md);
|
|
51
|
+
const tables = collect(tree, "table");
|
|
52
|
+
assert.equal(tables.length, 1);
|
|
53
|
+
assert.equal(collect(tree, "thead").length, 1);
|
|
54
|
+
assert.equal(collect(tree, "tr").length, 3);
|
|
55
|
+
assert.equal(collect(tree, "th").length, 2);
|
|
56
|
+
assert.equal(collect(tree, "td").length, 4);
|
|
57
|
+
// inline code survives inside cells
|
|
58
|
+
assert.equal(collect(tree, "code").length, 5);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("remarkBreaks does not inject <br> between table rows", () => {
|
|
62
|
+
const md = "| a | b |\n|---|---|\n| x | y |\n\n";
|
|
63
|
+
const tables = collect(process(md), "table");
|
|
64
|
+
assert.equal(tables.length, 1);
|
|
65
|
+
// every br that remarkBreaks produces must stay outside table cells
|
|
66
|
+
const row = collect(tables[0], "tr").pop();
|
|
67
|
+
assert.equal(collect(row, "br").length, 0);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("removal check: sanitize keeps tables but strips alignment/style", () => {
|
|
71
|
+
const md =
|
|
72
|
+
"| a | b |\n|:--|--:|\n| x | y |\n\n" + // alignment colons
|
|
73
|
+
"<style>body{}</style>\n\n";
|
|
74
|
+
const tree = process(md);
|
|
75
|
+
assert.equal(collect(tree, "table").length, 1);
|
|
76
|
+
// <style> is sanitized away
|
|
77
|
+
assert.deepEqual(collect(tree, "style"), []);
|
|
78
|
+
for (const cell of [...collect(tree, "th"), ...collect(tree, "td")]) {
|
|
79
|
+
// no inline-style smuggling (align survives the whitelist — the
|
|
80
|
+
// content-table CSS overrides it, so it is inert either way)
|
|
81
|
+
assert.equal(cell.properties.style, undefined);
|
|
82
|
+
assert.ok(
|
|
83
|
+
["left", "center", "right", undefined].includes(cell.properties.align),
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("line-oriented writing still breaks outside tables (remarkBreaks)", () => {
|
|
89
|
+
const tree = process("line one\nline two\n\n");
|
|
90
|
+
const paragraphs = collect(tree, "p");
|
|
91
|
+
assert.equal(paragraphs.length, 1);
|
|
92
|
+
assert.equal(collect(paragraphs[0], "br").length, 1);
|
|
93
|
+
// and the two lines are kept apart by that break
|
|
94
|
+
assert.match(textOf(paragraphs), /line one/);
|
|
95
|
+
assert.match(textOf(paragraphs), /line two/);
|
|
96
|
+
});
|