@justai/cuts 0.133.0 → 0.138.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/package.json +6 -3
- package/src/ActionList.astro +31 -27
- package/src/ActionRow.astro +68 -64
- package/src/BackToZone.astro +39 -35
- package/src/Base.astro +21 -3
- package/src/Catalogue.astro +95 -319
- package/src/CatalogueCard.astro +72 -68
- package/src/ChildPersona.astro +55 -51
- package/src/ConfirmSheet.astro +69 -65
- package/src/FilePicker.astro +21 -378
- package/src/LangPicker.astro +49 -104
- package/src/Posts.astro +177 -396
- package/src/Preroll.astro +204 -487
- package/src/Profile.astro +39 -35
- package/src/Segmented.astro +62 -111
- package/src/Sheet.astro +247 -507
- package/src/Toolbar.astro +288 -362
- package/src/behaviour/catalogue.ts +239 -0
- package/src/behaviour/filePicker.ts +372 -0
- package/src/behaviour/langPicker.ts +70 -0
- package/src/behaviour/posts.ts +234 -0
- package/src/behaviour/preroll.ts +298 -0
- package/src/behaviour/segmented.ts +64 -0
- package/src/behaviour/sheet.ts +300 -0
- package/src/behaviour/toolbar.ts +89 -0
- package/src/ground.css +124 -120
package/src/Posts.astro
CHANGED
|
@@ -160,415 +160,196 @@ const vars = [
|
|
|
160
160
|
{RELABEL && <script is:inline set:html={RELABEL}></script>}
|
|
161
161
|
|
|
162
162
|
<style>
|
|
163
|
-
/*
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
/* Scoped by Astro's hash AND placed in the cascade: a persona overriding this never has to
|
|
164
|
+
out-specify it. See @justai/ui/tokens.css for the order, and for what deliberately stays out. */
|
|
165
|
+
@layer justai.components {
|
|
166
|
+
/* ---- POSTS cut — a conversation: ONE line descends from the post's avatar and
|
|
167
|
+
connects every comment & reply (they're all replies to the post). ---- */
|
|
168
|
+
/* the cut owns its own landing offset (was `#kernel, #posts { scroll-margin-top }` in each persona —
|
|
169
|
+
which orphaned once #posts moved here and carried this component's scope cid instead of the persona's). */
|
|
170
|
+
/* The landing offset is `--shell-top` and only that — see base.css. A hardcoded twin here is a
|
|
171
|
+
second opinion the browser can pick when it scrolls to `#posts` by itself. */
|
|
172
|
+
.posts { border-block-start: 1px solid var(--border); scroll-margin-top: var(--shell-top); }
|
|
173
|
+
/* A post is hoverable because it is a link to its own page, and the hover used to say so with a grey wash
|
|
174
|
+
— `--text` at 3.5% — which reads as dimming rather than as lifting. It now uses the card material, so
|
|
175
|
+
hovering a post looks like the same gesture as hovering a catalogue card.
|
|
173
176
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
`var(--card-bg, ...)` with the old wash as the fallback ON PURPOSE. Those tokens exist in app.zone only;
|
|
178
|
+
the other eleven personas have no catalogue and never defined them, and their column already uses
|
|
179
|
+
`--surface` as its own background, so falling back to that would have made the hover invisible. This way
|
|
180
|
+
app.zone gets the material and nobody else changes at all, which is the difference between an
|
|
181
|
+
improvement and a regression in eleven repos.
|
|
179
182
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
16px of horizontal padding with a matching negative margin, so the box grows outward and the text does
|
|
184
|
+
not move. 16 rather than the 18 above it because the column's own padding is 16px on a phone and 28px
|
|
185
|
+
from 768px up: at 18 the box would overflow the narrow case by 2px. Two pixels of asymmetry nobody can
|
|
186
|
+
see beats a horizontal scrollbar on a phone.
|
|
184
187
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
188
|
+
Square corners, stated rather than inherited — a radius here would make it a card, and it is not one:
|
|
189
|
+
it spans the column and sits directly against its neighbours. */
|
|
190
|
+
.post {
|
|
191
|
+
padding-block: 18px;
|
|
192
|
+
padding-inline: 16px;
|
|
193
|
+
margin-inline: -16px;
|
|
194
|
+
border-radius: 0;
|
|
195
|
+
cursor: pointer;
|
|
196
|
+
transition: background 0.15s var(--ease-out), transform 0.15s var(--ease-out),
|
|
197
|
+
border-radius 0.15s var(--ease-out);
|
|
198
|
+
}
|
|
199
|
+
/* THE FILL LIVES IN ITS OWN PROPERTY, and that is not tidiness — it is the difference between a hover and
|
|
200
|
+
no hover. A color-mix over a bare --card-bg (no fallback) written straight into `background` is an
|
|
201
|
+
INVALID declaration for a persona that never defined --card-bg, and an invalid declaration is dropped, so
|
|
202
|
+
those pages would answer the cursor with nothing at all. Here the fallback sits inside the mix, so the
|
|
203
|
+
value is always valid; the defaults mirror app.zone's own tokens per scheme.
|
|
204
|
+
(app.zone is the only persona on this line today, but that is a fact about the migration, not a guarantee.)
|
|
202
205
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
55% rather than the full card colour, and no hairline. The full-strength version was measured at 7
|
|
207
|
+
luminance steps of lift in light, and it read as a slab competing with the text — the inset hairline was
|
|
208
|
+
doing most of that. At 55% the lift is 4 in light and still 9 in dark, so it calms down where it was loud
|
|
209
|
+
without disappearing where it was already subtle. 35% was tried and rejected: 2 steps in dark, which on a
|
|
210
|
+
bright screen is nothing.
|
|
208
211
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
212
|
+
The radius and the scale are why it now invites rather than announces. They only exist on hover — at rest
|
|
213
|
+
the post has no box to round. */
|
|
214
|
+
.post:hover {
|
|
215
|
+
background: color-mix(in srgb, var(--card-bg, rgba(255, 255, 255, 0.06)) 55%, transparent);
|
|
216
|
+
backdrop-filter: var(--card-blur, none);
|
|
217
|
+
-webkit-backdrop-filter: var(--card-blur, none);
|
|
218
|
+
border-radius: 14px;
|
|
219
|
+
transform: scale(1.006);
|
|
220
|
+
}
|
|
221
|
+
/* The light default is white because that is what --card-bg is there; the dark default is a faint white
|
|
222
|
+
overlay because on dark --card-bg equals --surface, which is the column, so copying it would vanish. */
|
|
223
|
+
@media (prefers-color-scheme: light) {
|
|
224
|
+
:global(html:not([data-theme="dark"])) .post:hover { background: color-mix(in srgb, var(--card-bg, #fff) 55%, transparent); }
|
|
225
|
+
}
|
|
226
|
+
.post + .post { border-block-start: 1px solid var(--border); }
|
|
224
227
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
.trow { display: flex; gap: 12px; }
|
|
229
|
+
.avc { flex: none; width: 42px; display: flex; flex-direction: column; align-items: center; }
|
|
230
|
+
.ln { width: 2px; flex: 1 1 auto; min-height: 12px; margin-block-start: 6px; background: var(--border); border-radius: var(--radius-pill); }
|
|
231
|
+
.cc { flex: 1; min-width: 0; padding-block-end: 14px; }
|
|
232
|
+
.trow.last .cc { padding-block-end: 0; }
|
|
230
233
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
.pa { flex: none; width: 42px; height: 42px; border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 22px; background: var(--feed-av-bg, #fff); border: 1px solid var(--border); overflow: hidden; }
|
|
235
|
+
/* A human's avatar: their initial on a disc in their own colour, which arrives from the API as --c.
|
|
236
|
+
It was the last flat-filled object in the family, so it takes the house FILL recipe
|
|
237
|
+
(app-zone/.justai/expert/how-an-app-zone-icon-is-lit.md): an off-centre radial at 37% 31% with three
|
|
238
|
+
stops at L+22 / L+4 / L−11, so the light falls from the upper left and the lower right carries the
|
|
239
|
+
shade.
|
|
237
240
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
THE SPECULAR IS DELIBERATELY OMITTED, which is the one place this departs from the recipe. The doc
|
|
242
|
+
defines it as "what makes it a sphere rather than a lighter disc" — exactly right for howlong's beads,
|
|
243
|
+
which are beads, and wrong here. With it the disc read as a ball; without it the same three stops read
|
|
244
|
+
as a flat disc with light across it, which is what an avatar should be. Measured on Dana's #0a84ff: the
|
|
245
|
+
highlight sits 63 luminance steps above the flat colour instead of 94, and the rim is untouched at L99
|
|
246
|
+
either way — only the middle came down.
|
|
244
247
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
248
|
+
The stops are derived in CSS rather than precomputed, because the colour only exists at runtime.
|
|
249
|
+
`hsl(from var(--c) h s calc(l ± n))` is the rule stated literally: hue and saturation are passed
|
|
250
|
+
through untouched and lightness does all the shading. Measured — lit end 210.2° S100, shaded end
|
|
251
|
+
210.1° S100, so nothing drifts.
|
|
249
252
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
NO % ON THOSE NUMBERS. Inside relative colour syntax `l` resolves to a <number>, so `calc(l + 22%)`
|
|
254
|
+
mixes types, the declaration is dropped, and the disc silently renders flat — it looked finished and
|
|
255
|
+
measured as zero light-to-shadow difference until the units came off. `background-color` is kept as a
|
|
256
|
+
separate declaration for the same reason: where the syntax is unsupported the disc loses its light
|
|
257
|
+
rather than disappearing.
|
|
255
258
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
259
|
+
`max(0, 39 - l)` is the doc's L28 floor as a LIFT applied to all three stops, not a clamp on the dark
|
|
260
|
+
end: clamping compresses the spread and weakens the emboss unevenly. 39 is the shortfall threshold
|
|
261
|
+
(28 + 11), so a colour light enough to clear it adds nothing. */
|
|
262
|
+
.uav {
|
|
263
|
+
flex: none; width: 30px; height: 30px; border-radius: 50%;
|
|
264
|
+
display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff;
|
|
265
|
+
background-color: var(--c, #888);
|
|
266
|
+
background-image:
|
|
267
|
+
radial-gradient(ellipse 80% 80% at 37% 31%,
|
|
268
|
+
hsl(from var(--c, #888) h s calc(l + 22 + max(0, 39 - l))) 0%,
|
|
269
|
+
hsl(from var(--c, #888) h s calc(l + 4 + max(0, 39 - l))) 40%,
|
|
270
|
+
hsl(from var(--c, #888) h s calc(l - 11 + max(0, 39 - l))) 100%);
|
|
271
|
+
}
|
|
272
|
+
.rav { flex: none; width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 15px; background: var(--feed-av-bg, #fff); border: 1px solid var(--border); overflow: hidden; }
|
|
273
|
+
.pa :global(svg), .rav :global(svg) { display: block; }
|
|
274
|
+
.pa .mk, .rav .mk { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
275
|
+
/* a dark tile must invert in light mode, not stay dark — personas whose avatar ground is a gradient
|
|
276
|
+
pass avatarBgLight; the rest fall back to their single background. */
|
|
277
|
+
@media (prefers-color-scheme: light) { :global(html:not([data-theme="dark"])) .pa, :global(html:not([data-theme="dark"])) .rav { background: var(--feed-av-bg-light, var(--feed-av-bg, #fff)); } }
|
|
275
278
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
279
|
+
/* A bare mark stands on the feed's own ground, so the tile and its hairline have to go — and they have to
|
|
280
|
+
go from the CONTAINER, which is why this reads upward from the image with :has(). Scoping it to the image
|
|
281
|
+
is what keeps a sibling persona's tiled icon tiled: .rav wraps their reply as well as a self-reply.
|
|
282
|
+
`contain` rather than `cover`, because a mark with transparent margins must not be cropped to fill. */
|
|
283
|
+
.pa:has(.mk.bare), .rav:has(.mk.bare) {
|
|
284
|
+
background: none; border-color: transparent;
|
|
285
|
+
/* The slot rounds its corners and clips, which is right for a tile whose own corners are round and wrong
|
|
286
|
+
for a mark with no tile: the arms reach the corners, so the radius sliced their round outer tips flat.
|
|
287
|
+
Measured before the fix — 27.5px wide against 28.0 tall inside a square 30px slot, the asymmetry being
|
|
288
|
+
the clipping showing up as numbers. Nothing is left to clip once the mark is inset below, but both go
|
|
289
|
+
anyway, or a later change to the inset brings the slicing back silently. */
|
|
290
|
+
border-radius: 0; overflow: visible;
|
|
291
|
+
}
|
|
292
|
+
/* 72%, measured rather than judged. Filling the slot, the arms painted 92% of it; a sibling's tiled icon
|
|
293
|
+
paints its glyph across 61%, because the glyph sits inset within its own tile. So app.zone carried half
|
|
294
|
+
again the painted width of every persona it was replying to, in a thread where it is one speaker among
|
|
295
|
+
peers rather than the platform above them. At 72% the arms land near 67% — a shade above the siblings,
|
|
296
|
+
which suits a bracket form being lighter than a filled ring. The feed permalink page uses the same number
|
|
297
|
+
for the same reason; the two surfaces render one conversation and must not disagree about it. */
|
|
298
|
+
.pa .mk.bare, .rav .mk.bare { width: 72%; height: 72%; object-fit: contain; }
|
|
299
|
+
/* The scheme pair: the page decides, because the SVG's own media query does not survive <img>.
|
|
300
|
+
Written as `.pa .mk.av-*` rather than `.av-*` deliberately — `.pa .mk { display: block }` above is two
|
|
301
|
+
classes deep, so a single-class `.av-light { display: none }` loses on specificity and the toggle silently
|
|
302
|
+
does nothing. Measured: it showed the pale-ground file in both schemes until these selectors matched. */
|
|
303
|
+
.pa .mk.av-dark, .rav .mk.av-dark { display: none; }
|
|
304
|
+
@media (prefers-color-scheme: dark) {
|
|
305
|
+
.pa .mk.av-light, .rav .mk.av-light { display: none; }
|
|
306
|
+
.pa .mk.av-dark, .rav .mk.av-dark { display: block; }
|
|
307
|
+
}
|
|
308
|
+
/* The dark fork's data-theme twin: a light-system page forced dark must swap the marks too. */
|
|
309
|
+
:global(html[data-theme="dark"]) .pa .mk.av-light, :global(html[data-theme="dark"]) .rav .mk.av-light { display: none; }
|
|
310
|
+
:global(html[data-theme="dark"]) .pa .mk.av-dark, :global(html[data-theme="dark"]) .rav .mk.av-dark { display: block; }
|
|
308
311
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
312
|
+
.ph { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); flex-wrap: wrap; }
|
|
313
|
+
.ph b { font-weight: 600; }
|
|
314
|
+
.phandle, .dot, .pt { color: var(--text-dim); font-weight: 400; }
|
|
315
|
+
/* a persona's name in the feed links to its profile (X-style); humans have no link */
|
|
316
|
+
.pn { color: inherit; text-decoration: none; }
|
|
317
|
+
/* `a.pn`, not `.pn` — a persona whose home we were not told renders as a span, and a name that
|
|
318
|
+
lights up under the cursor while going nowhere is a promise the markup cannot keep. */
|
|
319
|
+
a.pn:hover b { color: var(--accent-text, var(--accent)); }
|
|
320
|
+
a.pt { text-decoration: none; }
|
|
321
|
+
a.pt:hover { text-decoration: underline; }
|
|
322
|
+
.pbd { font-size: var(--fs-sm); line-height: 1.5; margin-block-start: 4px; }
|
|
323
|
+
/* The translation notice — dim, small, directly under the words it is about, and carrying the ONE
|
|
324
|
+
link back to what the persona actually wrote, so the link is the only lit thing in the row.
|
|
325
|
+
Matches the feed permalink page exactly: the two surfaces render one conversation. */
|
|
326
|
+
.tnote { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-block-start: 6px; font-size: var(--fs-2xs); color: var(--text-dim); }
|
|
327
|
+
.tnote a { color: var(--confirm-accent, var(--accent)); text-decoration: none; }
|
|
328
|
+
.tnote a:hover { text-decoration: underline; }
|
|
329
|
+
.pact { display: flex; gap: 22px; margin-block-start: 12px; color: var(--text-dim); }
|
|
330
|
+
.pact svg { width: 17px; height: 17px; }
|
|
331
|
+
.pact span { cursor: pointer; transition: color 0.2s; }
|
|
332
|
+
.pact span:hover { color: var(--accent-text, var(--accent)); }
|
|
333
|
+
.ch { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); }
|
|
334
|
+
.ch b { font-weight: 600; }
|
|
335
|
+
.ch .muted { color: var(--text-dim); font-weight: 400; }
|
|
336
|
+
.ck { width: 14px; height: 14px; flex: none; }
|
|
337
|
+
.cb { font-size: var(--fs-xs); line-height: 1.45; margin-block-start: 2px; }
|
|
335
338
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
339
|
+
/* the maker's signature — every persona signs off with justai.pro */
|
|
340
|
+
.z-foot { text-align: center; color: var(--text-dim); font-size: var(--fs-2xs); padding-block: 24px max(16px, env(safe-area-inset-bottom)); }
|
|
341
|
+
/* Underlined, deliberately: a link inside body text must not rely on colour alone to be seen
|
|
342
|
+
(WCAG link-in-text-block — the twins' quality gate flagged it where accent-vs-dim contrast ran
|
|
343
|
+
thin). The offset keeps it quiet; the ability to see it does not depend on your colour vision. */
|
|
344
|
+
/* --confirm-accent, then --accent: the raw accent is a BRAND colour, not a text colour — at this
|
|
345
|
+
size on a light ground Apple blue reads 3.2:1. The fleet already solved this once, for the
|
|
346
|
+
sheet: every persona carries a hue-preserving darkened accent that clears 4.5 as text. A link
|
|
347
|
+
is text; it uses the text-grade accent. */
|
|
348
|
+
.z-foot a { color: var(--confirm-accent, var(--accent)); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
|
|
349
|
+
}
|
|
346
350
|
</style>
|
|
347
351
|
|
|
348
|
-
<script>
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
(function () {
|
|
353
|
-
const section = document.getElementById("posts");
|
|
354
|
-
const feed = document.getElementById("feed");
|
|
355
|
-
if (!section || !feed) return;
|
|
356
|
-
// the persona identity travels on the section as data-attributes (the static cut set them from props).
|
|
357
|
-
// PERSONA is the KEY (feed query + the "is this reply mine?" test); HANDLE is what is rendered after
|
|
358
|
-
// the @ (they differ for the two apexes: app.zone → @appzone, justai → @justai.pro). NAME is the
|
|
359
|
-
// persona's OWN name and is injected RAW — it is authored in the persona's source, never user input,
|
|
360
|
-
// so it may carry markup (justai's ".pro" span). Every name that comes from the API is escaped.
|
|
361
|
-
const PERSONA = section.dataset.persona || "";
|
|
362
|
-
const NAME = section.dataset.name || "";
|
|
363
|
-
// THE PAGE'S LANGUAGE. `data-lang` is present only when the persona STATED it; otherwise the
|
|
364
|
-
// document's own `lang` is read, which is the one place every persona in this fleet agrees —
|
|
365
|
-
// `Astro.currentLocale` is undefined under `[lang]` routing and cannot be the fallback it looks
|
|
366
|
-
// like. Not localStorage either: on a localized home the language is in the URL, settled before
|
|
367
|
-
// this ran, and a link shared in Turkish must open in Turkish for whoever follows it.
|
|
368
|
-
const LANG = (section.dataset.lang || document.documentElement.lang || "en").toLowerCase().split("-")[0];
|
|
369
|
-
if (!PERSONA) return;
|
|
370
|
-
// Astro scopes this component's CSS by a data-astro-cid-* attribute; runtime nodes lack it, so copy it.
|
|
371
|
-
const scopeAttr = section.getAttributeNames().find((n) => n.startsWith("data-astro-cid-")) || null;
|
|
372
|
-
|
|
373
|
-
// Twitter-style: clicking anywhere on a post (except a real link) opens its feed page.
|
|
374
|
-
// The "show original" link is handled first and swallowed — it is a control, not a destination.
|
|
375
|
-
feed.addEventListener("click", (e) => {
|
|
376
|
-
const t = e.target as HTMLElement;
|
|
377
|
-
const tog = t.closest("[data-toggle-original]") as HTMLElement | null;
|
|
378
|
-
if (tog) {
|
|
379
|
-
const art = tog.closest(".post");
|
|
380
|
-
const body = art?.querySelector(".pbd") as HTMLElement | null;
|
|
381
|
-
const state = art?.querySelector("[data-tstate]") as HTMLElement | null;
|
|
382
|
-
// Only take over the click once everything it needs is in hand. If the markup ever changes
|
|
383
|
-
// shape the link stays a link and still reaches the original — a control that degrades to
|
|
384
|
-
// working beats one that silently does nothing.
|
|
385
|
-
if (!body || !state) return;
|
|
386
|
-
e.preventDefault();
|
|
387
|
-
const showing = tog.textContent === tog.dataset.showTranslation;
|
|
388
|
-
body.textContent = showing ? tog.dataset.translation! : tog.dataset.original!;
|
|
389
|
-
body.setAttribute("lang", (showing ? tog.dataset.lang : tog.dataset.originalLang) || "");
|
|
390
|
-
tog.textContent = showing ? tog.dataset.showOriginal! : tog.dataset.showTranslation!;
|
|
391
|
-
state.textContent = showing ? tog.dataset.translated! : tog.dataset.originalLabel!;
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
if (t.closest("a")) return;
|
|
395
|
-
const art = t.closest(".post[data-href]") as HTMLElement | null;
|
|
396
|
-
if (art?.dataset.href) location.assign(art.dataset.href);
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
const esc = (s: unknown): string =>
|
|
400
|
-
String(s ?? "").replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c] as string);
|
|
401
|
-
// Every persona signs its posts with its own face, /icon.svg by default (each app serves one at its
|
|
402
|
-
// root). The path is a data attribute rather than a literal because a persona may sign with a mark that
|
|
403
|
-
// has no tile — see avatarSrc / avatarBare above. `bare` rides on the IMAGE, not on the container:
|
|
404
|
-
// .rav wraps both a self-reply and ANOTHER persona's reply, so a container rule would strip the tile
|
|
405
|
-
// from siblings who legitimately have one.
|
|
406
|
-
const bare = section.hasAttribute("data-av-bare") ? " bare" : "";
|
|
407
|
-
const avLight = esc(section.dataset.av || "/icon.svg");
|
|
408
|
-
// When a dark twin is declared, BOTH are in the markup and CSS shows one. The alternative — one <img>
|
|
409
|
-
// whose src is chosen in JS off matchMedia — would be a second source of truth for the same decision and
|
|
410
|
-
// would not follow a scheme change without a listener.
|
|
411
|
-
const AV = section.dataset.avDark
|
|
412
|
-
? `<img class="mk${bare} av-light" src="${avLight}" alt=""><img class="mk${bare} av-dark" src="${esc(section.dataset.avDark)}" alt="">`
|
|
413
|
-
: `<img class="mk${bare}" src="${avLight}" alt="">`;
|
|
414
|
-
const ck = `<svg class="ck" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l2.4 1.8 3 .2.9 2.8 2.3 1.9-1 2.8 1 2.8-2.3 1.9-.9 2.8-3 .2L12 22l-2.4-1.8-3-.2-.9-2.8L3.4 14l1-2.8-1-2.8 2.3-1.9.9-2.8 3-.2z" fill="var(--accent)"/><path d="M9 12.5l2 2 4-4.5" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
415
|
-
const pact = `<div class="pact"><span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8.5a5.5 5.5 0 0 0-9-4.2A5.5 5.5 0 0 0 3 8.5c0 5 9 11 9 11s9-6 9-11z"/></svg></span><span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.3 9.6 9.6 0 0 1-4-.9L3 21l1.1-5A8.4 8.4 0 1 1 21 11.5z"/></svg></span></div>`;
|
|
416
|
-
|
|
417
|
-
type C = { body: string; createdAt: string | null; authorHandle: string; authorName: string; authorColor: string | null; isPersona: boolean; authorAvatar: string | null; authorGlyph: string | null; personaUrl: string | null };
|
|
418
|
-
// `lang` is what `body` IS; `translated` says a machine made it. Both are optional so this cut
|
|
419
|
-
// still renders against a console that predates them — the fleet installs its packages on its own
|
|
420
|
-
// schedule, and a persona that has not been bumped must not lose its feed.
|
|
421
|
-
type P = { id: string; body: string; lang?: string; originalLang?: string; originalBody?: string | null; translated?: boolean; createdAt: string | null; comments: C[] };
|
|
422
|
-
|
|
423
|
-
// queries: translated automatically · show original · machine translation notice on the home feed
|
|
424
|
-
//
|
|
425
|
-
// THE SAME LINE THE PERMALINK PAGE SHOWS, because they render one conversation and must not
|
|
426
|
-
// disagree about it. The original is canonical, marked, and one tap away — that pairing IS the
|
|
427
|
-
// doctrine (dna/entities/localization.md), not a courtesy.
|
|
428
|
-
//
|
|
429
|
-
// Thirteen strings rather than a lookup through the persona's own dictionary: this cut ships to
|
|
430
|
-
// every persona and cannot reach into any of their locale files. ~400 bytes, said once, for the
|
|
431
|
-
// whole fleet — the alternative is the same sentence copied into thirteen files times thirty
|
|
432
|
-
// repos, which is the shape `tagline.js` already exists to prevent.
|
|
433
|
-
const TRANSLATED: Record<string, string> = {
|
|
434
|
-
en: "Translated automatically", tr: "Otomatik olarak çevrildi", es: "Traducido automáticamente",
|
|
435
|
-
de: "Automatisch übersetzt", fr: "Traduit automatiquement", pt: "Traduzido automaticamente",
|
|
436
|
-
it: "Tradotto automaticamente", nl: "Automatisch vertaald", ru: "Переведено автоматически",
|
|
437
|
-
ja: "自動翻訳", zh: "自动翻译", ar: "تُرجم آليًا", hi: "स्वचालित रूप से अनूदित",
|
|
438
|
-
};
|
|
439
|
-
const SHOW_ORIGINAL: Record<string, string> = {
|
|
440
|
-
en: "Show original", tr: "Orijinali göster", es: "Ver original", de: "Original anzeigen",
|
|
441
|
-
fr: "Afficher l'original", pt: "Ver original", it: "Mostra originale", nl: "Origineel weergeven",
|
|
442
|
-
ru: "Показать оригинал", ja: "原文を表示", zh: "显示原文", ar: "عرض النص الأصلي", hi: "मूल दिखाएँ",
|
|
443
|
-
};
|
|
444
|
-
// The way BACK. It is a toggle, not a door: swapping in place keeps the reader on the feed they
|
|
445
|
-
// were reading, in the language they set — the alternative walks them to the permalink and hands
|
|
446
|
-
// them the whole page in English for the sake of one paragraph.
|
|
447
|
-
const SHOW_TRANSLATION: Record<string, string> = {
|
|
448
|
-
en: "Show translation", tr: "Çeviriyi göster", es: "Ver traducción", de: "Übersetzung anzeigen",
|
|
449
|
-
fr: "Afficher la traduction", pt: "Ver tradução", it: "Mostra traduzione", nl: "Vertaling weergeven",
|
|
450
|
-
ru: "Показать перевод", ja: "翻訳を表示", zh: "显示翻译", ar: "عرض الترجمة", hi: "अनुवाद दिखाएँ",
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
// Relative timestamps are DERIVED from each post/comment's real createdAt (never a stored string),
|
|
454
|
-
// localized to the visitor's language and recomputed at read time — so they age honestly.
|
|
455
|
-
const agoLang = (() => { try { return localStorage.getItem("lang") || document.documentElement.lang || "en"; } catch { return "en"; } })();
|
|
456
|
-
const agoRtf = (() => { try { return new Intl.RelativeTimeFormat(agoLang, { numeric: "auto", style: "narrow" }); } catch { return new Intl.RelativeTimeFormat("en", { numeric: "auto", style: "narrow" }); } })();
|
|
457
|
-
const timeAgo = (iso: string | null): string => {
|
|
458
|
-
if (!iso) return "";
|
|
459
|
-
const t = Date.parse(iso);
|
|
460
|
-
if (Number.isNaN(t)) return "";
|
|
461
|
-
let s = Math.round((Date.now() - t) / 1000);
|
|
462
|
-
if (s < 0) s = 0;
|
|
463
|
-
if (s < 60) return agoRtf.format(-s, "second");
|
|
464
|
-
const m = Math.floor(s / 60); if (m < 60) return agoRtf.format(-m, "minute");
|
|
465
|
-
const h = Math.floor(m / 60); if (h < 24) return agoRtf.format(-h, "hour");
|
|
466
|
-
const d = Math.floor(h / 24); if (d < 7) return agoRtf.format(-d, "day");
|
|
467
|
-
const w = Math.floor(d / 7); if (w < 5) return agoRtf.format(-w, "week");
|
|
468
|
-
const mo = Math.floor(d / 30); if (mo < 12) return agoRtf.format(-mo, "month");
|
|
469
|
-
return agoRtf.format(-Math.floor(d / 365), "year");
|
|
470
|
-
};
|
|
471
|
-
// queries: a persona's name links to the wrong place · a comment links to a host that does not
|
|
472
|
-
// exist · pin.games persona linked to app.zone · where does a commenter's name go
|
|
473
|
-
//
|
|
474
|
-
// WHERE A PERSONA LIVES IS A FACT WE ARE TOLD, NOT ONE WE DERIVE. The API sends `personaUrl`,
|
|
475
|
-
// built from the registry's own `home`, for every persona that has one — and `home` is required
|
|
476
|
-
// by the manifest, so in practice that is all of them.
|
|
477
|
-
//
|
|
478
|
-
// There used to be a fallback here that guessed: justai → justai.pro, app.zone → app.zone, and
|
|
479
|
-
// everything else → `${handle}.app.zone`. It was correct for exactly as long as one apex existed.
|
|
480
|
-
// The day a game persona comments on a feed, that guess sends the reader to a host that has never
|
|
481
|
-
// existed — and it does it silently, in a link, on somebody else's page.
|
|
482
|
-
//
|
|
483
|
-
// So there is no fallback now. If we were not told where a persona lives, its name is rendered
|
|
484
|
-
// WITHOUT a link: a name that goes nowhere is a small disappointment, and a name that goes
|
|
485
|
-
// somewhere wrong is a broken ecosystem seen by a stranger.
|
|
486
|
-
const comment = (c: C, last: boolean): string => {
|
|
487
|
-
const ln = last ? "" : `<span class="ln"></span>`;
|
|
488
|
-
if (c.isPersona) {
|
|
489
|
-
// THE SOCIAL LAYER: personas reply on each other's feeds. A self-reply wears this persona's own
|
|
490
|
-
// face and name; ANOTHER persona wears ITS canonical icon (glyph fallback), its own name, its
|
|
491
|
-
// @handle, and its name links to its own profile. The verified check stays for both.
|
|
492
|
-
const own = c.authorHandle === PERSONA;
|
|
493
|
-
const av = own
|
|
494
|
-
? AV
|
|
495
|
-
: c.authorAvatar
|
|
496
|
-
? `<img class="mk" src="${esc(c.authorAvatar)}" alt="">`
|
|
497
|
-
: `<span style="font-size:16px">${esc(c.authorGlyph || "✦")}</span>`;
|
|
498
|
-
const nm = own ? NAME : esc(c.authorName); // own name is authored markup; an API name is escaped
|
|
499
|
-
const purl = own ? "#profile" : c.personaUrl ? `${c.personaUrl}/#profile` : null;
|
|
500
|
-
const at = own ? PERSONA : c.authorHandle;
|
|
501
|
-
const meta = `${at ? `@${esc(at)} ` : ""}· ${timeAgo(c.createdAt)}`;
|
|
502
|
-
const nameEl = purl ? `<a class="pn" href="${esc(purl)}"><b>${nm}</b></a>` : `<span class="pn"><b>${nm}</b></span>`;
|
|
503
|
-
return `<div class="trow${last ? " last" : ""}"><div class="avc"><span class="rav">${av}</span>${ln}</div><div class="cc"><div class="ch">${nameEl}${ck}<span class="muted">${meta}</span></div><p class="cb">${esc(c.body)}</p></div></div>`;
|
|
504
|
-
}
|
|
505
|
-
const initial = esc(String(c.authorName || "?").slice(0, 1));
|
|
506
|
-
// A person needs the handle MORE than a persona does — display names collide constantly among
|
|
507
|
-
// people. Guarded on the value: a principal with none shows a gap, never a bare "@".
|
|
508
|
-
const uat = c.authorHandle ? `@${esc(c.authorHandle)} ` : "";
|
|
509
|
-
return `<div class="trow${last ? " last" : ""}"><div class="avc"><span class="uav" style="--c:${esc(c.authorColor || "#888")}">${initial}</span>${ln}</div><div class="cc"><div class="ch"><b>${esc(c.authorName)}</b><span class="muted">${uat}· ${timeAgo(c.createdAt)}</span></div><p class="cb">${esc(c.body)}</p></div></div>`;
|
|
510
|
-
};
|
|
511
|
-
const post = (p: P): string => {
|
|
512
|
-
const cs = p.comments || [];
|
|
513
|
-
const inner = cs.map((c, i) => comment(c, i === cs.length - 1)).join("");
|
|
514
|
-
// Twitter-style permalink: the timestamp links to the post's feed page, and the whole post is
|
|
515
|
-
// clickable (the delegated handler above). n = the post id's last segment ("post:qr:7" → 7).
|
|
516
|
-
const n = String(p.id || "").split(":").pop() || "";
|
|
517
|
-
// queries: clicking a post loses my language · the permalink is English · navigation language
|
|
518
|
-
//
|
|
519
|
-
// EVERY NAVIGATION STAYS IN THE READER'S LANGUAGE — the founder's rule, and it is stronger than
|
|
520
|
-
// "link to the translation when there is one". Set a persona to Italian and EVERY page of it is
|
|
521
|
-
// Italian; a post with no Italian gives the original words with Italian chrome around them, and
|
|
522
|
-
// `/feed/{n}/it` renders exactly that rather than 404ing.
|
|
523
|
-
//
|
|
524
|
-
// The one URL that carries no segment is the post read in the language it was written in: there
|
|
525
|
-
// is no "translation into the original", so the permalink is already that page.
|
|
526
|
-
const orig = p.originalLang || "en";
|
|
527
|
-
const tr = !!p.translated && !!p.originalBody;
|
|
528
|
-
const base = n ? `/feed/${n}` : "";
|
|
529
|
-
const perma = base && LANG !== orig ? `${base}/${LANG}` : base;
|
|
530
|
-
const pt = perma ? `<a class="pt" href="${perma}">${timeAgo(p.createdAt)}</a>` : `<span class="pt">${timeAgo(p.createdAt)}</span>`;
|
|
531
|
-
// The way back, in the language of the person reading it. A real <a> so the delegated
|
|
532
|
-
// click-anywhere handler above lets it through — it returns early on any link.
|
|
533
|
-
// Both texts ride in the markup so the swap is instant and needs no second request. The link
|
|
534
|
-
// keeps a real href — without scripts it still reaches the original's own page.
|
|
535
|
-
const note = tr
|
|
536
|
-
? `<p class="tnote" dir="auto"><span data-tstate>${esc(TRANSLATED[LANG] ?? TRANSLATED.en)}</span><span class="dot">·</span>` +
|
|
537
|
-
`<a href="${base}" data-toggle-original data-original="${esc(p.originalBody)}" data-translation="${esc(p.body)}"` +
|
|
538
|
-
` data-show-original="${esc(SHOW_ORIGINAL[LANG] ?? SHOW_ORIGINAL.en)}" data-show-translation="${esc(SHOW_TRANSLATION[LANG] ?? SHOW_TRANSLATION.en)}"` +
|
|
539
|
-
` data-translated="${esc(TRANSLATED[LANG] ?? TRANSLATED.en)}" data-original-label="${esc(orig.toUpperCase())} · ${esc(NAME).replace(/<[^>]*>/g, "")}"` +
|
|
540
|
-
` data-original-lang="${esc(orig)}" data-lang="${esc(p.lang || LANG)}">${esc(SHOW_ORIGINAL[LANG] ?? SHOW_ORIGINAL.en)}</a></p>`
|
|
541
|
-
: "";
|
|
542
|
-
// `dir="auto"` on the body: an Arabic post inside an LTR page — and the reverse — must lay
|
|
543
|
-
// itself out from its own first strong character, not from the page around it.
|
|
544
|
-
return `<article class="post"${perma ? ` data-href="${perma}"` : ""}><div class="trow"><div class="avc"><span class="pa">${AV}</span>${cs.length ? '<span class="ln"></span>' : ""}</div><div class="cc"><div class="ph"><a class="pn" href="#profile"><b>${NAME}</b></a>${ck}${PERSONA ? `<span class="phandle">@${esc(PERSONA)}</span>` : ""}<span class="dot">·</span>${pt}</div><p class="pbd" dir="auto"${tr ? ` lang="${esc(p.lang)}"` : ""}>${esc(p.body)}</p>${note}${pact}</div></div>${inner}</article>`;
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
let done = false;
|
|
548
|
-
const load = async (): Promise<void> => {
|
|
549
|
-
if (done) return;
|
|
550
|
-
done = true;
|
|
551
|
-
try {
|
|
552
|
-
// `lang` rides in the query because it IS the content here — api.justai.pro is CDN'd with the
|
|
553
|
-
// query string in the cache key, so this is one more entry rather than one more origin hit.
|
|
554
|
-
const res = await fetch(
|
|
555
|
-
"https://api.justai.pro/api/feed?persona=" + encodeURIComponent(PERSONA) + "&lang=" + encodeURIComponent(LANG));
|
|
556
|
-
if (!res.ok) return;
|
|
557
|
-
const data = await res.json();
|
|
558
|
-
feed.innerHTML = ((data.posts as P[]) || []).map(post).join("");
|
|
559
|
-
if (scopeAttr) feed.querySelectorAll("*").forEach((el) => el.setAttribute(scopeAttr, ""));
|
|
560
|
-
} catch {
|
|
561
|
-
/* offline → the feed simply stays empty; the rest of the page is unaffected */
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
if ("IntersectionObserver" in window) {
|
|
566
|
-
const io = new IntersectionObserver((es, obs) => {
|
|
567
|
-
if (es.some((e) => e.isIntersecting)) { obs.disconnect(); load(); }
|
|
568
|
-
}, { rootMargin: "400px" });
|
|
569
|
-
io.observe(section);
|
|
570
|
-
} else {
|
|
571
|
-
load();
|
|
572
|
-
}
|
|
573
|
-
})();
|
|
574
|
-
</script>
|
|
352
|
+
<script>
|
|
353
|
+
// The behaviour lives in ./behaviour/posts.ts — see that file for why it is not in here.
|
|
354
|
+
import "./behaviour/posts";
|
|
355
|
+
</script>
|