@justai/core 0.18.0 → 0.20.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 +78 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.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
|
@@ -526,15 +526,46 @@ export function personaScroll(options) {
|
|
|
526
526
|
};
|
|
527
527
|
const goTo = (sec, behavior) => window.scrollTo({ top: landingY(sec), behavior: behavior });
|
|
528
528
|
|
|
529
|
+
// queries: the page rests a few pixels short of the kernel · the hash flips to #profile on its own ·
|
|
530
|
+
// typing the bare host lands on the profile · below.top 4.36 · the landing is not repaired ·
|
|
531
|
+
// it works with #kernel in the URL but not without · unstable landing
|
|
532
|
+
//
|
|
533
|
+
// WHERE THIS PAGE WAS SENT — DECIDED ONCE, AND NEVER READ BACK OUT OF THE ADDRESS BAR.
|
|
534
|
+
//
|
|
535
|
+
// This used to be re-derived from `location.hash` on every attempt, and the spy WRITES that hash.
|
|
536
|
+
// So the repair mechanism took its definition of "where I was supposed to be" from the very thing
|
|
537
|
+
// that goes wrong. Traced frame by frame on a live persona at 1512×900:
|
|
538
|
+
//
|
|
539
|
+
// t=241 scrollTo(333.36) landed exactly, below.top 0.36, #kernel
|
|
540
|
+
// t=258 the title strip begins closing y 331, below.top 2.36
|
|
541
|
+
// t=272 below.top passes 1 the spy answers PROFILE and writes #profile
|
|
542
|
+
// t=313 the strip is closed, the page has drifted y 329, below.top 4.36
|
|
543
|
+
// t=342 the `load` repair runs — and reads #profile as its target, measures itself
|
|
544
|
+
// 329 against the PROFILE's landing, finds it further than any drift could be,
|
|
545
|
+
// and closes the promise for good.
|
|
546
|
+
//
|
|
547
|
+
// Four pixels, and the page is stable in the wrong state: the kernel is 4px under the toolbar, the
|
|
548
|
+
// spy says profile, the strip stays shut, and the address bar says #profile for a person who typed
|
|
549
|
+
// the bare host. It is not a hash bug — with #kernel in the URL the same drift flips the same spy
|
|
550
|
+
// and disarms the same repair. What made it look like one is that the two stable states are
|
|
551
|
+
// reachable by a hair: on a phone the landing happened to rest at below.top −0.27 and stayed right.
|
|
552
|
+
//
|
|
553
|
+
// Captured before the first landing, so the repair keeps asking the only question worth asking:
|
|
554
|
+
// *am I where I was SENT?* One re-assert settles it permanently — measured, four times over, no
|
|
555
|
+
// oscillation.
|
|
556
|
+
const sentTo = (() => {
|
|
557
|
+
const t = cuts.find((c) => "#" + c[0].id === location.hash);
|
|
558
|
+
// A section hash is honoured on load and refresh; anything else — including #kernel and no hash
|
|
559
|
+
// at all — lands on the kernel.
|
|
560
|
+
return t ? t[0] : kernel;
|
|
561
|
+
})();
|
|
562
|
+
|
|
529
563
|
const land = () => {
|
|
530
564
|
// presentation mode owns the viewport — a page presenting itself does not scroll out from under
|
|
531
565
|
// whoever opened it
|
|
532
566
|
if (document.body.dataset.present) return;
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
// A section hash is honoured on load and refresh; anything else — including #kernel and no hash
|
|
536
|
-
// at all — lands on the kernel. `instant` overrides the page's own scroll-behavior: smooth.
|
|
537
|
-
goTo(target ? target[0] : kernel, "instant");
|
|
567
|
+
// `instant` overrides the page's own scroll-behavior: smooth.
|
|
568
|
+
goTo(sentTo, "instant");
|
|
538
569
|
};
|
|
539
570
|
// queries: the page did not land on the kernel · landing scroll ignored · scrollTo does nothing on
|
|
540
571
|
// first paint · the page opens at the top sometimes
|
|
@@ -576,9 +607,7 @@ export function personaScroll(options) {
|
|
|
576
607
|
// Kept open until then rather than for a fixed number of tries, because the drift that has to be
|
|
577
608
|
// repaired happens after load, once the title strip has opened and closed.
|
|
578
609
|
if (taken || landed) return;
|
|
579
|
-
const
|
|
580
|
-
const t = cuts.find((c) => "#" + c[0].id === h);
|
|
581
|
-
const want = landingY(t ? t[0] : kernel);
|
|
610
|
+
const want = landingY(sentTo);
|
|
582
611
|
// A pixel of slack: a browser is free to land a scroll a hair off the number it was handed, and
|
|
583
612
|
// re-asserting over a rounding error would fight the person for the rest of the page's life.
|
|
584
613
|
const off = Math.abs(window.scrollY - want);
|
|
@@ -598,6 +627,15 @@ export function personaScroll(options) {
|
|
|
598
627
|
};
|
|
599
628
|
requestAnimationFrame(landIfUntouched);
|
|
600
629
|
window.addEventListener("load", landIfUntouched);
|
|
630
|
+
// queries: the landing is repaired too early · load fires before the strip settles · ResizeObserver
|
|
631
|
+
//
|
|
632
|
+
// AND WHEN THE THING THAT CAUSES THE DRIFT MOVES. rAF and `load` are two moments, and the drift is
|
|
633
|
+
// an event: the toolbar changes height, everything under it shifts, and the page comes to rest
|
|
634
|
+
// somewhere new. On the trace above `load` happened to fire after that; on a faster page it fires
|
|
635
|
+
// before, and then there is nothing left to notice. Watching the toolbar is watching the cause —
|
|
636
|
+
// and it costs nothing after the promise closes, because `landIfUntouched` returns on its first
|
|
637
|
+
// line once somebody has taken over or the page has plainly been moved elsewhere.
|
|
638
|
+
|
|
601
639
|
|
|
602
640
|
// The reveal rides with this on pages whose content is ready at first paint. A page that renders
|
|
603
641
|
// asynchronously — the vault, the file kernel — holds paint until its own data has arrived and
|
|
@@ -1011,6 +1049,38 @@ export function toolbarMark(iconSvg, options) {
|
|
|
1011
1049
|
if (!/aria-hidden/.test(s)) s = s.replace(/<svg /, '<svg aria-hidden="true" ');
|
|
1012
1050
|
if (o.class) s = s.replace(/<svg /, `<svg class="${o.class}" `);
|
|
1013
1051
|
|
|
1052
|
+
// queries: the persona mark is always coloured · two toolbar icons look active · the accent is
|
|
1053
|
+
// everywhere in the row · which icon should be coloured · currentColor toolbar mark
|
|
1054
|
+
//
|
|
1055
|
+
// THE MARK IS INK UNTIL ITS CUT IS CURRENT — the founder's golden rule, 2026-08-03:
|
|
1056
|
+
//
|
|
1057
|
+
// "active persona cut'un icon'u accent rengini alır. diğer passive cut iconları ise accent
|
|
1058
|
+
// rengini kullanmaz."
|
|
1059
|
+
//
|
|
1060
|
+
// The accent has exactly one job in this row: to answer *where am I*. A mark that keeps its own
|
|
1061
|
+
// colours while another cut is current is a second voice on that channel — measured at the kernel,
|
|
1062
|
+
// with the active bolt reading a chroma of 6 to 12, the passive marks read 8 to 20. Several were
|
|
1063
|
+
// MORE coloured than the icon that was actually current.
|
|
1064
|
+
//
|
|
1065
|
+
// THIS FILE ARGUED THE OPPOSITE, and the argument is kept because it shows a true premise ageing
|
|
1066
|
+
// into a wrong conclusion: *"a mark is an identity, not a UI state — a faded logo reads as disabled
|
|
1067
|
+
// rather than as not-current."* True while the mark arrived as an `<img>`, which cannot take
|
|
1068
|
+
// `currentColor`, so dimming was the only way to say "not here". That premise expired the day this
|
|
1069
|
+
// function started deriving an inline SVG. An inline mark can be ink, and ink is not dimming.
|
|
1070
|
+
//
|
|
1071
|
+
// Only the PAINT is neutralised, and only outside `<defs>`: the gradients stay defined, so a
|
|
1072
|
+
// persona that wants its own colours *while current* can re-point to them from its own CSS. qr
|
|
1073
|
+
// does. That is a decision about what the accent looks like, never about when it appears.
|
|
1074
|
+
{
|
|
1075
|
+
const cut = s.lastIndexOf("</defs>");
|
|
1076
|
+
const head = cut >= 0 ? s.slice(0, cut + 7) : "";
|
|
1077
|
+
const body = (cut >= 0 ? s.slice(cut + 7) : s)
|
|
1078
|
+
// `fill="none"` is not paint, it is the absence of it — a stroked shape says so and must keep
|
|
1079
|
+
// saying so, or every outline becomes a silhouette.
|
|
1080
|
+
.replace(/\b(fill|stroke)="(?!none")[^"]*"/g, '$1="currentColor"');
|
|
1081
|
+
s = head + body;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1014
1084
|
// queries: the derived mark is too small · fills · the mark shrank when the ground came off ·
|
|
1015
1085
|
// box for 20 ink
|
|
1016
1086
|
//
|