@justai/core 0.22.0 → 0.24.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 +102 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.22.0",
3
+ "version": "0.24.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
@@ -88,13 +88,53 @@ export const XRAY_JS = `(() => {
88
88
  var css = document.createElement("style");
89
89
  css.textContent = [
90
90
  ".xr{position:fixed;pointer-events:none;z-index:2147483000}",
91
- ".xr-rhythm{background:repeating-linear-gradient(to bottom,rgba(128,128,128,.22) 0 1px,transparent 1px 8px)}",
91
+ // ── THE RHYTHM IS DOT PAPER, THE SAME DOT PAPER THE FLEET ALREADY PAINTS ──────────────────
92
+ // It was ruled horizontal lines, which is notebook paper: it reads as a THING to look at, it
93
+ // fights every horizontal edge in the design, and it says nothing at all about the horizontal
94
+ // axis it does not draw. Dots say both axes at once and disappear behind the content, which is
95
+ // what a grid under a design is for.
96
+ // Same construction as the page background @justai/ui paints on html — a radial-gradient dot on
97
+ // a square tile — so the instrument speaks the fleet's own visual language rather than inventing
98
+ // a second one. The tile is 8px here rather than the page's 16: this is the 8pt rhythm the
99
+ // padding and the margins are actually built on.
100
+ //
101
+ // NO BACKTICKS ANYWHERE INSIDE THIS STRING. It is a template literal, so one in a COMMENT ends
102
+ // it — the file still parses, the script it produces is truncated garbage, and the build fails
103
+ // somewhere else entirely. Written here twice tonight before the fixture refused to build.
104
+ ".xr-rhythm{background-image:radial-gradient(circle,rgba(128,128,128,.34) 1px,transparent 1.4px);background-size:8px 8px}",
92
105
  ".xr-f{position:fixed;pointer-events:none;z-index:2147483000}",
93
- ".xr-f>i{position:absolute;top:3px;right:7px;font-size:.68rem;font-style:normal;letter-spacing:.07em;text-transform:uppercase;opacity:.55}",
106
+ // THREE CORNERS, BECAUSE THE ZONES ARE 16px APART AND A LABEL IS 11px TALL. Stacked at one
107
+ // corner the way a broadcast overlay does it, they collided the moment the gutter was a
108
+ // phone gutter rather than a television one: EDGE OF FRAME sat on ACTION SAFE and the amber
109
+ // line ran through both. Broadcast can stack them because its safe margins are 5% and 10% of
110
+ // the frame; ours are 16px and 32px. So each zone takes a corner of its own and they cannot
111
+ // meet at any width. The colours already say which is which — the words are the confirmation.
112
+ ".xr-f>i{position:absolute;font-size:.68rem;font-style:normal;letter-spacing:.07em;text-transform:uppercase;font-weight:700;white-space:nowrap}",
113
+ // THEY DIFFER IN BOTH AXES, and the second axis is what makes it work at any gutter: each label
114
+ // sits at its own box's top — 16px apart on a phone — AND at a different corner of it. Two of
115
+ // them could be one pixel apart vertically and still not touch.
116
+ // ALL THREE AT THE TOP, and that is not symmetry. An app kernel is at least a viewport tall, so
117
+ // its box ends below the fold: a label anchored to the bottom of the action-safe frame was simply
118
+ // not on the screen. Measured, after being written that way first.
119
+ ".xr-edge>i{top:3px;right:7px}",
120
+ ".xr-act>i{top:3px;left:50%;transform:translateX(-50%)}",
121
+ ".xr-ttl>i{top:3px;left:7px}",
122
+ // ── THREE ZONES, THREE COLOURS, AND THE ORDER MEANS SOMETHING ─────────────────────────────
123
+ // Red, amber, green — outward to inward, danger to safe. Everyone already reads that gradient
124
+ // without being taught it, and it is exactly what the three zones say: the edge is where things
125
+ // get cut, action-safe is where a control may sit, title-safe is where a word is certain to be
126
+ // read. Three greys distinguished only by their dash pattern made the reader count borders.
94
127
  ".xr-edge{border:3px solid #E8503A}",
95
- ".xr-act{border:1px solid rgba(128,128,128,.65)}",
96
- ".xr-ttl{border:1px dashed rgba(128,128,128,.5)}",
97
- ".xr-c{position:fixed;background:rgba(128,128,128,.7);pointer-events:none;z-index:2147483000}",
128
+ ".xr-edge>i{color:#E8503A}",
129
+ ".xr-act{border:1.5px solid #F5A623}",
130
+ ".xr-act>i{color:#C97F0B}",
131
+ ".xr-ttl{border:1.5px dashed #2E9E5B}",
132
+ ".xr-ttl>i{color:#2E9E5B}",
133
+ // The centre cross runs the WHOLE frame, in both axes. Ticks at the four edges said where the
134
+ // middle of each side was and left the reader to imagine the intersection; two full lines put
135
+ // the kernel's centre on the screen as a point you can hold something against. Blue, because it
136
+ // is the one thing on this overlay that is not a boundary — it is a reference.
137
+ ".xr-c{position:fixed;background:rgba(61,111,217,.55);pointer-events:none;z-index:2147483000}",
98
138
  ".xr-read{position:fixed;left:12px;bottom:12px;pointer-events:none;z-index:2147483001;",
99
139
  "display:grid;grid-template-columns:auto 1fr;gap:2px 12px;padding:10px 12px;border-radius:10px;",
100
140
  "background:rgba(20,22,28,.92);color:#f2f4f8;font:400 .78rem/1.35 ui-monospace,SFMono-Regular,Menlo,monospace}",
@@ -110,7 +150,7 @@ export const XRAY_JS = `(() => {
110
150
  var edge = mk("xr-f xr-edge", "<i>edge of frame</i>");
111
151
  var act = mk("xr-f xr-act", "<i>action safe</i>");
112
152
  var ttl = mk("xr-f xr-ttl", "<i>title safe</i>");
113
- var ticks = [0,1,2,3,4,5].map(() => mk("xr-c"));
153
+ var cross = [0,1].map(() => mk("xr-c"));
114
154
  var read = mk("xr-read");
115
155
 
116
156
  var row = (label) => {
@@ -120,7 +160,7 @@ export const XRAY_JS = `(() => {
120
160
  return s;
121
161
  };
122
162
  var R = { viewport: row("viewport"), column: row("column"), gutter: row("gutter L/R"),
123
- frame: row("frame"), act: row("action safe"), ttl: row("title safe"),
163
+ frame: row("frame"), inset: row("kernel inset"), act: row("action safe"), ttl: row("title safe"),
124
164
  bar: row("toolbar"), clear: row("clears bar"), safe: row("safe area L/R"),
125
165
  bleed: row("bleed") };
126
166
  var put = (el, text, ok) => { el.textContent = text; if (ok !== undefined) el.dataset.ok = ok ? "yes" : "no"; };
@@ -142,13 +182,13 @@ export const XRAY_JS = `(() => {
142
182
 
143
183
  box(edge, r, 0); box(act, r, g); box(ttl, r, g * 2); box(rhythm, r, 0);
144
184
 
145
- // ticks: N S W E and the centre cross — the two questions a printed overlay answers for free,
146
- // is this centred and is the middle where you think it is
147
- var t = [[r.left + r.width / 2, r.top, 1, 14], [r.left + r.width / 2, r.bottom - 14, 1, 14],
148
- [r.left, r.top + r.height / 2, 14, 1], [r.right - 14, r.top + r.height / 2, 14, 1],
149
- [r.left + r.width / 2, r.top + r.height / 2 - 9, 1, 18],
150
- [r.left + r.width / 2 - 9, r.top + r.height / 2, 18, 1]];
151
- ticks.forEach((el, i) => { el.style.left = t[i][0] + "px"; el.style.top = t[i][1] + "px";
185
+ // THE CENTRE CROSS, EDGE TO EDGE. Their intersection IS the kernel's centre — the one point a
186
+ // design gets measured against and the one an eye cannot find on its own. Drawn across the whole
187
+ // frame rather than as ticks, so anything meant to be centred can be held against a line instead
188
+ // of against a guess about where two marks would have met.
189
+ var t = [[r.left + r.width / 2, r.top, 1, r.height],
190
+ [r.left, r.top + r.height / 2, r.width, 1]];
191
+ cross.forEach((el, i) => { el.style.left = t[i][0] + "px"; el.style.top = t[i][1] + "px";
152
192
  el.style.width = t[i][2] + "px"; el.style.height = t[i][3] + "px"; });
153
193
 
154
194
  var aw = app ? app.getBoundingClientRect().width : r.width;
@@ -157,6 +197,22 @@ export const XRAY_JS = `(() => {
157
197
  var even = Math.abs(padL - padR) < 0.5;
158
198
  put(R.gutter, px(padL) + " / " + px(padR) + (even ? "" : " <- the two sides differ"), even);
159
199
  put(R.frame, px(r.width) + " x " + px(r.height));
200
+ // THE KERNEL'S OWN INSET, WITH THE LAW IT IS JUDGED AGAINST. Two laws, and which one applies is
201
+ // read from the document rather than guessed: an APP kernel is inset by the gutter on all four
202
+ // sides, a GAME kernel by nothing at all. This row is the reason the second law stopped being
203
+ // sixteen copies — 8px sat at the bottom of every persona in the fleet, matching neither the top
204
+ // nor the sides, and there was nowhere it was ever printed next to what it should have been.
205
+ var kind = document.documentElement.dataset.kind || "app";
206
+ var ks = getComputedStyle(k);
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.
213
+ var want = kind === "game" ? 0 : g;
214
+ var insetOk = kp[0] === want && kp[1] === want && kp[3] === want && kp[2] >= want;
215
+ put(R.inset, kp.join(" / ") + " (" + kind + " wants " + want + ")", insetOk);
160
216
  put(R.act, "inset " + px(g) + " . " + px(r.width - g * 2) + " wide");
161
217
  put(R.ttl, "inset " + px(g * 2) + " . " + px(r.width - g * 4) + " wide");
162
218
 
@@ -626,6 +682,38 @@ export function personaScroll(options) {
626
682
  .filter((c) => c[0] && c[1]);
627
683
  if (!cuts.length) return;
628
684
 
685
+ // queries: --shell-top · the kernel is under the toolbar · the gap under the bar is 4px ·
686
+ // the toolbar is taller than 82 · Dynamic Type · game kernel height wrong by a pixel
687
+ //
688
+ // ── THE SHELL'S OWN HEIGHT IS MEASURED, NOT ASSUMED ─────────────────────────────────────────
689
+ //
690
+ // `--shell-top` is what the shell takes above the kernel, and everything downstream reads it: the
691
+ // landing offset, an app kernel's minimum height, a game kernel's exact one. It was the literal 82
692
+ // in a stylesheet — and the toolbar is not 82. It renders 70.1px on one canary and 82.3 on another,
693
+ // because its height follows the persona's NAME, the reader's text size and iOS Dynamic Type. On
694
+ // the persona whose bar reached 82.3 the game frame sat 0.3px UNDER the sticky row: the harness
695
+ // caught it as "there is air under the bar: -0.27".
696
+ //
697
+ // So it is read from the row that is actually on the page, plus one gutter of air — the same inset
698
+ // the column keeps at its sides, which is what makes the air under the bar equal to the air beside
699
+ // the content instead of whatever 82 minus this persona's toolbar happens to be.
700
+ //
701
+ // WRITTEN ON `.app` RATHER THAN ON :root, because `--gutter` lives there and this is read from it.
702
+ // Re-measured on resize: a phone rotating, a window narrowing past 640 and a reader changing their
703
+ // text size all change the row's height, and a landing offset that was right at load is a kernel
704
+ // under the bar afterwards.
705
+ const measureShell = () => {
706
+ if (!toolbar) return;
707
+ const app = toolbar.closest(".app") || document.querySelector(".app");
708
+ if (!app) return;
709
+ const gutter = parseFloat(getComputedStyle(app).getPropertyValue("--gutter")) || 16;
710
+ const h = Math.round(toolbar.getBoundingClientRect().height + gutter);
711
+ if (h > 0) app.style.setProperty("--shell-top", h + "px");
712
+ };
713
+ measureShell();
714
+ addEventListener("resize", measureShell, { passive: true });
715
+ if (document.fonts && document.fonts.ready) document.fonts.ready.then(measureShell);
716
+
629
717
  if ("scrollRestoration" in history) history.scrollRestoration = "manual";
630
718
 
631
719
  // Only the FRAGMENT. `"#" + id` would clobber the path and the query, and both carry meaning here: