@justai/core 0.27.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +14 -108
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.27.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,51 +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 · 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
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
- // ── NEVER SAMPLE AN ANIMATION AND CALL IT A LAYOUT ─────────────────────────────────────────
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
- // `--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.
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
- // 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.
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 strip = tbTitle ? tbTitle.getBoundingClientRect().height : 0;
722
- const open = parseFloat(getComputedStyle(toolbar).getPropertyValue("--tb-strip")) || 26;
723
- // CEIL, NOT ROUND, AND IT IS LOAD-BEARING NOW: `--shell-top` is the slot's min-height as well as
724
- // the subtrahend, so it must never be LESS than the bar's tallest state or the slot starts
725
- // following the bar again and the 26px returns as a fraction. A bar under Dynamic Type is not an
726
- // integer — this file has already recorded one at 82.3 — and rounding down is half a CSS pixel,
727
- // one and a half device pixels at DPR 3, of permanent error in a law judged by eye against a
728
- // drawn rectangle.
729
- const h = Math.ceil(toolbar.getBoundingClientRect().height - strip + open);
698
+ const h = Math.ceil(toolbar.getBoundingClientRect().height);
730
699
  if (h > 0) app.style.setProperty("--shell-top", h + "px");
731
700
  };
732
701
  measureShell();
@@ -920,10 +889,6 @@ export function personaScroll(options) {
920
889
  const text = (sel) => (document.querySelector(sel)?.textContent || "").trim();
921
890
  // Kernel names the persona, Posts names its handle, Profile stays collapsed — its big header IS
922
891
  // the title, and repeating it in the bar above would say the same thing twice.
923
- const titleFor =
924
- o.titleFor ||
925
- ((id) => (id === "kernel" ? text(".pname") : id === "posts" ? text(".handle") : ""));
926
-
927
892
  // queries: the title strip jumps · the page jolts after tapping a cut · content shifts while scrolling
928
893
  // · toolbar title animation causes a layout shift · landing lands 26px off
929
894
  //
@@ -937,62 +902,6 @@ export function personaScroll(options) {
937
902
  //
938
903
  // So the write is factored out here and can be applied WITHOUT its transition, which lets a
939
904
  // navigation settle the height first and then scroll once, to a target that is already true.
940
- // queries: strip height before it opens · landing computed against the wrong toolbar height
941
- //
942
- // THE STRIP'S OPEN HEIGHT, NEEDED BEFORE IT OPENS. A landing for anything below the strip has to be
943
- // computed against the height the strip is GOING to have, not the one it has. Probed once and
944
- // synchronously — added, measured and removed inside a single task — so no paint ever shows it.
945
- let stripH = 0;
946
- const stripHeight = () => {
947
- if (stripH) return stripH;
948
- if (!tbTitle) return 0;
949
- if (tbTitle.classList.contains("show")) { stripH = tbTitle.offsetHeight; return stripH; }
950
- const keep = tbTitle.style.transition;
951
- tbTitle.style.transition = "none";
952
- tbTitle.classList.add("show");
953
- stripH = tbTitle.offsetHeight;
954
- tbTitle.classList.remove("show");
955
- void tbTitle.offsetHeight;
956
- tbTitle.style.transition = keep;
957
- return stripH;
958
- };
959
-
960
- // WHERE THE PAGE WILL REST ONCE THE STRIP HAS FINISHED MOVING — so the scroll can be aimed there
961
- // while the strip is still on its way, and the two motions arrive together.
962
- //
963
- // Only what FOLLOWS the strip is affected. The kernel is anchored to `#below`'s top, which the strip
964
- // cannot move because it lives inside it; the profile sits above `#below` entirely. Asked of the
965
- // document rather than assumed, so this stays true if the shell is ever rearranged.
966
- const landingAfterStrip = (sec, id) => {
967
- const y = landingY(sec);
968
- if (!tbTitle || sec === kernel) return y;
969
- const willShow = !!titleFor(id);
970
- if (willShow === tbTitle.classList.contains("show")) return y;
971
- const stripIsAbove = sec.compareDocumentPosition(tbTitle) & Node.DOCUMENT_POSITION_PRECEDING;
972
- if (!stripIsAbove) return y;
973
- return y + (willShow ? stripHeight() : -stripHeight());
974
- };
975
-
976
- const setStrip = (id, animate) => {
977
- if (!tbTitle) return;
978
- const t = titleFor(id);
979
- if (animate) {
980
- tbTitle.classList.toggle("show", !!t);
981
- if (t && tbTitleText && tbTitleText.textContent !== t) {
982
- tbTitleText.classList.add("fade");
983
- setTimeout(() => { tbTitleText.textContent = t; tbTitleText.classList.remove("fade"); }, 150);
984
- }
985
- return;
986
- }
987
- // Instant: the height must be final before this function returns, so the caller can measure. The
988
- // text goes with it — a settled height showing the previous words would be its own small lie.
989
- tbTitle.style.transition = "none";
990
- tbTitle.classList.toggle("show", !!t);
991
- if (t && tbTitleText) { tbTitleText.classList.remove("fade"); tbTitleText.textContent = t; }
992
- void tbTitle.offsetHeight;
993
- tbTitle.style.transition = "";
994
- };
995
-
996
905
  let lastCut = null;
997
906
  let first = true;
998
907
  // queries: the toolbar icon changes late · nav icon lags the tap · active state waits for the scroll
@@ -1029,7 +938,6 @@ export function personaScroll(options) {
1029
938
  // it arrives. Animating it in tells a person something changed when nothing did.
1030
939
  const wasFirst = first;
1031
940
  first = false;
1032
- setStrip(current[0].id, !wasFirst);
1033
941
  };
1034
942
  // queries: scroll janks while the toolbar updates · scroll handler runs too often · the spy reads a
1035
943
  // stale position · the section is right but the toolbar is one behind · scrollend
@@ -1102,11 +1010,10 @@ export function personaScroll(options) {
1102
1010
  // The icon answers the tap NOW, not when the scroll lands. `navTo` keeps it answered for the trip.
1103
1011
  navTo = t;
1104
1012
  for (const c of cuts) c[1].classList.toggle("active", c === t);
1105
- setStrip(t[0].id, true);
1106
1013
  // `landed` stays re-armed as a net. If the aim above is ever wrong the old instant repair still
1107
1014
  // catches it — a rare snap is a better failure than a landing left in the wrong place.
1108
1015
  landed = false;
1109
- window.scrollTo({ top: landingAfterStrip(t[0], t[0].id), behavior: "smooth" });
1016
+ window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
1110
1017
  setHash(t[0].id);
1111
1018
  });
1112
1019
 
@@ -1117,9 +1024,8 @@ export function personaScroll(options) {
1117
1024
  if (t) {
1118
1025
  navTo = t;
1119
1026
  for (const c of cuts) c[1].classList.toggle("active", c === t);
1120
- setStrip(t[0].id, true);
1121
1027
  landed = false;
1122
- window.scrollTo({ top: landingAfterStrip(t[0], t[0].id), behavior: "smooth" });
1028
+ window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
1123
1029
  }
1124
1030
  });
1125
1031
  }