@justai/core 0.35.0 → 0.37.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/analytics.d.ts +61 -0
- package/dist/analytics.js +129 -0
- package/dist/boot.d.ts +53 -0
- package/dist/boot.js +83 -0
- package/dist/chrome.d.ts +42 -0
- package/dist/chrome.js +25 -0
- package/dist/consent.d.ts +105 -0
- package/dist/consent.js +156 -0
- package/dist/face.d.ts +27 -0
- package/dist/face.js +85 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +55 -0
- package/dist/mark.d.ts +26 -0
- package/dist/mark.js +286 -0
- package/dist/presentation.d.ts +10 -0
- package/dist/presentation.js +54 -0
- package/dist/scroll.d.ts +23 -0
- package/dist/scroll.js +612 -0
- package/dist/xray.d.ts +40 -0
- package/dist/xray.js +316 -0
- package/package.json +48 -5
- package/src/index.d.ts +0 -147
- package/src/index.js +0 -1662
package/src/index.js
DELETED
|
@@ -1,1662 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @justai/core — the framework-free heart of the persona shell.
|
|
3
|
-
*
|
|
4
|
-
* The load-bearing behaviour of every persona page is plain JavaScript and CSS. It does not care
|
|
5
|
-
* whether an Astro template or a React component put it in the head — the SAME string of JS captures
|
|
6
|
-
* the SSO token whether it is injected with `set:html` or `dangerouslySetInnerHTML`. So it lives HERE,
|
|
7
|
-
* once, and the framework bindings (@justai/cuts for Astro, and a Next equivalent) inject it. When a
|
|
8
|
-
* string of shell logic lives inside a `.astro` component, a `.tsx` file that needs the same thing has
|
|
9
|
-
* no choice but to hand-copy it — which is exactly how `feed` (Next) came to carry its own byte-for-byte
|
|
10
|
-
* copy of the auth capture below. Two copies in two frameworks drift the same way nine copies in one
|
|
11
|
-
* framework did; this package is the fix, one level lower than @justai/cuts.
|
|
12
|
-
*
|
|
13
|
-
* These are STRINGS, deliberately, not functions that build DOM — because the thing that is identical
|
|
14
|
-
* across frameworks is the behaviour, and the thing that differs is only how a head is assembled. Keep
|
|
15
|
-
* anything framework-specific (JSX, Astro directives, `define:vars`) OUT of here.
|
|
16
|
-
*
|
|
17
|
-
* Whenever you change one of these, you are changing it for every persona on both frameworks at once —
|
|
18
|
-
* which is the point, and the responsibility. The reasons that make each one load-bearing live in
|
|
19
|
-
* @justai/web's expert corpus (the-shell-guarantees-you-cannot-see), where they survive a refactor of
|
|
20
|
-
* the code that carries them.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Capture the SSO token from the URL fragment, synchronously, and stash it for the deferred auth SDK.
|
|
25
|
-
*
|
|
26
|
-
* MUST run before anything else can touch `location.hash`. Two later scripts would otherwise take it:
|
|
27
|
-
* a scroll-spy that rewrites the hash to `#kernel` CLOBBERS `#auth_token` before the SDK reads it, and
|
|
28
|
-
* a language picker that copies the current hash onto the next locale's URL would PROPAGATE the raw
|
|
29
|
-
* token into history. Injecting this first, in the head, defeats both. Move it later and sign-in breaks
|
|
30
|
-
* SILENTLY — no error, the visitor simply lands back signed out.
|
|
31
|
-
*/
|
|
32
|
-
export const AUTH_CAPTURE_JS =
|
|
33
|
-
`(function(){try{var h=location.hash||"";var m=h.match(/(?:^#|&)auth_token=([^&]+)/);` +
|
|
34
|
-
`if(m){localStorage.setItem("justai_token",decodeURIComponent(m[1]))}` +
|
|
35
|
-
`else if(/(?:^#|&)auth_signout=1\\b/.test(h)){localStorage.removeItem("justai_token")}else{return}` +
|
|
36
|
-
`history.replaceState(null,"",location.pathname+location.search)}catch(e){}})();`;
|
|
37
|
-
|
|
38
|
-
/** Mark that JavaScript is running, so the reveal below can hold paint only when JS can un-hold it. */
|
|
39
|
-
export const JS_CLASS_JS = `document.documentElement.classList.add("js")`;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* queries: design grid · x-ray · ?xray · safe area · title safe · action safe · edge of frame ·
|
|
43
|
-
* debug overlay · is my content inside the safe area · does the kernel overlap the toolbar ·
|
|
44
|
-
* horizontal bleed · the column is not centred · layout debugging · developing a persona
|
|
45
|
-
*
|
|
46
|
-
* ── THE X-RAY: THE SHELL'S DESIGN GRID, ON DEMAND ─────────────────────────────────────────────
|
|
47
|
-
*
|
|
48
|
-
* Open any persona with `?xray` and its skeleton appears over the live page: the kernel's own frame,
|
|
49
|
-
* the two safe areas, centre crosshairs, an 8px rhythm, and every number the layout depends on with
|
|
50
|
-
* a verdict on each. You look THROUGH the persona's own controls and see whether they sit inside the
|
|
51
|
-
* safe areas or cross them.
|
|
52
|
-
*
|
|
53
|
-
* ── IT IS A PAIR OF GLASSES, NOT A RENOVATION ────────────────────────────────────────────────
|
|
54
|
-
*
|
|
55
|
-
* The founder's constraint, and it shapes every decision below: turning the x-ray on must not change
|
|
56
|
-
* the layout it is measuring. An instrument that moves the thing it measures is not an instrument.
|
|
57
|
-
*
|
|
58
|
-
* So nothing here touches the page. No class is added to the kernel, no `position: relative`, no
|
|
59
|
-
* flow element anywhere — the overlay is `position: fixed` and its coordinates are READ from
|
|
60
|
-
* `#kernel.getBoundingClientRect()` on every frame that matters. The page cannot tell it is there.
|
|
61
|
-
* `pointer-events: none` throughout, so it cannot even absorb a click.
|
|
62
|
-
*
|
|
63
|
-
* ── AND WHEN IT IS OFF IT COSTS NOTHING ──────────────────────────────────────────────────────
|
|
64
|
-
*
|
|
65
|
-
* This whole string returns on its second line unless the flag is present. The stylesheet, the DOM
|
|
66
|
-
* and the listeners are built inside that branch: a persona that nobody is debugging ships one
|
|
67
|
-
* `if`. A debug feature that is only free when somebody remembers to remove it is one that ships.
|
|
68
|
-
*
|
|
69
|
-
* The flag is read from `location.search`, so `?xray`, `?xray=1` and `&xray` all work. A flag you
|
|
70
|
-
* have to spell exactly right is one you will spell wrong at the moment you need it.
|
|
71
|
-
*/
|
|
72
|
-
export const XRAY_JS = `(() => {
|
|
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() {
|
|
85
|
-
var K = () => document.getElementById("kernel");
|
|
86
|
-
if (!K()) return;
|
|
87
|
-
|
|
88
|
-
var css = document.createElement("style");
|
|
89
|
-
css.textContent = [
|
|
90
|
-
".xr{position:fixed;pointer-events:none;z-index:2147483000}",
|
|
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}",
|
|
105
|
-
".xr-f{position:fixed;pointer-events:none;z-index:2147483000}",
|
|
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.
|
|
127
|
-
".xr-edge{border:3px solid #E8503A}",
|
|
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}",
|
|
138
|
-
// ── THE ARMATURE, AND IT IS ON IN EVERY TEMPLATE ──────────────────────────────────────────
|
|
139
|
-
// queries: diagonals · armature · regulating lines · traces regulateurs · where should this sit
|
|
140
|
-
// harmonic armature · rabatment · why are there diagonals over my kernel
|
|
141
|
-
//
|
|
142
|
-
// The lines the frame ALREADY CONTAINS: its two corner diagonals, the eight half-diagonals from
|
|
143
|
-
// each corner to the midpoints of the two sides it does not touch, and the rabatments — fold the
|
|
144
|
-
// short side onto the long and mark where it lands. Charles Bouleau reverse-engineered this
|
|
145
|
-
// fourteen-line lattice out of Raphael, Velazquez and Vermeer (The Painter's Secret Geometry,
|
|
146
|
-
// 1963); Jay Hambidge had the same lattice in 1920 as dynamic symmetry. Every crossing is a
|
|
147
|
-
// place the rectangle itself proposes, which is why an edge that lands on one reads as chosen
|
|
148
|
-
// and an edge two pixels off reads as approximate.
|
|
149
|
-
//
|
|
150
|
-
// THE CENTRE CROSS WAS ALREADY TWO OF THE FOURTEEN and nobody had noticed: the midlines. This
|
|
151
|
-
// draws the other twelve, so the instrument stops being only a set of boundaries and starts
|
|
152
|
-
// being a set of PROPOSALS as well.
|
|
153
|
-
//
|
|
154
|
-
// It is blue, like the cross, because the fleet's own colour grammar here is warm-for-boundary
|
|
155
|
-
// and blue-for-reference. Fainter than the cross: the centre is one place, the armature is
|
|
156
|
-
// twelve lines, and twelve lines at the cross's weight is a drawing rather than a guide.
|
|
157
|
-
".xr-arm{position:fixed;pointer-events:none;z-index:2147483000;overflow:visible}",
|
|
158
|
-
".xr-arm path{fill:none;stroke:rgba(61,111,217,.3);stroke-width:1;vector-effect:non-scaling-stroke}",
|
|
159
|
-
".xr-arm path.rab{stroke:rgba(61,111,217,.22);stroke-dasharray:6 5}",
|
|
160
|
-
".xr-read{position:fixed;left:12px;bottom:12px;pointer-events:none;z-index:2147483001;",
|
|
161
|
-
"display:grid;grid-template-columns:auto 1fr;gap:2px 12px;padding:10px 12px;border-radius:10px;",
|
|
162
|
-
"background:rgba(20,22,28,.92);color:#f2f4f8;font:400 .78rem/1.35 ui-monospace,SFMono-Regular,Menlo,monospace}",
|
|
163
|
-
".xr-read b{font-weight:400;opacity:.6}",
|
|
164
|
-
".xr-read s{text-decoration:none;font-variant-numeric:tabular-nums}",
|
|
165
|
-
".xr-read s[data-ok=no]{color:#ff6b6b;font-weight:700}",
|
|
166
|
-
".xr-read s[data-ok=yes]{color:#7ee787}",
|
|
167
|
-
].join("");
|
|
168
|
-
document.head.appendChild(css);
|
|
169
|
-
|
|
170
|
-
var mk = (cls, html) => { var d = document.createElement("div"); d.className = cls; if (html) d.innerHTML = html; document.body.appendChild(d); return d; };
|
|
171
|
-
var rhythm = mk("xr xr-rhythm");
|
|
172
|
-
var edge = mk("xr-f xr-edge", "<i>edge of frame</i>");
|
|
173
|
-
var act = mk("xr-f xr-act", "<i>action safe</i>");
|
|
174
|
-
var ttl = mk("xr-f xr-ttl", "<i>title safe</i>");
|
|
175
|
-
var cross = [0,1].map(() => mk("xr-c"));
|
|
176
|
-
var NS = "http://www.w3.org/2000/svg";
|
|
177
|
-
var arm = document.createElementNS(NS, "svg");
|
|
178
|
-
arm.setAttribute("class", "xr-arm");
|
|
179
|
-
var armMain = document.createElementNS(NS, "path");
|
|
180
|
-
var armRab = document.createElementNS(NS, "path"); armRab.setAttribute("class", "rab");
|
|
181
|
-
arm.appendChild(armMain); arm.appendChild(armRab);
|
|
182
|
-
document.body.appendChild(arm);
|
|
183
|
-
var read = mk("xr-read");
|
|
184
|
-
|
|
185
|
-
var row = (label) => {
|
|
186
|
-
var b = document.createElement("b"); b.textContent = label;
|
|
187
|
-
var s = document.createElement("s");
|
|
188
|
-
read.appendChild(b); 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
|
-
var put = (el, text, ok) => { el.textContent = text; if (ok !== undefined) el.dataset.ok = ok ? "yes" : "no"; };
|
|
196
|
-
var px = (n) => Math.round(n * 10) / 10 + "px";
|
|
197
|
-
var box = (el, r, inset) => {
|
|
198
|
-
el.style.left = (r.left + inset) + "px"; el.style.top = (r.top + inset) + "px";
|
|
199
|
-
el.style.width = Math.max(0, r.width - inset * 2) + "px";
|
|
200
|
-
el.style.height = Math.max(0, r.height - inset * 2) + "px";
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
var draw = () => {
|
|
204
|
-
var k = K(); if (!k) return;
|
|
205
|
-
var r = k.getBoundingClientRect();
|
|
206
|
-
var app = document.querySelector(".app");
|
|
207
|
-
var cs = app ? getComputedStyle(app) : null;
|
|
208
|
-
var padL = cs ? parseFloat(cs.paddingLeft) || 0 : 0;
|
|
209
|
-
var padR = cs ? parseFloat(cs.paddingRight) || 0 : 0;
|
|
210
|
-
var g = cs ? parseFloat(cs.getPropertyValue("--gutter")) || 16 : 16;
|
|
211
|
-
|
|
212
|
-
box(edge, r, 0); box(act, r, g); box(ttl, r, g * 2); box(rhythm, r, 0);
|
|
213
|
-
|
|
214
|
-
// THE CENTRE CROSS, EDGE TO EDGE. Their intersection IS the kernel's centre — the one point a
|
|
215
|
-
// design gets measured against and the one an eye cannot find on its own. Drawn across the whole
|
|
216
|
-
// frame rather than as ticks, so anything meant to be centred can be held against a line instead
|
|
217
|
-
// of against a guess about where two marks would have met.
|
|
218
|
-
var t = [[r.left + r.width / 2, r.top, 1, r.height],
|
|
219
|
-
[r.left, r.top + r.height / 2, r.width, 1]];
|
|
220
|
-
cross.forEach((el, i) => { el.style.left = t[i][0] + "px"; el.style.top = t[i][1] + "px";
|
|
221
|
-
el.style.width = t[i][2] + "px"; el.style.height = t[i][3] + "px"; });
|
|
222
|
-
|
|
223
|
-
// The armature is drawn in the frame's own coordinates and laid over the frame exactly, so it
|
|
224
|
-
// moves and rescales with the kernel and never needs a number of its own.
|
|
225
|
-
var W = r.width, H = r.height;
|
|
226
|
-
arm.style.left = r.left + "px"; arm.style.top = r.top + "px";
|
|
227
|
-
arm.setAttribute("width", W); arm.setAttribute("height", H);
|
|
228
|
-
arm.setAttribute("viewBox", "0 0 " + W + " " + H);
|
|
229
|
-
var seg = (x1, y1, x2, y2) => "M" + x1 + " " + y1 + "L" + x2 + " " + y2;
|
|
230
|
-
var d = [seg(0, 0, W, H), seg(W, 0, 0, H)];
|
|
231
|
-
// Each corner reaches the midpoints of the two sides it does NOT lie on — eight lines, and the
|
|
232
|
-
// pairs of them that cross mark the thirds and the fifths without anybody dividing anything.
|
|
233
|
-
d.push(seg(0, 0, W, H / 2), seg(0, 0, W / 2, H));
|
|
234
|
-
d.push(seg(W, 0, 0, H / 2), seg(W, 0, W / 2, H));
|
|
235
|
-
d.push(seg(W, H, W / 2, 0), seg(W, H, 0, H / 2));
|
|
236
|
-
d.push(seg(0, H, W / 2, 0), seg(0, H, W, H / 2));
|
|
237
|
-
armMain.setAttribute("d", d.join(""));
|
|
238
|
-
// RABATMENT: fold the short side onto the long one. Where it lands is the square, and what is
|
|
239
|
-
// left over is the rectangle the frame is "made of" — in a golden frame, another golden frame.
|
|
240
|
-
var rab = W > H ? [seg(H, 0, H, H), seg(W - H, 0, W - H, H)]
|
|
241
|
-
: H > W ? [seg(0, W, W, W), seg(0, H - W, W, H - W)] : [];
|
|
242
|
-
armRab.setAttribute("d", rab.join(""));
|
|
243
|
-
|
|
244
|
-
var aw = app ? app.getBoundingClientRect().width : r.width;
|
|
245
|
-
put(R.viewport, Math.round(innerWidth) + " x " + Math.round(innerHeight));
|
|
246
|
-
put(R.column, px(aw), aw <= 640);
|
|
247
|
-
var even = Math.abs(padL - padR) < 0.5;
|
|
248
|
-
put(R.gutter, px(padL) + " / " + px(padR) + (even ? "" : " <- the two sides differ"), even);
|
|
249
|
-
put(R.frame, px(r.width) + " x " + px(r.height));
|
|
250
|
-
// THE KERNEL'S OWN INSET, WITH THE LAW IT IS JUDGED AGAINST. Two laws, and which one applies is
|
|
251
|
-
// read from the document rather than guessed: an APP kernel is inset by the gutter on all four
|
|
252
|
-
// sides, a GAME kernel by nothing at all. This row is the reason the second law stopped being
|
|
253
|
-
// sixteen copies — 8px sat at the bottom of every persona in the fleet, matching neither the top
|
|
254
|
-
// nor the sides, and there was nowhere it was ever printed next to what it should have been.
|
|
255
|
-
var kind = document.documentElement.dataset.kind || "app";
|
|
256
|
-
var ks = getComputedStyle(k);
|
|
257
|
-
var kp = [ks.paddingTop, ks.paddingRight, ks.paddingBottom, ks.paddingLeft].map((v) => parseFloat(v) || 0);
|
|
258
|
-
// ONE NUMBER ON ALL FOUR SIDES — the frame is the active view for both kinds now, so what tells
|
|
259
|
-
// them apart is the padding INSIDE it: an app pads by the gutter, which puts its content exactly
|
|
260
|
-
// on the action-safe ring below, and a game pads by nothing.
|
|
261
|
-
// The bottom may EXCEED it and only the bottom may: env(safe-area-inset-bottom) is the strip the
|
|
262
|
-
// OS keeps for its home indicator, and it is added rather than substituted.
|
|
263
|
-
var want = kind === "game" ? 0 : g;
|
|
264
|
-
var insetOk = kp[0] === want && kp[1] === want && kp[3] === want && kp[2] >= want;
|
|
265
|
-
put(R.inset, kp.join(" / ") + " (" + kind + " wants " + want + ")", insetOk);
|
|
266
|
-
put(R.act, "inset " + px(g) + " . " + px(r.width - g * 2) + " wide");
|
|
267
|
-
put(R.ttl, "inset " + px(g * 2) + " . " + px(r.width - g * 4) + " wide");
|
|
268
|
-
|
|
269
|
-
var bar = document.querySelector(".toolbar");
|
|
270
|
-
if (bar) {
|
|
271
|
-
var bh = bar.getBoundingClientRect().height;
|
|
272
|
-
// Scroll-independent on purpose: comparing the kernel's top to the bar's bottom in viewport
|
|
273
|
-
// coordinates reports an overlap the moment the page has scrolled. The real question is about
|
|
274
|
-
// the LANDING — the bar is sticky, the page lands on #kernel, and scroll-margin-top decides
|
|
275
|
-
// whether the first thing here arrives below the bar or underneath it.
|
|
276
|
-
var landing = parseFloat(getComputedStyle(k).scrollMarginTop) || 0;
|
|
277
|
-
var air = landing - bh;
|
|
278
|
-
put(R.bar, px(bh) + " . lands at " + px(landing));
|
|
279
|
-
put(R.clear, air < -0.5 ? px(air) + " <- kernel UNDER the bar" : px(air), air >= -0.5);
|
|
280
|
-
} else { put(R.bar, "none"); put(R.clear, "-"); }
|
|
281
|
-
|
|
282
|
-
// env() is not readable from JS, so it is measured: what the browser applied minus what the CSS
|
|
283
|
-
// asked for IS the safe area.
|
|
284
|
-
put(R.safe, px(Math.max(0, padL - g)) + " / " + px(Math.max(0, padR - g)));
|
|
285
|
-
var over = Math.max(0, Math.round(document.documentElement.scrollWidth - innerWidth));
|
|
286
|
-
put(R.bleed, over ? over + "px past the viewport" : "none", over === 0);
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
var tick = false;
|
|
290
|
-
var schedule = () => { if (tick) return; tick = true; requestAnimationFrame(() => { tick = false; draw(); }); };
|
|
291
|
-
draw();
|
|
292
|
-
addEventListener("resize", schedule, { passive: true });
|
|
293
|
-
addEventListener("scroll", schedule, { passive: true });
|
|
294
|
-
if (document.fonts && document.fonts.ready) document.fonts.ready.then(draw);
|
|
295
|
-
}
|
|
296
|
-
})()`;
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Hold the paint until a page marks itself ready (`body.ready`), gated behind `.js` so the page is
|
|
300
|
-
* always visible with JS off and never flashes before positioning at the Kernel.
|
|
301
|
-
*
|
|
302
|
-
* This is a TRAP as much as a feature, and the warning belongs beside it: ANY page using this without a
|
|
303
|
-
* script that sets `body.ready` stays invisible FOREVER, and nothing errors — the page is simply never
|
|
304
|
-
* shown. A page with no kernel script (a 404, or a sub-persona like feed) must carry {@link READY_JS}.
|
|
305
|
-
*/
|
|
306
|
-
export const REVEAL_CSS = `html.js body{opacity:0}html.js body.ready{opacity:1}`;
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* The other half of {@link REVEAL_CSS}, for a page that has no kernel script to reveal it: set
|
|
310
|
-
* `body.ready` as soon as the body exists, and once more after load as a backstop. This is what keeps
|
|
311
|
-
* a sub-persona page (feed, a 404) from falling into the reveal trap.
|
|
312
|
-
*/
|
|
313
|
-
export const READY_JS =
|
|
314
|
-
`var r=function(){document.body&&document.body.classList.add("ready")};` +
|
|
315
|
-
`if(document.readyState!=="loading")r();else addEventListener("DOMContentLoaded",r);setTimeout(r,400);`;
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* queries: which measurement id does this host use · wrong GA4 stream · a persona reports into the
|
|
319
|
-
* wrong property · G-13L3BP6XCW vs G-K2J4FQTQ8L · how does feed pick its analytics tag
|
|
320
|
-
*
|
|
321
|
-
* THE ECOSYSTEM'S STREAM LAYOUT, declared once.
|
|
322
|
-
*
|
|
323
|
-
* One GA4 property, two web streams: `G-13L3BP6XCW` for app.zone and its personas, `G-K2J4FQTQ8L`
|
|
324
|
-
* for justai.pro and its own sub-domains. A page reports into whichever stream ITS CODE loads, so
|
|
325
|
-
* "app.zone versus justai.pro" is a fact about our code rather than a rule the platform enforces —
|
|
326
|
-
* put a persona on the wrong one and nothing errors, nothing is missing, the numbers simply land in
|
|
327
|
-
* the wrong column. That is why the mapping is a function here and not a constant copied per repo.
|
|
328
|
-
*
|
|
329
|
-
* A STATIC persona cannot call this — it has no host at build time — so @justai/cuts keeps its own
|
|
330
|
-
* default and `justai` passes the override. A SERVER-rendered surface (feed) knows the Host header
|
|
331
|
-
* and must use this. The two must agree; if a third stream ever appears, this is the one place it
|
|
332
|
-
* is added.
|
|
333
|
-
*/
|
|
334
|
-
export function measurementIdFor(host) {
|
|
335
|
-
const h = String(host || "").toLowerCase().split(":")[0];
|
|
336
|
-
return h === "justai.pro" || h.endsWith(".justai.pro") ? "G-K2J4FQTQ8L" : "G-13L3BP6XCW";
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* queries: analytics inline script · gtag block · consent defaults · why is dev traffic in GA4 ·
|
|
341
|
-
* non-production guard · localhost 127.0.0.1 in analytics · how does a page start measuring
|
|
342
|
-
*
|
|
343
|
-
* The whole analytics head block, for any framework, given a measurement id.
|
|
344
|
-
*
|
|
345
|
-
* Everything load-bearing about it, in the order it matters:
|
|
346
|
-
*
|
|
347
|
-
* A NON-PRODUCTION PAGE MEASURES NOTHING. Found by reading the property through the analytics MCP:
|
|
348
|
-
* `127.0.0.1` and `localhost` were its TOP "persona" — 546 sessions in four days, and on one of them
|
|
349
|
-
* 127.0.0.1 alone outranked every real persona. Local dev and every headless verification sweep
|
|
350
|
-
* loading built HTML. The guard also covers the edge's `dev-` preview hosts: previews are rehearsals,
|
|
351
|
-
* not visits. Everything before 2026-07-24 in that property is inflated by this.
|
|
352
|
-
*
|
|
353
|
-
* `gtag` GOES ON `window`, never `function gtag`. A framework that scopes an injected variable wraps
|
|
354
|
-
* this in an IIFE, and a function declaration would then be trapped inside it — while the consent
|
|
355
|
-
* dialog's own script, elsewhere on the page, calls `gtag`. The failure is silent and specific: a
|
|
356
|
-
* European visitor clicks Allow, "gtag is not defined", the choice is never applied and the sheet
|
|
357
|
-
* never closes. The stub is also assigned BEFORE the guard returns, so a silenced host still has a
|
|
358
|
-
* callable `gtag` and that same script cannot throw there either.
|
|
359
|
-
*
|
|
360
|
-
* CONSENT DEFAULTS, twice — REVISED 2026-07-25 with the founder, and the revision IS the doctrine:
|
|
361
|
-
* MEASUREMENT follows one rule everywhere (granted by default, EEA asks first), PROFILING is refused
|
|
362
|
-
* everywhere forever. Globally: analytics_storage + ad_storage + ad_user_data granted — counting the
|
|
363
|
-
* visit, and telling an ad its click worked; the dialog's question covers both, in the visitor's
|
|
364
|
-
* language. ad_personalization is DENIED with no path anywhere, which is what keeps "never who"
|
|
365
|
-
* true. The EEA + UK + CH region list denies everything until the dialog's answer — where consent is
|
|
366
|
-
* owed we ask first; where it is not, measurement is simply on (the founder's explicit instruction).
|
|
367
|
-
*
|
|
368
|
-
* STORED CHOICES ARE VERSIONED: "granted+ads" replays the full grant, a legacy "granted" replays
|
|
369
|
-
* analytics ONLY — a visitor who said yes to the narrower question is never silently upgraded to the
|
|
370
|
-
* wider one. "denied" denies the measurement trio.
|
|
371
|
-
*
|
|
372
|
-
* LEGAL POSTURE, noted with the founder: one sentence carries two purposes (counting + ad
|
|
373
|
-
* measurement), both stated plainly — defensible at today's traffic; when traffic grows, granular
|
|
374
|
-
* consent (two separate switches) should be revisited. ad_personalization staying dead is the
|
|
375
|
-
* strongest card in that file.
|
|
376
|
-
*
|
|
377
|
-
* The region list has a sibling: the timezone list in the consent dialog's script. Change one and
|
|
378
|
-
* the other must change, or a visitor is denied by region while never being offered the dialog.
|
|
379
|
-
*
|
|
380
|
-
* `page_title` IS PINNED at load. Only one persona mutates `document.title` today — time shows a live
|
|
381
|
-
* clock — and without this its analytics reports "13:32 · Amsterdam" as the page name. It costs every
|
|
382
|
-
* other persona nothing and removes a trap the next persona that animates its tab would walk into.
|
|
383
|
-
*
|
|
384
|
-
* The tag itself loads on idle after `load`: measurement must never compete with the kernel.
|
|
385
|
-
*
|
|
386
|
-
* WRAPPED IN AN IIFE, and it has to be. The Astro binding used to get one for free from `define:vars`;
|
|
387
|
-
* lifting the block out of the template removed it, and the locals became globals on every persona
|
|
388
|
-
* page — three names a persona could collide with, leaked by the shell, with nothing to notice it. A
|
|
389
|
-
* shared shell does not put anything in the global scope it did not mean to. `window.gtag` is still
|
|
390
|
-
* assigned explicitly on window, which is the one thing that MUST escape.
|
|
391
|
-
*/
|
|
392
|
-
export function analyticsJs(gaId) {
|
|
393
|
-
return `(function(){
|
|
394
|
-
window.gtag=window.gtag||function(){(window.dataLayer=window.dataLayer||[]).push(arguments)};
|
|
395
|
-
var __h=location.hostname;
|
|
396
|
-
if(!(__h==="localhost"||__h==="127.0.0.1"||__h==="::1"||__h==="[::1]"||__h.indexOf("dev-")===0)){
|
|
397
|
-
var __g=${JSON.stringify(gaId)};
|
|
398
|
-
window.dataLayer=window.dataLayer||[];
|
|
399
|
-
window.gtag=window.gtag||function(){window.dataLayer.push(arguments)};
|
|
400
|
-
gtag("js",new Date());
|
|
401
|
-
gtag("consent","default",{ad_storage:"granted",ad_user_data:"granted",ad_personalization:"denied",analytics_storage:"granted"});
|
|
402
|
-
gtag("consent","default",{region:["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE","IS","LI","NO","GB","CH"],ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied"});
|
|
403
|
-
try{var __c=localStorage.getItem("consent");
|
|
404
|
-
if(__c==="granted+ads")gtag("consent","update",{analytics_storage:"granted",ad_storage:"granted",ad_user_data:"granted"});
|
|
405
|
-
else if(__c==="granted")gtag("consent","update",{analytics_storage:"granted"});
|
|
406
|
-
else if(__c==="denied")gtag("consent","update",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied"})}catch(e){}
|
|
407
|
-
gtag("config",__g,{cookie_expires:60*60*24*60,page_title:document.title,page_location:location.origin+location.pathname,allow_google_signals:false,allow_ad_personalization_signals:false});
|
|
408
|
-
addEventListener("load",function(){(window.requestIdleCallback||function(f){setTimeout(f,1200)})(function(){var s=document.createElement("script");s.async=true;s.src="https://www.googletagmanager.com/gtag/js?id="+__g;document.head.appendChild(s)})});
|
|
409
|
-
}})();`;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* queries: where does the consent dialog text live · change the consent wording · consentText ·
|
|
415
|
-
* consentAllow consentDecline consentChoice · why is the consent copy not in the persona ·
|
|
416
|
-
* feed cannot show the consent sheet · translate the consent question
|
|
417
|
-
*
|
|
418
|
-
* THE CONSENT COPY — the ecosystem's question to a visitor, in thirteen languages, said once.
|
|
419
|
-
*
|
|
420
|
-
* It used to live in every persona's own dictionary: thirteen languages across thirteen repos, and
|
|
421
|
-
* measured before this moved, all 52 strings were byte-identical in all of them. That is the tell.
|
|
422
|
-
* A persona's dictionary holds what makes it that persona; this is the ECOSYSTEM speaking, and the
|
|
423
|
-
* same sentence copied into a hundred and sixty-nine files is not localisation, it is a maintenance
|
|
424
|
-
* bill. Changing one word meant thirteen pull requests, and getting twelve of them right meant a
|
|
425
|
-
* visitor somewhere read an older promise than the one we thought we were making.
|
|
426
|
-
*
|
|
427
|
-
* It is legally load-bearing text. There is exactly one place it may be edited, and this is it.
|
|
428
|
-
*
|
|
429
|
-
* WHY HERE rather than in @justai/cuts: `feed` renders on every persona's host and depends on core,
|
|
430
|
-
* not on cuts. Putting the copy where only the Astro shell could reach it is what kept feed from
|
|
431
|
-
* asking the question at all. Content, like behaviour, belongs at the layer every face can reach.
|
|
432
|
-
*
|
|
433
|
-
* A locale with no entry falls back to English rather than rendering an empty sheet — a missing
|
|
434
|
-
* translation must never become a dialog with no question in it.
|
|
435
|
-
*/
|
|
436
|
-
export const CONSENT_COPY = {
|
|
437
|
-
"ar": {
|
|
438
|
-
"consentText": "أودّ أن أعرف أنّ أحدًا زارني — بشكل مجهول، دون معرفة من هو أبدًا. هل لي أن أحسب زيارتك — وإن كان إعلانٌ قد أوصلك إلى هنا، أن أخبره أنه نجح؟",
|
|
439
|
-
"consentAllow": "احسبني ❤️",
|
|
440
|
-
"consentDecline": "أبقِني خفيًّا",
|
|
441
|
-
"consentChoice": "خيار الخصوصية"
|
|
442
|
-
},
|
|
443
|
-
"de": {
|
|
444
|
-
"consentText": "Ich wüsste gern, dass jemand da war — anonym, nie wer. Darf ich deinen Besuch zählen — und falls dich eine Anzeige hergebracht hat, ihr sagen, dass sie gewirkt hat?",
|
|
445
|
-
"consentAllow": "Zähl mich mit ❤️",
|
|
446
|
-
"consentDecline": "Unsichtbar bleiben",
|
|
447
|
-
"consentChoice": "Privatsphäre-Wahl"
|
|
448
|
-
},
|
|
449
|
-
"en": {
|
|
450
|
-
"consentText": "I'd love to know someone was here — anonymously, never who. May I count your visit, and if an ad brought you here, let it know it worked?",
|
|
451
|
-
"consentAllow": "Count me in ❤️",
|
|
452
|
-
"consentDecline": "Stay invisible",
|
|
453
|
-
"consentChoice": "privacy choice"
|
|
454
|
-
},
|
|
455
|
-
"es": {
|
|
456
|
-
"consentText": "Me encantaría saber que alguien estuvo aquí — de forma anónima, nunca quién. ¿Puedo contar tu visita y, si un anuncio te trajo hasta aquí, decirle que funcionó?",
|
|
457
|
-
"consentAllow": "Cuenta conmigo ❤️",
|
|
458
|
-
"consentDecline": "Seguir invisible",
|
|
459
|
-
"consentChoice": "elección de privacidad"
|
|
460
|
-
},
|
|
461
|
-
"fr": {
|
|
462
|
-
"consentText": "J'aimerais savoir que quelqu'un est passé — anonymement, jamais qui. Puis-je compter ta visite — et si une publicité t'a amené ici, lui dire qu'elle a fonctionné ?",
|
|
463
|
-
"consentAllow": "Compte ma visite ❤️",
|
|
464
|
-
"consentDecline": "Rester invisible",
|
|
465
|
-
"consentChoice": "choix de confidentialité"
|
|
466
|
-
},
|
|
467
|
-
"hi": {
|
|
468
|
-
"consentText": "मुझे यह जानना अच्छा लगेगा कि कोई आया था — गुमनाम तौर पर, कभी नहीं कि कौन। क्या मैं आपकी विज़िट गिन सकता हूँ — और अगर कोई विज्ञापन आपको यहाँ लाया, तो उसे बता दूँ कि उसने काम किया?",
|
|
469
|
-
"consentAllow": "मुझे गिनो ❤️",
|
|
470
|
-
"consentDecline": "अदृश्य रहूँ",
|
|
471
|
-
"consentChoice": "गोपनीयता विकल्प"
|
|
472
|
-
},
|
|
473
|
-
"it": {
|
|
474
|
-
"consentText": "Mi piacerebbe sapere che qualcuno è passato — in forma anonima, mai chi. Posso contare la tua visita — e, se ti ha portato qui una pubblicità, dirle che ha funzionato?",
|
|
475
|
-
"consentAllow": "Contami ❤️",
|
|
476
|
-
"consentDecline": "Resta invisibile",
|
|
477
|
-
"consentChoice": "scelta privacy"
|
|
478
|
-
},
|
|
479
|
-
"ja": {
|
|
480
|
-
"consentText": "誰かが来てくれたことだけ知りたいのです — 匿名で、誰かは決して分かりません。訪問を数えてもいいですか?広告がきっかけで来てくれたなら、役に立ったと広告に伝えてもいいですか?",
|
|
481
|
-
"consentAllow": "数えていいよ ❤️",
|
|
482
|
-
"consentDecline": "見えないままで",
|
|
483
|
-
"consentChoice": "プライバシー設定"
|
|
484
|
-
},
|
|
485
|
-
"nl": {
|
|
486
|
-
"consentText": "Ik zou graag weten dat er iemand was — anoniem, nooit wie. Mag ik je bezoek meetellen — en als een advertentie je hierheen bracht, laten weten dat die werkte?",
|
|
487
|
-
"consentAllow": "Tel me mee ❤️",
|
|
488
|
-
"consentDecline": "Onzichtbaar blijven",
|
|
489
|
-
"consentChoice": "privacykeuze"
|
|
490
|
-
},
|
|
491
|
-
"pt": {
|
|
492
|
-
"consentText": "Adoraria saber que alguém esteve aqui — anonimamente, nunca quem. Posso contar sua visita — e, se um anúncio trouxe você até aqui, dizer a ele que funcionou?",
|
|
493
|
-
"consentAllow": "Conta comigo ❤️",
|
|
494
|
-
"consentDecline": "Ficar invisível",
|
|
495
|
-
"consentChoice": "escolha de privacidade"
|
|
496
|
-
},
|
|
497
|
-
"ru": {
|
|
498
|
-
"consentText": "Мне бы хотелось знать, что кто-то заходил — анонимно, и никогда кто именно. Можно посчитать твой визит — и, если тебя привела реклама, дать ей знать, что она сработала?",
|
|
499
|
-
"consentAllow": "Посчитай меня ❤️",
|
|
500
|
-
"consentDecline": "Остаться невидимым",
|
|
501
|
-
"consentChoice": "выбор приватности"
|
|
502
|
-
},
|
|
503
|
-
"tr": {
|
|
504
|
-
"consentText": "Birinin uğradığını bilmek isterim — anonim olarak, asla kim olduğunu değil. Ziyaretini sayabilir miyim — ve seni buraya bir reklam getirdiyse, ona işe yaradığını söyleyebilir miyim?",
|
|
505
|
-
"consentAllow": "Beni say ❤️",
|
|
506
|
-
"consentDecline": "Görünmez kalayım",
|
|
507
|
-
"consentChoice": "gizlilik tercihi"
|
|
508
|
-
},
|
|
509
|
-
"zh": {
|
|
510
|
-
"consentText": "我只想知道有人来过 — 完全匿名,永远不知道是谁。可以把你的访问算上吗——如果是广告把你带来的,也让它知道它起了作用?",
|
|
511
|
-
"consentAllow": "算上我 ❤️",
|
|
512
|
-
"consentDecline": "保持隐身",
|
|
513
|
-
"consentChoice": "隐私选择"
|
|
514
|
-
}
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
/** The consent copy for a language, falling back to English. Never returns undefined. */
|
|
518
|
-
export function consentCopy(lang) {
|
|
519
|
-
return CONSENT_COPY[String(lang || "en").toLowerCase()] || CONSENT_COPY.en;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* queries: the sheet says Cancel in English · Cancel is not translated · Done is not translated ·
|
|
525
|
-
* the picker's cancel stays English in Arabic · sheet chrome language · translate a cut ·
|
|
526
|
-
* who owns the word Cancel · CHROME_COPY · a component's own words
|
|
527
|
-
*
|
|
528
|
-
* THE CHROME WORDS — Cancel and Done, in thirteen languages, said once.
|
|
529
|
-
*
|
|
530
|
-
* The same argument as CONSENT_COPY above, and found the same way: a picker opened on an Arabic page
|
|
531
|
-
* with every word around it in Arabic and `Cancel` in English, sitting in the sheet's own bar.
|
|
532
|
-
*
|
|
533
|
-
* `<Sheet>` had defaulted its Done to the literal "Done" and reasoned, in a comment, that a label is
|
|
534
|
-
* a prop "because the fleet speaks thirteen languages, and a cut that hardcoded the English would be
|
|
535
|
-
* a component making its consumer's copy decisions". The reasoning was inverted. Handing the word to
|
|
536
|
-
* the consumer does not avoid the decision — it makes it THIRTEEN TIMES, in every repo, and the
|
|
537
|
-
* hardcoded English default proved it: the cut was already deciding, and deciding wrong.
|
|
538
|
-
*
|
|
539
|
-
* These are not a persona's copy. `Cancel` is not qr's word or files' word; it is the ecosystem's,
|
|
540
|
-
* the way the back chevron is the ecosystem's shape. Law 1 — a component brings its own ground,
|
|
541
|
-
* style AND text — is what says the cut must carry them.
|
|
542
|
-
*
|
|
543
|
-
* WHY HERE rather than in @justai/cuts: same reason the consent copy is here. Every face reaches
|
|
544
|
-
* core; only the Astro shell reaches cuts.
|
|
545
|
-
*
|
|
546
|
-
* LIFTED FROM `files`, BYTE FOR BYTE, and that is the point rather than an economy. The file kernel
|
|
547
|
-
* mounts INSIDE a host's sheet: the guest draws its own cancel in the body and the host draws one in
|
|
548
|
-
* the bar, and a person looking at one surface must not be shown two different words for the one
|
|
549
|
-
* way out. One word per meaning — the same rule the `nameTaken` string learned the hard way.
|
|
550
|
-
*/
|
|
551
|
-
export const CHROME_COPY = {
|
|
552
|
-
"ar": { "cancel": "إلغاء", "done": "تم" },
|
|
553
|
-
"de": { "cancel": "Abbrechen", "done": "Fertig" },
|
|
554
|
-
"en": { "cancel": "Cancel", "done": "Done" },
|
|
555
|
-
"es": { "cancel": "Cancelar", "done": "Listo" },
|
|
556
|
-
"fr": { "cancel": "Annuler", "done": "OK" },
|
|
557
|
-
"hi": { "cancel": "रद्द करें", "done": "हो गया" },
|
|
558
|
-
"it": { "cancel": "Annulla", "done": "Fine" },
|
|
559
|
-
"ja": { "cancel": "キャンセル", "done": "完了" },
|
|
560
|
-
"nl": { "cancel": "Annuleren", "done": "Klaar" },
|
|
561
|
-
"pt": { "cancel": "Cancelar", "done": "Concluído" },
|
|
562
|
-
"ru": { "cancel": "Отмена", "done": "Готово" },
|
|
563
|
-
"tr": { "cancel": "Vazgeç", "done": "Bitti" },
|
|
564
|
-
"zh": { "cancel": "取消", "done": "完成" }
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
/** The chrome words for a language, falling back to English. Never returns undefined. */
|
|
568
|
-
export function chromeCopy(lang) {
|
|
569
|
-
return CHROME_COPY[String(lang || "en").toLowerCase().split("-")[0]] || CHROME_COPY.en;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* queries: consent dialog script · why does the sheet not appear on some pages · consent is asked
|
|
575
|
-
* per domain not per page · getElementById kernel · the sheet never opened on feed ·
|
|
576
|
-
* only a choice may be remembered · the change-your-mind door · consent timezone list
|
|
577
|
-
*
|
|
578
|
-
* The consent dialog's behaviour — one copy, for every surface on a persona's origin.
|
|
579
|
-
*
|
|
580
|
-
* CONSENT IS SCOPED TO THE ORIGIN, NOT TO A PAGE. Whichever page a visitor enters by, if this origin
|
|
581
|
-
* has never asked, it asks — once. That is what a consent flow IS, and it is worth stating because
|
|
582
|
-
* ours was accidentally page-scoped for three weeks: the script used to bail on
|
|
583
|
-
* `!document.getElementById("kernel")`, a DOM sniff added to avoid asking on a 404. Feed pages have
|
|
584
|
-
* no kernel either, so on every /feed/* page in the fleet the question was never asked — silently,
|
|
585
|
-
* with nothing to notice it. A trust decision must never be inferred from an unrelated layout
|
|
586
|
-
* detail; the check is gone, and any page that renders the sheet may ask.
|
|
587
|
-
*
|
|
588
|
-
* ONLY A CHOICE MAY BE REMEMBERED AS A CHOICE. "confirm" is the heart, "denied" is a chosen
|
|
589
|
-
* "Stay invisible". Anything else — Escape, a tap on the backdrop — is not an answer: nothing is
|
|
590
|
-
* stored, the regional default stands, and the ask returns next visit. The session flag only keeps
|
|
591
|
-
* THIS visit quiet, so one slip-away buys one visit of peace rather than an answer nobody gave.
|
|
592
|
-
*
|
|
593
|
-
* THE DOOR IS UNIVERSAL. The footer's hidden `[data-consent-open]` anchor is labelled, revealed and
|
|
594
|
-
* wired here for EVERY visitor in EVERY region — a non-EEA visitor gets a real opt-out they were
|
|
595
|
-
* never offered, and anyone can reverse either answer. Only the AUTO-ask has narrow gates.
|
|
596
|
-
*
|
|
597
|
-
* THE TIMEZONE LIST IS A PROXY for "consent is legally asked here", never the thing itself, and it is
|
|
598
|
-
* the sibling of the region array in {@link analyticsJs}. `Europe/` carries almost all of the EEA but
|
|
599
|
-
* not all of it: twelve zones sit on other continents. Change one list and you must change the other,
|
|
600
|
-
* or a visitor is denied by region while never being offered the dialog.
|
|
601
|
-
*
|
|
602
|
-
* `returnValue` survives a close, so it is reset before every open or a stale answer replays.
|
|
603
|
-
*
|
|
604
|
-
* FOCUS IS GIVEN AT OPEN, not by an autofocus attribute. Chrome refuses to process `autofocus` in
|
|
605
|
-
* any document whose URL carries a fragment and warns on every load — /me#profile met it first. So
|
|
606
|
-
* the sheet ships no attribute, and the opener places focus by the genre's law: the ask genre puts
|
|
607
|
-
* it on the invitation (here), the destructive genre on the cancel (that consumer's own open).
|
|
608
|
-
*/
|
|
609
|
-
export const CONSENT_JS = `(function(){try{
|
|
610
|
-
var h=location.hostname;
|
|
611
|
-
if(h==="localhost"||h==="127.0.0.1"||h==="::1"||h==="[::1]"||h.indexOf("dev-")===0)return;
|
|
612
|
-
var el=document.getElementById("consent");if(!el||!el.showModal)return;
|
|
613
|
-
var open=function(){if(!el.open){el.returnValue="";el.showModal();var p=el.querySelector(".preferred");if(p)p.focus()}};
|
|
614
|
-
el.addEventListener("close",function(){
|
|
615
|
-
var rv=el.returnValue;
|
|
616
|
-
var v=rv==="confirm"?"granted+ads":rv==="denied"?"denied":null;
|
|
617
|
-
if(v){var g=v==="denied"?"denied":"granted";
|
|
618
|
-
gtag("consent","update",{analytics_storage:g,ad_storage:g,ad_user_data:g});
|
|
619
|
-
try{localStorage.setItem("consent",v)}catch(_){}}
|
|
620
|
-
else{try{sessionStorage.setItem("consent-later","1")}catch(_){}}
|
|
621
|
-
});
|
|
622
|
-
var doors=document.querySelectorAll("[data-consent-open]");
|
|
623
|
-
for(var i=0;i<doors.length;i++){var a=doors[i];
|
|
624
|
-
if(!a.textContent)a.textContent=el.getAttribute("data-choice-label")||"privacy choice";
|
|
625
|
-
a.hidden=false;var w=a.closest("[data-consent-door]");if(w)w.hidden=false;
|
|
626
|
-
a.addEventListener("click",function(ev){ev.preventDefault();open()})}
|
|
627
|
-
if(localStorage.getItem("consent"))return;
|
|
628
|
-
try{if(sessionStorage.getItem("consent-later"))return}catch(_){}
|
|
629
|
-
var tz=Intl.DateTimeFormat().resolvedOptions().timeZone||"";
|
|
630
|
-
var asked=tz.indexOf("Europe/")===0||[
|
|
631
|
-
"Asia/Nicosia","Asia/Famagusta",
|
|
632
|
-
"Atlantic/Canary","Atlantic/Azores","Atlantic/Madeira","Atlantic/Reykjavik",
|
|
633
|
-
"Arctic/Longyearbyen",
|
|
634
|
-
"America/Guadeloupe","America/Martinique","America/Cayenne",
|
|
635
|
-
"Indian/Reunion","Indian/Mayotte"].indexOf(tz)>=0;
|
|
636
|
-
if(!asked)return;
|
|
637
|
-
setTimeout(open,700);
|
|
638
|
-
}catch(_){}})();`;
|
|
639
|
-
|
|
640
|
-
// queries: is this persona standalone or embedded · how does a persona know it is inside another
|
|
641
|
-
// persona · mode=atrium · presentation mode · a sub-persona should not show Cancel when
|
|
642
|
-
// opened directly · does this page have a caller
|
|
643
|
-
//
|
|
644
|
-
// WHICH PRESENTATION A PERSONA IS IN, AND WHY IT IS A QUESTION AT ALL.
|
|
645
|
-
//
|
|
646
|
-
// The founder, 2026-07-27, looking at `/files` opened directly in a tab and still wearing the
|
|
647
|
-
// clothes it wears inside somebody else's sheet:
|
|
648
|
-
//
|
|
649
|
-
// "bir persona veya sub personanin kendisinin standalone calisip calismadigini bilmesi gerekir
|
|
650
|
-
// ki ona gore ux deneyiminde degisiklige gidebilsin"
|
|
651
|
-
//
|
|
652
|
-
// A page opened by a person and a page opened by another persona are two different situations, and
|
|
653
|
-
// the same controls do not belong in both. Standalone there is nothing to cancel — "Cancel" is a
|
|
654
|
-
// button with no meaning, offered to somebody who never asked a question. "Choose from device" is
|
|
655
|
-
// the phrasing of an answer; alone, the same control is simply "Upload".
|
|
656
|
-
//
|
|
657
|
-
// TWO SIGNALS, AND THEY ANSWER DIFFERENT QUESTIONS:
|
|
658
|
-
//
|
|
659
|
-
// · `window.parent !== window` is the BROWSER's answer to "am I in a frame". It is true and it is
|
|
660
|
-
// free, but it says nothing about who put us there or what they want.
|
|
661
|
-
// · `?mode=atrium` is the CALLER's declaration of the experience it is asking for. It is a claim —
|
|
662
|
-
// anyone can type it — and that is fine, because it decides nothing but presentation.
|
|
663
|
-
//
|
|
664
|
-
// So both are required, and neither is a permission. Anything that must not be forged (who may read
|
|
665
|
-
// a file, whose persona owns a write) is decided by the verified origin on the atrium channel, never
|
|
666
|
-
// by this. What this decides is which words a person reads.
|
|
667
|
-
//
|
|
668
|
-
// The param exists at all because the frame is the SLOWER truth: a handshake takes a beat, and a
|
|
669
|
-
// page that waits for it shows the wrong chrome first and then rearranges itself in front of the
|
|
670
|
-
// person. The declaration is available in the first paint.
|
|
671
|
-
export const PRESENTATION_PARAM = "mode";
|
|
672
|
-
export const PRESENTATION_EMBEDDED = "atrium";
|
|
673
|
-
|
|
674
|
-
export function presentation(loc, win) {
|
|
675
|
-
const l = loc || (typeof location !== "undefined" ? location : null);
|
|
676
|
-
const w = win || (typeof window !== "undefined" ? window : null);
|
|
677
|
-
if (!l || !w) return "standalone";
|
|
678
|
-
let declared = null;
|
|
679
|
-
try {
|
|
680
|
-
declared = new URLSearchParams(l.search).get(PRESENTATION_PARAM);
|
|
681
|
-
} catch {
|
|
682
|
-
/* a search string we cannot parse is a page nobody addressed */
|
|
683
|
-
}
|
|
684
|
-
const framed = w.parent !== w;
|
|
685
|
-
return declared === PRESENTATION_EMBEDDED && framed ? "embedded" : "standalone";
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// queries: persona page scroll behaviour · land on the kernel · scroll spy · toolbar title strip ·
|
|
689
|
-
// the page opens on the profile instead of the kernel · toolbar hairline · hash sync ·
|
|
690
|
-
// why is this in core rather than in the Toolbar cut
|
|
691
|
-
//
|
|
692
|
-
// THE PERSONA PAGE'S SCROLL BEHAVIOUR, ONCE, FOR EVERY SURFACE THAT HAS ONE.
|
|
693
|
-
//
|
|
694
|
-
// A persona page lands on its KERNEL. The profile is the face — it is there when you go looking for
|
|
695
|
-
// it, and scrolling up is how you look; what a person came for is the thing the persona does. Once
|
|
696
|
-
// the profile has scrolled away, the name it carried reappears in the toolbar's second row, or the
|
|
697
|
-
// page loses its own title the moment you start using it.
|
|
698
|
-
//
|
|
699
|
-
// WHY HERE AND NOT IN THE TOOLBAR CUT. `@justai/cuts/Toolbar` owned this and still calls it, but the
|
|
700
|
-
// cut can only serve pages that adopt its MARKUP — and three surfaces cannot: `/me` and `/files`
|
|
701
|
-
// carry extra navigation of their own, and the feed is a different build. So all three hand-wrote
|
|
702
|
-
// the same eighty lines, and by the third copy they had already drifted: `/files` opened on the
|
|
703
|
-
// profile with an empty title strip for a week, and its hash writer clobbered the query string
|
|
704
|
-
// (`?mode=atrium` disappeared on the first scroll) where the cut's preserves it.
|
|
705
|
-
//
|
|
706
|
-
// That is the shape core exists for — the load-bearing behaviour, framework-free, so an Astro cut, a
|
|
707
|
-
// Next face and a hand-written page all run the SAME logic instead of three versions of it. What
|
|
708
|
-
// stays in the cut is the markup and the CSS; what moves here is the part that was being copied.
|
|
709
|
-
//
|
|
710
|
-
// Every element is found by id so a surface can bring its own markup: only the ids are the contract.
|
|
711
|
-
export function personaScroll(options) {
|
|
712
|
-
const o = options || {};
|
|
713
|
-
const cutIds = o.cuts || ["profile", "kernel", "posts"];
|
|
714
|
-
const el = (id) => (typeof id === "string" ? document.getElementById(id) : id);
|
|
715
|
-
|
|
716
|
-
const below = el(o.below || "below");
|
|
717
|
-
const kernel = el("kernel");
|
|
718
|
-
if (!below || !kernel) return;
|
|
719
|
-
|
|
720
|
-
const toolbar = typeof o.toolbar === "string" ? document.querySelector(o.toolbar) : o.toolbar || document.querySelector(".toolbar");
|
|
721
|
-
const tbTitle = el(o.title || "tbTitle");
|
|
722
|
-
const tbTitleText =
|
|
723
|
-
(typeof o.titleText === "string" ? document.getElementById(o.titleText) : o.titleText) ||
|
|
724
|
-
document.getElementById("tbTitleText") ||
|
|
725
|
-
(tbTitle && tbTitle.querySelector(".tb-title-text"));
|
|
726
|
-
|
|
727
|
-
// A cut is a section AND the nav that points at it; anything missing either half is simply not one.
|
|
728
|
-
// That is how a page with extra toolbar links — /me's vault, /files' host link — needs no
|
|
729
|
-
// configuration: they are links, not cuts, and they fall out of this list on their own.
|
|
730
|
-
const cuts = cutIds
|
|
731
|
-
.map((id) => [el(id), el(o.navFor ? o.navFor(id) : "nav" + id.charAt(0).toUpperCase() + id.slice(1))])
|
|
732
|
-
.filter((c) => c[0] && c[1]);
|
|
733
|
-
if (!cuts.length) return;
|
|
734
|
-
|
|
735
|
-
// queries: --shell-top · the kernel is 26px short · the game frame does not reach the fold ·
|
|
736
|
-
// a strip of posts shows above the fold · opening at #kernel is different from #profile ·
|
|
737
|
-
// the toolbar changes height · title strip · the layout depends on when it was measured
|
|
738
|
-
//
|
|
739
|
-
// ── NEVER SAMPLE AN ANIMATION AND CALL IT A LAYOUT ─────────────────────────────────────────
|
|
740
|
-
//
|
|
741
|
-
// `--shell-top` is what the shell takes above the kernel, and everything downstream reads it: the
|
|
742
|
-
// landing offset, an app kernel's minimum height, a game kernel's exact one.
|
|
743
|
-
//
|
|
744
|
-
// It was the literal `82` for a long time and that was stable and slightly wrong. Reading the
|
|
745
|
-
// toolbar's height instead made it exact and UNSTABLE, which is far worse: the row carries a title
|
|
746
|
-
// strip that opens and closes over 0.35s, so its height is anywhere in a 26px range depending on
|
|
747
|
-
// the instant somebody looked. Measured on tpl-sunshine at 1864x999, the same persona, same build:
|
|
748
|
-
//
|
|
749
|
-
// opened at #profile strip shut when measured shell-top 80 frame 919 reaches the fold
|
|
750
|
-
// opened at #kernel strip open when measured shell-top 106 frame 893 33px SHORT
|
|
751
|
-
//
|
|
752
|
-
// and the second is what a visitor gets, because a game persona lands on its kernel. Thirty-three
|
|
753
|
-
// pixels of the next section showing above the fold, and the "correct" case was correct by
|
|
754
|
-
// coincidence — a shut row plus a gutter happened to equal an open one.
|
|
755
|
-
//
|
|
756
|
-
// THE FIX IS NOT A BETTER MOMENT TO MEASURE, IT IS NOT MEASURING THE MOVING PART. The row minus the
|
|
757
|
-
// strip is the row, and it is the same number at every frame of the transition; the strip's OPEN
|
|
758
|
-
// height is `--tb-strip`, which the Toolbar cut declares beside the rule that uses it. Their sum is
|
|
759
|
-
// what the bar is whenever anybody is looking at the kernel — which is the only time this number
|
|
760
|
-
// decides anything.
|
|
761
|
-
//
|
|
762
|
-
// AND NO GUTTER IS ADDED. The frame is the active view, so it begins where the shell ends; the air
|
|
763
|
-
// an app keeps under the bar is its own padding, and adding a gutter here would spend it twice.
|
|
764
|
-
//
|
|
765
|
-
// Re-measured on resize because a rotation, a narrowing past 640 and a reader's text size all
|
|
766
|
-
// change the ROW — none of which is the animation this is written to ignore.
|
|
767
|
-
const measureShell = () => {
|
|
768
|
-
if (!toolbar) return;
|
|
769
|
-
// THE BAR'S EXPANDED HEIGHT, WITHOUT WAITING FOR OR RACING THE STRIP'S 0.35s. The row is the bar
|
|
770
|
-
// minus whatever the strip currently is — the same number at every frame of the transition — and
|
|
771
|
-
// the bar-to-be is that row plus the strip's declared open height. Nothing samples the animation,
|
|
772
|
-
// so nothing depends on when it was sampled.
|
|
773
|
-
//
|
|
774
|
-
// CEIL, NOT ROUND, AND LOAD-BEARING: this is the slot's reserved box as well as the landing
|
|
775
|
-
// offset, so it must never be LESS than the bar's tallest state or the slot starts following the
|
|
776
|
-
// bar again and the 26px returns as a fraction. A bar under Dynamic Type is not an integer —
|
|
777
|
-
// 82.3 is recorded in this file — and rounding down is half a CSS pixel of permanent error.
|
|
778
|
-
const strip = tbTitle ? tbTitle.getBoundingClientRect().height : 0;
|
|
779
|
-
const open = parseFloat(getComputedStyle(toolbar).getPropertyValue("--tb-strip")) || 26;
|
|
780
|
-
const h = Math.ceil(toolbar.getBoundingClientRect().height - strip + open);
|
|
781
|
-
// ON THE ROOT, because the kernel's `scroll-margin-top` reads it and THE BROWSER reads that when
|
|
782
|
-
// it scrolls to the fragment on its own. Written on `.app` this reached the kernel only when the
|
|
783
|
-
// kernel happened to sit inside one, and a surface where it did not is a surface where the
|
|
784
|
-
// browser's landing and the script's disagree — which is the whole bug this measurement exists
|
|
785
|
-
// to prevent. The root is the one element every consumer is inside.
|
|
786
|
-
if (h <= 0) return;
|
|
787
|
-
document.documentElement.style.setProperty("--shell-top", h + "px");
|
|
788
|
-
// queries: a persona overrides the landing offset · scroll-margin-top 82px in my own component ·
|
|
789
|
-
// the page lands 30px short · duplicate landing offset · my persona has its own #kernel
|
|
790
|
-
// rule · the framework does not reach my css
|
|
791
|
-
//
|
|
792
|
-
// AND ENFORCED, NOT MERELY DECLARED.
|
|
793
|
-
//
|
|
794
|
-
// The framework exists so that a number like this lives in ONE place. It cannot: CSS has no way
|
|
795
|
-
// to refuse an override, and on 2026-08-06 EIGHT personas — both apexes and justai.pro among them
|
|
796
|
-
// — still carried `#kernel { scroll-margin-top: 82px }` from before the shell was shared, a
|
|
797
|
-
// constant that stopped being true the day the secondary title strip was removed. Every one of
|
|
798
|
-
// them lands the page by measurement and is then overruled by the browser's own scroll to the
|
|
799
|
-
// fragment, which reads the persona's stale copy. Thirty pixels, on every bare load.
|
|
800
|
-
//
|
|
801
|
-
// Deleting the eight copies is the honest fix and it is being done. This is what makes the ninth
|
|
802
|
-
// impossible: whoever measures the bar owns what clearing it means, so EVERY CUT BELOW THE FIRST
|
|
803
|
-
// clears it by exactly the bar — written inline, which outranks any stylesheet.
|
|
804
|
-
//
|
|
805
|
-
// NOT "every cut that already declares an offset". That was the first version of this rule and it
|
|
806
|
-
// was too polite by one case: it read a zero as *"this section is not claiming to clear
|
|
807
|
-
// anything"*, and a persona that never loads `@justai/ui`'s base.css at all has exactly that
|
|
808
|
-
// zero. Measured on pin.games the moment its local `82px` was deleted — the offset fell to 0, the
|
|
809
|
-
// browser's own scroll put the kernel's top at the viewport top, and the persona's first line sat
|
|
810
|
-
// UNDER the sticky bar. Not landing short any more; landing under. Same bug, other direction.
|
|
811
|
-
//
|
|
812
|
-
// So it does not matter what the persona's CSS says or whether it loaded ours: a sticky bar is
|
|
813
|
-
// above every cut but the first, and the first is the top of the page with nothing to clear.
|
|
814
|
-
// The warning is only for a persona that declared a DIFFERENT number — that one has a stale rule
|
|
815
|
-
// to go and delete. A zero is just a surface that never had the stylesheet, and healing it
|
|
816
|
-
// silently is the whole point of the framework owning this.
|
|
817
|
-
cuts.forEach(([sec], i) => {
|
|
818
|
-
if (i === 0) return;
|
|
819
|
-
const declared = parseFloat(getComputedStyle(sec).scrollMarginTop) || 0;
|
|
820
|
-
if (Math.abs(declared - h) <= 0.5) return;
|
|
821
|
-
sec.style.scrollMarginTop = h + "px";
|
|
822
|
-
if (declared > 0) {
|
|
823
|
-
// Said out loud, because a healed page is a page nobody goes and fixes.
|
|
824
|
-
console.warn("[justai] #" + sec.id + " declares scroll-margin-top " + declared + "px; the shell measures " + h + "px. The landing offset belongs to @justai/ui — delete the local rule.");
|
|
825
|
-
}
|
|
826
|
-
});
|
|
827
|
-
};
|
|
828
|
-
measureShell();
|
|
829
|
-
addEventListener("resize", measureShell, { passive: true });
|
|
830
|
-
if (document.fonts && document.fonts.ready) document.fonts.ready.then(measureShell);
|
|
831
|
-
|
|
832
|
-
// queries: data-motion · the bar grows after load · animate only after interaction · first paint
|
|
833
|
-
// animation · the toolbar changes height on arrival
|
|
834
|
-
//
|
|
835
|
-
// ── THE SHELL'S TRANSITIONS BELONG TO A PAGE SOMEBODY IS USING ──────────────────────────────
|
|
836
|
-
//
|
|
837
|
-
// The founder's question, and it is the root of the whole class: *"why is this not activated only
|
|
838
|
-
// after the user's first interaction?"* A persona lands on its kernel, so the title strip's correct
|
|
839
|
-
// state on the first frame is OPEN — animating into it makes the bar grow 26px just after the page
|
|
840
|
-
// appears, and makes every measurement taken during that third of a second describe a state the
|
|
841
|
-
// page is never actually in.
|
|
842
|
-
//
|
|
843
|
-
// Nobody can see a transition they have not yet done anything to cause, so there is nothing to
|
|
844
|
-
// lose. `once: true` on each: the flag is set by whichever comes first and never again.
|
|
845
|
-
if ("scrollRestoration" in history) history.scrollRestoration = "manual";
|
|
846
|
-
|
|
847
|
-
// Only the FRAGMENT. `"#" + id` would clobber the path and the query, and both carry meaning here:
|
|
848
|
-
// a `?data=` link, a `?city=`, a `?mode=atrium`. A copy of this got that wrong.
|
|
849
|
-
const setHash = (id) => history.replaceState(null, "", location.pathname + location.search + "#" + id);
|
|
850
|
-
|
|
851
|
-
// queries: what is the 84px line · the scroll spy reports the wrong section · the hash flips back to
|
|
852
|
-
// #profile · clicking the avatar does not activate the kernel · the toolbar switches
|
|
853
|
-
// sections on its own · hash does not guarantee the cut · where does a cut begin
|
|
854
|
-
//
|
|
855
|
-
// WHERE A CUT BEGINS — ONE DEFINITION, USED BY THE NAVIGATOR AND BY THE SPY.
|
|
856
|
-
//
|
|
857
|
-
// This is the keystone of the whole behaviour, and getting it wrong is what made the hash a
|
|
858
|
-
// suggestion instead of a guarantee. There used to be TWO definitions: navigation scrolled to one
|
|
859
|
-
// place, and the spy tested against a different one — a hardcoded 84px line, paired by nothing but a
|
|
860
|
-
// comment with the `scroll-margin-top: 82px` that twelve personas each declared in their own CSS.
|
|
861
|
-
// Two magic numbers, two pixels apart, and the bug lived in the gap:
|
|
862
|
-
//
|
|
863
|
-
// click the avatar -> lands the kernel at 82 -> spy's last mid-flight sample read 85 -> profile
|
|
864
|
-
//
|
|
865
|
-
// A cut begins where the page COMES TO REST when you go to it. That is the only definition either
|
|
866
|
-
// side needs, and both now ask for it here — so the spy cannot contradict the navigator, because
|
|
867
|
-
// there is no second number for it to disagree with. The hash stops being a hint.
|
|
868
|
-
//
|
|
869
|
-
// Nothing is guessed. The position comes from the browser, and the landing inset comes from the
|
|
870
|
-
// CSS that already declares it (`scroll-margin-top`) rather than from a constant that has to be
|
|
871
|
-
// kept in sync by hand.
|
|
872
|
-
//
|
|
873
|
-
// THE KERNEL IS THE ONE EXCEPTION, and it is what kills an oscillation rather than papering over
|
|
874
|
-
// it. The kernel begins at the top of `#below` — above the sticky toolbar — not at its own box.
|
|
875
|
-
// The toolbar's title strip lives INSIDE `#below` and is in flow, so opening it pushes every
|
|
876
|
-
// section under it down by its own height (26px, measured). While the spy compared the kernel's own
|
|
877
|
-
// box against a fixed line, that 26px carried the kernel from 82 (inside the line) to 108 (outside
|
|
878
|
-
// it) — and the kernel being current is what opened the strip. Measured on app.zone by dispatching
|
|
879
|
-
// scroll events at a page that never moved:
|
|
880
|
-
//
|
|
881
|
-
// rest hash #profile kernelTop 82 strip 0 active profile
|
|
882
|
-
// spy run 1 hash #kernel kernelTop 108 strip 26 active kernel
|
|
883
|
-
// spy run 2 hash #profile kernelTop 82 strip 0 active profile
|
|
884
|
-
// spy run 3 hash #kernel kernelTop 108 strip 26 active kernel
|
|
885
|
-
//
|
|
886
|
-
// A bistable oscillator: the spy was measuring its own output. Anchoring the kernel to `#below`
|
|
887
|
-
// removes the coupling at the source, because the strip is inside that boundary and cannot move it.
|
|
888
|
-
// Widening the line would only have moved the tipping point.
|
|
889
|
-
const landingY = (sec) => {
|
|
890
|
-
if (sec === kernel) return below.getBoundingClientRect().top + window.scrollY;
|
|
891
|
-
const inset = parseFloat(getComputedStyle(sec).scrollMarginTop) || 0;
|
|
892
|
-
return sec.getBoundingClientRect().top + window.scrollY - inset;
|
|
893
|
-
};
|
|
894
|
-
const goTo = (sec, behavior) => window.scrollTo({ top: landingY(sec), behavior: behavior });
|
|
895
|
-
|
|
896
|
-
// queries: the page rests a few pixels short of the kernel · the hash flips to #profile on its own ·
|
|
897
|
-
// typing the bare host lands on the profile · below.top 4.36 · the landing is not repaired ·
|
|
898
|
-
// it works with #kernel in the URL but not without · unstable landing
|
|
899
|
-
//
|
|
900
|
-
// WHERE THIS PAGE WAS SENT — DECIDED ONCE, AND NEVER READ BACK OUT OF THE ADDRESS BAR.
|
|
901
|
-
//
|
|
902
|
-
// This used to be re-derived from `location.hash` on every attempt, and the spy WRITES that hash.
|
|
903
|
-
// So the repair mechanism took its definition of "where I was supposed to be" from the very thing
|
|
904
|
-
// that goes wrong. Traced frame by frame on a live persona at 1512×900:
|
|
905
|
-
//
|
|
906
|
-
// t=241 scrollTo(333.36) landed exactly, below.top 0.36, #kernel
|
|
907
|
-
// t=258 the title strip begins closing y 331, below.top 2.36
|
|
908
|
-
// t=272 below.top passes 1 the spy answers PROFILE and writes #profile
|
|
909
|
-
// t=313 the strip is closed, the page has drifted y 329, below.top 4.36
|
|
910
|
-
// t=342 the `load` repair runs — and reads #profile as its target, measures itself
|
|
911
|
-
// 329 against the PROFILE's landing, finds it further than any drift could be,
|
|
912
|
-
// and closes the promise for good.
|
|
913
|
-
//
|
|
914
|
-
// Four pixels, and the page is stable in the wrong state: the kernel is 4px under the toolbar, the
|
|
915
|
-
// spy says profile, the strip stays shut, and the address bar says #profile for a person who typed
|
|
916
|
-
// the bare host. It is not a hash bug — with #kernel in the URL the same drift flips the same spy
|
|
917
|
-
// and disarms the same repair. What made it look like one is that the two stable states are
|
|
918
|
-
// reachable by a hair: on a phone the landing happened to rest at below.top −0.27 and stayed right.
|
|
919
|
-
//
|
|
920
|
-
// Captured before the first landing, so the repair keeps asking the only question worth asking:
|
|
921
|
-
// *am I where I was SENT?* One re-assert settles it permanently — measured, four times over, no
|
|
922
|
-
// oscillation.
|
|
923
|
-
const sentTo = (() => {
|
|
924
|
-
const t = cuts.find((c) => "#" + c[0].id === location.hash);
|
|
925
|
-
// A section hash is honoured on load and refresh; anything else — including #kernel and no hash
|
|
926
|
-
// at all — lands on the kernel.
|
|
927
|
-
return t ? t[0] : kernel;
|
|
928
|
-
})();
|
|
929
|
-
|
|
930
|
-
const land = () => {
|
|
931
|
-
// presentation mode owns the viewport — a page presenting itself does not scroll out from under
|
|
932
|
-
// whoever opened it
|
|
933
|
-
if (document.body.dataset.present) return;
|
|
934
|
-
// `instant` overrides the page's own scroll-behavior: smooth.
|
|
935
|
-
goTo(sentTo, "instant");
|
|
936
|
-
};
|
|
937
|
-
// queries: the page did not land on the kernel · landing scroll ignored · scrollTo does nothing on
|
|
938
|
-
// first paint · the page opens at the top sometimes
|
|
939
|
-
//
|
|
940
|
-
// LANDED, OR TRIED AGAIN — but only for the one case where a scroll is REFUSED.
|
|
941
|
-
//
|
|
942
|
-
// `scrollTo` past the current document height is a no-op, and it does not report one: on a page
|
|
943
|
-
// whose sections size themselves a frame later, the landing is CALLED, the browser declines it, and
|
|
944
|
-
// the page opens at the top with nothing anywhere saying so. Measured in this behaviour's own
|
|
945
|
-
// fixture: `scrollTo({top: 548})` followed by a scroll event reading 0. So it is attempted again on
|
|
946
|
-
// the next frame, on `load`, and once more when the page comes to rest.
|
|
947
|
-
//
|
|
948
|
-
// ── WHAT USED TO BE HERE, AND WHY IT IS NOT ────────────────────────────────────────────────
|
|
949
|
-
//
|
|
950
|
-
// A second, much larger mechanism: a landing that ARRIVED and then DRIFTED, held as a promise until
|
|
951
|
-
// a wheel, a finger or a key "took over", with a tolerance derived from the toolbar's own height.
|
|
952
|
-
// Its trace, recorded in this file:
|
|
953
|
-
//
|
|
954
|
-
// scrollTo(468) y = 468 the landing is exact
|
|
955
|
-
// DOMContentLoaded y = 494 docH +26 — the title strip opened
|
|
956
|
-
// settled y = 465 docH -26 — and the strip closed again
|
|
957
|
-
//
|
|
958
|
-
// Every term of it was the secondary strip. It sat above the kernel inside the sticky bar, so each
|
|
959
|
-
// time it opened or closed the browser moved the scroll position to keep the content under it
|
|
960
|
-
// steady, and the page came to rest three pixels short of where the kernel began — close enough to
|
|
961
|
-
// look landed, far enough that the spy answered "profile", which closed the strip, which is what
|
|
962
|
-
// moved it. The founder removed the strip on 2026-08-06, and this went with it: measured after, the
|
|
963
|
-
// page scrolls exactly ONCE to its landing and never moves again, at 402x710 and at 1440x900.
|
|
964
|
-
//
|
|
965
|
-
// A workaround outlives its cause silently. This one would have kept re-asserting a landing nobody
|
|
966
|
-
// needed, over a drift that can no longer happen, for as long as the file existed.
|
|
967
|
-
// Only the DESTINATION is released when somebody takes over, never the landing: a tap on a cut
|
|
968
|
-
// shows where the page is GOING, and nobody should be shown a destination they have abandoned.
|
|
969
|
-
// The landing itself no longer needs protecting — there is no drift left for it to be protected
|
|
970
|
-
// from, which is the whole point of the note above.
|
|
971
|
-
const takeOver = () => { navTo = null; };
|
|
972
|
-
for (const ev of ["wheel", "touchmove", "keydown"]) window.addEventListener(ev, takeOver, { passive: true });
|
|
973
|
-
|
|
974
|
-
land();
|
|
975
|
-
|
|
976
|
-
// A CLICK CLOSES THIS ONE, AND THAT IS THE DIFFERENCE FROM WHAT WAS HERE BEFORE. The old promise
|
|
977
|
-
// deliberately survived clicks, because a tap on a cut is a request for a landing rather than an
|
|
978
|
-
// override — but that promise existed to repair the strip's drift, and it could tell the two apart
|
|
979
|
-
// because it only ever corrected by less than a toolbar's height. This one has no such tolerance:
|
|
980
|
-
// it can only distinguish "the browser refused the scroll" from "the page is somewhere on purpose",
|
|
981
|
-
// and after a tap those look identical. Caught by the row's own spec: clicking Profile rested the
|
|
982
|
-
// page at 0, this read it as a refusal, and pulled it back to the kernel.
|
|
983
|
-
let landed = false;
|
|
984
|
-
const settle = () => { landed = true; };
|
|
985
|
-
for (const ev of ["wheel", "touchmove", "keydown", "click"]) {
|
|
986
|
-
window.addEventListener(ev, settle, { passive: true, once: true });
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
// queries: the child persona lands short · /me lands a bit off · unstable landing · async content
|
|
990
|
-
// moves the page after it lands · vault read shifts the layout · below.top -18 · the
|
|
991
|
-
// landing is fine in one browser and off in another · ResizeObserver landing
|
|
992
|
-
//
|
|
993
|
-
// ── THE LANDING IS KEPT AGAINST LAYOUT — NEVER AGAINST SCROLLS ─────────────────────────────────
|
|
994
|
-
//
|
|
995
|
-
// A landing is a promise about a document that may not have finished becoming itself. The children
|
|
996
|
-
// proved it: /me lands exactly, the vault's async read completes, the profile grows and settles,
|
|
997
|
-
// and the page rests 18px from where it was put — with NOBODY having scrolled. Chromium's scroll
|
|
998
|
-
// anchoring sometimes absorbs this and sometimes does not, and WebKit has no anchoring at all,
|
|
999
|
-
// which is why the founder's phone showed what a laptop's headless run happened to hide. "Stable
|
|
1000
|
-
// olmayan bir durum" is half-applied compensation seen from the outside.
|
|
1001
|
-
//
|
|
1002
|
-
// A repair against ANY movement was tried once and fought a page that scrolls itself — that is the
|
|
1003
|
-
// workaround this file keeps warning about. The line is drawn elsewhere, and it is sharp: LAYOUT
|
|
1004
|
-
// is the page still under construction, so the promise holds; a SCROLL is an intent, and intents
|
|
1005
|
-
// are never fought. A ResizeObserver on the body sees exactly the first kind and cannot see the
|
|
1006
|
-
// second — a consumer calling scrollTo() resizes nothing. The first gesture ends it: after a
|
|
1007
|
-
// wheel, a finger, a key or a pointer the page belongs to the person, whatever the layout does.
|
|
1008
|
-
let touched = false;
|
|
1009
|
-
const takeBack = () => { touched = true; };
|
|
1010
|
-
for (const ev of ["wheel", "touchmove", "keydown", "pointerdown"]) {
|
|
1011
|
-
window.addEventListener(ev, takeBack, { passive: true, once: true, capture: true });
|
|
1012
|
-
}
|
|
1013
|
-
if (typeof ResizeObserver === "function") {
|
|
1014
|
-
// queries: the keeper fought a programmatic scroll · scrollTo(0) snapped back to the kernel ·
|
|
1015
|
-
// the query-survives spec times out in CI · near band 64
|
|
1016
|
-
//
|
|
1017
|
-
// AND THE KEEPER ONLY ACTS WHILE THE PAGE IS STILL AT THE LANDING. CI caught the first version
|
|
1018
|
-
// within the hour: a consumer's programmatic scrollTo(0) — which no gesture listener sees — was
|
|
1019
|
-
// followed by the fonts settling, the resize fired, and the keeper yanked the page back to the
|
|
1020
|
-
// kernel from somewhere it had been deliberately sent. Gestures cannot be the only release,
|
|
1021
|
-
// because a page is allowed to scroll ITSELF (lendcam's stage does; a spec does).
|
|
1022
|
-
//
|
|
1023
|
-
// So the promise is spatial as well: on every resize the keeper first asks whether the page is
|
|
1024
|
-
// still within a hand's width (64px) of where it last held it. Layout shifts displace a landed
|
|
1025
|
-
// page by small strokes — the vault's was 18px — while anybody scrolling AWAY, by hand or by
|
|
1026
|
-
// code, leaves that band immediately and permanently: the keeper reads leaving as being
|
|
1027
|
-
// relieved of duty, not as something to correct.
|
|
1028
|
-
let kept = landingY(sentTo);
|
|
1029
|
-
const keeper = new ResizeObserver(() => {
|
|
1030
|
-
if (touched || document.body.dataset.present) { keeper.disconnect(); return; }
|
|
1031
|
-
if (Math.abs(window.scrollY - kept) > 64) { keeper.disconnect(); return; }
|
|
1032
|
-
const want = landingY(sentTo);
|
|
1033
|
-
kept = want;
|
|
1034
|
-
// A pixel of slack: browsers land sub-pixel scrolls a hair off the number they were handed,
|
|
1035
|
-
// and re-asserting over a rounding error would run on every breath the page takes.
|
|
1036
|
-
if (Math.abs(window.scrollY - want) > 1) goTo(sentTo, "instant");
|
|
1037
|
-
});
|
|
1038
|
-
// NOT (only) the body: the fleet's ground gives `body { height: 100% }`, so the body's border
|
|
1039
|
-
// box is the viewport and never resizes when content grows — an observer there watched the one
|
|
1040
|
-
// box guaranteed to stay still. Caught by the spec modelling the vault's growth: 18px arrived,
|
|
1041
|
-
// the observer never fired. The boxes that actually change are the sections themselves, so the
|
|
1042
|
-
// keeper watches every cut and the below-boundary; body rides along for a consumer whose ground
|
|
1043
|
-
// differs.
|
|
1044
|
-
keeper.observe(document.body);
|
|
1045
|
-
keeper.observe(below);
|
|
1046
|
-
for (const c of cuts) keeper.observe(c[0]);
|
|
1047
|
-
}
|
|
1048
|
-
// The landing is attempted again when the page comes to rest, because `scrollTo` past a document
|
|
1049
|
-
// that has not sized itself yet is a silent no-op — cause 1, and the only cause left here. The
|
|
1050
|
-
// drift this used to repair as well was the secondary title strip moving the page after it landed,
|
|
1051
|
-
// and the strip is gone; the thirty-pixel glide that looked like drift afterwards was not one
|
|
1052
|
-
// either — it was the browser scrolling to the fragment with a number the persona still owned, and
|
|
1053
|
-
// that is fixed where the number lives rather than chased from here. A repair that re-asserts
|
|
1054
|
-
// against ANY movement fights a page that scrolls itself, which is a workaround growing back.
|
|
1055
|
-
const landIfRefused = () => {
|
|
1056
|
-
if (landed) return;
|
|
1057
|
-
// Anywhere but the very top means the scroll was accepted. A landing that IS the top has nothing
|
|
1058
|
-
// to be refused about. Either way this is the last thing it ever does.
|
|
1059
|
-
if (window.scrollY > 1 || landingY(sentTo) <= 1) { landed = true; return; }
|
|
1060
|
-
land();
|
|
1061
|
-
};
|
|
1062
|
-
requestAnimationFrame(landIfRefused);
|
|
1063
|
-
window.addEventListener("load", landIfRefused);
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
// The reveal rides with this on pages whose content is ready at first paint. A page that renders
|
|
1067
|
-
// asynchronously — the vault, the file kernel — holds paint until its own data has arrived and
|
|
1068
|
-
// passes `reveal: false`, because revealing before then shows an empty room.
|
|
1069
|
-
if (o.reveal !== false) {
|
|
1070
|
-
const reveal = () => document.body.classList.add("ready");
|
|
1071
|
-
requestAnimationFrame(reveal);
|
|
1072
|
-
setTimeout(reveal, 500);
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
const text = (sel) => (document.querySelector(sel)?.textContent || "").trim();
|
|
1076
|
-
// Kernel names the persona, Posts names its handle, Profile stays collapsed — its big header IS
|
|
1077
|
-
// the title, and repeating it in the bar above would say the same thing twice.
|
|
1078
|
-
const titleFor =
|
|
1079
|
-
o.titleFor ||
|
|
1080
|
-
((id) => (id === "kernel" ? text(".pname") : id === "posts" ? text(".handle") : ""));
|
|
1081
|
-
|
|
1082
|
-
// queries: the title strip jumps · the page jolts after tapping a cut · content shifts while
|
|
1083
|
-
// scrolling · toolbar title animation causes a layout shift · landing lands 26px off ·
|
|
1084
|
-
// landingAfterStrip · why is there no strip compensation any more · tb-slot min-height
|
|
1085
|
-
//
|
|
1086
|
-
// ── THERE IS NOTHING LEFT TO COMPENSATE FOR, AND THAT IS THE WHOLE POINT OF THE SLOT ──────────
|
|
1087
|
-
//
|
|
1088
|
-
// Two functions used to live here: one probed the strip's open height before it opened, the other
|
|
1089
|
-
// aimed a scroll at where the page WOULD rest once the strip had finished moving. They existed
|
|
1090
|
-
// because the strip was in flow above every section, so opening it pushed the whole page down by
|
|
1091
|
-
// its own 26px and a landing computed before it opened was wrong by exactly that much. A person
|
|
1092
|
-
// felt it as three motions for one tap.
|
|
1093
|
-
//
|
|
1094
|
-
// `.tb-slot` ends that at the source: the SLOT is what flow sees and its box is `--shell-top`, a
|
|
1095
|
-
// constant; the BAR is static inside it and may be any height it likes. Opening the strip moves
|
|
1096
|
-
// nothing outside the slot, so a landing computed before it opens is simply correct.
|
|
1097
|
-
//
|
|
1098
|
-
// The compensation is therefore not merely dead — it would be WRONG, adding a strip's height to
|
|
1099
|
-
// the posts landing for a shift that no longer happens. When the strip came back on 2026-08-06 the
|
|
1100
|
-
// reserved box came back with it FOR EVERY KIND, not only for games, and these two went for good.
|
|
1101
|
-
// If they are ever missed, the thing to check is whether the slot still reserves its box.
|
|
1102
|
-
const setStrip = (id, animate) => {
|
|
1103
|
-
if (!tbTitle) return;
|
|
1104
|
-
const t = titleFor(id);
|
|
1105
|
-
if (animate) {
|
|
1106
|
-
tbTitle.classList.toggle("show", !!t);
|
|
1107
|
-
if (t && tbTitleText && tbTitleText.textContent !== t) {
|
|
1108
|
-
tbTitleText.classList.add("fade");
|
|
1109
|
-
setTimeout(() => { tbTitleText.textContent = t; tbTitleText.classList.remove("fade"); }, 150);
|
|
1110
|
-
}
|
|
1111
|
-
return;
|
|
1112
|
-
}
|
|
1113
|
-
// Instant: the height must be final before this function returns, so the caller can measure. The
|
|
1114
|
-
// text goes with it — a settled height showing the previous words would be its own small lie.
|
|
1115
|
-
tbTitle.style.transition = "none";
|
|
1116
|
-
tbTitle.classList.toggle("show", !!t);
|
|
1117
|
-
if (t && tbTitleText) { tbTitleText.classList.remove("fade"); tbTitleText.textContent = t; }
|
|
1118
|
-
void tbTitle.offsetHeight;
|
|
1119
|
-
tbTitle.style.transition = "";
|
|
1120
|
-
};
|
|
1121
|
-
|
|
1122
|
-
let lastCut = null;
|
|
1123
|
-
let first = true;
|
|
1124
|
-
// queries: the toolbar icon changes late · nav icon lags the tap · active state waits for the scroll
|
|
1125
|
-
//
|
|
1126
|
-
// THE DESTINATION, HELD FOR THE LENGTH OF THE TRIP.
|
|
1127
|
-
//
|
|
1128
|
-
// The spy is truthful: it reports the section the page is actually over. During a smooth scroll that
|
|
1129
|
-
// is the section being LEFT, so the toolbar answered a tap only once the scroll finished — the icon
|
|
1130
|
-
// changed a beat late for no reason a person could see. A tap is a request to arrive, the same
|
|
1131
|
-
// reading the landing promise already takes, so the toolbar may show where it is going.
|
|
1132
|
-
//
|
|
1133
|
-
// Held rather than merely set, because setting it optimistically would be undone by the very next
|
|
1134
|
-
// spy frame and flicker. Released the moment the page arrives, or the moment somebody takes over —
|
|
1135
|
-
// nobody is shown a destination they have already abandoned.
|
|
1136
|
-
let navTo = null;
|
|
1137
|
-
// The cut you are on is the last one you have reached — asked in the one vocabulary `landingY`
|
|
1138
|
-
// defines, so this can never answer something a click could not produce. A pixel of tolerance,
|
|
1139
|
-
// because a browser is free to land a smooth scroll a hair short of the number it was given.
|
|
1140
|
-
const measure = () => {
|
|
1141
|
-
if (toolbar) toolbar.classList.toggle("stuck", window.scrollY >= below.offsetTop - 1);
|
|
1142
|
-
const y = window.scrollY + 1;
|
|
1143
|
-
let current = cuts[0];
|
|
1144
|
-
for (const c of cuts) if (landingY(c[0]) <= y) current = c;
|
|
1145
|
-
if (navTo) {
|
|
1146
|
-
if (current === navTo) navTo = null;
|
|
1147
|
-
else current = navTo;
|
|
1148
|
-
}
|
|
1149
|
-
for (const c of cuts) c[1].classList.toggle("active", c === current);
|
|
1150
|
-
if (current === lastCut) return;
|
|
1151
|
-
lastCut = current;
|
|
1152
|
-
if (current[0].id && "#" + current[0].id !== location.hash) setHash(current[0].id);
|
|
1153
|
-
|
|
1154
|
-
// First paint is not a transition: the page opens at the kernel, so the title is already true when
|
|
1155
|
-
// it arrives. Animating it in tells a person something changed when nothing did.
|
|
1156
|
-
const wasFirst = first;
|
|
1157
|
-
first = false;
|
|
1158
|
-
setStrip(current[0].id, !wasFirst);
|
|
1159
|
-
};
|
|
1160
|
-
// queries: scroll janks while the toolbar updates · scroll handler runs too often · the spy reads a
|
|
1161
|
-
// stale position · the section is right but the toolbar is one behind · scrollend
|
|
1162
|
-
//
|
|
1163
|
-
// THE LISTENER SCHEDULES; THE FRAME MEASURES. AND THE LAST WORD IS ALWAYS THE RESTING POSITION.
|
|
1164
|
-
//
|
|
1165
|
-
// Two rules, and the second one is what actually fixed the reported bug.
|
|
1166
|
-
//
|
|
1167
|
-
// NEVER IN THE EVENT. `measure` reads geometry, and reading geometry inside a scroll handler forces
|
|
1168
|
-
// the browser to lay the page out synchronously on a thread that is trying to move it. So the
|
|
1169
|
-
// handler does nothing but ask for a frame; all reading and writing happens in that frame, at most
|
|
1170
|
-
// once per frame however many events arrived. Intermediate positions are DISCARDED — only the
|
|
1171
|
-
// newest is ever measured, which is the whole point of coalescing rather than throttling.
|
|
1172
|
-
//
|
|
1173
|
-
// AND THE PAGE MUST BE MEASURED WHERE IT STOPS. Scroll events stop arriving slightly before a
|
|
1174
|
-
// smooth scroll finishes settling, so the last position the old code ever evaluated was in flight:
|
|
1175
|
-
// it read 85, decided "profile", and the page then came to rest at 82 — inside the kernel — with
|
|
1176
|
-
// nothing left to run and say so. That single unread pixel is the entire reported symptom.
|
|
1177
|
-
//
|
|
1178
|
-
// So a frame that finds the page still moving asks for another one, and the loop ends on the frame
|
|
1179
|
-
// where nothing changed — which is, by construction, the resting position. No timer, no `scrollend`
|
|
1180
|
-
// (still not everywhere), and nothing running once the page is still.
|
|
1181
|
-
let queued = false;
|
|
1182
|
-
let lastY = null;
|
|
1183
|
-
const frame = () => {
|
|
1184
|
-
queued = false;
|
|
1185
|
-
const y = window.scrollY;
|
|
1186
|
-
const moved = y !== lastY;
|
|
1187
|
-
lastY = y;
|
|
1188
|
-
measure();
|
|
1189
|
-
if (moved) schedule();
|
|
1190
|
-
// The page has stopped. If the landing was refused because the document had not sized itself
|
|
1191
|
-
// yet, this is the last chance to notice — and it is the ONLY thing left here: the drift this
|
|
1192
|
-
// used to repair was the secondary strip moving the page, and the strip is gone.
|
|
1193
|
-
else landIfRefused();
|
|
1194
|
-
};
|
|
1195
|
-
const schedule = () => { if (!queued) { queued = true; requestAnimationFrame(frame); } };
|
|
1196
|
-
window.addEventListener("scroll", schedule, { passive: true });
|
|
1197
|
-
measure();
|
|
1198
|
-
|
|
1199
|
-
// queries: a link to #kernel does not activate the kernel · the avatar link does not land · in-page
|
|
1200
|
-
// hash link · anchor click · hash from another page
|
|
1201
|
-
//
|
|
1202
|
-
// EVERY HASH LINK IS A CUT LINK — not only the three in the toolbar.
|
|
1203
|
-
//
|
|
1204
|
-
// The toolbar's own navs used to be the only anchors wired up, so any OTHER link to the same place
|
|
1205
|
-
// fell through to the browser's native anchor jump and was then overruled by the spy. The profile
|
|
1206
|
-
// avatar is exactly that: a link to `#kernel` that took you near the kernel and left the page
|
|
1207
|
-
// saying `#profile`. Delegated, so a cut link works wherever a persona puts one — today the avatar,
|
|
1208
|
-
// tomorrow something nobody has written yet — with no registration and no per-persona wiring.
|
|
1209
|
-
//
|
|
1210
|
-
// Programmatic rather than native, so the landing is the one `landingY` defines. A native jump uses
|
|
1211
|
-
// `scroll-margin` alone and lands the kernel below the sticky bar it should sit under.
|
|
1212
|
-
document.addEventListener("click", (e) => {
|
|
1213
|
-
const a = e.target && e.target.closest ? e.target.closest('a[href^="#"]') : null;
|
|
1214
|
-
if (!a) return;
|
|
1215
|
-
const t = cuts.find((c) => "#" + c[0].id === a.getAttribute("href"));
|
|
1216
|
-
if (!t) return;
|
|
1217
|
-
e.preventDefault();
|
|
1218
|
-
// A NEW LANDING RE-ARMS THE PROMISE. Somebody asking for a cut is asking to arrive at it, and the
|
|
1219
|
-
// arrival needs the same protection the page's first one had: the title strip opens as the kernel
|
|
1220
|
-
// becomes current, which drags the scroll ~18px past the mark and tucks the kernel's first line
|
|
1221
|
-
// under the sticky bar. Without this the toolbar's own icon landed flush and the avatar did not,
|
|
1222
|
-
// for no reason a person could see.
|
|
1223
|
-
// THE STRIP AND THE SCROLL RUN TOGETHER. The strip keeps its own transition — it is meant to be
|
|
1224
|
-
// seen growing, and snapping it open instead just moves the jolt to the moment of the tap. What
|
|
1225
|
-
// changes is the AIM: the scroll is sent to where the page will rest once the strip has finished,
|
|
1226
|
-
// so the growing band and the moving page arrive at the same place at the same time and nothing
|
|
1227
|
-
// has to be corrected afterwards.
|
|
1228
|
-
// The icon answers the tap NOW, not when the scroll lands. `navTo` keeps it answered for the trip.
|
|
1229
|
-
navTo = t;
|
|
1230
|
-
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1231
|
-
// queries: clicking profile throws me back to the kernel · the second cycle · landed re-armed
|
|
1232
|
-
//
|
|
1233
|
-
// ** NOTHING IS RE-ARMED HERE, AND THAT LINE COST AN HOUR. ** This used to set `landed = false`,
|
|
1234
|
-
// which was right while `landed` meant "the landing promise is open": a tap on a cut IS a request
|
|
1235
|
-
// for a landing, so the drift repair was re-armed to protect the new one. That promise is gone —
|
|
1236
|
-
// `landed` now means only "the initial scroll was accepted, stop retrying it" — and re-arming it
|
|
1237
|
-
// told the retry that the page had never landed. The tap scrolls to the profile, the page comes
|
|
1238
|
-
// to rest at 0, the retry reads `scrollY <= 1` with a landing of 376, calls it a refusal and
|
|
1239
|
-
// pulls the person back to the kernel.
|
|
1240
|
-
//
|
|
1241
|
-
// It survived the first cycle by luck: the same click also tripped the `once` listener that sets
|
|
1242
|
-
// `landed = true`, in the later bubble phase, so the flag ended true anyway. The listener is
|
|
1243
|
-
// spent after that, and from the SECOND tap onward the page snapped back every time — which is
|
|
1244
|
-
// exactly how the founder found it: "profile · kernel · profile · kernel … 2. cycle'da başlıyor."
|
|
1245
|
-
//
|
|
1246
|
-
// The strip still follows the tap — it is the row saying which cut you are on, which is the one
|
|
1247
|
-
// thing about it the founder said he could not give up.
|
|
1248
|
-
setStrip(t[0].id, true);
|
|
1249
|
-
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1250
|
-
setHash(t[0].id);
|
|
1251
|
-
});
|
|
1252
|
-
|
|
1253
|
-
// A hash that arrives without a click — the back button, or a link from another page to this one.
|
|
1254
|
-
// `setHash` uses replaceState and fires nothing, so this can only be somebody else's navigation.
|
|
1255
|
-
window.addEventListener("hashchange", () => {
|
|
1256
|
-
// The back button or a link from outside — a person navigated, so the load-landing promise ends
|
|
1257
|
-
// here too: the layout keeper must not snap a page somebody just steered somewhere else.
|
|
1258
|
-
touched = true;
|
|
1259
|
-
const t = cuts.find((c) => "#" + c[0].id === location.hash);
|
|
1260
|
-
if (t) {
|
|
1261
|
-
navTo = t;
|
|
1262
|
-
for (const c of cuts) c[1].classList.toggle("active", c === t);
|
|
1263
|
-
// Nor here — same reason as the click above.
|
|
1264
|
-
setStrip(t[0].id, true);
|
|
1265
|
-
window.scrollTo({ top: landingY(t[0], t[0].id), behavior: "smooth" });
|
|
1266
|
-
}
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
// queries: persona scroll for a surface that cannot bundle · inline scroll script · feed toolbar
|
|
1271
|
-
// script · why is there a JS string version of personaScroll
|
|
1272
|
-
//
|
|
1273
|
-
// THE SAME BEHAVIOUR, AS A STRING, FOR A SURFACE THAT CANNOT IMPORT IT.
|
|
1274
|
-
//
|
|
1275
|
-
// The feed is served under every persona's host from its own origin, so its scripts are `is:inline`
|
|
1276
|
-
// rather than bundled assets — a cross-origin module would need CORS on every one of them. That is
|
|
1277
|
-
// why core's other load-bearing pieces are strings too (AUTH_CAPTURE_JS, READY_JS, CONSENT_JS).
|
|
1278
|
-
//
|
|
1279
|
-
// It is generated FROM the function rather than written twice, which is the only version of this
|
|
1280
|
-
// worth having: a second hand-minified copy is what the feed already had, and it had drifted — its
|
|
1281
|
-
// hash writer dropped the query, it never set the title text, and it found its navs by href. One
|
|
1282
|
-
// source, two shapes.
|
|
1283
|
-
//
|
|
1284
|
-
// This works because `personaScroll` closes over nothing: every helper it uses is defined inside it.
|
|
1285
|
-
// A future edit that reaches for a module-level helper would compile, ship, and throw here — so if
|
|
1286
|
-
// you add one, inline it.
|
|
1287
|
-
export function personaScrollJs(options) {
|
|
1288
|
-
return "(" + personaScroll.toString() + ")(" + JSON.stringify(options || {}) + ");";
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
// queries: child persona face · the file room is blue · my child persona has the wrong accent ·
|
|
1292
|
-
// /api/face · a hidden persona's child · childFace · host persona colour in a child
|
|
1293
|
-
//
|
|
1294
|
-
// THE HOST PERSONA'S FACE, FOR A CHILD PERSONA THAT IS MOUNTED ON IT.
|
|
1295
|
-
//
|
|
1296
|
-
// `me`, `files` and `feed` render on every persona's host and have to wear that persona's colour,
|
|
1297
|
-
// name and mark. Each of them wrote this fetch by hand, and the line has now moved THREE times —
|
|
1298
|
-
// which is the argument for it living here rather than in a fourth copy:
|
|
1299
|
-
//
|
|
1300
|
-
// 1. `/api/personas` — serves five fields and none of the three needed. Every `if` was false, so
|
|
1301
|
-
// every file room wore the platform's default blue. Nothing errored; a 200 is not a face.
|
|
1302
|
-
// 2. `/api/catalog` — carries the face, and was right until a persona could be HIDDEN. The catalog
|
|
1303
|
-
// filters `hidden` on purpose because it IS the storefront, so from 2026-08-02 a persona born
|
|
1304
|
-
// from the template was invisible to its own child personas.
|
|
1305
|
-
// 3. `/api/face?host=` — "who owns this address", which is the question this code was always
|
|
1306
|
-
// asking. Only the storefront's question is about visibility.
|
|
1307
|
-
//
|
|
1308
|
-
// ── WHERE THE ACCENT HAS TO BE WRITTEN, WHICH IS BOTH PLACES ────────────────────────────────────
|
|
1309
|
-
//
|
|
1310
|
-
// A child scopes its whole token set under `.pp` — `--accent` included — so a value written only to
|
|
1311
|
-
// `:root` is SHADOWED for everything inside it, which is the entire surface. It looks correct, it
|
|
1312
|
-
// measures correct at `documentElement`, and it changes nothing a person can see. The root still
|
|
1313
|
-
// gets it too, because a few rules live outside `.pp` (`::selection` is one) and read the document's.
|
|
1314
|
-
//
|
|
1315
|
-
// Learned by moving it off `.pp` "to be more correct" and undoing a shipped fix — so both, always.
|
|
1316
|
-
export async function childFace(options) {
|
|
1317
|
-
const o = options || {};
|
|
1318
|
-
const host = o.host || (typeof location !== "undefined" ? location.hostname : "");
|
|
1319
|
-
if (!host) return null;
|
|
1320
|
-
const root = o.root || (typeof document !== "undefined" ? document.getElementById("pp") : null);
|
|
1321
|
-
const base = o.api || "https://api.justai.pro";
|
|
1322
|
-
let face = null;
|
|
1323
|
-
try {
|
|
1324
|
-
const r = await fetch(`${base}/api/face?host=${encodeURIComponent(host)}`);
|
|
1325
|
-
face = r.ok ? await r.json() : null;
|
|
1326
|
-
} catch {
|
|
1327
|
-
// A child whose host cannot be resolved is a child wearing the platform's default, which is a
|
|
1328
|
-
// legible state. It is not an error to report to somebody looking at their own files.
|
|
1329
|
-
return null;
|
|
1330
|
-
}
|
|
1331
|
-
if (!face) return null;
|
|
1332
|
-
if (typeof document === "undefined") return face;
|
|
1333
|
-
if (face.accent) {
|
|
1334
|
-
document.documentElement.style.setProperty("--accent", face.accent);
|
|
1335
|
-
if (root) root.style.setProperty("--accent", face.accent);
|
|
1336
|
-
}
|
|
1337
|
-
// queries: pnName pnHandle pnMeta · the child persona shows its own name instead of the host's
|
|
1338
|
-
//
|
|
1339
|
-
// THE HOST'S IDENTITY, WRITTEN INTO THE SHELL'S IDS. <ChildPersona> renders name, handle and the
|
|
1340
|
-
// small print as spans with these ids precisely so one function can fill them: the page is built
|
|
1341
|
-
// once and mounted on every persona's host, so none of it is knowable at build time.
|
|
1342
|
-
//
|
|
1343
|
-
// Each write is guarded because a MISSING value must leave the server's fallback standing — the
|
|
1344
|
-
// child's own words, which are correct when the lookup never returns. Blanking them on a failed
|
|
1345
|
-
// fetch would turn "we could not reach the registry" into "this persona has no name".
|
|
1346
|
-
const put = (id, text) => { const el = document.getElementById(id); if (el && text) el.textContent = text; };
|
|
1347
|
-
put("pnName", face.name);
|
|
1348
|
-
put("pnHandle", face.handle ? "@" + face.handle : null);
|
|
1349
|
-
|
|
1350
|
-
// queries: the child persona shows raw HTML · <span class="mtag"> printed as text · the meta line
|
|
1351
|
-
// shows markup · unrendered html in the profile · pnMeta
|
|
1352
|
-
//
|
|
1353
|
-
// THE META LINE IS MARKUP, AND IT ARRIVES FROM A REGISTRY. A persona's `meta` is a row of chips —
|
|
1354
|
-
// `<span class="mtag">Fast</span>…` — and the Profile cut renders the persona's OWN with `set:html`
|
|
1355
|
-
// because it is that persona's file. This is the same string coming back over the network, and
|
|
1356
|
-
// `textContent` printed it verbatim: three child personas on every host showed a paragraph of angle
|
|
1357
|
-
// brackets under the bio.
|
|
1358
|
-
//
|
|
1359
|
-
// `innerHTML` IS THE OBVIOUS FIX AND IT IS THE WRONG ONE. That would put remote markup into the
|
|
1360
|
-
// document on every host in the fleet, and `meta` is written by each persona's own manifest — an
|
|
1361
|
-
// `onerror=` in one persona's registry entry would then run inside /me, /files and the feed
|
|
1362
|
-
// wherever they are mounted. A child persona is the LAST place to be permissive: it is the surface
|
|
1363
|
-
// that shows a person their own vault.
|
|
1364
|
-
//
|
|
1365
|
-
// So the markup is parsed but never adopted. DOMParser builds an inert document — no scripts, no
|
|
1366
|
-
// network — the TEXT of each chip is read out of it, and this file creates the elements itself.
|
|
1367
|
-
// Whatever arrives, what reaches the page is spans this code made.
|
|
1368
|
-
const meta = document.getElementById("pnMeta");
|
|
1369
|
-
if (meta && face.meta) {
|
|
1370
|
-
const inert = new DOMParser().parseFromString("<body>" + face.meta + "</body>", "text/html");
|
|
1371
|
-
const chips = [...inert.body.querySelectorAll("span, li")].filter((n) => n.textContent.trim());
|
|
1372
|
-
meta.textContent = "";
|
|
1373
|
-
if (!chips.length) meta.textContent = inert.body.textContent.trim();
|
|
1374
|
-
else for (const c of chips) {
|
|
1375
|
-
const span = document.createElement("span");
|
|
1376
|
-
span.className = "mtag";
|
|
1377
|
-
span.textContent = c.textContent.trim();
|
|
1378
|
-
meta.append(span);
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
if (face.avatar) {
|
|
1382
|
-
const slot = document.getElementById("hostGlyph");
|
|
1383
|
-
if (slot) slot.innerHTML = '<img class="mk" src="' + face.avatar + '" alt="">';
|
|
1384
|
-
}
|
|
1385
|
-
return face;
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
// queries: toolbar mark · the persona icon has a background in the row · icon.svg in the toolbar ·
|
|
1389
|
-
// a filled tile in the toolbar · derive the row's mark from the avatar · toolbarMark
|
|
1390
|
-
//
|
|
1391
|
-
// THE AVATAR'S MARK, MADE FIT FOR A ROW OF ICONS — from the SAME FILE, not a second drawing.
|
|
1392
|
-
//
|
|
1393
|
-
// A persona's `icon.svg` is a TILE: a squircle ground with the mark on it, drawn to sit in an avatar
|
|
1394
|
-
// well or a Home Screen. Put that file in the toolbar as an `<img>` and it arrives with its ground
|
|
1395
|
-
// intact — the only object in the row with a background, a little coloured card among four inks. It
|
|
1396
|
-
// is exactly what the founder kept seeing and could not name: *"neden background olacak sekilde
|
|
1397
|
-
// fill edip kullaniyorsun"*.
|
|
1398
|
-
//
|
|
1399
|
-
// qr had already solved it, and the shape of the solution is the reason this is here rather than in
|
|
1400
|
-
// fifteen repos: **derive, never redraw.** Its comment says it best — *"THE SAME FILE, three edits
|
|
1401
|
-
// deep — not a second drawing. Whatever happens to icon.svg happens here."* A clever second face is
|
|
1402
|
-
// still a second face, and it drifts the day somebody redraws one of them.
|
|
1403
|
-
//
|
|
1404
|
-
// The three edits, generalised across the fleet's fourteen marks (all `viewBox="0 0 100 100"` with an
|
|
1405
|
-
// identical `<rect width="100" height="100" rx="26" fill="#0a0d18">` ground):
|
|
1406
|
-
//
|
|
1407
|
-
// 1. THE GROUND GOES. In the avatar the mark is a tile ON something; in the row it is one item IN
|
|
1408
|
-
// a line, and a filled tile there is the only thing with a background.
|
|
1409
|
-
// 2. IDS ARE NAMESPACED. Both copies are on the same page — the avatar and the row — and two
|
|
1410
|
-
// elements cannot share an id: a `url(#…)` silently resolves to whichever came first, so one of
|
|
1411
|
-
// the two marks loses its gradient with nothing reported.
|
|
1412
|
-
// 3. THE AUTHORING NOTE GOES. It is explanation aimed at whoever edits the file, and it has no
|
|
1413
|
-
// business shipping twice on every page load.
|
|
1414
|
-
//
|
|
1415
|
-
// What it does NOT do is recolour. Whether the row's mark takes `currentColor` is the persona's own
|
|
1416
|
-
// decision, made in its CSS — some marks are a silhouette and read as ink, some carry a gradient
|
|
1417
|
-
// that IS the identity. This only removes what the row cannot use.
|
|
1418
|
-
export function toolbarMark(iconSvg, options) {
|
|
1419
|
-
const o = options || {};
|
|
1420
|
-
const ns = o.id || "tb";
|
|
1421
|
-
let s = String(iconSvg || "");
|
|
1422
|
-
if (!s) return "";
|
|
1423
|
-
|
|
1424
|
-
// 1. the authoring note
|
|
1425
|
-
s = s.replace(/<!--[\s\S]*?-->/g, "");
|
|
1426
|
-
|
|
1427
|
-
// 2. the ground — a rect that covers the whole viewBox, whatever its corner radius or fill.
|
|
1428
|
-
// Matched against the viewBox rather than against "100" so a mark drawn at another size still
|
|
1429
|
-
// loses its tile.
|
|
1430
|
-
const vb = /viewBox="\s*0\s+0\s+([\d.]+)\s+([\d.]+)/.exec(s);
|
|
1431
|
-
if (vb) {
|
|
1432
|
-
const [, w, h] = vb;
|
|
1433
|
-
const tile = new RegExp(`<rect(?=[^>]*\\bwidth="${w}")(?=[^>]*\\bheight="${h}")[^>]*/>\\s*`, "g");
|
|
1434
|
-
s = s.replace(tile, "");
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
// 3. ids, and every reference to them. Done together so a rename cannot half-apply.
|
|
1438
|
-
const ids = [...s.matchAll(/\bid="([^"]+)"/g)].map((m) => m[1]);
|
|
1439
|
-
for (const id of ids) {
|
|
1440
|
-
const safe = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1441
|
-
s = s.replace(new RegExp(`\\bid="${safe}"`, "g"), `id="${id}-${ns}"`)
|
|
1442
|
-
.replace(new RegExp(`url\\(#${safe}\\)`, "g"), `url(#${id}-${ns})`)
|
|
1443
|
-
.replace(new RegExp(`(href|xlink:href)="#${safe}"`, "g"), `$1="#${id}-${ns}"`);
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
// queries: the track ring disappears in the toolbar · white on white · the dial is missing in light
|
|
1447
|
-
// mode · rgba(255,255,255,0.16) · half the mark vanished when the ground came off
|
|
1448
|
-
//
|
|
1449
|
-
// 4. WHAT ONLY MADE SENSE ON THE TILE. Five marks in the fleet draw an unlit "track" — a dial, the
|
|
1450
|
-
// ring a progress arc runs on — as `rgba(255,255,255,0.16)`. White at 16% is a correct choice
|
|
1451
|
-
// ON the near-black tile and a meaningless one off it: in a light toolbar it is white on white,
|
|
1452
|
-
// so the mark arrives with a piece silently missing, and only in one colour scheme. time's dial
|
|
1453
|
-
// vanished exactly this way the day it was drawn, leaving the two hands reading as an L.
|
|
1454
|
-
//
|
|
1455
|
-
// It becomes the row's own ink at the same weight. This is not recolouring the mark — the rule
|
|
1456
|
-
// above still stands, and the FIGURE is left alone. It is the same act as removing the ground:
|
|
1457
|
-
// the tile is gone, so what was drawn against the tile has to be told what it is against now.
|
|
1458
|
-
s = s.replace(/(stroke|fill)="rgba\(\s*255\s*,\s*255\s*,\s*255\s*,\s*([\d.]+)\s*\)"/g,
|
|
1459
|
-
(_, prop, a) => `${prop}="currentColor" ${prop}-opacity="${a}"`);
|
|
1460
|
-
|
|
1461
|
-
// 5. it is decoration in the row — the link around it carries the name
|
|
1462
|
-
s = s.replace(/\srole="img"/, "").replace(/\saria-label="[^"]*"/, "");
|
|
1463
|
-
if (!/aria-hidden/.test(s)) s = s.replace(/<svg /, '<svg aria-hidden="true" ');
|
|
1464
|
-
if (o.class) s = s.replace(/<svg /, `<svg class="${o.class}" `);
|
|
1465
|
-
|
|
1466
|
-
// queries: the persona mark is always coloured · two toolbar icons look active · the accent is
|
|
1467
|
-
// everywhere in the row · which icon should be coloured · currentColor toolbar mark
|
|
1468
|
-
//
|
|
1469
|
-
// THE MARK IS INK UNTIL ITS CUT IS CURRENT — the founder's golden rule, 2026-08-03:
|
|
1470
|
-
//
|
|
1471
|
-
// "active persona cut'un icon'u accent rengini alır. diğer passive cut iconları ise accent
|
|
1472
|
-
// rengini kullanmaz."
|
|
1473
|
-
//
|
|
1474
|
-
// The accent has exactly one job in this row: to answer *where am I*. A mark that keeps its own
|
|
1475
|
-
// colours while another cut is current is a second voice on that channel — measured at the kernel,
|
|
1476
|
-
// with the active bolt reading a chroma of 6 to 12, the passive marks read 8 to 20. Several were
|
|
1477
|
-
// MORE coloured than the icon that was actually current.
|
|
1478
|
-
//
|
|
1479
|
-
// THIS FILE ARGUED THE OPPOSITE, and the argument is kept because it shows a true premise ageing
|
|
1480
|
-
// into a wrong conclusion: *"a mark is an identity, not a UI state — a faded logo reads as disabled
|
|
1481
|
-
// rather than as not-current."* True while the mark arrived as an `<img>`, which cannot take
|
|
1482
|
-
// `currentColor`, so dimming was the only way to say "not here". That premise expired the day this
|
|
1483
|
-
// function started deriving an inline SVG. An inline mark can be ink, and ink is not dimming.
|
|
1484
|
-
//
|
|
1485
|
-
// Only the PAINT is neutralised, and only outside `<defs>`: the gradients stay defined, so a
|
|
1486
|
-
// persona that wants its own colours *while current* can re-point to them from its own CSS. qr
|
|
1487
|
-
// does. That is a decision about what the accent looks like, never about when it appears.
|
|
1488
|
-
{
|
|
1489
|
-
const cut = s.lastIndexOf("</defs>");
|
|
1490
|
-
const head = cut >= 0 ? s.slice(0, cut + 7) : "";
|
|
1491
|
-
const body = (cut >= 0 ? s.slice(cut + 7) : s)
|
|
1492
|
-
// `fill="none"` is not paint, it is the absence of it — a stroked shape says so and must keep
|
|
1493
|
-
// saying so, or every outline becomes a silhouette.
|
|
1494
|
-
.replace(/\b(fill|stroke)="(?!none")[^"]*"/g, '$1="currentColor"');
|
|
1495
|
-
s = head + body;
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
// queries: the derived mark is too small · fills · the mark shrank when the ground came off ·
|
|
1499
|
-
// box for 20 ink
|
|
1500
|
-
//
|
|
1501
|
-
// TAKING THE GROUND OFF DOES NOT MAKE THE DRAWING BIGGER — it only removes what was behind it. A
|
|
1502
|
-
// mark drawn to sit inside a tile keeps the tile's padding: measured across the fleet, the marks
|
|
1503
|
-
// occupy between 0.46 and 0.68 of their viewBox, so in a 20px box they put 9 to 13 on screen. The
|
|
1504
|
-
// row's rule is 20 of INK, so the box has to be 20 divided by that fraction.
|
|
1505
|
-
//
|
|
1506
|
-
// `fills` is the persona's own measurement, the way its accent is — a property of ITS drawing, not
|
|
1507
|
-
// a rule copied between repos. That distinction is the whole reason it is a number passed in
|
|
1508
|
-
// rather than a stylesheet each persona keeps: copying a rule is O(N) debt, carrying your own
|
|
1509
|
-
// measurement is data. Redraw the mark and this moves; nothing else does.
|
|
1510
|
-
//
|
|
1511
|
-
// Written as an inline style because the cut's `.tb-nav svg { width: 20px }` would beat a width
|
|
1512
|
-
// ATTRIBUTE. Left out, the mark takes the row's default and reads small — which is what shipped for
|
|
1513
|
-
// one deploy and is exactly how the fleet's ratios came to be measured.
|
|
1514
|
-
// queries: the mark in the preroll is tiny · ink option · use the derived mark somewhere else ·
|
|
1515
|
-
// toolbarMark size
|
|
1516
|
-
//
|
|
1517
|
-
// `ink` IS THE MEASURE, AND THE ROW IS ONLY ITS FIRST CUSTOMER. The derivation here — take the
|
|
1518
|
-
// ground off, namespace the ids so two copies on one page do not fight over a gradient — is what
|
|
1519
|
-
// ANY surface needs that wants the mark without its tile. The preroll wants exactly that at 300px
|
|
1520
|
-
// rather than 20, and the alternative was a second copy of the stripping logic under a second
|
|
1521
|
-
// name, which is the O(N) debt this package exists to refuse.
|
|
1522
|
-
//
|
|
1523
|
-
// So the number is a parameter and the default is the row's. The function keeps its name because
|
|
1524
|
-
// the row is still what it is for nine times in ten; that the name is now narrower than the job is
|
|
1525
|
-
// worth one line of honesty rather than a rename across sixteen repos.
|
|
1526
|
-
if (o.fills > 0) {
|
|
1527
|
-
const px = ((o.ink || 20) / o.fills).toFixed(2);
|
|
1528
|
-
s = s.replace(/<svg /, `<svg style="width:${px}px;height:${px}px" `);
|
|
1529
|
-
}
|
|
1530
|
-
return s.trim();
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
// queries: the child persona shows the parent's icon with a background · navParent has a ground ·
|
|
1534
|
-
// a child cannot know the parent's fills · adopt the host's mark · adoptMark ·
|
|
1535
|
-
// the parent icon in the child toolbar is small · derive a mark I only have a URL for
|
|
1536
|
-
//
|
|
1537
|
-
// THE SAME RULE, FOR THE ONE CASE THAT CANNOT BE BUILT — a child persona holds a URL, not a drawing.
|
|
1538
|
-
//
|
|
1539
|
-
// `toolbarMark` above runs at BUILD time on a file the persona imports, and takes `fills` as data
|
|
1540
|
-
// because a persona knows its own drawing. A child persona knows neither: `/me`, `/files` and the
|
|
1541
|
-
// feed are built once and mounted on every host in the fleet, so the mark in their row belongs to
|
|
1542
|
-
// whichever persona they happen to be inside. It arrives as `<img src="/icon.svg">` — the tile, the
|
|
1543
|
-
// ground, the one background in a line of inks — and there is no build step at which it is known.
|
|
1544
|
-
//
|
|
1545
|
-
// So it is fetched and derived in the browser instead, through the SAME function, and then the thing
|
|
1546
|
-
// that could not be passed in is MEASURED: `getBBox()` reports the ink's extent in viewBox units,
|
|
1547
|
-
// which is `fills` — read off the drawing rather than told to us. That is the better half of this:
|
|
1548
|
-
// it needs no registry field, no per-parent table, and a persona that redraws its icon tomorrow gets
|
|
1549
|
-
// the right box the same afternoon, with nothing to bump.
|
|
1550
|
-
//
|
|
1551
|
-
// IT DEGRADES TO THE TILE. Every failure — offline, a 404 that answers with HTML, a hidden row where
|
|
1552
|
-
// `getBBox` throws — leaves the `<img>` standing, which is today's appearance and legible. The image
|
|
1553
|
-
// is removed only once the derived mark is in the document.
|
|
1554
|
-
export async function adoptMark(options) {
|
|
1555
|
-
const o = options || {};
|
|
1556
|
-
if (typeof document === "undefined") return null;
|
|
1557
|
-
const el = o.el || document.getElementById(o.id || "navParent");
|
|
1558
|
-
if (!el) return null;
|
|
1559
|
-
const img = el.querySelector("img");
|
|
1560
|
-
const url = o.url || (img && img.getAttribute("src")) || "/icon.svg";
|
|
1561
|
-
|
|
1562
|
-
let src = "";
|
|
1563
|
-
try {
|
|
1564
|
-
const r = await fetch(url);
|
|
1565
|
-
if (!r.ok) return null;
|
|
1566
|
-
src = await r.text();
|
|
1567
|
-
} catch { return null; }
|
|
1568
|
-
// A missing file that answers with the persona's 404 PAGE is still a 200 in some setups, and
|
|
1569
|
-
// injecting that would put a document where a glyph goes.
|
|
1570
|
-
if (!/<svg[\s>]/.test(src)) return null;
|
|
1571
|
-
|
|
1572
|
-
const html = toolbarMark(src, { id: o.ns || "adopted", class: o.class });
|
|
1573
|
-
if (!html) return null;
|
|
1574
|
-
el.insertAdjacentHTML("afterbegin", html);
|
|
1575
|
-
const svg = el.querySelector("svg");
|
|
1576
|
-
if (!svg) return null;
|
|
1577
|
-
if (img) img.remove();
|
|
1578
|
-
|
|
1579
|
-
// queries: the parent icon still has a background · app.zone mark has a black tile in the child
|
|
1580
|
-
// toolbar · the ground was not removed · a path ground · squircle path
|
|
1581
|
-
//
|
|
1582
|
-
// THE GROUND IS WHATEVER IS BEHIND EVERYTHING, AND HERE IT CAN BE MEASURED.
|
|
1583
|
-
//
|
|
1584
|
-
// `toolbarMark` finds a ground by matching a `<rect>` against the viewBox, because at build time a
|
|
1585
|
-
// string is all it has. Fourteen personas draw exactly that rect. The fifteenth is app.zone, whose
|
|
1586
|
-
// mark comes out of a design tool as a 1024 viewBox with the squircle as a hand-drawn `<path>` —
|
|
1587
|
-
// so its tile survived, and /me and /files on app.zone showed a black card in a row of inks while
|
|
1588
|
-
// every other host was correct.
|
|
1589
|
-
//
|
|
1590
|
-
// Chasing that with another string rule would be chasing the sixteenth drawing next. In the
|
|
1591
|
-
// browser the question is geometric and answerable: a ground is the BACKMOST painted shape that
|
|
1592
|
-
// covers the whole viewBox. Measure it and remove it, whatever it was drawn as.
|
|
1593
|
-
//
|
|
1594
|
-
// Only the first shape, and only a shape — a `<g>` may legitimately wrap the entire mark, and
|
|
1595
|
-
// removing that would remove the drawing rather than what is behind it.
|
|
1596
|
-
const vb = (svg.getAttribute("viewBox") || "").split(/[\s,]+/).map(Number);
|
|
1597
|
-
if (vb.length === 4 && vb[2] > 0 && vb[3] > 0) {
|
|
1598
|
-
const back = [...svg.children].find((n) => /^(path|rect|circle|ellipse|polygon|polyline)$/i.test(n.tagName));
|
|
1599
|
-
try {
|
|
1600
|
-
if (back) {
|
|
1601
|
-
const bb = back.getBBox();
|
|
1602
|
-
if (bb.width >= vb[2] * 0.97 && bb.height >= vb[3] * 0.97) back.remove();
|
|
1603
|
-
}
|
|
1604
|
-
} catch { /* not rendered — leave the drawing whole */ }
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
// the measurement `fills` would have carried, taken from the drawing itself
|
|
1608
|
-
let box = 20;
|
|
1609
|
-
try {
|
|
1610
|
-
const bb = svg.getBBox();
|
|
1611
|
-
if (vb.length === 4 && vb[2] > 0 && vb[3] > 0 && bb.width > 0) {
|
|
1612
|
-
const fills = Math.max(bb.width / vb[2], bb.height / vb[3]);
|
|
1613
|
-
// a sane band: a drawing filling under a twentieth of its box is a parse we do not trust, and
|
|
1614
|
-
// one filling it whole needs no help.
|
|
1615
|
-
if (fills > 0.05 && fills < 1) box = 20 / fills;
|
|
1616
|
-
}
|
|
1617
|
-
} catch { /* not rendered — the row's default stands */ }
|
|
1618
|
-
|
|
1619
|
-
// queries: the parent icon is bigger than the other icons · the parent mark overflows the row ·
|
|
1620
|
-
// navParent looks shifted · the child toolbar mark is twice the size · adoptMark overflow
|
|
1621
|
-
//
|
|
1622
|
-
// A CEILING, BECAUSE NORMALISING INK CANNOT BE ALLOWED TO BREAK THE ROW.
|
|
1623
|
-
//
|
|
1624
|
-
// The scale above equalises INK: whatever the drawing, its ink lands at 20px, so a mark with
|
|
1625
|
-
// generous padding is scaled up until it reads like its neighbours. That is right, and it is
|
|
1626
|
-
// unbounded — the more padding a drawing carries, the larger the box it asks for, with nothing
|
|
1627
|
-
// stopping it at the size of the slot it lives in.
|
|
1628
|
-
//
|
|
1629
|
-
// Measured on the fleet, 2026-08-06, after the founder reported the parent mark looking shifted on
|
|
1630
|
-
// pin.games' children and nowhere else:
|
|
1631
|
-
//
|
|
1632
|
-
// app.zone/icon.svg ink fills 73% → 27.3px, inside a 38×36 slot
|
|
1633
|
-
// pin.games/icon.svg ink fills 37% → 53.8px, half again the slot's height
|
|
1634
|
-
//
|
|
1635
|
-
// pin.games draws its glyph with an app icon's padding — an iOS tile, correct on a home screen and
|
|
1636
|
-
// twice the fleet's inset. Nothing was wrong with the file and nothing was wrong with the scale;
|
|
1637
|
-
// what was missing is that a row icon belongs to the ROW, so the row's box is the limit. Clamped
|
|
1638
|
-
// rather than skipped, so the mark still grows as far as it usefully can.
|
|
1639
|
-
//
|
|
1640
|
-
// The remaining half is the persona's: a mark clamped to the slot reads smaller than its
|
|
1641
|
-
// neighbours, because the drawing genuinely carries less ink. That is a drawing to redraw, not a
|
|
1642
|
-
// number to fudge here.
|
|
1643
|
-
//
|
|
1644
|
-
// THE CEILING IS THE SLOT AND NOT A PIXEL LESS, because the founder asked the right question —
|
|
1645
|
-
// *"sadece pin games için böyle oldu, şimdi diğer tüm personalar bundan olumsuz etkilenir mi?"* —
|
|
1646
|
-
// and the first answer was yes. A ceiling of `slot − 4` was measured against all twenty-one live
|
|
1647
|
-
// personas and would have shrunk THIRTEEN of them, from 33–35px down to 32, none of which was
|
|
1648
|
-
// overflowing anything. Computed across the fleet, 2026-08-06:
|
|
1649
|
-
//
|
|
1650
|
-
// under the slot, untouched app.zone 27.3 · justai.pro 29.4 · lendcam 30.8 · qr 34.2 ·
|
|
1651
|
-
// time 34.5 · sudoku 34.6 · whatismyip 35.7 · fourteen more
|
|
1652
|
-
// over it, clamped pin.games 53.8 · auth 38.5 · password-generator 38.5
|
|
1653
|
-
//
|
|
1654
|
-
// A rail that changes anything already inside its limit is not a rail, it is a redesign — so the
|
|
1655
|
-
// limit is exactly the box the mark has to live in, and a mark that fits is left alone to the pixel.
|
|
1656
|
-
const ceiling = Math.max(20, el.clientHeight || 36);
|
|
1657
|
-
if (box > ceiling) box = ceiling;
|
|
1658
|
-
|
|
1659
|
-
svg.style.width = box.toFixed(2) + "px";
|
|
1660
|
-
svg.style.height = box.toFixed(2) + "px";
|
|
1661
|
-
return svg;
|
|
1662
|
-
}
|