@justai/core 0.39.0 → 0.41.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/scroll.d.ts +1 -5
- package/dist/scroll.js +24 -143
- package/dist/xray.js +1 -1
- package/package.json +1 -1
package/dist/scroll.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @justai/core/scroll — the persona page's scroll behaviour — landing on the kernel
|
|
2
|
+
* @justai/core/scroll — the persona page's scroll behaviour — landing on the kernel and the spy. It knows a set of element ids and nothing about which framework drew them.
|
|
3
3
|
*
|
|
4
4
|
* Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
|
|
5
5
|
* and why its behaviour lives one level below @justai/cuts.
|
|
@@ -10,12 +10,8 @@ export interface PersonaScrollOptions {
|
|
|
10
10
|
/** Id of the element the toolbar sits at the top of. Default `"below"`. */
|
|
11
11
|
below?: string | HTMLElement | null;
|
|
12
12
|
toolbar?: string | HTMLElement | null;
|
|
13
|
-
title?: string | HTMLElement | null;
|
|
14
|
-
titleText?: string | HTMLElement | null;
|
|
15
13
|
/** Maps a section id to its nav's id. Default `profile` → `navProfile`. */
|
|
16
14
|
navFor?: (id: string) => string;
|
|
17
|
-
/** What the title strip says for a section. Default: kernel → `.pname`, posts → `.handle`. */
|
|
18
|
-
titleFor?: (id: string) => string;
|
|
19
15
|
/** Whether this owns `body.ready`. Pass `false` on a page that renders asynchronously. */
|
|
20
16
|
reveal?: boolean;
|
|
21
17
|
/**
|
package/dist/scroll.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @justai/core/scroll — the persona page's scroll behaviour — landing on the kernel
|
|
2
|
+
* @justai/core/scroll — the persona page's scroll behaviour — landing on the kernel and the spy. It knows a set of element ids and nothing about which framework drew them.
|
|
3
3
|
*
|
|
4
4
|
* Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
|
|
5
5
|
* and why its behaviour lives one level below @justai/cuts.
|
|
@@ -13,10 +13,6 @@ export function personaScroll(options) {
|
|
|
13
13
|
if (!below || !kernel)
|
|
14
14
|
return;
|
|
15
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
16
|
// A cut is a section AND the nav that points at it; anything missing either half is simply not one.
|
|
21
17
|
// That is how a page with extra toolbar links — /me's vault, /files' host link — needs no
|
|
22
18
|
// configuration: they are links, not cuts, and they fall out of this list on their own.
|
|
@@ -28,53 +24,27 @@ export function personaScroll(options) {
|
|
|
28
24
|
.filter((c) => Boolean(c[0] && c[1]));
|
|
29
25
|
if (!cuts.length)
|
|
30
26
|
return;
|
|
31
|
-
// queries: --shell-top · the
|
|
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
|
|
27
|
+
// queries: --shell-top · the gap under the toolbar · what the shell takes above the kernel
|
|
34
28
|
//
|
|
35
|
-
// ──
|
|
29
|
+
// ── WHAT THE SHELL TAKES ABOVE THE KERNEL IS THE BAR, MEASURED ─────────────────────────────
|
|
36
30
|
//
|
|
37
|
-
// `--shell-top` is
|
|
38
|
-
//
|
|
31
|
+
// `--shell-top` is read by the landing offset, an app kernel's minimum height and a game kernel's
|
|
32
|
+
// exact one. It is the toolbar's height, and since the title strip went (2026-10-12) that height
|
|
33
|
+
// does not move: one row, so whatever is measured is what the bar is at every instant.
|
|
39
34
|
//
|
|
40
|
-
// It was the
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
35
|
+
// It was the strip that made this hard. While a second line opened and closed over 0.35s, the
|
|
36
|
+
// number had to be "the row plus the strip's OPEN height, whatever it is doing now", and that sum
|
|
37
|
+
// was also the slot's reserved box — which is why a shut strip left 26px of empty bar under the
|
|
38
|
+
// row on every persona. Measured here, nothing is added: the bar is the number.
|
|
44
39
|
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
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.
|
|
40
|
+
// CEIL, NOT ROUND: this is the landing offset, and a bar under Dynamic Type is not an integer —
|
|
41
|
+
// 82.3 has been recorded — so rounding down would put the kernel's first line half a pixel under
|
|
42
|
+
// the bar. Re-measured on resize because a rotation, a narrowing past 640 and a reader's text size
|
|
43
|
+
// all change the row.
|
|
63
44
|
const measureShell = () => {
|
|
64
45
|
if (!toolbar)
|
|
65
46
|
return;
|
|
66
|
-
|
|
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);
|
|
47
|
+
const h = Math.ceil(toolbar.getBoundingClientRect().height);
|
|
78
48
|
// ON THE ROOT, because the kernel's `scroll-margin-top` reads it and THE BROWSER reads that when
|
|
79
49
|
// it scrolls to the fragment on its own. Written on `.app` this reached the kernel only when the
|
|
80
50
|
// kernel happened to sit inside one, and a surface where it did not is a surface where the
|
|
@@ -129,19 +99,6 @@ export function personaScroll(options) {
|
|
|
129
99
|
addEventListener("resize", measureShell, { passive: true });
|
|
130
100
|
if (document.fonts && document.fonts.ready)
|
|
131
101
|
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
102
|
if ("scrollRestoration" in history)
|
|
146
103
|
history.scrollRestoration = "manual";
|
|
147
104
|
// Only the FRAGMENT. `"#" + id` would clobber the path and the query, and both carry meaning here:
|
|
@@ -169,22 +126,12 @@ export function personaScroll(options) {
|
|
|
169
126
|
// CSS that already declares it (`scroll-margin-top`) rather than from a constant that has to be
|
|
170
127
|
// kept in sync by hand.
|
|
171
128
|
//
|
|
172
|
-
// THE KERNEL IS THE ONE EXCEPTION
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
//
|
|
177
|
-
// it
|
|
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.
|
|
129
|
+
// THE KERNEL IS THE ONE EXCEPTION: it begins at the top of `#below`, above the sticky toolbar,
|
|
130
|
+
// rather than at its own box. The toolbar lives inside `#below`, so landing there is landing with
|
|
131
|
+
// the bar pinned flush and the kernel directly under it. (It was written to kill an oscillation the
|
|
132
|
+
// old title strip caused — the strip was in flow and moved the kernel's own box by 26px each time
|
|
133
|
+
// it opened, and the spy then measured its own output. With the strip gone the anchor stays,
|
|
134
|
+
// because it is simply the right place: where the toolbar sticks.)
|
|
188
135
|
const landingY = (sec) => {
|
|
189
136
|
if (sec === kernel)
|
|
190
137
|
return below.getBoundingClientRect().top + window.scrollY;
|
|
@@ -382,56 +329,7 @@ export function personaScroll(options) {
|
|
|
382
329
|
requestAnimationFrame(reveal);
|
|
383
330
|
setTimeout(reveal, 500);
|
|
384
331
|
}
|
|
385
|
-
const text = (sel) => (document.querySelector(sel)?.textContent || "").trim();
|
|
386
|
-
// Kernel names the persona, Posts names its handle, Profile stays collapsed — its big header IS
|
|
387
|
-
// the title, and repeating it in the bar above would say the same thing twice.
|
|
388
|
-
const titleFor = o.titleFor ||
|
|
389
|
-
((id) => (id === "kernel" ? text(".pname") : id === "posts" ? text(".handle") : ""));
|
|
390
|
-
// queries: the title strip jumps · the page jolts after tapping a cut · content shifts while
|
|
391
|
-
// scrolling · toolbar title animation causes a layout shift · landing lands 26px off ·
|
|
392
|
-
// landingAfterStrip · why is there no strip compensation any more · tb-slot min-height
|
|
393
|
-
//
|
|
394
|
-
// ── THERE IS NOTHING LEFT TO COMPENSATE FOR, AND THAT IS THE WHOLE POINT OF THE SLOT ──────────
|
|
395
|
-
//
|
|
396
|
-
// Two functions used to live here: one probed the strip's open height before it opened, the other
|
|
397
|
-
// aimed a scroll at where the page WOULD rest once the strip had finished moving. They existed
|
|
398
|
-
// because the strip was in flow above every section, so opening it pushed the whole page down by
|
|
399
|
-
// its own 26px and a landing computed before it opened was wrong by exactly that much. A person
|
|
400
|
-
// felt it as three motions for one tap.
|
|
401
|
-
//
|
|
402
|
-
// `.tb-slot` ends that at the source: the SLOT is what flow sees and its box is `--shell-top`, a
|
|
403
|
-
// constant; the BAR is static inside it and may be any height it likes. Opening the strip moves
|
|
404
|
-
// nothing outside the slot, so a landing computed before it opens is simply correct.
|
|
405
|
-
//
|
|
406
|
-
// The compensation is therefore not merely dead — it would be WRONG, adding a strip's height to
|
|
407
|
-
// the posts landing for a shift that no longer happens. When the strip came back on 2026-08-06 the
|
|
408
|
-
// reserved box came back with it FOR EVERY KIND, not only for games, and these two went for good.
|
|
409
|
-
// If they are ever missed, the thing to check is whether the slot still reserves its box.
|
|
410
|
-
const setStrip = (id, animate) => {
|
|
411
|
-
if (!tbTitle)
|
|
412
|
-
return;
|
|
413
|
-
const t = titleFor(id);
|
|
414
|
-
if (animate) {
|
|
415
|
-
tbTitle.classList.toggle("show", !!t);
|
|
416
|
-
if (t && tbTitleText && tbTitleText.textContent !== t) {
|
|
417
|
-
tbTitleText.classList.add("fade");
|
|
418
|
-
setTimeout(() => { tbTitleText.textContent = t; tbTitleText.classList.remove("fade"); }, 150);
|
|
419
|
-
}
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
// Instant: the height must be final before this function returns, so the caller can measure. The
|
|
423
|
-
// text goes with it — a settled height showing the previous words would be its own small lie.
|
|
424
|
-
tbTitle.style.transition = "none";
|
|
425
|
-
tbTitle.classList.toggle("show", !!t);
|
|
426
|
-
if (t && tbTitleText) {
|
|
427
|
-
tbTitleText.classList.remove("fade");
|
|
428
|
-
tbTitleText.textContent = t;
|
|
429
|
-
}
|
|
430
|
-
void tbTitle.offsetHeight;
|
|
431
|
-
tbTitle.style.transition = "";
|
|
432
|
-
};
|
|
433
332
|
let lastCut = null;
|
|
434
|
-
let first = true;
|
|
435
333
|
// queries: the toolbar icon changes late · nav icon lags the tap · active state waits for the scroll
|
|
436
334
|
//
|
|
437
335
|
// THE DESTINATION, HELD FOR THE LENGTH OF THE TRIP.
|
|
@@ -469,11 +367,6 @@ export function personaScroll(options) {
|
|
|
469
367
|
lastCut = current;
|
|
470
368
|
if (current[0].id && "#" + current[0].id !== location.hash)
|
|
471
369
|
setHash(current[0].id);
|
|
472
|
-
// First paint is not a transition: the page opens at the kernel, so the title is already true when
|
|
473
|
-
// it arrives. Animating it in tells a person something changed when nothing did.
|
|
474
|
-
const wasFirst = first;
|
|
475
|
-
first = false;
|
|
476
|
-
setStrip(current[0].id, !wasFirst);
|
|
477
370
|
};
|
|
478
371
|
// queries: scroll janks while the toolbar updates · scroll handler runs too often · the spy reads a
|
|
479
372
|
// stale position · the section is right but the toolbar is one behind · scrollend
|
|
@@ -542,16 +435,6 @@ export function personaScroll(options) {
|
|
|
542
435
|
if (!t)
|
|
543
436
|
return;
|
|
544
437
|
e.preventDefault();
|
|
545
|
-
// A NEW LANDING RE-ARMS THE PROMISE. Somebody asking for a cut is asking to arrive at it, and the
|
|
546
|
-
// arrival needs the same protection the page's first one had: the title strip opens as the kernel
|
|
547
|
-
// becomes current, which drags the scroll ~18px past the mark and tucks the kernel's first line
|
|
548
|
-
// under the sticky bar. Without this the toolbar's own icon landed flush and the avatar did not,
|
|
549
|
-
// for no reason a person could see.
|
|
550
|
-
// THE STRIP AND THE SCROLL RUN TOGETHER. The strip keeps its own transition — it is meant to be
|
|
551
|
-
// seen growing, and snapping it open instead just moves the jolt to the moment of the tap. What
|
|
552
|
-
// changes is the AIM: the scroll is sent to where the page will rest once the strip has finished,
|
|
553
|
-
// so the growing band and the moving page arrive at the same place at the same time and nothing
|
|
554
|
-
// has to be corrected afterwards.
|
|
555
438
|
// The icon answers the tap NOW, not when the scroll lands. `navTo` keeps it answered for the trip.
|
|
556
439
|
navTo = t;
|
|
557
440
|
for (const c of cuts)
|
|
@@ -571,9 +454,9 @@ export function personaScroll(options) {
|
|
|
571
454
|
// spent after that, and from the SECOND tap onward the page snapped back every time — which is
|
|
572
455
|
// exactly how the founder found it: "profile · kernel · profile · kernel … 2. cycle'da başlıyor."
|
|
573
456
|
//
|
|
574
|
-
// The
|
|
575
|
-
// thing about
|
|
576
|
-
|
|
457
|
+
// The row says which cut you are on through the icon that answered the tap above — that was the
|
|
458
|
+
// one thing about the old title strip the founder said he could not give up, and it is the
|
|
459
|
+
// icon's job now, not a second line's.
|
|
577
460
|
window.scrollTo({ top: landingY(t[0]), behavior: "smooth" });
|
|
578
461
|
setHash(t[0].id);
|
|
579
462
|
});
|
|
@@ -588,8 +471,6 @@ export function personaScroll(options) {
|
|
|
588
471
|
navTo = t;
|
|
589
472
|
for (const c of cuts)
|
|
590
473
|
c[1].classList.toggle("active", c === t);
|
|
591
|
-
// Nor here — same reason as the click above.
|
|
592
|
-
setStrip(t[0].id, true);
|
|
593
474
|
window.scrollTo({ top: landingY(t[0]), behavior: "smooth" });
|
|
594
475
|
}
|
|
595
476
|
});
|
package/dist/xray.js
CHANGED
|
@@ -275,7 +275,7 @@ export function xray() {
|
|
|
275
275
|
// on the action-safe ring below, and a game pads by nothing.
|
|
276
276
|
// The bottom may EXCEED it and only the bottom may: env(safe-area-inset-bottom) is the strip the
|
|
277
277
|
// OS keeps for its home indicator, and it is added rather than substituted.
|
|
278
|
-
var want = kind === "game" ? 0 : g;
|
|
278
|
+
var want = kind === "game" || kind === "art" ? 0 : g; // an art kernel is a place, like a game (ui base.css)
|
|
279
279
|
var insetOk = kp[0] === want && kp[1] === want && kp[3] === want && kp[2] >= want;
|
|
280
280
|
put(R.inset, kp.join(" / ") + " (" + kind + " wants " + want + ")", insetOk);
|
|
281
281
|
put(R.act, "inset " + px(g) + " . " + px(r.width - g * 2) + " wide");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "The framework-free heart of the persona shell — the load-bearing behaviour (auth capture, reveal, ready) as plain strings, so Astro and Next inject the SAME logic instead of each re-writing it.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|