@justai/core 0.23.0 → 0.25.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 +64 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.23.0",
3
+ "version": "0.25.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
@@ -205,10 +205,13 @@ export const XRAY_JS = `(() => {
205
205
  var kind = document.documentElement.dataset.kind || "app";
206
206
  var ks = getComputedStyle(k);
207
207
  var kp = [ks.paddingTop, ks.paddingRight, ks.paddingBottom, ks.paddingLeft].map((v) => parseFloat(v) || 0);
208
+ // ONE NUMBER ON ALL FOUR SIDES — the frame is the active view for both kinds now, so what tells
209
+ // them apart is the padding INSIDE it: an app pads by the gutter, which puts its content exactly
210
+ // on the action-safe ring below, and a game pads by nothing.
211
+ // The bottom may EXCEED it and only the bottom may: env(safe-area-inset-bottom) is the strip the
212
+ // OS keeps for its home indicator, and it is added rather than substituted.
208
213
  var want = kind === "game" ? 0 : g;
209
- // The bottom may EXCEED the gutter and only the bottom may: env(safe-area-inset-bottom) is the
210
- // strip the OS keeps for its home indicator, and it is added rather than substituted.
211
- var insetOk = kp[0] === want && kp[1] === 0 && kp[3] === 0 && kp[2] >= want;
214
+ var insetOk = kp[0] === want && kp[1] === want && kp[3] === want && kp[2] >= want;
212
215
  put(R.inset, kp.join(" / ") + " (" + kind + " wants " + want + ")", insetOk);
213
216
  put(R.act, "inset " + px(g) + " . " + px(r.width - g * 2) + " wide");
214
217
  put(R.ttl, "inset " + px(g * 2) + " . " + px(r.width - g * 4) + " wide");
@@ -679,6 +682,64 @@ export function personaScroll(options) {
679
682
  .filter((c) => c[0] && c[1]);
680
683
  if (!cuts.length) return;
681
684
 
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
688
+ //
689
+ // ── NEVER SAMPLE AN ANIMATION AND CALL IT A LAYOUT ─────────────────────────────────────────
690
+ //
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.
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.
717
+ const measureShell = () => {
718
+ if (!toolbar) return;
719
+ const app = toolbar.closest(".app") || document.querySelector(".app");
720
+ if (!app) return;
721
+ const strip = tbTitle ? tbTitle.getBoundingClientRect().height : 0;
722
+ const open = parseFloat(getComputedStyle(toolbar).getPropertyValue("--tb-strip")) || 26;
723
+ const h = Math.round(toolbar.getBoundingClientRect().height - strip + open);
724
+ if (h > 0) app.style.setProperty("--shell-top", h + "px");
725
+ };
726
+ measureShell();
727
+ addEventListener("resize", measureShell, { passive: true });
728
+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(measureShell);
729
+
730
+ // queries: data-motion · the bar grows after load · animate only after interaction · first paint
731
+ // animation · the toolbar changes height on arrival
732
+ //
733
+ // ── THE SHELL'S TRANSITIONS BELONG TO A PAGE SOMEBODY IS USING ──────────────────────────────
734
+ //
735
+ // The founder's question, and it is the root of the whole class: *"why is this not activated only
736
+ // after the user's first interaction?"* A persona lands on its kernel, so the title strip's correct
737
+ // state on the first frame is OPEN — animating into it makes the bar grow 26px just after the page
738
+ // appears, and makes every measurement taken during that third of a second describe a state the
739
+ // page is never actually in.
740
+ //
741
+ // Nobody can see a transition they have not yet done anything to cause, so there is nothing to
742
+ // lose. `once: true` on each: the flag is set by whichever comes first and never again.
682
743
  if ("scrollRestoration" in history) history.scrollRestoration = "manual";
683
744
 
684
745
  // Only the FRAGMENT. `"#" + id` would clobber the path and the query, and both carry meaning here: