@justai/core 0.29.1 → 0.32.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 +146 -25
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.32.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
|
@@ -668,6 +668,11 @@ export function personaScroll(options) {
|
|
|
668
668
|
if (!below || !kernel) return;
|
|
669
669
|
|
|
670
670
|
const toolbar = typeof o.toolbar === "string" ? document.querySelector(o.toolbar) : o.toolbar || document.querySelector(".toolbar");
|
|
671
|
+
const tbTitle = el(o.title || "tbTitle");
|
|
672
|
+
const tbTitleText =
|
|
673
|
+
(typeof o.titleText === "string" ? document.getElementById(o.titleText) : o.titleText) ||
|
|
674
|
+
document.getElementById("tbTitleText") ||
|
|
675
|
+
(tbTitle && tbTitle.querySelector(".tb-title-text"));
|
|
671
676
|
|
|
672
677
|
// A cut is a section AND the nav that points at it; anything missing either half is simply not one.
|
|
673
678
|
// That is how a page with extra toolbar links — /me's vault, /files' host link — needs no
|
|
@@ -677,26 +682,98 @@ export function personaScroll(options) {
|
|
|
677
682
|
.filter((c) => c[0] && c[1]);
|
|
678
683
|
if (!cuts.length) return;
|
|
679
684
|
|
|
680
|
-
// queries: --shell-top ·
|
|
681
|
-
// the kernel is
|
|
685
|
+
// queries: --shell-top · the kernel is 26px short · the game frame does not reach the fold ·
|
|
686
|
+
// a strip of posts shows above the fold · opening at #kernel is different from #profile ·
|
|
687
|
+
// the toolbar changes height · title strip · the layout depends on when it was measured
|
|
682
688
|
//
|
|
683
|
-
//
|
|
684
|
-
// strip on 2026-08-06 and with it the whole reason this number was ever hard: nothing above the
|
|
685
|
-
// kernel changes size any more, so there is no animation to avoid sampling and no "which state?"
|
|
686
|
-
// to answer. It is the bar, measured.
|
|
689
|
+
// ── NEVER SAMPLE AN ANIMATION AND CALL IT A LAYOUT ─────────────────────────────────────────
|
|
687
690
|
//
|
|
688
|
-
//
|
|
689
|
-
//
|
|
690
|
-
// whose height is exact.
|
|
691
|
+
// `--shell-top` is what the shell takes above the kernel, and everything downstream reads it: the
|
|
692
|
+
// landing offset, an app kernel's minimum height, a game kernel's exact one.
|
|
691
693
|
//
|
|
692
|
-
//
|
|
693
|
-
//
|
|
694
|
+
// It was the literal `82` for a long time and that was stable and slightly wrong. Reading the
|
|
695
|
+
// toolbar's height instead made it exact and UNSTABLE, which is far worse: the row carries a title
|
|
696
|
+
// strip that opens and closes over 0.35s, so its height is anywhere in a 26px range depending on
|
|
697
|
+
// the instant somebody looked. Measured on tpl-sunshine at 1864x999, the same persona, same build:
|
|
698
|
+
//
|
|
699
|
+
// opened at #profile strip shut when measured shell-top 80 frame 919 reaches the fold
|
|
700
|
+
// opened at #kernel strip open when measured shell-top 106 frame 893 33px SHORT
|
|
701
|
+
//
|
|
702
|
+
// and the second is what a visitor gets, because a game persona lands on its kernel. Thirty-three
|
|
703
|
+
// pixels of the next section showing above the fold, and the "correct" case was correct by
|
|
704
|
+
// coincidence — a shut row plus a gutter happened to equal an open one.
|
|
705
|
+
//
|
|
706
|
+
// THE FIX IS NOT A BETTER MOMENT TO MEASURE, IT IS NOT MEASURING THE MOVING PART. The row minus the
|
|
707
|
+
// strip is the row, and it is the same number at every frame of the transition; the strip's OPEN
|
|
708
|
+
// height is `--tb-strip`, which the Toolbar cut declares beside the rule that uses it. Their sum is
|
|
709
|
+
// what the bar is whenever anybody is looking at the kernel — which is the only time this number
|
|
710
|
+
// decides anything.
|
|
711
|
+
//
|
|
712
|
+
// AND NO GUTTER IS ADDED. The frame is the active view, so it begins where the shell ends; the air
|
|
713
|
+
// an app keeps under the bar is its own padding, and adding a gutter here would spend it twice.
|
|
714
|
+
//
|
|
715
|
+
// Re-measured on resize because a rotation, a narrowing past 640 and a reader's text size all
|
|
716
|
+
// change the ROW — none of which is the animation this is written to ignore.
|
|
694
717
|
const measureShell = () => {
|
|
695
718
|
if (!toolbar) return;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
719
|
+
// THE BAR'S EXPANDED HEIGHT, WITHOUT WAITING FOR OR RACING THE STRIP'S 0.35s. The row is the bar
|
|
720
|
+
// minus whatever the strip currently is — the same number at every frame of the transition — and
|
|
721
|
+
// the bar-to-be is that row plus the strip's declared open height. Nothing samples the animation,
|
|
722
|
+
// so nothing depends on when it was sampled.
|
|
723
|
+
//
|
|
724
|
+
// CEIL, NOT ROUND, AND LOAD-BEARING: this is the slot's reserved box as well as the landing
|
|
725
|
+
// offset, so it must never be LESS than the bar's tallest state or the slot starts following the
|
|
726
|
+
// bar again and the 26px returns as a fraction. A bar under Dynamic Type is not an integer —
|
|
727
|
+
// 82.3 is recorded in this file — and rounding down is half a CSS pixel of permanent error.
|
|
728
|
+
const strip = tbTitle ? tbTitle.getBoundingClientRect().height : 0;
|
|
729
|
+
const open = parseFloat(getComputedStyle(toolbar).getPropertyValue("--tb-strip")) || 26;
|
|
730
|
+
const h = Math.ceil(toolbar.getBoundingClientRect().height - strip + open);
|
|
731
|
+
// ON THE ROOT, because the kernel's `scroll-margin-top` reads it and THE BROWSER reads that when
|
|
732
|
+
// it scrolls to the fragment on its own. Written on `.app` this reached the kernel only when the
|
|
733
|
+
// kernel happened to sit inside one, and a surface where it did not is a surface where the
|
|
734
|
+
// browser's landing and the script's disagree — which is the whole bug this measurement exists
|
|
735
|
+
// to prevent. The root is the one element every consumer is inside.
|
|
736
|
+
if (h <= 0) return;
|
|
737
|
+
document.documentElement.style.setProperty("--shell-top", h + "px");
|
|
738
|
+
// queries: a persona overrides the landing offset · scroll-margin-top 82px in my own component ·
|
|
739
|
+
// the page lands 30px short · duplicate landing offset · my persona has its own #kernel
|
|
740
|
+
// rule · the framework does not reach my css
|
|
741
|
+
//
|
|
742
|
+
// AND ENFORCED, NOT MERELY DECLARED.
|
|
743
|
+
//
|
|
744
|
+
// The framework exists so that a number like this lives in ONE place. It cannot: CSS has no way
|
|
745
|
+
// to refuse an override, and on 2026-08-06 EIGHT personas — both apexes and justai.pro among them
|
|
746
|
+
// — still carried `#kernel { scroll-margin-top: 82px }` from before the shell was shared, a
|
|
747
|
+
// constant that stopped being true the day the secondary title strip was removed. Every one of
|
|
748
|
+
// them lands the page by measurement and is then overruled by the browser's own scroll to the
|
|
749
|
+
// fragment, which reads the persona's stale copy. Thirty pixels, on every bare load.
|
|
750
|
+
//
|
|
751
|
+
// Deleting the eight copies is the honest fix and it is being done. This is what makes the ninth
|
|
752
|
+
// impossible: whoever measures the bar owns what clearing it means, so EVERY CUT BELOW THE FIRST
|
|
753
|
+
// clears it by exactly the bar — written inline, which outranks any stylesheet.
|
|
754
|
+
//
|
|
755
|
+
// NOT "every cut that already declares an offset". That was the first version of this rule and it
|
|
756
|
+
// was too polite by one case: it read a zero as *"this section is not claiming to clear
|
|
757
|
+
// anything"*, and a persona that never loads `@justai/ui`'s base.css at all has exactly that
|
|
758
|
+
// zero. Measured on pin.games the moment its local `82px` was deleted — the offset fell to 0, the
|
|
759
|
+
// browser's own scroll put the kernel's top at the viewport top, and the persona's first line sat
|
|
760
|
+
// UNDER the sticky bar. Not landing short any more; landing under. Same bug, other direction.
|
|
761
|
+
//
|
|
762
|
+
// So it does not matter what the persona's CSS says or whether it loaded ours: a sticky bar is
|
|
763
|
+
// above every cut but the first, and the first is the top of the page with nothing to clear.
|
|
764
|
+
// The warning is only for a persona that declared a DIFFERENT number — that one has a stale rule
|
|
765
|
+
// to go and delete. A zero is just a surface that never had the stylesheet, and healing it
|
|
766
|
+
// silently is the whole point of the framework owning this.
|
|
767
|
+
cuts.forEach(([sec], i) => {
|
|
768
|
+
if (i === 0) return;
|
|
769
|
+
const declared = parseFloat(getComputedStyle(sec).scrollMarginTop) || 0;
|
|
770
|
+
if (Math.abs(declared - h) <= 0.5) return;
|
|
771
|
+
sec.style.scrollMarginTop = h + "px";
|
|
772
|
+
if (declared > 0) {
|
|
773
|
+
// Said out loud, because a healed page is a page nobody goes and fixes.
|
|
774
|
+
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.");
|
|
775
|
+
}
|
|
776
|
+
});
|
|
700
777
|
};
|
|
701
778
|
measureShell();
|
|
702
779
|
addEventListener("resize", measureShell, { passive: true });
|
|
@@ -858,6 +935,13 @@ export function personaScroll(options) {
|
|
|
858
935
|
for (const ev of ["wheel", "touchmove", "keydown", "click"]) {
|
|
859
936
|
window.addEventListener(ev, settle, { passive: true, once: true });
|
|
860
937
|
}
|
|
938
|
+
// The landing is attempted again when the page comes to rest, because `scrollTo` past a document
|
|
939
|
+
// that has not sized itself yet is a silent no-op — cause 1, and the only cause left here. The
|
|
940
|
+
// drift this used to repair as well was the secondary title strip moving the page after it landed,
|
|
941
|
+
// and the strip is gone; the thirty-pixel glide that looked like drift afterwards was not one
|
|
942
|
+
// either — it was the browser scrolling to the fragment with a number the persona still owned, and
|
|
943
|
+
// that is fixed where the number lives rather than chased from here. A repair that re-asserts
|
|
944
|
+
// against ANY movement fights a page that scrolls itself, which is a workaround growing back.
|
|
861
945
|
const landIfRefused = () => {
|
|
862
946
|
if (landed) return;
|
|
863
947
|
// Anywhere but the very top means the scroll was accepted. A landing that IS the top has nothing
|
|
@@ -881,19 +965,50 @@ export function personaScroll(options) {
|
|
|
881
965
|
const text = (sel) => (document.querySelector(sel)?.textContent || "").trim();
|
|
882
966
|
// Kernel names the persona, Posts names its handle, Profile stays collapsed — its big header IS
|
|
883
967
|
// the title, and repeating it in the bar above would say the same thing twice.
|
|
884
|
-
|
|
885
|
-
|
|
968
|
+
const titleFor =
|
|
969
|
+
o.titleFor ||
|
|
970
|
+
((id) => (id === "kernel" ? text(".pname") : id === "posts" ? text(".handle") : ""));
|
|
971
|
+
|
|
972
|
+
// queries: the title strip jumps · the page jolts after tapping a cut · content shifts while
|
|
973
|
+
// scrolling · toolbar title animation causes a layout shift · landing lands 26px off ·
|
|
974
|
+
// landingAfterStrip · why is there no strip compensation any more · tb-slot min-height
|
|
886
975
|
//
|
|
887
|
-
//
|
|
976
|
+
// ── THERE IS NOTHING LEFT TO COMPENSATE FOR, AND THAT IS THE WHOLE POINT OF THE SLOT ──────────
|
|
888
977
|
//
|
|
889
|
-
//
|
|
890
|
-
//
|
|
891
|
-
//
|
|
892
|
-
//
|
|
893
|
-
//
|
|
978
|
+
// Two functions used to live here: one probed the strip's open height before it opened, the other
|
|
979
|
+
// aimed a scroll at where the page WOULD rest once the strip had finished moving. They existed
|
|
980
|
+
// because the strip was in flow above every section, so opening it pushed the whole page down by
|
|
981
|
+
// its own 26px and a landing computed before it opened was wrong by exactly that much. A person
|
|
982
|
+
// felt it as three motions for one tap.
|
|
894
983
|
//
|
|
895
|
-
//
|
|
896
|
-
//
|
|
984
|
+
// `.tb-slot` ends that at the source: the SLOT is what flow sees and its box is `--shell-top`, a
|
|
985
|
+
// constant; the BAR is static inside it and may be any height it likes. Opening the strip moves
|
|
986
|
+
// nothing outside the slot, so a landing computed before it opens is simply correct.
|
|
987
|
+
//
|
|
988
|
+
// The compensation is therefore not merely dead — it would be WRONG, adding a strip's height to
|
|
989
|
+
// the posts landing for a shift that no longer happens. When the strip came back on 2026-08-06 the
|
|
990
|
+
// reserved box came back with it FOR EVERY KIND, not only for games, and these two went for good.
|
|
991
|
+
// If they are ever missed, the thing to check is whether the slot still reserves its box.
|
|
992
|
+
const setStrip = (id, animate) => {
|
|
993
|
+
if (!tbTitle) return;
|
|
994
|
+
const t = titleFor(id);
|
|
995
|
+
if (animate) {
|
|
996
|
+
tbTitle.classList.toggle("show", !!t);
|
|
997
|
+
if (t && tbTitleText && tbTitleText.textContent !== t) {
|
|
998
|
+
tbTitleText.classList.add("fade");
|
|
999
|
+
setTimeout(() => { tbTitleText.textContent = t; tbTitleText.classList.remove("fade"); }, 150);
|
|
1000
|
+
}
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
// Instant: the height must be final before this function returns, so the caller can measure. The
|
|
1004
|
+
// text goes with it — a settled height showing the previous words would be its own small lie.
|
|
1005
|
+
tbTitle.style.transition = "none";
|
|
1006
|
+
tbTitle.classList.toggle("show", !!t);
|
|
1007
|
+
if (t && tbTitleText) { tbTitleText.classList.remove("fade"); tbTitleText.textContent = t; }
|
|
1008
|
+
void tbTitle.offsetHeight;
|
|
1009
|
+
tbTitle.style.transition = "";
|
|
1010
|
+
};
|
|
1011
|
+
|
|
897
1012
|
let lastCut = null;
|
|
898
1013
|
let first = true;
|
|
899
1014
|
// queries: the toolbar icon changes late · nav icon lags the tap · active state waits for the scroll
|
|
@@ -930,6 +1045,7 @@ export function personaScroll(options) {
|
|
|
930
1045
|
// it arrives. Animating it in tells a person something changed when nothing did.
|
|
931
1046
|
const wasFirst = first;
|
|
932
1047
|
first = false;
|
|
1048
|
+
setStrip(current[0].id, !wasFirst);
|
|
933
1049
|
};
|
|
934
1050
|
// queries: scroll janks while the toolbar updates · scroll handler runs too often · the spy reads a
|
|
935
1051
|
// stale position · the section is right but the toolbar is one behind · scrollend
|
|
@@ -1016,6 +1132,10 @@ export function personaScroll(options) {
|
|
|
1016
1132
|
// `landed = true`, in the later bubble phase, so the flag ended true anyway. The listener is
|
|
1017
1133
|
// spent after that, and from the SECOND tap onward the page snapped back every time — which is
|
|
1018
1134
|
// exactly how the founder found it: "profile · kernel · profile · kernel … 2. cycle'da başlıyor."
|
|
1135
|
+
//
|
|
1136
|
+
// The strip still follows the tap — it is the row saying which cut you are on, which is the one
|
|
1137
|
+
// thing about it the founder said he could not give up.
|
|
1138
|
+
setStrip(t[0].id, true);
|
|
1019
1139
|
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1020
1140
|
setHash(t[0].id);
|
|
1021
1141
|
});
|
|
@@ -1028,6 +1148,7 @@ export function personaScroll(options) {
|
|
|
1028
1148
|
navTo = t;
|
|
1029
1149
|
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1030
1150
|
// Nor here — same reason as the click above.
|
|
1151
|
+
setStrip(t[0].id, true);
|
|
1031
1152
|
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1032
1153
|
}
|
|
1033
1154
|
});
|