@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/dist/mark.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @justai/core/mark — the persona's mark in a toolbar, and adopting a host's mark into a child. It knows SVG and the DOM.
|
|
3
|
+
*
|
|
4
|
+
* Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
|
|
5
|
+
* and why its behaviour lives one level below @justai/cuts.
|
|
6
|
+
*/
|
|
7
|
+
// queries: toolbar mark · the persona icon has a background in the row · icon.svg in the toolbar ·
|
|
8
|
+
// a filled tile in the toolbar · derive the row's mark from the avatar · toolbarMark
|
|
9
|
+
//
|
|
10
|
+
// THE AVATAR'S MARK, MADE FIT FOR A ROW OF ICONS — from the SAME FILE, not a second drawing.
|
|
11
|
+
//
|
|
12
|
+
// A persona's `icon.svg` is a TILE: a squircle ground with the mark on it, drawn to sit in an avatar
|
|
13
|
+
// well or a Home Screen. Put that file in the toolbar as an `<img>` and it arrives with its ground
|
|
14
|
+
// intact — the only object in the row with a background, a little coloured card among four inks. It
|
|
15
|
+
// is exactly what the founder kept seeing and could not name: *"neden background olacak sekilde
|
|
16
|
+
// fill edip kullaniyorsun"*.
|
|
17
|
+
//
|
|
18
|
+
// qr had already solved it, and the shape of the solution is the reason this is here rather than in
|
|
19
|
+
// fifteen repos: **derive, never redraw.** Its comment says it best — *"THE SAME FILE, three edits
|
|
20
|
+
// deep — not a second drawing. Whatever happens to icon.svg happens here."* A clever second face is
|
|
21
|
+
// still a second face, and it drifts the day somebody redraws one of them.
|
|
22
|
+
//
|
|
23
|
+
// The three edits, generalised across the fleet's fourteen marks (all `viewBox="0 0 100 100"` with an
|
|
24
|
+
// identical `<rect width="100" height="100" rx="26" fill="#0a0d18">` ground):
|
|
25
|
+
//
|
|
26
|
+
// 1. THE GROUND GOES. In the avatar the mark is a tile ON something; in the row it is one item IN
|
|
27
|
+
// a line, and a filled tile there is the only thing with a background.
|
|
28
|
+
// 2. IDS ARE NAMESPACED. Both copies are on the same page — the avatar and the row — and two
|
|
29
|
+
// elements cannot share an id: a `url(#…)` silently resolves to whichever came first, so one of
|
|
30
|
+
// the two marks loses its gradient with nothing reported.
|
|
31
|
+
// 3. THE AUTHORING NOTE GOES. It is explanation aimed at whoever edits the file, and it has no
|
|
32
|
+
// business shipping twice on every page load.
|
|
33
|
+
//
|
|
34
|
+
// What it does NOT do is recolour. Whether the row's mark takes `currentColor` is the persona's own
|
|
35
|
+
// decision, made in its CSS — some marks are a silhouette and read as ink, some carry a gradient
|
|
36
|
+
// that IS the identity. This only removes what the row cannot use.
|
|
37
|
+
export function toolbarMark(iconSvg, options) {
|
|
38
|
+
const o = options || {};
|
|
39
|
+
const ns = o.id || "tb";
|
|
40
|
+
let s = String(iconSvg || "");
|
|
41
|
+
if (!s)
|
|
42
|
+
return "";
|
|
43
|
+
// 1. the authoring note
|
|
44
|
+
s = s.replace(/<!--[\s\S]*?-->/g, "");
|
|
45
|
+
// 2. the ground — a rect that covers the whole viewBox, whatever its corner radius or fill.
|
|
46
|
+
// Matched against the viewBox rather than against "100" so a mark drawn at another size still
|
|
47
|
+
// loses its tile.
|
|
48
|
+
const vb = /viewBox="\s*0\s+0\s+([\d.]+)\s+([\d.]+)/.exec(s);
|
|
49
|
+
if (vb) {
|
|
50
|
+
const [, w, h] = vb;
|
|
51
|
+
const tile = new RegExp(`<rect(?=[^>]*\\bwidth="${w}")(?=[^>]*\\bheight="${h}")[^>]*/>\\s*`, "g");
|
|
52
|
+
s = s.replace(tile, "");
|
|
53
|
+
}
|
|
54
|
+
// 3. ids, and every reference to them. Done together so a rename cannot half-apply.
|
|
55
|
+
const ids = [...s.matchAll(/\bid="([^"]+)"/g)].map((m) => m[1]);
|
|
56
|
+
for (const id of ids) {
|
|
57
|
+
const safe = id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
58
|
+
s = s.replace(new RegExp(`\\bid="${safe}"`, "g"), `id="${id}-${ns}"`)
|
|
59
|
+
.replace(new RegExp(`url\\(#${safe}\\)`, "g"), `url(#${id}-${ns})`)
|
|
60
|
+
.replace(new RegExp(`(href|xlink:href)="#${safe}"`, "g"), `$1="#${id}-${ns}"`);
|
|
61
|
+
}
|
|
62
|
+
// queries: the track ring disappears in the toolbar · white on white · the dial is missing in light
|
|
63
|
+
// mode · rgba(255,255,255,0.16) · half the mark vanished when the ground came off
|
|
64
|
+
//
|
|
65
|
+
// 4. WHAT ONLY MADE SENSE ON THE TILE. Five marks in the fleet draw an unlit "track" — a dial, the
|
|
66
|
+
// ring a progress arc runs on — as `rgba(255,255,255,0.16)`. White at 16% is a correct choice
|
|
67
|
+
// ON the near-black tile and a meaningless one off it: in a light toolbar it is white on white,
|
|
68
|
+
// so the mark arrives with a piece silently missing, and only in one colour scheme. time's dial
|
|
69
|
+
// vanished exactly this way the day it was drawn, leaving the two hands reading as an L.
|
|
70
|
+
//
|
|
71
|
+
// It becomes the row's own ink at the same weight. This is not recolouring the mark — the rule
|
|
72
|
+
// above still stands, and the FIGURE is left alone. It is the same act as removing the ground:
|
|
73
|
+
// the tile is gone, so what was drawn against the tile has to be told what it is against now.
|
|
74
|
+
s = s.replace(/(stroke|fill)="rgba\(\s*255\s*,\s*255\s*,\s*255\s*,\s*([\d.]+)\s*\)"/g, (_, prop, a) => `${prop}="currentColor" ${prop}-opacity="${a}"`);
|
|
75
|
+
// 5. it is decoration in the row — the link around it carries the name
|
|
76
|
+
s = s.replace(/\srole="img"/, "").replace(/\saria-label="[^"]*"/, "");
|
|
77
|
+
if (!/aria-hidden/.test(s))
|
|
78
|
+
s = s.replace(/<svg /, '<svg aria-hidden="true" ');
|
|
79
|
+
if (o.class)
|
|
80
|
+
s = s.replace(/<svg /, `<svg class="${o.class}" `);
|
|
81
|
+
// queries: the persona mark is always coloured · two toolbar icons look active · the accent is
|
|
82
|
+
// everywhere in the row · which icon should be coloured · currentColor toolbar mark
|
|
83
|
+
//
|
|
84
|
+
// THE MARK IS INK UNTIL ITS CUT IS CURRENT — the founder's golden rule, 2026-08-03:
|
|
85
|
+
//
|
|
86
|
+
// "active persona cut'un icon'u accent rengini alır. diğer passive cut iconları ise accent
|
|
87
|
+
// rengini kullanmaz."
|
|
88
|
+
//
|
|
89
|
+
// The accent has exactly one job in this row: to answer *where am I*. A mark that keeps its own
|
|
90
|
+
// colours while another cut is current is a second voice on that channel — measured at the kernel,
|
|
91
|
+
// with the active bolt reading a chroma of 6 to 12, the passive marks read 8 to 20. Several were
|
|
92
|
+
// MORE coloured than the icon that was actually current.
|
|
93
|
+
//
|
|
94
|
+
// THIS FILE ARGUED THE OPPOSITE, and the argument is kept because it shows a true premise ageing
|
|
95
|
+
// into a wrong conclusion: *"a mark is an identity, not a UI state — a faded logo reads as disabled
|
|
96
|
+
// rather than as not-current."* True while the mark arrived as an `<img>`, which cannot take
|
|
97
|
+
// `currentColor`, so dimming was the only way to say "not here". That premise expired the day this
|
|
98
|
+
// function started deriving an inline SVG. An inline mark can be ink, and ink is not dimming.
|
|
99
|
+
//
|
|
100
|
+
// Only the PAINT is neutralised, and only outside `<defs>`: the gradients stay defined, so a
|
|
101
|
+
// persona that wants its own colours *while current* can re-point to them from its own CSS. qr
|
|
102
|
+
// does. That is a decision about what the accent looks like, never about when it appears.
|
|
103
|
+
{
|
|
104
|
+
const cut = s.lastIndexOf("</defs>");
|
|
105
|
+
const head = cut >= 0 ? s.slice(0, cut + 7) : "";
|
|
106
|
+
const body = (cut >= 0 ? s.slice(cut + 7) : s)
|
|
107
|
+
// `fill="none"` is not paint, it is the absence of it — a stroked shape says so and must keep
|
|
108
|
+
// saying so, or every outline becomes a silhouette.
|
|
109
|
+
.replace(/\b(fill|stroke)="(?!none")[^"]*"/g, '$1="currentColor"');
|
|
110
|
+
s = head + body;
|
|
111
|
+
}
|
|
112
|
+
// queries: the derived mark is too small · fills · the mark shrank when the ground came off ·
|
|
113
|
+
// box for 20 ink
|
|
114
|
+
//
|
|
115
|
+
// TAKING THE GROUND OFF DOES NOT MAKE THE DRAWING BIGGER — it only removes what was behind it. A
|
|
116
|
+
// mark drawn to sit inside a tile keeps the tile's padding: measured across the fleet, the marks
|
|
117
|
+
// occupy between 0.46 and 0.68 of their viewBox, so in a 20px box they put 9 to 13 on screen. The
|
|
118
|
+
// row's rule is 20 of INK, so the box has to be 20 divided by that fraction.
|
|
119
|
+
//
|
|
120
|
+
// `fills` is the persona's own measurement, the way its accent is — a property of ITS drawing, not
|
|
121
|
+
// a rule copied between repos. That distinction is the whole reason it is a number passed in
|
|
122
|
+
// rather than a stylesheet each persona keeps: copying a rule is O(N) debt, carrying your own
|
|
123
|
+
// measurement is data. Redraw the mark and this moves; nothing else does.
|
|
124
|
+
//
|
|
125
|
+
// Written as an inline style because the cut's `.tb-nav svg { width: 20px }` would beat a width
|
|
126
|
+
// ATTRIBUTE. Left out, the mark takes the row's default and reads small — which is what shipped for
|
|
127
|
+
// one deploy and is exactly how the fleet's ratios came to be measured.
|
|
128
|
+
// queries: the mark in the preroll is tiny · ink option · use the derived mark somewhere else ·
|
|
129
|
+
// toolbarMark size
|
|
130
|
+
//
|
|
131
|
+
// `ink` IS THE MEASURE, AND THE ROW IS ONLY ITS FIRST CUSTOMER. The derivation here — take the
|
|
132
|
+
// ground off, namespace the ids so two copies on one page do not fight over a gradient — is what
|
|
133
|
+
// ANY surface needs that wants the mark without its tile. The preroll wants exactly that at 300px
|
|
134
|
+
// rather than 20, and the alternative was a second copy of the stripping logic under a second
|
|
135
|
+
// name, which is the O(N) debt this package exists to refuse.
|
|
136
|
+
//
|
|
137
|
+
// So the number is a parameter and the default is the row's. The function keeps its name because
|
|
138
|
+
// the row is still what it is for nine times in ten; that the name is now narrower than the job is
|
|
139
|
+
// worth one line of honesty rather than a rename across sixteen repos.
|
|
140
|
+
if (o.fills !== undefined && o.fills > 0) {
|
|
141
|
+
const px = ((o.ink || 20) / o.fills).toFixed(2);
|
|
142
|
+
s = s.replace(/<svg /, `<svg style="width:${px}px;height:${px}px" `);
|
|
143
|
+
}
|
|
144
|
+
return s.trim();
|
|
145
|
+
}
|
|
146
|
+
// queries: the child persona shows the parent's icon with a background · navParent has a ground ·
|
|
147
|
+
// a child cannot know the parent's fills · adopt the host's mark · adoptMark ·
|
|
148
|
+
// the parent icon in the child toolbar is small · derive a mark I only have a URL for
|
|
149
|
+
//
|
|
150
|
+
// THE SAME RULE, FOR THE ONE CASE THAT CANNOT BE BUILT — a child persona holds a URL, not a drawing.
|
|
151
|
+
//
|
|
152
|
+
// `toolbarMark` above runs at BUILD time on a file the persona imports, and takes `fills` as data
|
|
153
|
+
// because a persona knows its own drawing. A child persona knows neither: `/me`, `/files` and the
|
|
154
|
+
// feed are built once and mounted on every host in the fleet, so the mark in their row belongs to
|
|
155
|
+
// whichever persona they happen to be inside. It arrives as `<img src="/icon.svg">` — the tile, the
|
|
156
|
+
// ground, the one background in a line of inks — and there is no build step at which it is known.
|
|
157
|
+
//
|
|
158
|
+
// So it is fetched and derived in the browser instead, through the SAME function, and then the thing
|
|
159
|
+
// that could not be passed in is MEASURED: `getBBox()` reports the ink's extent in viewBox units,
|
|
160
|
+
// which is `fills` — read off the drawing rather than told to us. That is the better half of this:
|
|
161
|
+
// it needs no registry field, no per-parent table, and a persona that redraws its icon tomorrow gets
|
|
162
|
+
// the right box the same afternoon, with nothing to bump.
|
|
163
|
+
//
|
|
164
|
+
// IT DEGRADES TO THE TILE. Every failure — offline, a 404 that answers with HTML, a hidden row where
|
|
165
|
+
// `getBBox` throws — leaves the `<img>` standing, which is today's appearance and legible. The image
|
|
166
|
+
// is removed only once the derived mark is in the document.
|
|
167
|
+
export async function adoptMark(options) {
|
|
168
|
+
const o = options || {};
|
|
169
|
+
if (typeof document === "undefined")
|
|
170
|
+
return null;
|
|
171
|
+
const el = o.el || document.getElementById(o.id || "navParent");
|
|
172
|
+
if (!el)
|
|
173
|
+
return null;
|
|
174
|
+
const img = el.querySelector("img");
|
|
175
|
+
const url = o.url || (img && img.getAttribute("src")) || "/icon.svg";
|
|
176
|
+
let src = "";
|
|
177
|
+
try {
|
|
178
|
+
const r = await fetch(url);
|
|
179
|
+
if (!r.ok)
|
|
180
|
+
return null;
|
|
181
|
+
src = await r.text();
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
// A missing file that answers with the persona's 404 PAGE is still a 200 in some setups, and
|
|
187
|
+
// injecting that would put a document where a glyph goes.
|
|
188
|
+
if (!/<svg[\s>]/.test(src))
|
|
189
|
+
return null;
|
|
190
|
+
const html = toolbarMark(src, { id: o.ns || "adopted", class: o.class });
|
|
191
|
+
if (!html)
|
|
192
|
+
return null;
|
|
193
|
+
el.insertAdjacentHTML("afterbegin", html);
|
|
194
|
+
const svg = el.querySelector("svg");
|
|
195
|
+
if (!svg)
|
|
196
|
+
return null;
|
|
197
|
+
if (img)
|
|
198
|
+
img.remove();
|
|
199
|
+
// queries: the parent icon still has a background · app.zone mark has a black tile in the child
|
|
200
|
+
// toolbar · the ground was not removed · a path ground · squircle path
|
|
201
|
+
//
|
|
202
|
+
// THE GROUND IS WHATEVER IS BEHIND EVERYTHING, AND HERE IT CAN BE MEASURED.
|
|
203
|
+
//
|
|
204
|
+
// `toolbarMark` finds a ground by matching a `<rect>` against the viewBox, because at build time a
|
|
205
|
+
// string is all it has. Fourteen personas draw exactly that rect. The fifteenth is app.zone, whose
|
|
206
|
+
// mark comes out of a design tool as a 1024 viewBox with the squircle as a hand-drawn `<path>` —
|
|
207
|
+
// so its tile survived, and /me and /files on app.zone showed a black card in a row of inks while
|
|
208
|
+
// every other host was correct.
|
|
209
|
+
//
|
|
210
|
+
// Chasing that with another string rule would be chasing the sixteenth drawing next. In the
|
|
211
|
+
// browser the question is geometric and answerable: a ground is the BACKMOST painted shape that
|
|
212
|
+
// covers the whole viewBox. Measure it and remove it, whatever it was drawn as.
|
|
213
|
+
//
|
|
214
|
+
// Only the first shape, and only a shape — a `<g>` may legitimately wrap the entire mark, and
|
|
215
|
+
// removing that would remove the drawing rather than what is behind it.
|
|
216
|
+
const vb = (svg.getAttribute("viewBox") || "").split(/[\s,]+/).map(Number);
|
|
217
|
+
if (vb.length === 4 && vb[2] > 0 && vb[3] > 0) {
|
|
218
|
+
// SVGGraphicsElement is the type that HAS getBBox — `Element` does not, and the filter below is
|
|
219
|
+
// exactly the check that makes the narrowing true rather than asserted.
|
|
220
|
+
const back = [...svg.children].find((n) => /^(path|rect|circle|ellipse|polygon|polyline)$/i.test(n.tagName));
|
|
221
|
+
try {
|
|
222
|
+
if (back) {
|
|
223
|
+
const bb = back.getBBox();
|
|
224
|
+
if (bb.width >= vb[2] * 0.97 && bb.height >= vb[3] * 0.97)
|
|
225
|
+
back.remove();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch { /* not rendered — leave the drawing whole */ }
|
|
229
|
+
}
|
|
230
|
+
// the measurement `fills` would have carried, taken from the drawing itself
|
|
231
|
+
let box = 20;
|
|
232
|
+
try {
|
|
233
|
+
const bb = svg.getBBox();
|
|
234
|
+
if (vb.length === 4 && vb[2] > 0 && vb[3] > 0 && bb.width > 0) {
|
|
235
|
+
const fills = Math.max(bb.width / vb[2], bb.height / vb[3]);
|
|
236
|
+
// a sane band: a drawing filling under a twentieth of its box is a parse we do not trust, and
|
|
237
|
+
// one filling it whole needs no help.
|
|
238
|
+
if (fills > 0.05 && fills < 1)
|
|
239
|
+
box = 20 / fills;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch { /* not rendered — the row's default stands */ }
|
|
243
|
+
// queries: the parent icon is bigger than the other icons · the parent mark overflows the row ·
|
|
244
|
+
// navParent looks shifted · the child toolbar mark is twice the size · adoptMark overflow
|
|
245
|
+
//
|
|
246
|
+
// A CEILING, BECAUSE NORMALISING INK CANNOT BE ALLOWED TO BREAK THE ROW.
|
|
247
|
+
//
|
|
248
|
+
// The scale above equalises INK: whatever the drawing, its ink lands at 20px, so a mark with
|
|
249
|
+
// generous padding is scaled up until it reads like its neighbours. That is right, and it is
|
|
250
|
+
// unbounded — the more padding a drawing carries, the larger the box it asks for, with nothing
|
|
251
|
+
// stopping it at the size of the slot it lives in.
|
|
252
|
+
//
|
|
253
|
+
// Measured on the fleet, 2026-08-06, after the founder reported the parent mark looking shifted on
|
|
254
|
+
// pin.games' children and nowhere else:
|
|
255
|
+
//
|
|
256
|
+
// app.zone/icon.svg ink fills 73% → 27.3px, inside a 38×36 slot
|
|
257
|
+
// pin.games/icon.svg ink fills 37% → 53.8px, half again the slot's height
|
|
258
|
+
//
|
|
259
|
+
// pin.games draws its glyph with an app icon's padding — an iOS tile, correct on a home screen and
|
|
260
|
+
// twice the fleet's inset. Nothing was wrong with the file and nothing was wrong with the scale;
|
|
261
|
+
// what was missing is that a row icon belongs to the ROW, so the row's box is the limit. Clamped
|
|
262
|
+
// rather than skipped, so the mark still grows as far as it usefully can.
|
|
263
|
+
//
|
|
264
|
+
// The remaining half is the persona's: a mark clamped to the slot reads smaller than its
|
|
265
|
+
// neighbours, because the drawing genuinely carries less ink. That is a drawing to redraw, not a
|
|
266
|
+
// number to fudge here.
|
|
267
|
+
//
|
|
268
|
+
// THE CEILING IS THE SLOT AND NOT A PIXEL LESS, because the founder asked the right question —
|
|
269
|
+
// *"sadece pin games için böyle oldu, şimdi diğer tüm personalar bundan olumsuz etkilenir mi?"* —
|
|
270
|
+
// and the first answer was yes. A ceiling of `slot − 4` was measured against all twenty-one live
|
|
271
|
+
// personas and would have shrunk THIRTEEN of them, from 33–35px down to 32, none of which was
|
|
272
|
+
// overflowing anything. Computed across the fleet, 2026-08-06:
|
|
273
|
+
//
|
|
274
|
+
// under the slot, untouched app.zone 27.3 · justai.pro 29.4 · lendcam 30.8 · qr 34.2 ·
|
|
275
|
+
// time 34.5 · sudoku 34.6 · whatismyip 35.7 · fourteen more
|
|
276
|
+
// over it, clamped pin.games 53.8 · auth 38.5 · password-generator 38.5
|
|
277
|
+
//
|
|
278
|
+
// A rail that changes anything already inside its limit is not a rail, it is a redesign — so the
|
|
279
|
+
// limit is exactly the box the mark has to live in, and a mark that fits is left alone to the pixel.
|
|
280
|
+
const ceiling = Math.max(20, el.clientHeight || 36);
|
|
281
|
+
if (box > ceiling)
|
|
282
|
+
box = ceiling;
|
|
283
|
+
svg.style.width = box.toFixed(2) + "px";
|
|
284
|
+
svg.style.height = box.toFixed(2) + "px";
|
|
285
|
+
return svg;
|
|
286
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @justai/core/presentation — standalone or inside somebody else's sheet. Pure: give it a location and a window and it answers, so it is checkable with two plain objects rather than with two pages.
|
|
3
|
+
*
|
|
4
|
+
* Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
|
|
5
|
+
* and why its behaviour lives one level below @justai/cuts.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PRESENTATION_PARAM = "mode";
|
|
8
|
+
export declare const PRESENTATION_EMBEDDED = "atrium";
|
|
9
|
+
export type Presentation = "standalone" | "embedded";
|
|
10
|
+
export declare function presentation(loc?: Location | null, win?: Window | null): Presentation;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @justai/core/presentation — standalone or inside somebody else's sheet. Pure: give it a location and a window and it answers, so it is checkable with two plain objects rather than with two pages.
|
|
3
|
+
*
|
|
4
|
+
* Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
|
|
5
|
+
* and why its behaviour lives one level below @justai/cuts.
|
|
6
|
+
*/
|
|
7
|
+
// queries: is this persona standalone or embedded · how does a persona know it is inside another
|
|
8
|
+
// persona · mode=atrium · presentation mode · a sub-persona should not show Cancel when
|
|
9
|
+
// opened directly · does this page have a caller
|
|
10
|
+
//
|
|
11
|
+
// WHICH PRESENTATION A PERSONA IS IN, AND WHY IT IS A QUESTION AT ALL.
|
|
12
|
+
//
|
|
13
|
+
// The founder, 2026-07-27, looking at `/files` opened directly in a tab and still wearing the
|
|
14
|
+
// clothes it wears inside somebody else's sheet:
|
|
15
|
+
//
|
|
16
|
+
// "bir persona veya sub personanin kendisinin standalone calisip calismadigini bilmesi gerekir
|
|
17
|
+
// ki ona gore ux deneyiminde degisiklige gidebilsin"
|
|
18
|
+
//
|
|
19
|
+
// A page opened by a person and a page opened by another persona are two different situations, and
|
|
20
|
+
// the same controls do not belong in both. Standalone there is nothing to cancel — "Cancel" is a
|
|
21
|
+
// button with no meaning, offered to somebody who never asked a question. "Choose from device" is
|
|
22
|
+
// the phrasing of an answer; alone, the same control is simply "Upload".
|
|
23
|
+
//
|
|
24
|
+
// TWO SIGNALS, AND THEY ANSWER DIFFERENT QUESTIONS:
|
|
25
|
+
//
|
|
26
|
+
// · `window.parent !== window` is the BROWSER's answer to "am I in a frame". It is true and it is
|
|
27
|
+
// free, but it says nothing about who put us there or what they want.
|
|
28
|
+
// · `?mode=atrium` is the CALLER's declaration of the experience it is asking for. It is a claim —
|
|
29
|
+
// anyone can type it — and that is fine, because it decides nothing but presentation.
|
|
30
|
+
//
|
|
31
|
+
// So both are required, and neither is a permission. Anything that must not be forged (who may read
|
|
32
|
+
// a file, whose persona owns a write) is decided by the verified origin on the atrium channel, never
|
|
33
|
+
// by this. What this decides is which words a person reads.
|
|
34
|
+
//
|
|
35
|
+
// The param exists at all because the frame is the SLOWER truth: a handshake takes a beat, and a
|
|
36
|
+
// page that waits for it shows the wrong chrome first and then rearranges itself in front of the
|
|
37
|
+
// person. The declaration is available in the first paint.
|
|
38
|
+
export const PRESENTATION_PARAM = "mode";
|
|
39
|
+
export const PRESENTATION_EMBEDDED = "atrium";
|
|
40
|
+
export function presentation(loc, win) {
|
|
41
|
+
const l = loc || (typeof location !== "undefined" ? location : null);
|
|
42
|
+
const w = win || (typeof window !== "undefined" ? window : null);
|
|
43
|
+
if (!l || !w)
|
|
44
|
+
return "standalone";
|
|
45
|
+
let declared = null;
|
|
46
|
+
try {
|
|
47
|
+
declared = new URLSearchParams(l.search).get(PRESENTATION_PARAM);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
/* a search string we cannot parse is a page nobody addressed */
|
|
51
|
+
}
|
|
52
|
+
const framed = w.parent !== w;
|
|
53
|
+
return declared === PRESENTATION_EMBEDDED && framed ? "embedded" : "standalone";
|
|
54
|
+
}
|
package/dist/scroll.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @justai/core/scroll — the persona page's scroll behaviour — landing on the kernel, the spy, the toolbar's title strip. It knows a set of element ids and nothing about which framework drew them.
|
|
3
|
+
*
|
|
4
|
+
* Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
|
|
5
|
+
* and why its behaviour lives one level below @justai/cuts.
|
|
6
|
+
*/
|
|
7
|
+
export interface PersonaScrollOptions {
|
|
8
|
+
/** Section ids in document order. Default `["profile", "kernel", "posts"]`. */
|
|
9
|
+
cuts?: string[];
|
|
10
|
+
/** Id of the element the toolbar sits at the top of. Default `"below"`. */
|
|
11
|
+
below?: string | HTMLElement | null;
|
|
12
|
+
toolbar?: string | HTMLElement | null;
|
|
13
|
+
title?: string | HTMLElement | null;
|
|
14
|
+
titleText?: string | HTMLElement | null;
|
|
15
|
+
/** Maps a section id to its nav's id. Default `profile` → `navProfile`. */
|
|
16
|
+
navFor?: (id: string) => string;
|
|
17
|
+
/** What the title strip says for a section. Default: kernel → `.pname`, posts → `.handle`. */
|
|
18
|
+
titleFor?: (id: string) => string;
|
|
19
|
+
/** Whether this owns `body.ready`. Pass `false` on a page that renders asynchronously. */
|
|
20
|
+
reveal?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function personaScroll(options?: PersonaScrollOptions): void;
|
|
23
|
+
export declare function personaScrollJs(options?: PersonaScrollOptions): string;
|