@justai/core 0.33.0 → 0.34.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 +46 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
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": {
package/src/index.js CHANGED
@@ -935,6 +935,49 @@ export function personaScroll(options) {
935
935
  for (const ev of ["wheel", "touchmove", "keydown", "click"]) {
936
936
  window.addEventListener(ev, settle, { passive: true, once: true });
937
937
  }
938
+
939
+ // queries: the child persona lands short · /me lands a bit off · unstable landing · async content
940
+ // moves the page after it lands · vault read shifts the layout · below.top -18 · the
941
+ // landing is fine in one browser and off in another · ResizeObserver landing
942
+ //
943
+ // ── THE LANDING IS KEPT AGAINST LAYOUT — NEVER AGAINST SCROLLS ─────────────────────────────────
944
+ //
945
+ // A landing is a promise about a document that may not have finished becoming itself. The children
946
+ // proved it: /me lands exactly, the vault's async read completes, the profile grows and settles,
947
+ // and the page rests 18px from where it was put — with NOBODY having scrolled. Chromium's scroll
948
+ // anchoring sometimes absorbs this and sometimes does not, and WebKit has no anchoring at all,
949
+ // which is why the founder's phone showed what a laptop's headless run happened to hide. "Stable
950
+ // olmayan bir durum" is half-applied compensation seen from the outside.
951
+ //
952
+ // A repair against ANY movement was tried once and fought a page that scrolls itself — that is the
953
+ // workaround this file keeps warning about. The line is drawn elsewhere, and it is sharp: LAYOUT
954
+ // is the page still under construction, so the promise holds; a SCROLL is an intent, and intents
955
+ // are never fought. A ResizeObserver on the body sees exactly the first kind and cannot see the
956
+ // second — a consumer calling scrollTo() resizes nothing. The first gesture ends it: after a
957
+ // wheel, a finger, a key or a pointer the page belongs to the person, whatever the layout does.
958
+ let touched = false;
959
+ const takeBack = () => { touched = true; };
960
+ for (const ev of ["wheel", "touchmove", "keydown", "pointerdown"]) {
961
+ window.addEventListener(ev, takeBack, { passive: true, once: true, capture: true });
962
+ }
963
+ if (typeof ResizeObserver === "function") {
964
+ const keeper = new ResizeObserver(() => {
965
+ if (touched || document.body.dataset.present) { keeper.disconnect(); return; }
966
+ const want = landingY(sentTo);
967
+ // A pixel of slack: browsers land sub-pixel scrolls a hair off the number they were handed,
968
+ // and re-asserting over a rounding error would run on every breath the page takes.
969
+ if (Math.abs(window.scrollY - want) > 1) goTo(sentTo, "instant");
970
+ });
971
+ // NOT (only) the body: the fleet's ground gives `body { height: 100% }`, so the body's border
972
+ // box is the viewport and never resizes when content grows — an observer there watched the one
973
+ // box guaranteed to stay still. Caught by the spec modelling the vault's growth: 18px arrived,
974
+ // the observer never fired. The boxes that actually change are the sections themselves, so the
975
+ // keeper watches every cut and the below-boundary; body rides along for a consumer whose ground
976
+ // differs.
977
+ keeper.observe(document.body);
978
+ keeper.observe(below);
979
+ for (const c of cuts) keeper.observe(c[0]);
980
+ }
938
981
  // The landing is attempted again when the page comes to rest, because `scrollTo` past a document
939
982
  // that has not sized itself yet is a silent no-op — cause 1, and the only cause left here. The
940
983
  // drift this used to repair as well was the secondary title strip moving the page after it landed,
@@ -1143,6 +1186,9 @@ export function personaScroll(options) {
1143
1186
  // A hash that arrives without a click — the back button, or a link from another page to this one.
1144
1187
  // `setHash` uses replaceState and fires nothing, so this can only be somebody else's navigation.
1145
1188
  window.addEventListener("hashchange", () => {
1189
+ // The back button or a link from outside — a person navigated, so the load-landing promise ends
1190
+ // here too: the layout keeper must not snap a page somebody just steered somewhere else.
1191
+ touched = true;
1146
1192
  const t = cuts.find((c) => "#" + c[0].id === location.hash);
1147
1193
  if (t) {
1148
1194
  navTo = t;