@justai/core 0.33.0 → 0.34.1
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 +63 -0
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.34.1",
|
|
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": {
|
|
7
7
|
"type": "git",
|
package/src/index.js
CHANGED
|
@@ -935,6 +935,66 @@ 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
|
+
// queries: the keeper fought a programmatic scroll · scrollTo(0) snapped back to the kernel ·
|
|
965
|
+
// the query-survives spec times out in CI · near band 64
|
|
966
|
+
//
|
|
967
|
+
// AND THE KEEPER ONLY ACTS WHILE THE PAGE IS STILL AT THE LANDING. CI caught the first version
|
|
968
|
+
// within the hour: a consumer's programmatic scrollTo(0) — which no gesture listener sees — was
|
|
969
|
+
// followed by the fonts settling, the resize fired, and the keeper yanked the page back to the
|
|
970
|
+
// kernel from somewhere it had been deliberately sent. Gestures cannot be the only release,
|
|
971
|
+
// because a page is allowed to scroll ITSELF (lendcam's stage does; a spec does).
|
|
972
|
+
//
|
|
973
|
+
// So the promise is spatial as well: on every resize the keeper first asks whether the page is
|
|
974
|
+
// still within a hand's width (64px) of where it last held it. Layout shifts displace a landed
|
|
975
|
+
// page by small strokes — the vault's was 18px — while anybody scrolling AWAY, by hand or by
|
|
976
|
+
// code, leaves that band immediately and permanently: the keeper reads leaving as being
|
|
977
|
+
// relieved of duty, not as something to correct.
|
|
978
|
+
let kept = landingY(sentTo);
|
|
979
|
+
const keeper = new ResizeObserver(() => {
|
|
980
|
+
if (touched || document.body.dataset.present) { keeper.disconnect(); return; }
|
|
981
|
+
if (Math.abs(window.scrollY - kept) > 64) { keeper.disconnect(); return; }
|
|
982
|
+
const want = landingY(sentTo);
|
|
983
|
+
kept = want;
|
|
984
|
+
// A pixel of slack: browsers land sub-pixel scrolls a hair off the number they were handed,
|
|
985
|
+
// and re-asserting over a rounding error would run on every breath the page takes.
|
|
986
|
+
if (Math.abs(window.scrollY - want) > 1) goTo(sentTo, "instant");
|
|
987
|
+
});
|
|
988
|
+
// NOT (only) the body: the fleet's ground gives `body { height: 100% }`, so the body's border
|
|
989
|
+
// box is the viewport and never resizes when content grows — an observer there watched the one
|
|
990
|
+
// box guaranteed to stay still. Caught by the spec modelling the vault's growth: 18px arrived,
|
|
991
|
+
// the observer never fired. The boxes that actually change are the sections themselves, so the
|
|
992
|
+
// keeper watches every cut and the below-boundary; body rides along for a consumer whose ground
|
|
993
|
+
// differs.
|
|
994
|
+
keeper.observe(document.body);
|
|
995
|
+
keeper.observe(below);
|
|
996
|
+
for (const c of cuts) keeper.observe(c[0]);
|
|
997
|
+
}
|
|
938
998
|
// The landing is attempted again when the page comes to rest, because `scrollTo` past a document
|
|
939
999
|
// that has not sized itself yet is a silent no-op — cause 1, and the only cause left here. The
|
|
940
1000
|
// drift this used to repair as well was the secondary title strip moving the page after it landed,
|
|
@@ -1143,6 +1203,9 @@ export function personaScroll(options) {
|
|
|
1143
1203
|
// A hash that arrives without a click — the back button, or a link from another page to this one.
|
|
1144
1204
|
// `setHash` uses replaceState and fires nothing, so this can only be somebody else's navigation.
|
|
1145
1205
|
window.addEventListener("hashchange", () => {
|
|
1206
|
+
// The back button or a link from outside — a person navigated, so the load-landing promise ends
|
|
1207
|
+
// here too: the layout keeper must not snap a page somebody just steered somewhere else.
|
|
1208
|
+
touched = true;
|
|
1146
1209
|
const t = cuts.find((c) => "#" + c[0].id === location.hash);
|
|
1147
1210
|
if (t) {
|
|
1148
1211
|
navTo = t;
|