@justai/core 0.28.0 → 0.29.1
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/package.json +1 -1
- package/src/index.js +65 -62
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"description": "The framework-free heart of the persona shell \u2014 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": {
|
package/src/index.js
CHANGED
|
@@ -810,71 +810,63 @@ export function personaScroll(options) {
|
|
|
810
810
|
// queries: the page did not land on the kernel · landing scroll ignored · scrollTo does nothing on
|
|
811
811
|
// first paint · the page opens at the top sometimes
|
|
812
812
|
//
|
|
813
|
-
// LANDED, OR TRIED AGAIN —
|
|
813
|
+
// LANDED, OR TRIED AGAIN — but only for the one case where a scroll is REFUSED.
|
|
814
814
|
//
|
|
815
815
|
// `scrollTo` past the current document height is a no-op, and it does not report one: on a page
|
|
816
|
-
// whose sections size themselves a frame later, the landing is CALLED, the browser declines it,
|
|
817
|
-
//
|
|
818
|
-
// fixture: `scrollTo({top: 548})` followed by a scroll event reading 0.
|
|
816
|
+
// whose sections size themselves a frame later, the landing is CALLED, the browser declines it, and
|
|
817
|
+
// the page opens at the top with nothing anywhere saying so. Measured in this behaviour's own
|
|
818
|
+
// fixture: `scrollTo({top: 548})` followed by a scroll event reading 0. So it is attempted again on
|
|
819
|
+
// the next frame, on `load`, and once more when the page comes to rest.
|
|
819
820
|
//
|
|
820
|
-
//
|
|
821
|
-
//
|
|
822
|
-
//
|
|
821
|
+
// ── WHAT USED TO BE HERE, AND WHY IT IS NOT ────────────────────────────────────────────────
|
|
822
|
+
//
|
|
823
|
+
// A second, much larger mechanism: a landing that ARRIVED and then DRIFTED, held as a promise until
|
|
824
|
+
// a wheel, a finger or a key "took over", with a tolerance derived from the toolbar's own height.
|
|
825
|
+
// Its trace, recorded in this file:
|
|
823
826
|
//
|
|
824
827
|
// scrollTo(468) y = 468 the landing is exact
|
|
825
828
|
// DOMContentLoaded y = 494 docH +26 — the title strip opened
|
|
826
829
|
// settled y = 465 docH -26 — and the strip closed again
|
|
827
830
|
//
|
|
828
|
-
//
|
|
829
|
-
// browser
|
|
830
|
-
// pixels short of where the kernel
|
|
831
|
-
//
|
|
831
|
+
// Every term of it was the secondary strip. It sat above the kernel inside the sticky bar, so each
|
|
832
|
+
// time it opened or closed the browser moved the scroll position to keep the content under it
|
|
833
|
+
// steady, and the page came to rest three pixels short of where the kernel began — close enough to
|
|
834
|
+
// look landed, far enough that the spy answered "profile", which closed the strip, which is what
|
|
835
|
+
// moved it. The founder removed the strip on 2026-08-06, and this went with it: measured after, the
|
|
836
|
+
// page scrolls exactly ONCE to its landing and never moves again, at 402x710 and at 1440x900.
|
|
832
837
|
//
|
|
833
|
-
// A
|
|
834
|
-
//
|
|
835
|
-
//
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
// not on this list — pressing a link to a cut is asking for a landing, not overriding one.
|
|
838
|
+
// A workaround outlives its cause silently. This one would have kept re-asserting a landing nobody
|
|
839
|
+
// needed, over a drift that can no longer happen, for as long as the file existed.
|
|
840
|
+
// Only the DESTINATION is released when somebody takes over, never the landing: a tap on a cut
|
|
841
|
+
// shows where the page is GOING, and nobody should be shown a destination they have abandoned.
|
|
842
|
+
// The landing itself no longer needs protecting — there is no drift left for it to be protected
|
|
843
|
+
// from, which is the whole point of the note above.
|
|
844
|
+
const takeOver = () => { navTo = null; };
|
|
841
845
|
for (const ev of ["wheel", "touchmove", "keydown"]) window.addEventListener(ev, takeOver, { passive: true });
|
|
846
|
+
|
|
842
847
|
land();
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
//
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
// back to the profile while the kernel fills the screen. The promise ends when somebody takes
|
|
863
|
-
// over, or when the page is moved somewhere it was plainly never sent.
|
|
864
|
-
if (off <= 1) return;
|
|
865
|
-
if (off <= drift) land();
|
|
866
|
-
else landed = true;
|
|
848
|
+
|
|
849
|
+
// A CLICK CLOSES THIS ONE, AND THAT IS THE DIFFERENCE FROM WHAT WAS HERE BEFORE. The old promise
|
|
850
|
+
// deliberately survived clicks, because a tap on a cut is a request for a landing rather than an
|
|
851
|
+
// override — but that promise existed to repair the strip's drift, and it could tell the two apart
|
|
852
|
+
// because it only ever corrected by less than a toolbar's height. This one has no such tolerance:
|
|
853
|
+
// it can only distinguish "the browser refused the scroll" from "the page is somewhere on purpose",
|
|
854
|
+
// and after a tap those look identical. Caught by the row's own spec: clicking Profile rested the
|
|
855
|
+
// page at 0, this read it as a refusal, and pulled it back to the kernel.
|
|
856
|
+
let landed = false;
|
|
857
|
+
const settle = () => { landed = true; };
|
|
858
|
+
for (const ev of ["wheel", "touchmove", "keydown", "click"]) {
|
|
859
|
+
window.addEventListener(ev, settle, { passive: true, once: true });
|
|
860
|
+
}
|
|
861
|
+
const landIfRefused = () => {
|
|
862
|
+
if (landed) return;
|
|
863
|
+
// Anywhere but the very top means the scroll was accepted. A landing that IS the top has nothing
|
|
864
|
+
// to be refused about. Either way this is the last thing it ever does.
|
|
865
|
+
if (window.scrollY > 1 || landingY(sentTo) <= 1) { landed = true; return; }
|
|
866
|
+
land();
|
|
867
867
|
};
|
|
868
|
-
requestAnimationFrame(
|
|
869
|
-
window.addEventListener("load",
|
|
870
|
-
// queries: the landing is repaired too early · load fires before the strip settles · ResizeObserver
|
|
871
|
-
//
|
|
872
|
-
// AND WHEN THE THING THAT CAUSES THE DRIFT MOVES. rAF and `load` are two moments, and the drift is
|
|
873
|
-
// an event: the toolbar changes height, everything under it shifts, and the page comes to rest
|
|
874
|
-
// somewhere new. On the trace above `load` happened to fire after that; on a faster page it fires
|
|
875
|
-
// before, and then there is nothing left to notice. Watching the toolbar is watching the cause —
|
|
876
|
-
// and it costs nothing after the promise closes, because `landIfUntouched` returns on its first
|
|
877
|
-
// line once somebody has taken over or the page has plainly been moved elsewhere.
|
|
868
|
+
requestAnimationFrame(landIfRefused);
|
|
869
|
+
window.addEventListener("load", landIfRefused);
|
|
878
870
|
|
|
879
871
|
|
|
880
872
|
// The reveal rides with this on pages whose content is ready at first paint. A page that renders
|
|
@@ -926,7 +918,7 @@ export function personaScroll(options) {
|
|
|
926
918
|
let current = cuts[0];
|
|
927
919
|
for (const c of cuts) if (landingY(c[0]) <= y) current = c;
|
|
928
920
|
if (navTo) {
|
|
929
|
-
if (current === navTo
|
|
921
|
+
if (current === navTo) navTo = null;
|
|
930
922
|
else current = navTo;
|
|
931
923
|
}
|
|
932
924
|
for (const c of cuts) c[1].classList.toggle("active", c === current);
|
|
@@ -969,10 +961,10 @@ export function personaScroll(options) {
|
|
|
969
961
|
lastY = y;
|
|
970
962
|
measure();
|
|
971
963
|
if (moved) schedule();
|
|
972
|
-
// The page has stopped. If
|
|
973
|
-
//
|
|
974
|
-
// the
|
|
975
|
-
else
|
|
964
|
+
// The page has stopped. If the landing was refused because the document had not sized itself
|
|
965
|
+
// yet, this is the last chance to notice — and it is the ONLY thing left here: the drift this
|
|
966
|
+
// used to repair was the secondary strip moving the page, and the strip is gone.
|
|
967
|
+
else landIfRefused();
|
|
976
968
|
};
|
|
977
969
|
const schedule = () => { if (!queued) { queued = true; requestAnimationFrame(frame); } };
|
|
978
970
|
window.addEventListener("scroll", schedule, { passive: true });
|
|
@@ -1010,9 +1002,20 @@ export function personaScroll(options) {
|
|
|
1010
1002
|
// The icon answers the tap NOW, not when the scroll lands. `navTo` keeps it answered for the trip.
|
|
1011
1003
|
navTo = t;
|
|
1012
1004
|
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1013
|
-
//
|
|
1014
|
-
//
|
|
1015
|
-
landed = false
|
|
1005
|
+
// queries: clicking profile throws me back to the kernel · the second cycle · landed re-armed
|
|
1006
|
+
//
|
|
1007
|
+
// ** NOTHING IS RE-ARMED HERE, AND THAT LINE COST AN HOUR. ** This used to set `landed = false`,
|
|
1008
|
+
// which was right while `landed` meant "the landing promise is open": a tap on a cut IS a request
|
|
1009
|
+
// for a landing, so the drift repair was re-armed to protect the new one. That promise is gone —
|
|
1010
|
+
// `landed` now means only "the initial scroll was accepted, stop retrying it" — and re-arming it
|
|
1011
|
+
// told the retry that the page had never landed. The tap scrolls to the profile, the page comes
|
|
1012
|
+
// to rest at 0, the retry reads `scrollY <= 1` with a landing of 376, calls it a refusal and
|
|
1013
|
+
// pulls the person back to the kernel.
|
|
1014
|
+
//
|
|
1015
|
+
// It survived the first cycle by luck: the same click also tripped the `once` listener that sets
|
|
1016
|
+
// `landed = true`, in the later bubble phase, so the flag ended true anyway. The listener is
|
|
1017
|
+
// spent after that, and from the SECOND tap onward the page snapped back every time — which is
|
|
1018
|
+
// exactly how the founder found it: "profile · kernel · profile · kernel … 2. cycle'da başlıyor."
|
|
1016
1019
|
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1017
1020
|
setHash(t[0].id);
|
|
1018
1021
|
});
|
|
@@ -1024,7 +1027,7 @@ export function personaScroll(options) {
|
|
|
1024
1027
|
if (t) {
|
|
1025
1028
|
navTo = t;
|
|
1026
1029
|
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1027
|
-
|
|
1030
|
+
// Nor here — same reason as the click above.
|
|
1028
1031
|
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1029
1032
|
}
|
|
1030
1033
|
});
|