@justai/core 0.35.0 → 0.36.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/dist/xray.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @justai/core/xray — the design grid, on demand. It knows `#kernel`'s rectangle and nothing else on the page — an instrument that moved what it measures would not be one.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /**
8
+ * queries: design grid · x-ray · ?xray · safe area · title safe · action safe · edge of frame ·
9
+ * debug overlay · is my content inside the safe area · does the kernel overlap the toolbar ·
10
+ * horizontal bleed · the column is not centred · layout debugging · developing a persona
11
+ *
12
+ * ── THE X-RAY: THE SHELL'S DESIGN GRID, ON DEMAND ─────────────────────────────────────────────
13
+ *
14
+ * Open any persona with `?xray` and its skeleton appears over the live page: the kernel's own frame,
15
+ * the two safe areas, centre crosshairs, an 8px rhythm, and every number the layout depends on with
16
+ * a verdict on each. You look THROUGH the persona's own controls and see whether they sit inside the
17
+ * safe areas or cross them.
18
+ *
19
+ * ── IT IS A PAIR OF GLASSES, NOT A RENOVATION ────────────────────────────────────────────────
20
+ *
21
+ * The founder's constraint, and it shapes every decision below: turning the x-ray on must not change
22
+ * the layout it is measuring. An instrument that moves the thing it measures is not an instrument.
23
+ *
24
+ * So nothing here touches the page. No class is added to the kernel, no `position: relative`, no
25
+ * flow element anywhere — the overlay is `position: fixed` and its coordinates are READ from
26
+ * `#kernel.getBoundingClientRect()` on every frame that matters. The page cannot tell it is there.
27
+ * `pointer-events: none` throughout, so it cannot even absorb a click.
28
+ *
29
+ * ── AND WHEN IT IS OFF IT COSTS NOTHING ──────────────────────────────────────────────────────
30
+ *
31
+ * This whole string returns on its second line unless the flag is present. The stylesheet, the DOM
32
+ * and the listeners are built inside that branch: a persona that nobody is debugging ships one
33
+ * `if`. A debug feature that is only free when somebody remembers to remove it is one that ships.
34
+ *
35
+ * The flag is read from `location.search`, so `?xray`, `?xray=1` and `&xray` all work. A flag you
36
+ * have to spell exactly right is one you will spell wrong at the moment you need it.
37
+ */
38
+ export declare function xray(): undefined;
39
+ /** The x-ray as an injectable IIFE — derived from {@link xray}, never written twice. */
40
+ export declare const XRAY_JS: string;
package/dist/xray.js ADDED
@@ -0,0 +1,316 @@
1
+ /**
2
+ * @justai/core/xray — the design grid, on demand. It knows `#kernel`'s rectangle and nothing else on the page — an instrument that moved what it measures would not be one.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /**
8
+ * queries: design grid · x-ray · ?xray · safe area · title safe · action safe · edge of frame ·
9
+ * debug overlay · is my content inside the safe area · does the kernel overlap the toolbar ·
10
+ * horizontal bleed · the column is not centred · layout debugging · developing a persona
11
+ *
12
+ * ── THE X-RAY: THE SHELL'S DESIGN GRID, ON DEMAND ─────────────────────────────────────────────
13
+ *
14
+ * Open any persona with `?xray` and its skeleton appears over the live page: the kernel's own frame,
15
+ * the two safe areas, centre crosshairs, an 8px rhythm, and every number the layout depends on with
16
+ * a verdict on each. You look THROUGH the persona's own controls and see whether they sit inside the
17
+ * safe areas or cross them.
18
+ *
19
+ * ── IT IS A PAIR OF GLASSES, NOT A RENOVATION ────────────────────────────────────────────────
20
+ *
21
+ * The founder's constraint, and it shapes every decision below: turning the x-ray on must not change
22
+ * the layout it is measuring. An instrument that moves the thing it measures is not an instrument.
23
+ *
24
+ * So nothing here touches the page. No class is added to the kernel, no `position: relative`, no
25
+ * flow element anywhere — the overlay is `position: fixed` and its coordinates are READ from
26
+ * `#kernel.getBoundingClientRect()` on every frame that matters. The page cannot tell it is there.
27
+ * `pointer-events: none` throughout, so it cannot even absorb a click.
28
+ *
29
+ * ── AND WHEN IT IS OFF IT COSTS NOTHING ──────────────────────────────────────────────────────
30
+ *
31
+ * This whole string returns on its second line unless the flag is present. The stylesheet, the DOM
32
+ * and the listeners are built inside that branch: a persona that nobody is debugging ships one
33
+ * `if`. A debug feature that is only free when somebody remembers to remove it is one that ships.
34
+ *
35
+ * The flag is read from `location.search`, so `?xray`, `?xray=1` and `&xray` all work. A flag you
36
+ * have to spell exactly right is one you will spell wrong at the moment you need it.
37
+ */
38
+ // queries: xray is a string · why is XRAY_JS generated · no backticks in this string · the design
39
+ // grid script · editing a script that lives inside a template literal
40
+ //
41
+ // ── IT IS A FUNCTION NOW, AND THE STRING IS DERIVED FROM IT ──────────────────────────────────
42
+ //
43
+ // This was two hundred and twenty-five lines of JavaScript inside a template literal, and the proof
44
+ // of what that costs was a warning sitting in the middle of it: *"NO BACKTICKS ANYWHERE INSIDE THIS
45
+ // STRING — one in a COMMENT ends it, the file still parses, the script it produces is truncated
46
+ // garbage, and the build fails somewhere else entirely."* A language having to watch the syntax of
47
+ // the language it is quoted inside is the definition of the problem.
48
+ //
49
+ // What an editor sees in a template literal is TEXT. No highlighting, no completion, no go-to-
50
+ // definition, no rename, no lint, no formatter, no error underline — and a typo surfaces months
51
+ // later in a visitor's browser rather than in a build. The file parses either way, which is what
52
+ // makes it the quiet kind of failure.
53
+ //
54
+ // So the behaviour is a real function and the injected string is GENERATED from it, which is the
55
+ // pattern this package already proved once in `./scroll`: *"generated FROM the function rather than
56
+ // written twice, which is the only version of this worth having."* One source, two shapes.
57
+ //
58
+ // THE FUNCTION CLOSES OVER NOTHING, and it must not. It is serialised with `toString()` and run in
59
+ // a page that has never seen this module, so a reference to anything outside it would compile here,
60
+ // ship, and throw there. Every helper it uses is defined inside it.
61
+ export function xray() {
62
+ if (!new URLSearchParams(location.search).has("xray"))
63
+ return;
64
+ // IT RUNS IN <head>, SO IT WAITS. The shell mounts this beside its other inline scripts, which is
65
+ // the right place — before first paint, so the overlay does not appear a beat late. But #kernel
66
+ // does not exist yet at that moment, and the first version simply returned: the flag was read, the
67
+ // element was absent, and nothing happened with nothing said. Deferring is one line; finding out
68
+ // why an instrument silently does not work is not.
69
+ if (document.readyState === "loading") {
70
+ return void document.addEventListener("DOMContentLoaded", () => start(), { once: true });
71
+ }
72
+ start();
73
+ function start() {
74
+ var K = () => document.getElementById("kernel");
75
+ if (!K())
76
+ return;
77
+ var css = document.createElement("style");
78
+ css.textContent = [
79
+ ".xr{position:fixed;pointer-events:none;z-index:2147483000}",
80
+ // ── THE RHYTHM IS DOT PAPER, THE SAME DOT PAPER THE FLEET ALREADY PAINTS ──────────────────
81
+ // It was ruled horizontal lines, which is notebook paper: it reads as a THING to look at, it
82
+ // fights every horizontal edge in the design, and it says nothing at all about the horizontal
83
+ // axis it does not draw. Dots say both axes at once and disappear behind the content, which is
84
+ // what a grid under a design is for.
85
+ // Same construction as the page background @justai/ui paints on html — a radial-gradient dot on
86
+ // a square tile — so the instrument speaks the fleet's own visual language rather than inventing
87
+ // a second one. The tile is 8px here rather than the page's 16: this is the 8pt rhythm the
88
+ // padding and the margins are actually built on.
89
+ //
90
+ // NO BACKTICKS ANYWHERE INSIDE THIS STRING. It is a template literal, so one in a COMMENT ends
91
+ // it — the file still parses, the script it produces is truncated garbage, and the build fails
92
+ // somewhere else entirely. Written here twice tonight before the fixture refused to build.
93
+ ".xr-rhythm{background-image:radial-gradient(circle,rgba(128,128,128,.34) 1px,transparent 1.4px);background-size:8px 8px}",
94
+ ".xr-f{position:fixed;pointer-events:none;z-index:2147483000}",
95
+ // THREE CORNERS, BECAUSE THE ZONES ARE 16px APART AND A LABEL IS 11px TALL. Stacked at one
96
+ // corner the way a broadcast overlay does it, they collided the moment the gutter was a
97
+ // phone gutter rather than a television one: EDGE OF FRAME sat on ACTION SAFE and the amber
98
+ // line ran through both. Broadcast can stack them because its safe margins are 5% and 10% of
99
+ // the frame; ours are 16px and 32px. So each zone takes a corner of its own and they cannot
100
+ // meet at any width. The colours already say which is which — the words are the confirmation.
101
+ ".xr-f>i{position:absolute;font-size:.68rem;font-style:normal;letter-spacing:.07em;text-transform:uppercase;font-weight:700;white-space:nowrap}",
102
+ // THEY DIFFER IN BOTH AXES, and the second axis is what makes it work at any gutter: each label
103
+ // sits at its own box's top — 16px apart on a phone — AND at a different corner of it. Two of
104
+ // them could be one pixel apart vertically and still not touch.
105
+ // ALL THREE AT THE TOP, and that is not symmetry. An app kernel is at least a viewport tall, so
106
+ // its box ends below the fold: a label anchored to the bottom of the action-safe frame was simply
107
+ // not on the screen. Measured, after being written that way first.
108
+ ".xr-edge>i{top:3px;right:7px}",
109
+ ".xr-act>i{top:3px;left:50%;transform:translateX(-50%)}",
110
+ ".xr-ttl>i{top:3px;left:7px}",
111
+ // ── THREE ZONES, THREE COLOURS, AND THE ORDER MEANS SOMETHING ─────────────────────────────
112
+ // Red, amber, green — outward to inward, danger to safe. Everyone already reads that gradient
113
+ // without being taught it, and it is exactly what the three zones say: the edge is where things
114
+ // get cut, action-safe is where a control may sit, title-safe is where a word is certain to be
115
+ // read. Three greys distinguished only by their dash pattern made the reader count borders.
116
+ ".xr-edge{border:3px solid #E8503A}",
117
+ ".xr-edge>i{color:#E8503A}",
118
+ ".xr-act{border:1.5px solid #F5A623}",
119
+ ".xr-act>i{color:#C97F0B}",
120
+ ".xr-ttl{border:1.5px dashed #2E9E5B}",
121
+ ".xr-ttl>i{color:#2E9E5B}",
122
+ // The centre cross runs the WHOLE frame, in both axes. Ticks at the four edges said where the
123
+ // middle of each side was and left the reader to imagine the intersection; two full lines put
124
+ // the kernel's centre on the screen as a point you can hold something against. Blue, because it
125
+ // is the one thing on this overlay that is not a boundary — it is a reference.
126
+ ".xr-c{position:fixed;background:rgba(61,111,217,.55);pointer-events:none;z-index:2147483000}",
127
+ // ── THE ARMATURE, AND IT IS ON IN EVERY TEMPLATE ──────────────────────────────────────────
128
+ // queries: diagonals · armature · regulating lines · traces regulateurs · where should this sit
129
+ // harmonic armature · rabatment · why are there diagonals over my kernel
130
+ //
131
+ // The lines the frame ALREADY CONTAINS: its two corner diagonals, the eight half-diagonals from
132
+ // each corner to the midpoints of the two sides it does not touch, and the rabatments — fold the
133
+ // short side onto the long and mark where it lands. Charles Bouleau reverse-engineered this
134
+ // fourteen-line lattice out of Raphael, Velazquez and Vermeer (The Painter's Secret Geometry,
135
+ // 1963); Jay Hambidge had the same lattice in 1920 as dynamic symmetry. Every crossing is a
136
+ // place the rectangle itself proposes, which is why an edge that lands on one reads as chosen
137
+ // and an edge two pixels off reads as approximate.
138
+ //
139
+ // THE CENTRE CROSS WAS ALREADY TWO OF THE FOURTEEN and nobody had noticed: the midlines. This
140
+ // draws the other twelve, so the instrument stops being only a set of boundaries and starts
141
+ // being a set of PROPOSALS as well.
142
+ //
143
+ // It is blue, like the cross, because the fleet's own colour grammar here is warm-for-boundary
144
+ // and blue-for-reference. Fainter than the cross: the centre is one place, the armature is
145
+ // twelve lines, and twelve lines at the cross's weight is a drawing rather than a guide.
146
+ ".xr-arm{position:fixed;pointer-events:none;z-index:2147483000;overflow:visible}",
147
+ ".xr-arm path{fill:none;stroke:rgba(61,111,217,.3);stroke-width:1;vector-effect:non-scaling-stroke}",
148
+ ".xr-arm path.rab{stroke:rgba(61,111,217,.22);stroke-dasharray:6 5}",
149
+ ".xr-read{position:fixed;left:12px;bottom:12px;pointer-events:none;z-index:2147483001;",
150
+ "display:grid;grid-template-columns:auto 1fr;gap:2px 12px;padding:10px 12px;border-radius:10px;",
151
+ "background:rgba(20,22,28,.92);color:#f2f4f8;font:400 .78rem/1.35 ui-monospace,SFMono-Regular,Menlo,monospace}",
152
+ ".xr-read b{font-weight:400;opacity:.6}",
153
+ ".xr-read s{text-decoration:none;font-variant-numeric:tabular-nums}",
154
+ ".xr-read s[data-ok=no]{color:#ff6b6b;font-weight:700}",
155
+ ".xr-read s[data-ok=yes]{color:#7ee787}",
156
+ ].join("");
157
+ document.head.appendChild(css);
158
+ const mk = (cls, html) => {
159
+ const d = document.createElement("div");
160
+ d.className = cls;
161
+ if (html)
162
+ d.innerHTML = html;
163
+ document.body.appendChild(d);
164
+ return d;
165
+ };
166
+ var rhythm = mk("xr xr-rhythm");
167
+ var edge = mk("xr-f xr-edge", "<i>edge of frame</i>");
168
+ var act = mk("xr-f xr-act", "<i>action safe</i>");
169
+ var ttl = mk("xr-f xr-ttl", "<i>title safe</i>");
170
+ const cross = [0, 1].map(() => mk("xr-c"));
171
+ var NS = "http://www.w3.org/2000/svg";
172
+ // createElementNS returns `Element` for a namespace it cannot narrow — naming the type is what
173
+ // gives back `.style`, and it is the drawing surface, so the type is the honest one.
174
+ const arm = document.createElementNS(NS, "svg");
175
+ arm.setAttribute("class", "xr-arm");
176
+ var armMain = document.createElementNS(NS, "path");
177
+ var armRab = document.createElementNS(NS, "path");
178
+ armRab.setAttribute("class", "rab");
179
+ arm.appendChild(armMain);
180
+ arm.appendChild(armRab);
181
+ document.body.appendChild(arm);
182
+ var read = mk("xr-read");
183
+ const row = (label) => {
184
+ const b = document.createElement("b");
185
+ b.textContent = label;
186
+ const s = document.createElement("s");
187
+ read.appendChild(b);
188
+ read.appendChild(s);
189
+ return s;
190
+ };
191
+ var R = { viewport: row("viewport"), column: row("column"), gutter: row("gutter L/R"),
192
+ frame: row("frame"), inset: row("kernel inset"), act: row("action safe"), ttl: row("title safe"),
193
+ bar: row("toolbar"), clear: row("clears bar"), safe: row("safe area L/R"),
194
+ bleed: row("bleed") };
195
+ // `ok` is optional and always was — the body has checked `ok !== undefined` since the day it was
196
+ // written. Saying so in the signature is the difference between a contract and a habit.
197
+ const put = (el, text, ok) => {
198
+ el.textContent = text;
199
+ if (ok !== undefined)
200
+ el.dataset.ok = ok ? "yes" : "no";
201
+ };
202
+ const px = (n) => Math.round(n * 10) / 10 + "px";
203
+ const box = (el, r, inset) => {
204
+ el.style.left = (r.left + inset) + "px";
205
+ el.style.top = (r.top + inset) + "px";
206
+ el.style.width = Math.max(0, r.width - inset * 2) + "px";
207
+ el.style.height = Math.max(0, r.height - inset * 2) + "px";
208
+ };
209
+ var draw = () => {
210
+ var k = K();
211
+ if (!k)
212
+ return;
213
+ var r = k.getBoundingClientRect();
214
+ var app = document.querySelector(".app");
215
+ var cs = app ? getComputedStyle(app) : null;
216
+ var padL = cs ? parseFloat(cs.paddingLeft) || 0 : 0;
217
+ var padR = cs ? parseFloat(cs.paddingRight) || 0 : 0;
218
+ var g = cs ? parseFloat(cs.getPropertyValue("--gutter")) || 16 : 16;
219
+ box(edge, r, 0);
220
+ box(act, r, g);
221
+ box(ttl, r, g * 2);
222
+ box(rhythm, r, 0);
223
+ // THE CENTRE CROSS, EDGE TO EDGE. Their intersection IS the kernel's centre — the one point a
224
+ // design gets measured against and the one an eye cannot find on its own. Drawn across the whole
225
+ // frame rather than as ticks, so anything meant to be centred can be held against a line instead
226
+ // of against a guess about where two marks would have met.
227
+ var t = [[r.left + r.width / 2, r.top, 1, r.height],
228
+ [r.left, r.top + r.height / 2, r.width, 1]];
229
+ cross.forEach((el, i) => {
230
+ el.style.left = t[i][0] + "px";
231
+ el.style.top = t[i][1] + "px";
232
+ el.style.width = t[i][2] + "px";
233
+ el.style.height = t[i][3] + "px";
234
+ });
235
+ // The armature is drawn in the frame's own coordinates and laid over the frame exactly, so it
236
+ // moves and rescales with the kernel and never needs a number of its own.
237
+ var W = r.width, H = r.height;
238
+ arm.style.left = r.left + "px";
239
+ arm.style.top = r.top + "px";
240
+ // setAttribute takes a STRING. Handing it a number worked because the DOM coerces — but it is
241
+ // the same looseness that lets a unit slip away unnoticed, so it is said out loud here.
242
+ arm.setAttribute("width", String(W));
243
+ arm.setAttribute("height", String(H));
244
+ arm.setAttribute("viewBox", "0 0 " + W + " " + H);
245
+ const seg = (x1, y1, x2, y2) => "M" + x1 + " " + y1 + "L" + x2 + " " + y2;
246
+ var d = [seg(0, 0, W, H), seg(W, 0, 0, H)];
247
+ // Each corner reaches the midpoints of the two sides it does NOT lie on — eight lines, and the
248
+ // pairs of them that cross mark the thirds and the fifths without anybody dividing anything.
249
+ d.push(seg(0, 0, W, H / 2), seg(0, 0, W / 2, H));
250
+ d.push(seg(W, 0, 0, H / 2), seg(W, 0, W / 2, H));
251
+ d.push(seg(W, H, W / 2, 0), seg(W, H, 0, H / 2));
252
+ d.push(seg(0, H, W / 2, 0), seg(0, H, W, H / 2));
253
+ armMain.setAttribute("d", d.join(""));
254
+ // RABATMENT: fold the short side onto the long one. Where it lands is the square, and what is
255
+ // left over is the rectangle the frame is "made of" — in a golden frame, another golden frame.
256
+ var rab = W > H ? [seg(H, 0, H, H), seg(W - H, 0, W - H, H)]
257
+ : H > W ? [seg(0, W, W, W), seg(0, H - W, W, H - W)] : [];
258
+ armRab.setAttribute("d", rab.join(""));
259
+ var aw = app ? app.getBoundingClientRect().width : r.width;
260
+ put(R.viewport, Math.round(innerWidth) + " x " + Math.round(innerHeight));
261
+ put(R.column, px(aw), aw <= 640);
262
+ var even = Math.abs(padL - padR) < 0.5;
263
+ put(R.gutter, px(padL) + " / " + px(padR) + (even ? "" : " <- the two sides differ"), even);
264
+ put(R.frame, px(r.width) + " x " + px(r.height));
265
+ // THE KERNEL'S OWN INSET, WITH THE LAW IT IS JUDGED AGAINST. Two laws, and which one applies is
266
+ // read from the document rather than guessed: an APP kernel is inset by the gutter on all four
267
+ // sides, a GAME kernel by nothing at all. This row is the reason the second law stopped being
268
+ // sixteen copies — 8px sat at the bottom of every persona in the fleet, matching neither the top
269
+ // nor the sides, and there was nowhere it was ever printed next to what it should have been.
270
+ var kind = document.documentElement.dataset.kind || "app";
271
+ var ks = getComputedStyle(k);
272
+ var kp = [ks.paddingTop, ks.paddingRight, ks.paddingBottom, ks.paddingLeft].map((v) => parseFloat(v) || 0);
273
+ // ONE NUMBER ON ALL FOUR SIDES — the frame is the active view for both kinds now, so what tells
274
+ // them apart is the padding INSIDE it: an app pads by the gutter, which puts its content exactly
275
+ // on the action-safe ring below, and a game pads by nothing.
276
+ // The bottom may EXCEED it and only the bottom may: env(safe-area-inset-bottom) is the strip the
277
+ // OS keeps for its home indicator, and it is added rather than substituted.
278
+ var want = kind === "game" ? 0 : g;
279
+ var insetOk = kp[0] === want && kp[1] === want && kp[3] === want && kp[2] >= want;
280
+ put(R.inset, kp.join(" / ") + " (" + kind + " wants " + want + ")", insetOk);
281
+ put(R.act, "inset " + px(g) + " . " + px(r.width - g * 2) + " wide");
282
+ put(R.ttl, "inset " + px(g * 2) + " . " + px(r.width - g * 4) + " wide");
283
+ var bar = document.querySelector(".toolbar");
284
+ if (bar) {
285
+ var bh = bar.getBoundingClientRect().height;
286
+ // Scroll-independent on purpose: comparing the kernel's top to the bar's bottom in viewport
287
+ // coordinates reports an overlap the moment the page has scrolled. The real question is about
288
+ // the LANDING — the bar is sticky, the page lands on #kernel, and scroll-margin-top decides
289
+ // whether the first thing here arrives below the bar or underneath it.
290
+ var landing = parseFloat(getComputedStyle(k).scrollMarginTop) || 0;
291
+ var air = landing - bh;
292
+ put(R.bar, px(bh) + " . lands at " + px(landing));
293
+ put(R.clear, air < -0.5 ? px(air) + " <- kernel UNDER the bar" : px(air), air >= -0.5);
294
+ }
295
+ else {
296
+ put(R.bar, "none");
297
+ put(R.clear, "-");
298
+ }
299
+ // env() is not readable from JS, so it is measured: what the browser applied minus what the CSS
300
+ // asked for IS the safe area.
301
+ put(R.safe, px(Math.max(0, padL - g)) + " / " + px(Math.max(0, padR - g)));
302
+ var over = Math.max(0, Math.round(document.documentElement.scrollWidth - innerWidth));
303
+ put(R.bleed, over ? over + "px past the viewport" : "none", over === 0);
304
+ };
305
+ var tick = false;
306
+ var schedule = () => { if (tick)
307
+ return; tick = true; requestAnimationFrame(() => { tick = false; draw(); }); };
308
+ draw();
309
+ addEventListener("resize", schedule, { passive: true });
310
+ addEventListener("scroll", schedule, { passive: true });
311
+ if (document.fonts && document.fonts.ready)
312
+ document.fonts.ready.then(draw);
313
+ }
314
+ }
315
+ /** The x-ray as an injectable IIFE — derived from {@link xray}, never written twice. */
316
+ export const XRAY_JS = "(" + xray.toString() + ")();";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.35.0",
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.",
3
+ "version": "0.36.0",
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",
@@ -10,15 +10,58 @@
10
10
  },
11
11
  "type": "module",
12
12
  "files": [
13
- "src"
13
+ "dist",
14
+ "README.md"
14
15
  ],
15
16
  "exports": {
16
17
  ".": {
17
- "types": "./src/index.d.ts",
18
- "default": "./src/index.js"
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./boot": {
22
+ "types": "./dist/boot.d.ts",
23
+ "default": "./dist/boot.js"
24
+ },
25
+ "./xray": {
26
+ "types": "./dist/xray.d.ts",
27
+ "default": "./dist/xray.js"
28
+ },
29
+ "./analytics": {
30
+ "types": "./dist/analytics.d.ts",
31
+ "default": "./dist/analytics.js"
32
+ },
33
+ "./consent": {
34
+ "types": "./dist/consent.d.ts",
35
+ "default": "./dist/consent.js"
36
+ },
37
+ "./chrome": {
38
+ "types": "./dist/chrome.d.ts",
39
+ "default": "./dist/chrome.js"
40
+ },
41
+ "./presentation": {
42
+ "types": "./dist/presentation.d.ts",
43
+ "default": "./dist/presentation.js"
44
+ },
45
+ "./scroll": {
46
+ "types": "./dist/scroll.d.ts",
47
+ "default": "./dist/scroll.js"
48
+ },
49
+ "./mark": {
50
+ "types": "./dist/mark.d.ts",
51
+ "default": "./dist/mark.js"
52
+ },
53
+ "./face": {
54
+ "types": "./dist/face.d.ts",
55
+ "default": "./dist/face.js"
19
56
  }
20
57
  },
21
58
  "publishConfig": {
22
59
  "access": "public"
60
+ },
61
+ "scripts": {
62
+ "prepack": "bunx tsc -p tsconfig.json"
63
+ },
64
+ "devDependencies": {
65
+ "typescript": "^5.6.0"
23
66
  }
24
67
  }
package/src/index.d.ts DELETED
@@ -1,147 +0,0 @@
1
- /** Capture the SSO token from the URL fragment, synchronously. MUST run first in the head — see index.js. */
2
- export declare const AUTH_CAPTURE_JS: string;
3
-
4
- /** Mark that JavaScript is running, so the reveal can hold paint only when JS can un-hold it. */
5
- export declare const JS_CLASS_JS: string;
6
-
7
- /** Hold paint until a page sets `body.ready`. A page with no kernel script must carry READY_JS. */
8
- export declare const REVEAL_CSS: string;
9
-
10
- /** Self-reveal for a page with no kernel script (a 404, a child persona like feed). */
11
- export declare const READY_JS: string;
12
-
13
- /** Which GA4 measurement id a host reports into. The ecosystem's stream layout, declared once. */
14
- export declare function measurementIdFor(host: string | null | undefined): string;
15
-
16
- /** The whole analytics head block for a measurement id — non-production guard, consent defaults, config, deferred loader. */
17
- export declare function analyticsJs(gaId: string): string;
18
-
19
- /** The consent question in thirteen languages — the ecosystem's promise, said once. */
20
- export declare const CONSENT_COPY: Record<string, { consentText: string; consentAllow: string; consentDecline: string; consentChoice: string }>;
21
-
22
- /** The consent copy for a language, falling back to English. */
23
- export declare function consentCopy(lang: string): { consentText: string; consentAllow: string; consentDecline: string; consentChoice: string };
24
-
25
- /** Cancel and Done in thirteen languages — the ecosystem's chrome words, not a persona's copy. */
26
- export declare const CHROME_COPY: Record<string, { cancel: string; done: string }>;
27
-
28
- /** The chrome words for a language, falling back to English. */
29
- export declare function chromeCopy(lang: string): { cancel: string; done: string };
30
-
31
- /** The consent dialog's behaviour — origin-scoped, asked once, with the universal change-your-mind door. */
32
- export declare const CONSENT_JS: string;
33
-
34
- /** The query parameter a caller uses to declare which presentation it is asking for. */
35
- export declare const PRESENTATION_PARAM: string;
36
- /** Its value when the caller is another persona speaking over atrium. */
37
- export declare const PRESENTATION_EMBEDDED: string;
38
- /**
39
- * Which presentation this page is in: `"embedded"` only when a caller DECLARED it and the browser
40
- * agrees we are in a frame. Presentation only — never a permission. See the note in index.js.
41
- */
42
- export declare function presentation(loc?: Location, win?: Window): "standalone" | "embedded";
43
-
44
- export interface PersonaScrollOptions {
45
- /** Section ids in document order. Default `["profile", "kernel", "posts"]`. */
46
- cuts?: string[];
47
- /** Id of the element the toolbar sits at the top of. Default `"below"`. */
48
- below?: string | HTMLElement;
49
- toolbar?: string | HTMLElement;
50
- title?: string | HTMLElement;
51
- titleText?: string | HTMLElement;
52
- /** Maps a section id to its nav's id. Default `profile` → `navProfile`. */
53
- navFor?: (id: string) => string;
54
- /** What the title strip says for a section. Default: kernel → `.pname`, posts → `.handle`. */
55
- titleFor?: (id: string) => string;
56
- /** Whether this owns `body.ready`. Pass `false` on a page that renders asynchronously. */
57
- reveal?: boolean;
58
- // `line` was here — a pixel threshold a section had to cross to count as current, defaulting to 84.
59
- // It is gone rather than deprecated, because it was the bug: a constant that had to be kept in step
60
- // by hand with the `scroll-margin-top` twelve personas declared separately, and the two-pixel gap
61
- // between them is where the hash stopped guaranteeing the cut. A cut now begins where the page
62
- // comes to rest when you go to it — one definition, read from the DOM, nothing to tune.
63
- }
64
-
65
- /**
66
- * The persona page's scroll behaviour: land on the kernel, the toolbar hairline, the scroll-spy,
67
- * the title strip and the hash. Framework-free, so the Astro cut, the Next face and hand-written
68
- * surfaces (`/me`, `/files`, the feed) run one implementation rather than four copies.
69
- */
70
- export declare function personaScroll(options?: PersonaScrollOptions): void;
71
-
72
- /**
73
- * `personaScroll` as an inline script string, for surfaces that cannot bundle a module (the feed).
74
- * Generated from the function itself, so there is never a second implementation to keep in step.
75
- */
76
- export declare function personaScrollJs(options?: PersonaScrollOptions): string;
77
-
78
- /** The host persona's face, as a child persona reads it from `/api/face?host=`. */
79
- export interface ChildFace {
80
- handle: string;
81
- home: string | null;
82
- name: string | null;
83
- /** The canonical icon — ONE face everywhere. */
84
- avatar: string | null;
85
- glyph: string | null;
86
- accent: string | null;
87
- bio: string | null;
88
- meta: string | null;
89
- }
90
-
91
- /**
92
- * Fetch the HOST persona's face and apply its accent — for a child persona (`/me`, `/files`,
93
- * `/feed`) mounted on that host.
94
- *
95
- * Reads `/api/face?host=`, which answers "who owns this address" rather than "what is on the
96
- * storefront": the catalog filters `visibility: hidden` on purpose, so a newborn persona would be
97
- * invisible to its own child personas.
98
- *
99
- * The accent is written to BOTH `:root` and the `.pp` wrapper, because a child scopes its whole
100
- * token set under `.pp` — writing only to the root is shadowed for the entire surface and changes
101
- * nothing a person can see.
102
- *
103
- * Returns `null` when the host is not a persona, which is a legible state rather than an error.
104
- */
105
- export declare function childFace(options?: {
106
- /** Defaults to `location.hostname`. */
107
- host?: string;
108
- /** The `.pp` wrapper. Defaults to `document.getElementById("pp")`. */
109
- root?: HTMLElement | null;
110
- /** Defaults to `https://api.justai.pro`. */
111
- api?: string;
112
- }): Promise<ChildFace | null>;
113
-
114
- /**
115
- * Derive a toolbar mark from a persona's `icon.svg` — the SAME file, not a second drawing.
116
- *
117
- * An `icon.svg` is a TILE: a squircle ground with the mark on it. In a row of icons that ground is
118
- * the only object with a background. This removes it, namespaces every id so the avatar and the row
119
- * can coexist on one page, and drops the authoring comment and the accessible name (the link around
120
- * it carries that).
121
- *
122
- * It does not recolour: whether the row's mark takes `currentColor` is the persona's decision.
123
- *
124
- * @param iconSvg the file's contents — `import iconSvg from "../../public/icon.svg?raw"`
125
- */
126
- export declare function toolbarMark(
127
- iconSvg: string,
128
- options?: {
129
- id?: string;
130
- class?: string;
131
- /**
132
- * How much of its viewBox this persona's drawing actually fills, 0–1. The row shows 20px of INK,
133
- * so the box becomes `20 / fills` — a mark drawn inside a tile keeps the tile's padding and would
134
- * otherwise read at 9–13px. Measure it once (`getBBox().width / viewBox width`, longer side) and
135
- * write it down; it is this persona's own number, like its accent, and it moves when the mark is
136
- * redrawn.
137
- */
138
- fills?: number;
139
- /**
140
- * How many pixels of INK the surface wants, default 20 — the toolbar row's rule. The preroll
141
- * asks for 300: the derivation is the same (take the tile's ground off, namespace the ids so two
142
- * copies on one page do not fight over a gradient), only the measure differs, and a second copy
143
- * of that logic under a second name is the O(N) debt this package exists to refuse.
144
- */
145
- ink?: number;
146
- },
147
- ): string;