@justai/core 0.21.0 → 0.23.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 +79 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.21.0",
3
+ "version": "0.23.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
@@ -71,19 +71,70 @@ export const JS_CLASS_JS = `document.documentElement.classList.add("js")`;
71
71
  */
72
72
  export const XRAY_JS = `(() => {
73
73
  if (!new URLSearchParams(location.search).has("xray")) return;
74
+ // IT RUNS IN <head>, SO IT WAITS. The shell mounts this beside its other inline scripts, which is
75
+ // the right place — before first paint, so the overlay does not appear a beat late. But #kernel
76
+ // does not exist yet at that moment, and the first version simply returned: the flag was read, the
77
+ // element was absent, and nothing happened with nothing said. Deferring is one line; finding out
78
+ // why an instrument silently does not work is not.
79
+ if (document.readyState === "loading") {
80
+ return void document.addEventListener("DOMContentLoaded", () => start(), { once: true });
81
+ }
82
+ start();
83
+
84
+ function start() {
74
85
  var K = () => document.getElementById("kernel");
75
86
  if (!K()) return;
76
87
 
77
88
  var css = document.createElement("style");
78
89
  css.textContent = [
79
90
  ".xr{position:fixed;pointer-events:none;z-index:2147483000}",
80
- ".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}",
81
105
  ".xr-f{position:fixed;pointer-events:none;z-index:2147483000}",
82
- ".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.
83
127
  ".xr-edge{border:3px solid #E8503A}",
84
- ".xr-act{border:1px solid rgba(128,128,128,.65)}",
85
- ".xr-ttl{border:1px dashed rgba(128,128,128,.5)}",
86
- ".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}",
87
138
  ".xr-read{position:fixed;left:12px;bottom:12px;pointer-events:none;z-index:2147483001;",
88
139
  "display:grid;grid-template-columns:auto 1fr;gap:2px 12px;padding:10px 12px;border-radius:10px;",
89
140
  "background:rgba(20,22,28,.92);color:#f2f4f8;font:400 .78rem/1.35 ui-monospace,SFMono-Regular,Menlo,monospace}",
@@ -99,7 +150,7 @@ export const XRAY_JS = `(() => {
99
150
  var edge = mk("xr-f xr-edge", "<i>edge of frame</i>");
100
151
  var act = mk("xr-f xr-act", "<i>action safe</i>");
101
152
  var ttl = mk("xr-f xr-ttl", "<i>title safe</i>");
102
- var ticks = [0,1,2,3,4,5].map(() => mk("xr-c"));
153
+ var cross = [0,1].map(() => mk("xr-c"));
103
154
  var read = mk("xr-read");
104
155
 
105
156
  var row = (label) => {
@@ -109,7 +160,7 @@ export const XRAY_JS = `(() => {
109
160
  return s;
110
161
  };
111
162
  var R = { viewport: row("viewport"), column: row("column"), gutter: row("gutter L/R"),
112
- 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"),
113
164
  bar: row("toolbar"), clear: row("clears bar"), safe: row("safe area L/R"),
114
165
  bleed: row("bleed") };
115
166
  var put = (el, text, ok) => { el.textContent = text; if (ok !== undefined) el.dataset.ok = ok ? "yes" : "no"; };
@@ -131,13 +182,13 @@ export const XRAY_JS = `(() => {
131
182
 
132
183
  box(edge, r, 0); box(act, r, g); box(ttl, r, g * 2); box(rhythm, r, 0);
133
184
 
134
- // ticks: N S W E and the centre cross — the two questions a printed overlay answers for free,
135
- // is this centred and is the middle where you think it is
136
- var t = [[r.left + r.width / 2, r.top, 1, 14], [r.left + r.width / 2, r.bottom - 14, 1, 14],
137
- [r.left, r.top + r.height / 2, 14, 1], [r.right - 14, r.top + r.height / 2, 14, 1],
138
- [r.left + r.width / 2, r.top + r.height / 2 - 9, 1, 18],
139
- [r.left + r.width / 2 - 9, r.top + r.height / 2, 18, 1]];
140
- 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";
141
192
  el.style.width = t[i][2] + "px"; el.style.height = t[i][3] + "px"; });
142
193
 
143
194
  var aw = app ? app.getBoundingClientRect().width : r.width;
@@ -146,6 +197,19 @@ export const XRAY_JS = `(() => {
146
197
  var even = Math.abs(padL - padR) < 0.5;
147
198
  put(R.gutter, px(padL) + " / " + px(padR) + (even ? "" : " <- the two sides differ"), even);
148
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
+ 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;
212
+ put(R.inset, kp.join(" / ") + " (" + kind + " wants " + want + ")", insetOk);
149
213
  put(R.act, "inset " + px(g) + " . " + px(r.width - g * 2) + " wide");
150
214
  put(R.ttl, "inset " + px(g * 2) + " . " + px(r.width - g * 4) + " wide");
151
215
 
@@ -175,6 +239,7 @@ export const XRAY_JS = `(() => {
175
239
  addEventListener("resize", schedule, { passive: true });
176
240
  addEventListener("scroll", schedule, { passive: true });
177
241
  if (document.fonts && document.fonts.ready) document.fonts.ready.then(draw);
242
+ }
178
243
  })()`;
179
244
 
180
245
  /**