@justai/core 0.26.0 → 0.28.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 +1 -1
- package/src/index.js +14 -102
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
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
|
@@ -668,11 +668,6 @@ 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"));
|
|
676
671
|
|
|
677
672
|
// A cut is a section AND the nav that points at it; anything missing either half is simply not one.
|
|
678
673
|
// That is how a page with extra toolbar links — /me's vault, /files' host link — needs no
|
|
@@ -682,45 +677,25 @@ export function personaScroll(options) {
|
|
|
682
677
|
.filter((c) => c[0] && c[1]);
|
|
683
678
|
if (!cuts.length) return;
|
|
684
679
|
|
|
685
|
-
// queries: --shell-top ·
|
|
686
|
-
//
|
|
687
|
-
// the toolbar changes height · title strip · the layout depends on when it was measured
|
|
680
|
+
// queries: --shell-top · what does the shell take above the kernel · landing offset ·
|
|
681
|
+
// the kernel is under the toolbar · toolbar height
|
|
688
682
|
//
|
|
689
|
-
//
|
|
683
|
+
// WHAT THE SHELL TAKES ABOVE THE KERNEL. One row, one height — the founder removed the secondary
|
|
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.
|
|
690
687
|
//
|
|
691
|
-
//
|
|
692
|
-
//
|
|
688
|
+
// CEIL, because a bar under iOS Dynamic Type is not an integer — this file has recorded one at
|
|
689
|
+
// 82.3 — and rounding down leaves half a CSS pixel of the next section above the fold on a kernel
|
|
690
|
+
// whose height is exact.
|
|
693
691
|
//
|
|
694
|
-
//
|
|
695
|
-
//
|
|
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.
|
|
692
|
+
// Re-measured on resize: a rotation, a narrowing past 640 and a reader's text size all change the
|
|
693
|
+
// row, and a landing offset that was right at load is a kernel under the bar afterwards.
|
|
717
694
|
const measureShell = () => {
|
|
718
695
|
if (!toolbar) return;
|
|
719
696
|
const app = toolbar.closest(".app") || document.querySelector(".app");
|
|
720
697
|
if (!app) return;
|
|
721
|
-
const
|
|
722
|
-
const open = parseFloat(getComputedStyle(toolbar).getPropertyValue("--tb-strip")) || 26;
|
|
723
|
-
const h = Math.round(toolbar.getBoundingClientRect().height - strip + open);
|
|
698
|
+
const h = Math.ceil(toolbar.getBoundingClientRect().height);
|
|
724
699
|
if (h > 0) app.style.setProperty("--shell-top", h + "px");
|
|
725
700
|
};
|
|
726
701
|
measureShell();
|
|
@@ -914,10 +889,6 @@ export function personaScroll(options) {
|
|
|
914
889
|
const text = (sel) => (document.querySelector(sel)?.textContent || "").trim();
|
|
915
890
|
// Kernel names the persona, Posts names its handle, Profile stays collapsed — its big header IS
|
|
916
891
|
// the title, and repeating it in the bar above would say the same thing twice.
|
|
917
|
-
const titleFor =
|
|
918
|
-
o.titleFor ||
|
|
919
|
-
((id) => (id === "kernel" ? text(".pname") : id === "posts" ? text(".handle") : ""));
|
|
920
|
-
|
|
921
892
|
// queries: the title strip jumps · the page jolts after tapping a cut · content shifts while scrolling
|
|
922
893
|
// · toolbar title animation causes a layout shift · landing lands 26px off
|
|
923
894
|
//
|
|
@@ -931,62 +902,6 @@ export function personaScroll(options) {
|
|
|
931
902
|
//
|
|
932
903
|
// So the write is factored out here and can be applied WITHOUT its transition, which lets a
|
|
933
904
|
// navigation settle the height first and then scroll once, to a target that is already true.
|
|
934
|
-
// queries: strip height before it opens · landing computed against the wrong toolbar height
|
|
935
|
-
//
|
|
936
|
-
// THE STRIP'S OPEN HEIGHT, NEEDED BEFORE IT OPENS. A landing for anything below the strip has to be
|
|
937
|
-
// computed against the height the strip is GOING to have, not the one it has. Probed once and
|
|
938
|
-
// synchronously — added, measured and removed inside a single task — so no paint ever shows it.
|
|
939
|
-
let stripH = 0;
|
|
940
|
-
const stripHeight = () => {
|
|
941
|
-
if (stripH) return stripH;
|
|
942
|
-
if (!tbTitle) return 0;
|
|
943
|
-
if (tbTitle.classList.contains("show")) { stripH = tbTitle.offsetHeight; return stripH; }
|
|
944
|
-
const keep = tbTitle.style.transition;
|
|
945
|
-
tbTitle.style.transition = "none";
|
|
946
|
-
tbTitle.classList.add("show");
|
|
947
|
-
stripH = tbTitle.offsetHeight;
|
|
948
|
-
tbTitle.classList.remove("show");
|
|
949
|
-
void tbTitle.offsetHeight;
|
|
950
|
-
tbTitle.style.transition = keep;
|
|
951
|
-
return stripH;
|
|
952
|
-
};
|
|
953
|
-
|
|
954
|
-
// WHERE THE PAGE WILL REST ONCE THE STRIP HAS FINISHED MOVING — so the scroll can be aimed there
|
|
955
|
-
// while the strip is still on its way, and the two motions arrive together.
|
|
956
|
-
//
|
|
957
|
-
// Only what FOLLOWS the strip is affected. The kernel is anchored to `#below`'s top, which the strip
|
|
958
|
-
// cannot move because it lives inside it; the profile sits above `#below` entirely. Asked of the
|
|
959
|
-
// document rather than assumed, so this stays true if the shell is ever rearranged.
|
|
960
|
-
const landingAfterStrip = (sec, id) => {
|
|
961
|
-
const y = landingY(sec);
|
|
962
|
-
if (!tbTitle || sec === kernel) return y;
|
|
963
|
-
const willShow = !!titleFor(id);
|
|
964
|
-
if (willShow === tbTitle.classList.contains("show")) return y;
|
|
965
|
-
const stripIsAbove = sec.compareDocumentPosition(tbTitle) & Node.DOCUMENT_POSITION_PRECEDING;
|
|
966
|
-
if (!stripIsAbove) return y;
|
|
967
|
-
return y + (willShow ? stripHeight() : -stripHeight());
|
|
968
|
-
};
|
|
969
|
-
|
|
970
|
-
const setStrip = (id, animate) => {
|
|
971
|
-
if (!tbTitle) return;
|
|
972
|
-
const t = titleFor(id);
|
|
973
|
-
if (animate) {
|
|
974
|
-
tbTitle.classList.toggle("show", !!t);
|
|
975
|
-
if (t && tbTitleText && tbTitleText.textContent !== t) {
|
|
976
|
-
tbTitleText.classList.add("fade");
|
|
977
|
-
setTimeout(() => { tbTitleText.textContent = t; tbTitleText.classList.remove("fade"); }, 150);
|
|
978
|
-
}
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
// Instant: the height must be final before this function returns, so the caller can measure. The
|
|
982
|
-
// text goes with it — a settled height showing the previous words would be its own small lie.
|
|
983
|
-
tbTitle.style.transition = "none";
|
|
984
|
-
tbTitle.classList.toggle("show", !!t);
|
|
985
|
-
if (t && tbTitleText) { tbTitleText.classList.remove("fade"); tbTitleText.textContent = t; }
|
|
986
|
-
void tbTitle.offsetHeight;
|
|
987
|
-
tbTitle.style.transition = "";
|
|
988
|
-
};
|
|
989
|
-
|
|
990
905
|
let lastCut = null;
|
|
991
906
|
let first = true;
|
|
992
907
|
// queries: the toolbar icon changes late · nav icon lags the tap · active state waits for the scroll
|
|
@@ -1023,7 +938,6 @@ export function personaScroll(options) {
|
|
|
1023
938
|
// it arrives. Animating it in tells a person something changed when nothing did.
|
|
1024
939
|
const wasFirst = first;
|
|
1025
940
|
first = false;
|
|
1026
|
-
setStrip(current[0].id, !wasFirst);
|
|
1027
941
|
};
|
|
1028
942
|
// queries: scroll janks while the toolbar updates · scroll handler runs too often · the spy reads a
|
|
1029
943
|
// stale position · the section is right but the toolbar is one behind · scrollend
|
|
@@ -1096,11 +1010,10 @@ export function personaScroll(options) {
|
|
|
1096
1010
|
// The icon answers the tap NOW, not when the scroll lands. `navTo` keeps it answered for the trip.
|
|
1097
1011
|
navTo = t;
|
|
1098
1012
|
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1099
|
-
setStrip(t[0].id, true);
|
|
1100
1013
|
// `landed` stays re-armed as a net. If the aim above is ever wrong the old instant repair still
|
|
1101
1014
|
// catches it — a rare snap is a better failure than a landing left in the wrong place.
|
|
1102
1015
|
landed = false;
|
|
1103
|
-
window.scrollTo({ top:
|
|
1016
|
+
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1104
1017
|
setHash(t[0].id);
|
|
1105
1018
|
});
|
|
1106
1019
|
|
|
@@ -1111,9 +1024,8 @@ export function personaScroll(options) {
|
|
|
1111
1024
|
if (t) {
|
|
1112
1025
|
navTo = t;
|
|
1113
1026
|
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1114
|
-
setStrip(t[0].id, true);
|
|
1115
1027
|
landed = false;
|
|
1116
|
-
window.scrollTo({ top:
|
|
1028
|
+
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1117
1029
|
}
|
|
1118
1030
|
});
|
|
1119
1031
|
}
|