@justai/core 0.28.0 → 0.30.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/package.json +2 -2
- package/src/index.js +104 -65
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justai/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The framework-free heart of the persona shell
|
|
3
|
+
"version": "0.30.0",
|
|
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": {
|
|
7
7
|
"type": "git",
|
package/src/index.js
CHANGED
|
@@ -693,10 +693,39 @@ export function personaScroll(options) {
|
|
|
693
693
|
// row, and a landing offset that was right at load is a kernel under the bar afterwards.
|
|
694
694
|
const measureShell = () => {
|
|
695
695
|
if (!toolbar) return;
|
|
696
|
-
const app = toolbar.closest(".app") || document.querySelector(".app");
|
|
697
|
-
if (!app) return;
|
|
698
696
|
const h = Math.ceil(toolbar.getBoundingClientRect().height);
|
|
699
|
-
|
|
697
|
+
// ON THE ROOT, because the kernel's `scroll-margin-top` reads it and THE BROWSER reads that when
|
|
698
|
+
// it scrolls to the fragment on its own. Written on `.app` this reached the kernel only when the
|
|
699
|
+
// kernel happened to sit inside one, and a surface where it did not is a surface where the
|
|
700
|
+
// browser's landing and the script's disagree — which is the whole bug this measurement exists
|
|
701
|
+
// to prevent. The root is the one element every consumer is inside.
|
|
702
|
+
if (h <= 0) return;
|
|
703
|
+
document.documentElement.style.setProperty("--shell-top", h + "px");
|
|
704
|
+
// queries: a persona overrides the landing offset · scroll-margin-top 82px in my own component ·
|
|
705
|
+
// the page lands 30px short · duplicate landing offset · my persona has its own #kernel
|
|
706
|
+
// rule · the framework does not reach my css
|
|
707
|
+
//
|
|
708
|
+
// AND ENFORCED, NOT MERELY DECLARED.
|
|
709
|
+
//
|
|
710
|
+
// The framework exists so that a number like this lives in ONE place. It cannot: CSS has no way
|
|
711
|
+
// to refuse an override, and on 2026-08-06 EIGHT personas — both apexes and justai.pro among them
|
|
712
|
+
// — still carried `#kernel { scroll-margin-top: 82px }` from before the shell was shared, a
|
|
713
|
+
// constant that stopped being true the day the secondary title strip was removed. Every one of
|
|
714
|
+
// them lands the page by measurement and is then overruled by the browser's own scroll to the
|
|
715
|
+
// fragment, which reads the persona's stale copy. Thirty pixels, on every bare load.
|
|
716
|
+
//
|
|
717
|
+
// Deleting the eight copies is the honest fix and it is being done. This is what makes the ninth
|
|
718
|
+
// impossible: whoever measures the bar owns what clearing it means, so a section that says it
|
|
719
|
+
// clears the bar clears it by the bar — inline, which outranks any stylesheet. A section that
|
|
720
|
+
// asks for NO offset is left alone; it is not claiming to clear anything.
|
|
721
|
+
for (const [sec] of cuts) {
|
|
722
|
+
const declared = parseFloat(getComputedStyle(sec).scrollMarginTop) || 0;
|
|
723
|
+
if (declared > 0 && Math.abs(declared - h) > 0.5) {
|
|
724
|
+
sec.style.scrollMarginTop = h + "px";
|
|
725
|
+
// Said out loud, because a healed page is a page nobody goes and fixes.
|
|
726
|
+
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.");
|
|
727
|
+
}
|
|
728
|
+
}
|
|
700
729
|
};
|
|
701
730
|
measureShell();
|
|
702
731
|
addEventListener("resize", measureShell, { passive: true });
|
|
@@ -810,71 +839,70 @@ export function personaScroll(options) {
|
|
|
810
839
|
// queries: the page did not land on the kernel · landing scroll ignored · scrollTo does nothing on
|
|
811
840
|
// first paint · the page opens at the top sometimes
|
|
812
841
|
//
|
|
813
|
-
// LANDED, OR TRIED AGAIN —
|
|
842
|
+
// LANDED, OR TRIED AGAIN — but only for the one case where a scroll is REFUSED.
|
|
814
843
|
//
|
|
815
844
|
// `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.
|
|
845
|
+
// whose sections size themselves a frame later, the landing is CALLED, the browser declines it, and
|
|
846
|
+
// the page opens at the top with nothing anywhere saying so. Measured in this behaviour's own
|
|
847
|
+
// fixture: `scrollTo({top: 548})` followed by a scroll event reading 0. So it is attempted again on
|
|
848
|
+
// the next frame, on `load`, and once more when the page comes to rest.
|
|
849
|
+
//
|
|
850
|
+
// ── WHAT USED TO BE HERE, AND WHY IT IS NOT ────────────────────────────────────────────────
|
|
819
851
|
//
|
|
820
|
-
//
|
|
821
|
-
//
|
|
822
|
-
//
|
|
852
|
+
// A second, much larger mechanism: a landing that ARRIVED and then DRIFTED, held as a promise until
|
|
853
|
+
// a wheel, a finger or a key "took over", with a tolerance derived from the toolbar's own height.
|
|
854
|
+
// Its trace, recorded in this file:
|
|
823
855
|
//
|
|
824
856
|
// scrollTo(468) y = 468 the landing is exact
|
|
825
857
|
// DOMContentLoaded y = 494 docH +26 — the title strip opened
|
|
826
858
|
// settled y = 465 docH -26 — and the strip closed again
|
|
827
859
|
//
|
|
828
|
-
//
|
|
829
|
-
// browser
|
|
830
|
-
// pixels short of where the kernel
|
|
831
|
-
//
|
|
860
|
+
// Every term of it was the secondary strip. It sat above the kernel inside the sticky bar, so each
|
|
861
|
+
// time it opened or closed the browser moved the scroll position to keep the content under it
|
|
862
|
+
// steady, and the page came to rest three pixels short of where the kernel began — close enough to
|
|
863
|
+
// look landed, far enough that the spy answered "profile", which closed the strip, which is what
|
|
864
|
+
// moved it. The founder removed the strip on 2026-08-06, and this went with it: measured after, the
|
|
865
|
+
// page scrolls exactly ONCE to its landing and never moves again, at 402x710 and at 1440x900.
|
|
832
866
|
//
|
|
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.
|
|
867
|
+
// A workaround outlives its cause silently. This one would have kept re-asserting a landing nobody
|
|
868
|
+
// needed, over a drift that can no longer happen, for as long as the file existed.
|
|
869
|
+
// Only the DESTINATION is released when somebody takes over, never the landing: a tap on a cut
|
|
870
|
+
// shows where the page is GOING, and nobody should be shown a destination they have abandoned.
|
|
871
|
+
// The landing itself no longer needs protecting — there is no drift left for it to be protected
|
|
872
|
+
// from, which is the whole point of the note above.
|
|
873
|
+
const takeOver = () => { navTo = null; };
|
|
841
874
|
for (const ev of ["wheel", "touchmove", "keydown"]) window.addEventListener(ev, takeOver, { passive: true });
|
|
875
|
+
|
|
842
876
|
land();
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
if (
|
|
865
|
-
|
|
866
|
-
|
|
877
|
+
|
|
878
|
+
// A CLICK CLOSES THIS ONE, AND THAT IS THE DIFFERENCE FROM WHAT WAS HERE BEFORE. The old promise
|
|
879
|
+
// deliberately survived clicks, because a tap on a cut is a request for a landing rather than an
|
|
880
|
+
// override — but that promise existed to repair the strip's drift, and it could tell the two apart
|
|
881
|
+
// because it only ever corrected by less than a toolbar's height. This one has no such tolerance:
|
|
882
|
+
// it can only distinguish "the browser refused the scroll" from "the page is somewhere on purpose",
|
|
883
|
+
// and after a tap those look identical. Caught by the row's own spec: clicking Profile rested the
|
|
884
|
+
// page at 0, this read it as a refusal, and pulled it back to the kernel.
|
|
885
|
+
let landed = false;
|
|
886
|
+
const settle = () => { landed = true; };
|
|
887
|
+
for (const ev of ["wheel", "touchmove", "keydown", "click"]) {
|
|
888
|
+
window.addEventListener(ev, settle, { passive: true, once: true });
|
|
889
|
+
}
|
|
890
|
+
// The landing is attempted again when the page comes to rest, because `scrollTo` past a document
|
|
891
|
+
// that has not sized itself yet is a silent no-op — cause 1, and the only cause left here. The
|
|
892
|
+
// drift this used to repair as well was the secondary title strip moving the page after it landed,
|
|
893
|
+
// and the strip is gone; the thirty-pixel glide that looked like drift afterwards was not one
|
|
894
|
+
// either — it was the browser scrolling to the fragment with a number the persona still owned, and
|
|
895
|
+
// that is fixed where the number lives rather than chased from here. A repair that re-asserts
|
|
896
|
+
// against ANY movement fights a page that scrolls itself, which is a workaround growing back.
|
|
897
|
+
const landIfRefused = () => {
|
|
898
|
+
if (landed) return;
|
|
899
|
+
// Anywhere but the very top means the scroll was accepted. A landing that IS the top has nothing
|
|
900
|
+
// to be refused about. Either way this is the last thing it ever does.
|
|
901
|
+
if (window.scrollY > 1 || landingY(sentTo) <= 1) { landed = true; return; }
|
|
902
|
+
land();
|
|
867
903
|
};
|
|
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.
|
|
904
|
+
requestAnimationFrame(landIfRefused);
|
|
905
|
+
window.addEventListener("load", landIfRefused);
|
|
878
906
|
|
|
879
907
|
|
|
880
908
|
// The reveal rides with this on pages whose content is ready at first paint. A page that renders
|
|
@@ -926,7 +954,7 @@ export function personaScroll(options) {
|
|
|
926
954
|
let current = cuts[0];
|
|
927
955
|
for (const c of cuts) if (landingY(c[0]) <= y) current = c;
|
|
928
956
|
if (navTo) {
|
|
929
|
-
if (current === navTo
|
|
957
|
+
if (current === navTo) navTo = null;
|
|
930
958
|
else current = navTo;
|
|
931
959
|
}
|
|
932
960
|
for (const c of cuts) c[1].classList.toggle("active", c === current);
|
|
@@ -969,10 +997,10 @@ export function personaScroll(options) {
|
|
|
969
997
|
lastY = y;
|
|
970
998
|
measure();
|
|
971
999
|
if (moved) schedule();
|
|
972
|
-
// The page has stopped. If
|
|
973
|
-
//
|
|
974
|
-
// the
|
|
975
|
-
else
|
|
1000
|
+
// The page has stopped. If the landing was refused because the document had not sized itself
|
|
1001
|
+
// yet, this is the last chance to notice — and it is the ONLY thing left here: the drift this
|
|
1002
|
+
// used to repair was the secondary strip moving the page, and the strip is gone.
|
|
1003
|
+
else landIfRefused();
|
|
976
1004
|
};
|
|
977
1005
|
const schedule = () => { if (!queued) { queued = true; requestAnimationFrame(frame); } };
|
|
978
1006
|
window.addEventListener("scroll", schedule, { passive: true });
|
|
@@ -1010,9 +1038,20 @@ export function personaScroll(options) {
|
|
|
1010
1038
|
// The icon answers the tap NOW, not when the scroll lands. `navTo` keeps it answered for the trip.
|
|
1011
1039
|
navTo = t;
|
|
1012
1040
|
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1013
|
-
//
|
|
1014
|
-
//
|
|
1015
|
-
landed = false
|
|
1041
|
+
// queries: clicking profile throws me back to the kernel · the second cycle · landed re-armed
|
|
1042
|
+
//
|
|
1043
|
+
// ** NOTHING IS RE-ARMED HERE, AND THAT LINE COST AN HOUR. ** This used to set `landed = false`,
|
|
1044
|
+
// which was right while `landed` meant "the landing promise is open": a tap on a cut IS a request
|
|
1045
|
+
// for a landing, so the drift repair was re-armed to protect the new one. That promise is gone —
|
|
1046
|
+
// `landed` now means only "the initial scroll was accepted, stop retrying it" — and re-arming it
|
|
1047
|
+
// told the retry that the page had never landed. The tap scrolls to the profile, the page comes
|
|
1048
|
+
// to rest at 0, the retry reads `scrollY <= 1` with a landing of 376, calls it a refusal and
|
|
1049
|
+
// pulls the person back to the kernel.
|
|
1050
|
+
//
|
|
1051
|
+
// It survived the first cycle by luck: the same click also tripped the `once` listener that sets
|
|
1052
|
+
// `landed = true`, in the later bubble phase, so the flag ended true anyway. The listener is
|
|
1053
|
+
// spent after that, and from the SECOND tap onward the page snapped back every time — which is
|
|
1054
|
+
// exactly how the founder found it: "profile · kernel · profile · kernel … 2. cycle'da başlıyor."
|
|
1016
1055
|
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1017
1056
|
setHash(t[0].id);
|
|
1018
1057
|
});
|
|
@@ -1024,7 +1063,7 @@ export function personaScroll(options) {
|
|
|
1024
1063
|
if (t) {
|
|
1025
1064
|
navTo = t;
|
|
1026
1065
|
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1027
|
-
|
|
1066
|
+
// Nor here — same reason as the click above.
|
|
1028
1067
|
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1029
1068
|
}
|
|
1030
1069
|
});
|