@justai/core 0.35.0 → 0.36.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/dist/analytics.d.ts +78 -0
- package/dist/analytics.js +99 -0
- package/dist/boot.d.ts +53 -0
- package/dist/boot.js +83 -0
- package/dist/chrome.d.ts +42 -0
- package/dist/chrome.js +25 -0
- package/dist/consent.d.ts +105 -0
- package/dist/consent.js +156 -0
- package/dist/face.d.ts +27 -0
- package/dist/face.js +85 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +55 -0
- package/dist/mark.d.ts +26 -0
- package/dist/mark.js +286 -0
- package/dist/presentation.d.ts +10 -0
- package/dist/presentation.js +54 -0
- package/dist/scroll.d.ts +23 -0
- package/dist/scroll.js +612 -0
- package/dist/xray.d.ts +40 -0
- package/dist/xray.js +316 -0
- package/package.json +48 -5
- package/src/index.d.ts +0 -147
- package/src/index.js +0 -1662
package/dist/scroll.js
ADDED
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @justai/core/scroll — the persona page's scroll behaviour — landing on the kernel, the spy, the toolbar's title strip. It knows a set of element ids and nothing about which framework drew them.
|
|
3
|
+
*
|
|
4
|
+
* Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
|
|
5
|
+
* and why its behaviour lives one level below @justai/cuts.
|
|
6
|
+
*/
|
|
7
|
+
export function personaScroll(options) {
|
|
8
|
+
const o = options || {};
|
|
9
|
+
const cutIds = o.cuts || ["profile", "kernel", "posts"];
|
|
10
|
+
const el = (id) => typeof id === "string" ? document.getElementById(id) : (id ?? null);
|
|
11
|
+
const below = el(o.below || "below");
|
|
12
|
+
const kernel = el("kernel");
|
|
13
|
+
if (!below || !kernel)
|
|
14
|
+
return;
|
|
15
|
+
const toolbar = typeof o.toolbar === "string" ? document.querySelector(o.toolbar) : o.toolbar || document.querySelector(".toolbar");
|
|
16
|
+
const tbTitle = el(o.title || "tbTitle");
|
|
17
|
+
const tbTitleText = (typeof o.titleText === "string" ? document.getElementById(o.titleText) : o.titleText) ||
|
|
18
|
+
document.getElementById("tbTitleText") ||
|
|
19
|
+
(tbTitle && tbTitle.querySelector(".tb-title-text"));
|
|
20
|
+
// A cut is a section AND the nav that points at it; anything missing either half is simply not one.
|
|
21
|
+
// That is how a page with extra toolbar links — /me's vault, /files' host link — needs no
|
|
22
|
+
// configuration: they are links, not cuts, and they fall out of this list on their own.
|
|
23
|
+
const cuts = cutIds
|
|
24
|
+
.map((id) => [
|
|
25
|
+
el(id),
|
|
26
|
+
el(o.navFor ? o.navFor(id) : "nav" + id.charAt(0).toUpperCase() + id.slice(1)),
|
|
27
|
+
])
|
|
28
|
+
.filter((c) => Boolean(c[0] && c[1]));
|
|
29
|
+
if (!cuts.length)
|
|
30
|
+
return;
|
|
31
|
+
// queries: --shell-top · the kernel is 26px short · the game frame does not reach the fold ·
|
|
32
|
+
// a strip of posts shows above the fold · opening at #kernel is different from #profile ·
|
|
33
|
+
// the toolbar changes height · title strip · the layout depends on when it was measured
|
|
34
|
+
//
|
|
35
|
+
// ── NEVER SAMPLE AN ANIMATION AND CALL IT A LAYOUT ─────────────────────────────────────────
|
|
36
|
+
//
|
|
37
|
+
// `--shell-top` is what the shell takes above the kernel, and everything downstream reads it: the
|
|
38
|
+
// landing offset, an app kernel's minimum height, a game kernel's exact one.
|
|
39
|
+
//
|
|
40
|
+
// It was the literal `82` for a long time and that was stable and slightly wrong. Reading the
|
|
41
|
+
// toolbar's height instead made it exact and UNSTABLE, which is far worse: the row carries a title
|
|
42
|
+
// strip that opens and closes over 0.35s, so its height is anywhere in a 26px range depending on
|
|
43
|
+
// the instant somebody looked. Measured on tpl-sunshine at 1864x999, the same persona, same build:
|
|
44
|
+
//
|
|
45
|
+
// opened at #profile strip shut when measured shell-top 80 frame 919 reaches the fold
|
|
46
|
+
// opened at #kernel strip open when measured shell-top 106 frame 893 33px SHORT
|
|
47
|
+
//
|
|
48
|
+
// and the second is what a visitor gets, because a game persona lands on its kernel. Thirty-three
|
|
49
|
+
// pixels of the next section showing above the fold, and the "correct" case was correct by
|
|
50
|
+
// coincidence — a shut row plus a gutter happened to equal an open one.
|
|
51
|
+
//
|
|
52
|
+
// THE FIX IS NOT A BETTER MOMENT TO MEASURE, IT IS NOT MEASURING THE MOVING PART. The row minus the
|
|
53
|
+
// strip is the row, and it is the same number at every frame of the transition; the strip's OPEN
|
|
54
|
+
// height is `--tb-strip`, which the Toolbar cut declares beside the rule that uses it. Their sum is
|
|
55
|
+
// what the bar is whenever anybody is looking at the kernel — which is the only time this number
|
|
56
|
+
// decides anything.
|
|
57
|
+
//
|
|
58
|
+
// AND NO GUTTER IS ADDED. The frame is the active view, so it begins where the shell ends; the air
|
|
59
|
+
// an app keeps under the bar is its own padding, and adding a gutter here would spend it twice.
|
|
60
|
+
//
|
|
61
|
+
// Re-measured on resize because a rotation, a narrowing past 640 and a reader's text size all
|
|
62
|
+
// change the ROW — none of which is the animation this is written to ignore.
|
|
63
|
+
const measureShell = () => {
|
|
64
|
+
if (!toolbar)
|
|
65
|
+
return;
|
|
66
|
+
// THE BAR'S EXPANDED HEIGHT, WITHOUT WAITING FOR OR RACING THE STRIP'S 0.35s. The row is the bar
|
|
67
|
+
// minus whatever the strip currently is — the same number at every frame of the transition — and
|
|
68
|
+
// the bar-to-be is that row plus the strip's declared open height. Nothing samples the animation,
|
|
69
|
+
// so nothing depends on when it was sampled.
|
|
70
|
+
//
|
|
71
|
+
// CEIL, NOT ROUND, AND LOAD-BEARING: this is the slot's reserved box as well as the landing
|
|
72
|
+
// offset, so it must never be LESS than the bar's tallest state or the slot starts following the
|
|
73
|
+
// bar again and the 26px returns as a fraction. A bar under Dynamic Type is not an integer —
|
|
74
|
+
// 82.3 is recorded in this file — and rounding down is half a CSS pixel of permanent error.
|
|
75
|
+
const strip = tbTitle ? tbTitle.getBoundingClientRect().height : 0;
|
|
76
|
+
const open = parseFloat(getComputedStyle(toolbar).getPropertyValue("--tb-strip")) || 26;
|
|
77
|
+
const h = Math.ceil(toolbar.getBoundingClientRect().height - strip + open);
|
|
78
|
+
// ON THE ROOT, because the kernel's `scroll-margin-top` reads it and THE BROWSER reads that when
|
|
79
|
+
// it scrolls to the fragment on its own. Written on `.app` this reached the kernel only when the
|
|
80
|
+
// kernel happened to sit inside one, and a surface where it did not is a surface where the
|
|
81
|
+
// browser's landing and the script's disagree — which is the whole bug this measurement exists
|
|
82
|
+
// to prevent. The root is the one element every consumer is inside.
|
|
83
|
+
if (h <= 0)
|
|
84
|
+
return;
|
|
85
|
+
document.documentElement.style.setProperty("--shell-top", h + "px");
|
|
86
|
+
// queries: a persona overrides the landing offset · scroll-margin-top 82px in my own component ·
|
|
87
|
+
// the page lands 30px short · duplicate landing offset · my persona has its own #kernel
|
|
88
|
+
// rule · the framework does not reach my css
|
|
89
|
+
//
|
|
90
|
+
// AND ENFORCED, NOT MERELY DECLARED.
|
|
91
|
+
//
|
|
92
|
+
// The framework exists so that a number like this lives in ONE place. It cannot: CSS has no way
|
|
93
|
+
// to refuse an override, and on 2026-08-06 EIGHT personas — both apexes and justai.pro among them
|
|
94
|
+
// — still carried `#kernel { scroll-margin-top: 82px }` from before the shell was shared, a
|
|
95
|
+
// constant that stopped being true the day the secondary title strip was removed. Every one of
|
|
96
|
+
// them lands the page by measurement and is then overruled by the browser's own scroll to the
|
|
97
|
+
// fragment, which reads the persona's stale copy. Thirty pixels, on every bare load.
|
|
98
|
+
//
|
|
99
|
+
// Deleting the eight copies is the honest fix and it is being done. This is what makes the ninth
|
|
100
|
+
// impossible: whoever measures the bar owns what clearing it means, so EVERY CUT BELOW THE FIRST
|
|
101
|
+
// clears it by exactly the bar — written inline, which outranks any stylesheet.
|
|
102
|
+
//
|
|
103
|
+
// NOT "every cut that already declares an offset". That was the first version of this rule and it
|
|
104
|
+
// was too polite by one case: it read a zero as *"this section is not claiming to clear
|
|
105
|
+
// anything"*, and a persona that never loads `@justai/ui`'s base.css at all has exactly that
|
|
106
|
+
// zero. Measured on pin.games the moment its local `82px` was deleted — the offset fell to 0, the
|
|
107
|
+
// browser's own scroll put the kernel's top at the viewport top, and the persona's first line sat
|
|
108
|
+
// UNDER the sticky bar. Not landing short any more; landing under. Same bug, other direction.
|
|
109
|
+
//
|
|
110
|
+
// So it does not matter what the persona's CSS says or whether it loaded ours: a sticky bar is
|
|
111
|
+
// above every cut but the first, and the first is the top of the page with nothing to clear.
|
|
112
|
+
// The warning is only for a persona that declared a DIFFERENT number — that one has a stale rule
|
|
113
|
+
// to go and delete. A zero is just a surface that never had the stylesheet, and healing it
|
|
114
|
+
// silently is the whole point of the framework owning this.
|
|
115
|
+
cuts.forEach(([sec], i) => {
|
|
116
|
+
if (i === 0)
|
|
117
|
+
return;
|
|
118
|
+
const declared = parseFloat(getComputedStyle(sec).scrollMarginTop) || 0;
|
|
119
|
+
if (Math.abs(declared - h) <= 0.5)
|
|
120
|
+
return;
|
|
121
|
+
sec.style.scrollMarginTop = h + "px";
|
|
122
|
+
if (declared > 0) {
|
|
123
|
+
// Said out loud, because a healed page is a page nobody goes and fixes.
|
|
124
|
+
console.warn("[justai] #" + sec.id + " declares scroll-margin-top " + declared + "px; the shell measures " + h + "px. The landing offset belongs to @justai/ui — delete the local rule.");
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
measureShell();
|
|
129
|
+
addEventListener("resize", measureShell, { passive: true });
|
|
130
|
+
if (document.fonts && document.fonts.ready)
|
|
131
|
+
document.fonts.ready.then(measureShell);
|
|
132
|
+
// queries: data-motion · the bar grows after load · animate only after interaction · first paint
|
|
133
|
+
// animation · the toolbar changes height on arrival
|
|
134
|
+
//
|
|
135
|
+
// ── THE SHELL'S TRANSITIONS BELONG TO A PAGE SOMEBODY IS USING ──────────────────────────────
|
|
136
|
+
//
|
|
137
|
+
// The founder's question, and it is the root of the whole class: *"why is this not activated only
|
|
138
|
+
// after the user's first interaction?"* A persona lands on its kernel, so the title strip's correct
|
|
139
|
+
// state on the first frame is OPEN — animating into it makes the bar grow 26px just after the page
|
|
140
|
+
// appears, and makes every measurement taken during that third of a second describe a state the
|
|
141
|
+
// page is never actually in.
|
|
142
|
+
//
|
|
143
|
+
// Nobody can see a transition they have not yet done anything to cause, so there is nothing to
|
|
144
|
+
// lose. `once: true` on each: the flag is set by whichever comes first and never again.
|
|
145
|
+
if ("scrollRestoration" in history)
|
|
146
|
+
history.scrollRestoration = "manual";
|
|
147
|
+
// Only the FRAGMENT. `"#" + id` would clobber the path and the query, and both carry meaning here:
|
|
148
|
+
// a `?data=` link, a `?city=`, a `?mode=atrium`. A copy of this got that wrong.
|
|
149
|
+
const setHash = (id) => history.replaceState(null, "", location.pathname + location.search + "#" + id);
|
|
150
|
+
// queries: what is the 84px line · the scroll spy reports the wrong section · the hash flips back to
|
|
151
|
+
// #profile · clicking the avatar does not activate the kernel · the toolbar switches
|
|
152
|
+
// sections on its own · hash does not guarantee the cut · where does a cut begin
|
|
153
|
+
//
|
|
154
|
+
// WHERE A CUT BEGINS — ONE DEFINITION, USED BY THE NAVIGATOR AND BY THE SPY.
|
|
155
|
+
//
|
|
156
|
+
// This is the keystone of the whole behaviour, and getting it wrong is what made the hash a
|
|
157
|
+
// suggestion instead of a guarantee. There used to be TWO definitions: navigation scrolled to one
|
|
158
|
+
// place, and the spy tested against a different one — a hardcoded 84px line, paired by nothing but a
|
|
159
|
+
// comment with the `scroll-margin-top: 82px` that twelve personas each declared in their own CSS.
|
|
160
|
+
// Two magic numbers, two pixels apart, and the bug lived in the gap:
|
|
161
|
+
//
|
|
162
|
+
// click the avatar -> lands the kernel at 82 -> spy's last mid-flight sample read 85 -> profile
|
|
163
|
+
//
|
|
164
|
+
// A cut begins where the page COMES TO REST when you go to it. That is the only definition either
|
|
165
|
+
// side needs, and both now ask for it here — so the spy cannot contradict the navigator, because
|
|
166
|
+
// there is no second number for it to disagree with. The hash stops being a hint.
|
|
167
|
+
//
|
|
168
|
+
// Nothing is guessed. The position comes from the browser, and the landing inset comes from the
|
|
169
|
+
// CSS that already declares it (`scroll-margin-top`) rather than from a constant that has to be
|
|
170
|
+
// kept in sync by hand.
|
|
171
|
+
//
|
|
172
|
+
// THE KERNEL IS THE ONE EXCEPTION, and it is what kills an oscillation rather than papering over
|
|
173
|
+
// it. The kernel begins at the top of `#below` — above the sticky toolbar — not at its own box.
|
|
174
|
+
// The toolbar's title strip lives INSIDE `#below` and is in flow, so opening it pushes every
|
|
175
|
+
// section under it down by its own height (26px, measured). While the spy compared the kernel's own
|
|
176
|
+
// box against a fixed line, that 26px carried the kernel from 82 (inside the line) to 108 (outside
|
|
177
|
+
// it) — and the kernel being current is what opened the strip. Measured on app.zone by dispatching
|
|
178
|
+
// scroll events at a page that never moved:
|
|
179
|
+
//
|
|
180
|
+
// rest hash #profile kernelTop 82 strip 0 active profile
|
|
181
|
+
// spy run 1 hash #kernel kernelTop 108 strip 26 active kernel
|
|
182
|
+
// spy run 2 hash #profile kernelTop 82 strip 0 active profile
|
|
183
|
+
// spy run 3 hash #kernel kernelTop 108 strip 26 active kernel
|
|
184
|
+
//
|
|
185
|
+
// A bistable oscillator: the spy was measuring its own output. Anchoring the kernel to `#below`
|
|
186
|
+
// removes the coupling at the source, because the strip is inside that boundary and cannot move it.
|
|
187
|
+
// Widening the line would only have moved the tipping point.
|
|
188
|
+
const landingY = (sec) => {
|
|
189
|
+
if (sec === kernel)
|
|
190
|
+
return below.getBoundingClientRect().top + window.scrollY;
|
|
191
|
+
const inset = parseFloat(getComputedStyle(sec).scrollMarginTop) || 0;
|
|
192
|
+
return sec.getBoundingClientRect().top + window.scrollY - inset;
|
|
193
|
+
};
|
|
194
|
+
const goTo = (sec, behavior) => window.scrollTo({ top: landingY(sec), behavior });
|
|
195
|
+
// queries: the page rests a few pixels short of the kernel · the hash flips to #profile on its own ·
|
|
196
|
+
// typing the bare host lands on the profile · below.top 4.36 · the landing is not repaired ·
|
|
197
|
+
// it works with #kernel in the URL but not without · unstable landing
|
|
198
|
+
//
|
|
199
|
+
// WHERE THIS PAGE WAS SENT — DECIDED ONCE, AND NEVER READ BACK OUT OF THE ADDRESS BAR.
|
|
200
|
+
//
|
|
201
|
+
// This used to be re-derived from `location.hash` on every attempt, and the spy WRITES that hash.
|
|
202
|
+
// So the repair mechanism took its definition of "where I was supposed to be" from the very thing
|
|
203
|
+
// that goes wrong. Traced frame by frame on a live persona at 1512×900:
|
|
204
|
+
//
|
|
205
|
+
// t=241 scrollTo(333.36) landed exactly, below.top 0.36, #kernel
|
|
206
|
+
// t=258 the title strip begins closing y 331, below.top 2.36
|
|
207
|
+
// t=272 below.top passes 1 the spy answers PROFILE and writes #profile
|
|
208
|
+
// t=313 the strip is closed, the page has drifted y 329, below.top 4.36
|
|
209
|
+
// t=342 the `load` repair runs — and reads #profile as its target, measures itself
|
|
210
|
+
// 329 against the PROFILE's landing, finds it further than any drift could be,
|
|
211
|
+
// and closes the promise for good.
|
|
212
|
+
//
|
|
213
|
+
// Four pixels, and the page is stable in the wrong state: the kernel is 4px under the toolbar, the
|
|
214
|
+
// spy says profile, the strip stays shut, and the address bar says #profile for a person who typed
|
|
215
|
+
// the bare host. It is not a hash bug — with #kernel in the URL the same drift flips the same spy
|
|
216
|
+
// and disarms the same repair. What made it look like one is that the two stable states are
|
|
217
|
+
// reachable by a hair: on a phone the landing happened to rest at below.top −0.27 and stayed right.
|
|
218
|
+
//
|
|
219
|
+
// Captured before the first landing, so the repair keeps asking the only question worth asking:
|
|
220
|
+
// *am I where I was SENT?* One re-assert settles it permanently — measured, four times over, no
|
|
221
|
+
// oscillation.
|
|
222
|
+
const sentTo = (() => {
|
|
223
|
+
const t = cuts.find((c) => "#" + c[0].id === location.hash);
|
|
224
|
+
// A section hash is honoured on load and refresh; anything else — including #kernel and no hash
|
|
225
|
+
// at all — lands on the kernel.
|
|
226
|
+
return t ? t[0] : kernel;
|
|
227
|
+
})();
|
|
228
|
+
const land = () => {
|
|
229
|
+
// presentation mode owns the viewport — a page presenting itself does not scroll out from under
|
|
230
|
+
// whoever opened it
|
|
231
|
+
if (document.body.dataset.present)
|
|
232
|
+
return;
|
|
233
|
+
// `instant` overrides the page's own scroll-behavior: smooth.
|
|
234
|
+
goTo(sentTo, "instant");
|
|
235
|
+
};
|
|
236
|
+
// queries: the page did not land on the kernel · landing scroll ignored · scrollTo does nothing on
|
|
237
|
+
// first paint · the page opens at the top sometimes
|
|
238
|
+
//
|
|
239
|
+
// LANDED, OR TRIED AGAIN — but only for the one case where a scroll is REFUSED.
|
|
240
|
+
//
|
|
241
|
+
// `scrollTo` past the current document height is a no-op, and it does not report one: on a page
|
|
242
|
+
// whose sections size themselves a frame later, the landing is CALLED, the browser declines it, and
|
|
243
|
+
// the page opens at the top with nothing anywhere saying so. Measured in this behaviour's own
|
|
244
|
+
// fixture: `scrollTo({top: 548})` followed by a scroll event reading 0. So it is attempted again on
|
|
245
|
+
// the next frame, on `load`, and once more when the page comes to rest.
|
|
246
|
+
//
|
|
247
|
+
// ── WHAT USED TO BE HERE, AND WHY IT IS NOT ────────────────────────────────────────────────
|
|
248
|
+
//
|
|
249
|
+
// A second, much larger mechanism: a landing that ARRIVED and then DRIFTED, held as a promise until
|
|
250
|
+
// a wheel, a finger or a key "took over", with a tolerance derived from the toolbar's own height.
|
|
251
|
+
// Its trace, recorded in this file:
|
|
252
|
+
//
|
|
253
|
+
// scrollTo(468) y = 468 the landing is exact
|
|
254
|
+
// DOMContentLoaded y = 494 docH +26 — the title strip opened
|
|
255
|
+
// settled y = 465 docH -26 — and the strip closed again
|
|
256
|
+
//
|
|
257
|
+
// Every term of it was the secondary strip. It sat above the kernel inside the sticky bar, so each
|
|
258
|
+
// time it opened or closed the browser moved the scroll position to keep the content under it
|
|
259
|
+
// steady, and the page came to rest three pixels short of where the kernel began — close enough to
|
|
260
|
+
// look landed, far enough that the spy answered "profile", which closed the strip, which is what
|
|
261
|
+
// moved it. The founder removed the strip on 2026-08-06, and this went with it: measured after, the
|
|
262
|
+
// page scrolls exactly ONCE to its landing and never moves again, at 402x710 and at 1440x900.
|
|
263
|
+
//
|
|
264
|
+
// A workaround outlives its cause silently. This one would have kept re-asserting a landing nobody
|
|
265
|
+
// needed, over a drift that can no longer happen, for as long as the file existed.
|
|
266
|
+
// Only the DESTINATION is released when somebody takes over, never the landing: a tap on a cut
|
|
267
|
+
// shows where the page is GOING, and nobody should be shown a destination they have abandoned.
|
|
268
|
+
// The landing itself no longer needs protecting — there is no drift left for it to be protected
|
|
269
|
+
// from, which is the whole point of the note above.
|
|
270
|
+
const takeOver = () => { navTo = null; };
|
|
271
|
+
for (const ev of ["wheel", "touchmove", "keydown"])
|
|
272
|
+
window.addEventListener(ev, takeOver, { passive: true });
|
|
273
|
+
land();
|
|
274
|
+
// A CLICK CLOSES THIS ONE, AND THAT IS THE DIFFERENCE FROM WHAT WAS HERE BEFORE. The old promise
|
|
275
|
+
// deliberately survived clicks, because a tap on a cut is a request for a landing rather than an
|
|
276
|
+
// override — but that promise existed to repair the strip's drift, and it could tell the two apart
|
|
277
|
+
// because it only ever corrected by less than a toolbar's height. This one has no such tolerance:
|
|
278
|
+
// it can only distinguish "the browser refused the scroll" from "the page is somewhere on purpose",
|
|
279
|
+
// and after a tap those look identical. Caught by the row's own spec: clicking Profile rested the
|
|
280
|
+
// page at 0, this read it as a refusal, and pulled it back to the kernel.
|
|
281
|
+
let landed = false;
|
|
282
|
+
const settle = () => { landed = true; };
|
|
283
|
+
for (const ev of ["wheel", "touchmove", "keydown", "click"]) {
|
|
284
|
+
window.addEventListener(ev, settle, { passive: true, once: true });
|
|
285
|
+
}
|
|
286
|
+
// queries: the child persona lands short · /me lands a bit off · unstable landing · async content
|
|
287
|
+
// moves the page after it lands · vault read shifts the layout · below.top -18 · the
|
|
288
|
+
// landing is fine in one browser and off in another · ResizeObserver landing
|
|
289
|
+
//
|
|
290
|
+
// ── THE LANDING IS KEPT AGAINST LAYOUT — NEVER AGAINST SCROLLS ─────────────────────────────────
|
|
291
|
+
//
|
|
292
|
+
// A landing is a promise about a document that may not have finished becoming itself. The children
|
|
293
|
+
// proved it: /me lands exactly, the vault's async read completes, the profile grows and settles,
|
|
294
|
+
// and the page rests 18px from where it was put — with NOBODY having scrolled. Chromium's scroll
|
|
295
|
+
// anchoring sometimes absorbs this and sometimes does not, and WebKit has no anchoring at all,
|
|
296
|
+
// which is why the founder's phone showed what a laptop's headless run happened to hide. "Stable
|
|
297
|
+
// olmayan bir durum" is half-applied compensation seen from the outside.
|
|
298
|
+
//
|
|
299
|
+
// A repair against ANY movement was tried once and fought a page that scrolls itself — that is the
|
|
300
|
+
// workaround this file keeps warning about. The line is drawn elsewhere, and it is sharp: LAYOUT
|
|
301
|
+
// is the page still under construction, so the promise holds; a SCROLL is an intent, and intents
|
|
302
|
+
// are never fought. A ResizeObserver on the body sees exactly the first kind and cannot see the
|
|
303
|
+
// second — a consumer calling scrollTo() resizes nothing. The first gesture ends it: after a
|
|
304
|
+
// wheel, a finger, a key or a pointer the page belongs to the person, whatever the layout does.
|
|
305
|
+
let touched = false;
|
|
306
|
+
const takeBack = () => { touched = true; };
|
|
307
|
+
for (const ev of ["wheel", "touchmove", "keydown", "pointerdown"]) {
|
|
308
|
+
window.addEventListener(ev, takeBack, { passive: true, once: true, capture: true });
|
|
309
|
+
}
|
|
310
|
+
if (typeof ResizeObserver === "function") {
|
|
311
|
+
// queries: the keeper fought a programmatic scroll · scrollTo(0) snapped back to the kernel ·
|
|
312
|
+
// the query-survives spec times out in CI · near band 64
|
|
313
|
+
//
|
|
314
|
+
// AND THE KEEPER ONLY ACTS WHILE THE PAGE IS STILL AT THE LANDING. CI caught the first version
|
|
315
|
+
// within the hour: a consumer's programmatic scrollTo(0) — which no gesture listener sees — was
|
|
316
|
+
// followed by the fonts settling, the resize fired, and the keeper yanked the page back to the
|
|
317
|
+
// kernel from somewhere it had been deliberately sent. Gestures cannot be the only release,
|
|
318
|
+
// because a page is allowed to scroll ITSELF (lendcam's stage does; a spec does).
|
|
319
|
+
//
|
|
320
|
+
// So the promise is spatial as well: on every resize the keeper first asks whether the page is
|
|
321
|
+
// still within a hand's width (64px) of where it last held it. Layout shifts displace a landed
|
|
322
|
+
// page by small strokes — the vault's was 18px — while anybody scrolling AWAY, by hand or by
|
|
323
|
+
// code, leaves that band immediately and permanently: the keeper reads leaving as being
|
|
324
|
+
// relieved of duty, not as something to correct.
|
|
325
|
+
let kept = landingY(sentTo);
|
|
326
|
+
const keeper = new ResizeObserver(() => {
|
|
327
|
+
if (touched || document.body.dataset.present) {
|
|
328
|
+
keeper.disconnect();
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (Math.abs(window.scrollY - kept) > 64) {
|
|
332
|
+
keeper.disconnect();
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const want = landingY(sentTo);
|
|
336
|
+
kept = want;
|
|
337
|
+
// A pixel of slack: browsers land sub-pixel scrolls a hair off the number they were handed,
|
|
338
|
+
// and re-asserting over a rounding error would run on every breath the page takes.
|
|
339
|
+
if (Math.abs(window.scrollY - want) > 1)
|
|
340
|
+
goTo(sentTo, "instant");
|
|
341
|
+
});
|
|
342
|
+
// NOT (only) the body: the fleet's ground gives `body { height: 100% }`, so the body's border
|
|
343
|
+
// box is the viewport and never resizes when content grows — an observer there watched the one
|
|
344
|
+
// box guaranteed to stay still. Caught by the spec modelling the vault's growth: 18px arrived,
|
|
345
|
+
// the observer never fired. The boxes that actually change are the sections themselves, so the
|
|
346
|
+
// keeper watches every cut and the below-boundary; body rides along for a consumer whose ground
|
|
347
|
+
// differs.
|
|
348
|
+
keeper.observe(document.body);
|
|
349
|
+
keeper.observe(below);
|
|
350
|
+
for (const c of cuts)
|
|
351
|
+
keeper.observe(c[0]);
|
|
352
|
+
}
|
|
353
|
+
// The landing is attempted again when the page comes to rest, because `scrollTo` past a document
|
|
354
|
+
// that has not sized itself yet is a silent no-op — cause 1, and the only cause left here. The
|
|
355
|
+
// drift this used to repair as well was the secondary title strip moving the page after it landed,
|
|
356
|
+
// and the strip is gone; the thirty-pixel glide that looked like drift afterwards was not one
|
|
357
|
+
// either — it was the browser scrolling to the fragment with a number the persona still owned, and
|
|
358
|
+
// that is fixed where the number lives rather than chased from here. A repair that re-asserts
|
|
359
|
+
// against ANY movement fights a page that scrolls itself, which is a workaround growing back.
|
|
360
|
+
const landIfRefused = () => {
|
|
361
|
+
if (landed)
|
|
362
|
+
return;
|
|
363
|
+
// Anywhere but the very top means the scroll was accepted. A landing that IS the top has nothing
|
|
364
|
+
// to be refused about. Either way this is the last thing it ever does.
|
|
365
|
+
if (window.scrollY > 1 || landingY(sentTo) <= 1) {
|
|
366
|
+
landed = true;
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
land();
|
|
370
|
+
};
|
|
371
|
+
requestAnimationFrame(landIfRefused);
|
|
372
|
+
window.addEventListener("load", landIfRefused);
|
|
373
|
+
// The reveal rides with this on pages whose content is ready at first paint. A page that renders
|
|
374
|
+
// asynchronously — the vault, the file kernel — holds paint until its own data has arrived and
|
|
375
|
+
// passes `reveal: false`, because revealing before then shows an empty room.
|
|
376
|
+
if (o.reveal !== false) {
|
|
377
|
+
const reveal = () => document.body.classList.add("ready");
|
|
378
|
+
requestAnimationFrame(reveal);
|
|
379
|
+
setTimeout(reveal, 500);
|
|
380
|
+
}
|
|
381
|
+
const text = (sel) => (document.querySelector(sel)?.textContent || "").trim();
|
|
382
|
+
// Kernel names the persona, Posts names its handle, Profile stays collapsed — its big header IS
|
|
383
|
+
// the title, and repeating it in the bar above would say the same thing twice.
|
|
384
|
+
const titleFor = o.titleFor ||
|
|
385
|
+
((id) => (id === "kernel" ? text(".pname") : id === "posts" ? text(".handle") : ""));
|
|
386
|
+
// queries: the title strip jumps · the page jolts after tapping a cut · content shifts while
|
|
387
|
+
// scrolling · toolbar title animation causes a layout shift · landing lands 26px off ·
|
|
388
|
+
// landingAfterStrip · why is there no strip compensation any more · tb-slot min-height
|
|
389
|
+
//
|
|
390
|
+
// ── THERE IS NOTHING LEFT TO COMPENSATE FOR, AND THAT IS THE WHOLE POINT OF THE SLOT ──────────
|
|
391
|
+
//
|
|
392
|
+
// Two functions used to live here: one probed the strip's open height before it opened, the other
|
|
393
|
+
// aimed a scroll at where the page WOULD rest once the strip had finished moving. They existed
|
|
394
|
+
// because the strip was in flow above every section, so opening it pushed the whole page down by
|
|
395
|
+
// its own 26px and a landing computed before it opened was wrong by exactly that much. A person
|
|
396
|
+
// felt it as three motions for one tap.
|
|
397
|
+
//
|
|
398
|
+
// `.tb-slot` ends that at the source: the SLOT is what flow sees and its box is `--shell-top`, a
|
|
399
|
+
// constant; the BAR is static inside it and may be any height it likes. Opening the strip moves
|
|
400
|
+
// nothing outside the slot, so a landing computed before it opens is simply correct.
|
|
401
|
+
//
|
|
402
|
+
// The compensation is therefore not merely dead — it would be WRONG, adding a strip's height to
|
|
403
|
+
// the posts landing for a shift that no longer happens. When the strip came back on 2026-08-06 the
|
|
404
|
+
// reserved box came back with it FOR EVERY KIND, not only for games, and these two went for good.
|
|
405
|
+
// If they are ever missed, the thing to check is whether the slot still reserves its box.
|
|
406
|
+
const setStrip = (id, animate) => {
|
|
407
|
+
if (!tbTitle)
|
|
408
|
+
return;
|
|
409
|
+
const t = titleFor(id);
|
|
410
|
+
if (animate) {
|
|
411
|
+
tbTitle.classList.toggle("show", !!t);
|
|
412
|
+
if (t && tbTitleText && tbTitleText.textContent !== t) {
|
|
413
|
+
tbTitleText.classList.add("fade");
|
|
414
|
+
setTimeout(() => { tbTitleText.textContent = t; tbTitleText.classList.remove("fade"); }, 150);
|
|
415
|
+
}
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
// Instant: the height must be final before this function returns, so the caller can measure. The
|
|
419
|
+
// text goes with it — a settled height showing the previous words would be its own small lie.
|
|
420
|
+
tbTitle.style.transition = "none";
|
|
421
|
+
tbTitle.classList.toggle("show", !!t);
|
|
422
|
+
if (t && tbTitleText) {
|
|
423
|
+
tbTitleText.classList.remove("fade");
|
|
424
|
+
tbTitleText.textContent = t;
|
|
425
|
+
}
|
|
426
|
+
void tbTitle.offsetHeight;
|
|
427
|
+
tbTitle.style.transition = "";
|
|
428
|
+
};
|
|
429
|
+
let lastCut = null;
|
|
430
|
+
let first = true;
|
|
431
|
+
// queries: the toolbar icon changes late · nav icon lags the tap · active state waits for the scroll
|
|
432
|
+
//
|
|
433
|
+
// THE DESTINATION, HELD FOR THE LENGTH OF THE TRIP.
|
|
434
|
+
//
|
|
435
|
+
// The spy is truthful: it reports the section the page is actually over. During a smooth scroll that
|
|
436
|
+
// is the section being LEFT, so the toolbar answered a tap only once the scroll finished — the icon
|
|
437
|
+
// changed a beat late for no reason a person could see. A tap is a request to arrive, the same
|
|
438
|
+
// reading the landing promise already takes, so the toolbar may show where it is going.
|
|
439
|
+
//
|
|
440
|
+
// Held rather than merely set, because setting it optimistically would be undone by the very next
|
|
441
|
+
// spy frame and flicker. Released the moment the page arrives, or the moment somebody takes over —
|
|
442
|
+
// nobody is shown a destination they have already abandoned.
|
|
443
|
+
let navTo = null;
|
|
444
|
+
// The cut you are on is the last one you have reached — asked in the one vocabulary `landingY`
|
|
445
|
+
// defines, so this can never answer something a click could not produce. A pixel of tolerance,
|
|
446
|
+
// because a browser is free to land a smooth scroll a hair short of the number it was given.
|
|
447
|
+
const measure = () => {
|
|
448
|
+
if (toolbar)
|
|
449
|
+
toolbar.classList.toggle("stuck", window.scrollY >= below.offsetTop - 1);
|
|
450
|
+
const y = window.scrollY + 1;
|
|
451
|
+
let current = cuts[0];
|
|
452
|
+
for (const c of cuts)
|
|
453
|
+
if (landingY(c[0]) <= y)
|
|
454
|
+
current = c;
|
|
455
|
+
if (navTo) {
|
|
456
|
+
if (current === navTo)
|
|
457
|
+
navTo = null;
|
|
458
|
+
else
|
|
459
|
+
current = navTo;
|
|
460
|
+
}
|
|
461
|
+
for (const c of cuts)
|
|
462
|
+
c[1].classList.toggle("active", c === current);
|
|
463
|
+
if (current === lastCut)
|
|
464
|
+
return;
|
|
465
|
+
lastCut = current;
|
|
466
|
+
if (current[0].id && "#" + current[0].id !== location.hash)
|
|
467
|
+
setHash(current[0].id);
|
|
468
|
+
// First paint is not a transition: the page opens at the kernel, so the title is already true when
|
|
469
|
+
// it arrives. Animating it in tells a person something changed when nothing did.
|
|
470
|
+
const wasFirst = first;
|
|
471
|
+
first = false;
|
|
472
|
+
setStrip(current[0].id, !wasFirst);
|
|
473
|
+
};
|
|
474
|
+
// queries: scroll janks while the toolbar updates · scroll handler runs too often · the spy reads a
|
|
475
|
+
// stale position · the section is right but the toolbar is one behind · scrollend
|
|
476
|
+
//
|
|
477
|
+
// THE LISTENER SCHEDULES; THE FRAME MEASURES. AND THE LAST WORD IS ALWAYS THE RESTING POSITION.
|
|
478
|
+
//
|
|
479
|
+
// Two rules, and the second one is what actually fixed the reported bug.
|
|
480
|
+
//
|
|
481
|
+
// NEVER IN THE EVENT. `measure` reads geometry, and reading geometry inside a scroll handler forces
|
|
482
|
+
// the browser to lay the page out synchronously on a thread that is trying to move it. So the
|
|
483
|
+
// handler does nothing but ask for a frame; all reading and writing happens in that frame, at most
|
|
484
|
+
// once per frame however many events arrived. Intermediate positions are DISCARDED — only the
|
|
485
|
+
// newest is ever measured, which is the whole point of coalescing rather than throttling.
|
|
486
|
+
//
|
|
487
|
+
// AND THE PAGE MUST BE MEASURED WHERE IT STOPS. Scroll events stop arriving slightly before a
|
|
488
|
+
// smooth scroll finishes settling, so the last position the old code ever evaluated was in flight:
|
|
489
|
+
// it read 85, decided "profile", and the page then came to rest at 82 — inside the kernel — with
|
|
490
|
+
// nothing left to run and say so. That single unread pixel is the entire reported symptom.
|
|
491
|
+
//
|
|
492
|
+
// So a frame that finds the page still moving asks for another one, and the loop ends on the frame
|
|
493
|
+
// where nothing changed — which is, by construction, the resting position. No timer, no `scrollend`
|
|
494
|
+
// (still not everywhere), and nothing running once the page is still.
|
|
495
|
+
let queued = false;
|
|
496
|
+
let lastY = null;
|
|
497
|
+
const frame = () => {
|
|
498
|
+
queued = false;
|
|
499
|
+
const y = window.scrollY;
|
|
500
|
+
const moved = y !== lastY;
|
|
501
|
+
lastY = y;
|
|
502
|
+
measure();
|
|
503
|
+
if (moved)
|
|
504
|
+
schedule();
|
|
505
|
+
// The page has stopped. If the landing was refused because the document had not sized itself
|
|
506
|
+
// yet, this is the last chance to notice — and it is the ONLY thing left here: the drift this
|
|
507
|
+
// used to repair was the secondary strip moving the page, and the strip is gone.
|
|
508
|
+
else
|
|
509
|
+
landIfRefused();
|
|
510
|
+
};
|
|
511
|
+
const schedule = () => { if (!queued) {
|
|
512
|
+
queued = true;
|
|
513
|
+
requestAnimationFrame(frame);
|
|
514
|
+
} };
|
|
515
|
+
window.addEventListener("scroll", schedule, { passive: true });
|
|
516
|
+
measure();
|
|
517
|
+
// queries: a link to #kernel does not activate the kernel · the avatar link does not land · in-page
|
|
518
|
+
// hash link · anchor click · hash from another page
|
|
519
|
+
//
|
|
520
|
+
// EVERY HASH LINK IS A CUT LINK — not only the three in the toolbar.
|
|
521
|
+
//
|
|
522
|
+
// The toolbar's own navs used to be the only anchors wired up, so any OTHER link to the same place
|
|
523
|
+
// fell through to the browser's native anchor jump and was then overruled by the spy. The profile
|
|
524
|
+
// avatar is exactly that: a link to `#kernel` that took you near the kernel and left the page
|
|
525
|
+
// saying `#profile`. Delegated, so a cut link works wherever a persona puts one — today the avatar,
|
|
526
|
+
// tomorrow something nobody has written yet — with no registration and no per-persona wiring.
|
|
527
|
+
//
|
|
528
|
+
// Programmatic rather than native, so the landing is the one `landingY` defines. A native jump uses
|
|
529
|
+
// `scroll-margin` alone and lands the kernel below the sticky bar it should sit under.
|
|
530
|
+
document.addEventListener("click", (e) => {
|
|
531
|
+
// `EventTarget` has no `closest` — a click can land on a node that is not an Element at all,
|
|
532
|
+
// and the old duck-check (`e.target.closest ? …`) was the untyped spelling of exactly this.
|
|
533
|
+
const target = e.target instanceof Element ? e.target : null;
|
|
534
|
+
const a = target ? target.closest('a[href^="#"]') : null;
|
|
535
|
+
if (!a)
|
|
536
|
+
return;
|
|
537
|
+
const t = cuts.find((c) => "#" + c[0].id === a.getAttribute("href"));
|
|
538
|
+
if (!t)
|
|
539
|
+
return;
|
|
540
|
+
e.preventDefault();
|
|
541
|
+
// A NEW LANDING RE-ARMS THE PROMISE. Somebody asking for a cut is asking to arrive at it, and the
|
|
542
|
+
// arrival needs the same protection the page's first one had: the title strip opens as the kernel
|
|
543
|
+
// becomes current, which drags the scroll ~18px past the mark and tucks the kernel's first line
|
|
544
|
+
// under the sticky bar. Without this the toolbar's own icon landed flush and the avatar did not,
|
|
545
|
+
// for no reason a person could see.
|
|
546
|
+
// THE STRIP AND THE SCROLL RUN TOGETHER. The strip keeps its own transition — it is meant to be
|
|
547
|
+
// seen growing, and snapping it open instead just moves the jolt to the moment of the tap. What
|
|
548
|
+
// changes is the AIM: the scroll is sent to where the page will rest once the strip has finished,
|
|
549
|
+
// so the growing band and the moving page arrive at the same place at the same time and nothing
|
|
550
|
+
// has to be corrected afterwards.
|
|
551
|
+
// The icon answers the tap NOW, not when the scroll lands. `navTo` keeps it answered for the trip.
|
|
552
|
+
navTo = t;
|
|
553
|
+
for (const c of cuts)
|
|
554
|
+
c[1].classList.toggle("active", c === t);
|
|
555
|
+
// queries: clicking profile throws me back to the kernel · the second cycle · landed re-armed
|
|
556
|
+
//
|
|
557
|
+
// ** NOTHING IS RE-ARMED HERE, AND THAT LINE COST AN HOUR. ** This used to set `landed = false`,
|
|
558
|
+
// which was right while `landed` meant "the landing promise is open": a tap on a cut IS a request
|
|
559
|
+
// for a landing, so the drift repair was re-armed to protect the new one. That promise is gone —
|
|
560
|
+
// `landed` now means only "the initial scroll was accepted, stop retrying it" — and re-arming it
|
|
561
|
+
// told the retry that the page had never landed. The tap scrolls to the profile, the page comes
|
|
562
|
+
// to rest at 0, the retry reads `scrollY <= 1` with a landing of 376, calls it a refusal and
|
|
563
|
+
// pulls the person back to the kernel.
|
|
564
|
+
//
|
|
565
|
+
// It survived the first cycle by luck: the same click also tripped the `once` listener that sets
|
|
566
|
+
// `landed = true`, in the later bubble phase, so the flag ended true anyway. The listener is
|
|
567
|
+
// spent after that, and from the SECOND tap onward the page snapped back every time — which is
|
|
568
|
+
// exactly how the founder found it: "profile · kernel · profile · kernel … 2. cycle'da başlıyor."
|
|
569
|
+
//
|
|
570
|
+
// The strip still follows the tap — it is the row saying which cut you are on, which is the one
|
|
571
|
+
// thing about it the founder said he could not give up.
|
|
572
|
+
setStrip(t[0].id, true);
|
|
573
|
+
window.scrollTo({ top: landingY(t[0]), behavior: "smooth" });
|
|
574
|
+
setHash(t[0].id);
|
|
575
|
+
});
|
|
576
|
+
// A hash that arrives without a click — the back button, or a link from another page to this one.
|
|
577
|
+
// `setHash` uses replaceState and fires nothing, so this can only be somebody else's navigation.
|
|
578
|
+
window.addEventListener("hashchange", () => {
|
|
579
|
+
// The back button or a link from outside — a person navigated, so the load-landing promise ends
|
|
580
|
+
// here too: the layout keeper must not snap a page somebody just steered somewhere else.
|
|
581
|
+
touched = true;
|
|
582
|
+
const t = cuts.find((c) => "#" + c[0].id === location.hash);
|
|
583
|
+
if (t) {
|
|
584
|
+
navTo = t;
|
|
585
|
+
for (const c of cuts)
|
|
586
|
+
c[1].classList.toggle("active", c === t);
|
|
587
|
+
// Nor here — same reason as the click above.
|
|
588
|
+
setStrip(t[0].id, true);
|
|
589
|
+
window.scrollTo({ top: landingY(t[0]), behavior: "smooth" });
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
// queries: persona scroll for a surface that cannot bundle · inline scroll script · feed toolbar
|
|
594
|
+
// script · why is there a JS string version of personaScroll
|
|
595
|
+
//
|
|
596
|
+
// THE SAME BEHAVIOUR, AS A STRING, FOR A SURFACE THAT CANNOT IMPORT IT.
|
|
597
|
+
//
|
|
598
|
+
// The feed is served under every persona's host from its own origin, so its scripts are `is:inline`
|
|
599
|
+
// rather than bundled assets — a cross-origin module would need CORS on every one of them. That is
|
|
600
|
+
// why core's other load-bearing pieces are strings too (AUTH_CAPTURE_JS, READY_JS, CONSENT_JS).
|
|
601
|
+
//
|
|
602
|
+
// It is generated FROM the function rather than written twice, which is the only version of this
|
|
603
|
+
// worth having: a second hand-minified copy is what the feed already had, and it had drifted — its
|
|
604
|
+
// hash writer dropped the query, it never set the title text, and it found its navs by href. One
|
|
605
|
+
// source, two shapes.
|
|
606
|
+
//
|
|
607
|
+
// This works because `personaScroll` closes over nothing: every helper it uses is defined inside it.
|
|
608
|
+
// A future edit that reaches for a module-level helper would compile, ship, and throw here — so if
|
|
609
|
+
// you add one, inline it.
|
|
610
|
+
export function personaScrollJs(options) {
|
|
611
|
+
return "(" + personaScroll.toString() + ")(" + JSON.stringify(options || {}) + ");";
|
|
612
|
+
}
|