@justai/core 0.9.3 → 0.11.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.9.3",
3
+ "version": "0.11.0",
4
4
  "description": "The framework-free heart of the persona shell — the load-bearing behaviour (auth capture, reveal, ready) as plain strings, so Astro and Next inject the SAME logic instead of each re-writing it.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
package/src/index.d.ts CHANGED
@@ -22,6 +22,12 @@ export declare const CONSENT_COPY: Record<string, { consentText: string; consent
22
22
  /** The consent copy for a language, falling back to English. */
23
23
  export declare function consentCopy(lang: string): { consentText: string; consentAllow: string; consentDecline: string; consentChoice: string };
24
24
 
25
+ /** Cancel and Done in thirteen languages — the ecosystem's chrome words, not a persona's copy. */
26
+ export declare const CHROME_COPY: Record<string, { cancel: string; done: string }>;
27
+
28
+ /** The chrome words for a language, falling back to English. */
29
+ export declare function chromeCopy(lang: string): { cancel: string; done: string };
30
+
25
31
  /** The consent dialog's behaviour — origin-scoped, asked once, with the universal change-your-mind door. */
26
32
  export declare const CONSENT_JS: string;
27
33
 
@@ -68,3 +74,39 @@ export declare function personaScroll(options?: PersonaScrollOptions): void;
68
74
  * Generated from the function itself, so there is never a second implementation to keep in step.
69
75
  */
70
76
  export declare function personaScrollJs(options?: PersonaScrollOptions): string;
77
+
78
+ /** The host persona's face, as a child persona reads it from `/api/face?host=`. */
79
+ export interface ChildFace {
80
+ handle: string;
81
+ home: string | null;
82
+ name: string | null;
83
+ /** The canonical icon — ONE face everywhere. */
84
+ avatar: string | null;
85
+ glyph: string | null;
86
+ accent: string | null;
87
+ bio: string | null;
88
+ meta: string | null;
89
+ }
90
+
91
+ /**
92
+ * Fetch the HOST persona's face and apply its accent — for a child persona (`/me`, `/files`,
93
+ * `/feed`) mounted on that host.
94
+ *
95
+ * Reads `/api/face?host=`, which answers "who owns this address" rather than "what is on the
96
+ * storefront": the catalog filters `visibility: hidden` on purpose, so a newborn persona would be
97
+ * invisible to its own child personas.
98
+ *
99
+ * The accent is written to BOTH `:root` and the `.pp` wrapper, because a child scopes its whole
100
+ * token set under `.pp` — writing only to the root is shadowed for the entire surface and changes
101
+ * nothing a person can see.
102
+ *
103
+ * Returns `null` when the host is not a persona, which is a legible state rather than an error.
104
+ */
105
+ export declare function childFace(options?: {
106
+ /** Defaults to `location.hostname`. */
107
+ host?: string;
108
+ /** The `.pp` wrapper. Defaults to `document.getElementById("pp")`. */
109
+ root?: HTMLElement | null;
110
+ /** Defaults to `https://api.justai.pro`. */
111
+ api?: string;
112
+ }): Promise<ChildFace | null>;
package/src/index.js CHANGED
@@ -263,6 +263,56 @@ export function consentCopy(lang) {
263
263
  }
264
264
 
265
265
 
266
+ /**
267
+ * queries: the sheet says Cancel in English · Cancel is not translated · Done is not translated ·
268
+ * the picker's cancel stays English in Arabic · sheet chrome language · translate a cut ·
269
+ * who owns the word Cancel · CHROME_COPY · a component's own words
270
+ *
271
+ * THE CHROME WORDS — Cancel and Done, in thirteen languages, said once.
272
+ *
273
+ * The same argument as CONSENT_COPY above, and found the same way: a picker opened on an Arabic page
274
+ * with every word around it in Arabic and `Cancel` in English, sitting in the sheet's own bar.
275
+ *
276
+ * `<Sheet>` had defaulted its Done to the literal "Done" and reasoned, in a comment, that a label is
277
+ * a prop "because the fleet speaks thirteen languages, and a cut that hardcoded the English would be
278
+ * a component making its consumer's copy decisions". The reasoning was inverted. Handing the word to
279
+ * the consumer does not avoid the decision — it makes it THIRTEEN TIMES, in every repo, and the
280
+ * hardcoded English default proved it: the cut was already deciding, and deciding wrong.
281
+ *
282
+ * These are not a persona's copy. `Cancel` is not qr's word or files' word; it is the ecosystem's,
283
+ * the way the back chevron is the ecosystem's shape. Law 1 — a component brings its own ground,
284
+ * style AND text — is what says the cut must carry them.
285
+ *
286
+ * WHY HERE rather than in @justai/cuts: same reason the consent copy is here. Every face reaches
287
+ * core; only the Astro shell reaches cuts.
288
+ *
289
+ * LIFTED FROM `files`, BYTE FOR BYTE, and that is the point rather than an economy. The file kernel
290
+ * mounts INSIDE a host's sheet: the guest draws its own cancel in the body and the host draws one in
291
+ * the bar, and a person looking at one surface must not be shown two different words for the one
292
+ * way out. One word per meaning — the same rule the `nameTaken` string learned the hard way.
293
+ */
294
+ export const CHROME_COPY = {
295
+ "ar": { "cancel": "إلغاء", "done": "تم" },
296
+ "de": { "cancel": "Abbrechen", "done": "Fertig" },
297
+ "en": { "cancel": "Cancel", "done": "Done" },
298
+ "es": { "cancel": "Cancelar", "done": "Listo" },
299
+ "fr": { "cancel": "Annuler", "done": "OK" },
300
+ "hi": { "cancel": "रद्द करें", "done": "हो गया" },
301
+ "it": { "cancel": "Annulla", "done": "Fine" },
302
+ "ja": { "cancel": "キャンセル", "done": "完了" },
303
+ "nl": { "cancel": "Annuleren", "done": "Klaar" },
304
+ "pt": { "cancel": "Cancelar", "done": "Concluído" },
305
+ "ru": { "cancel": "Отмена", "done": "Готово" },
306
+ "tr": { "cancel": "Vazgeç", "done": "Bitti" },
307
+ "zh": { "cancel": "取消", "done": "完成" }
308
+ };
309
+
310
+ /** The chrome words for a language, falling back to English. Never returns undefined. */
311
+ export function chromeCopy(lang) {
312
+ return CHROME_COPY[String(lang || "en").toLowerCase().split("-")[0]] || CHROME_COPY.en;
313
+ }
314
+
315
+
266
316
  /**
267
317
  * queries: consent dialog script · why does the sheet not appear on some pages · consent is asked
268
318
  * per domain not per page · getElementById kernel · the sheet never opened on feed ·
@@ -785,3 +835,51 @@ export function personaScroll(options) {
785
835
  export function personaScrollJs(options) {
786
836
  return "(" + personaScroll.toString() + ")(" + JSON.stringify(options || {}) + ");";
787
837
  }
838
+
839
+ // queries: child persona face · the file room is blue · my child persona has the wrong accent ·
840
+ // /api/face · a hidden persona's child · childFace · host persona colour in a child
841
+ //
842
+ // THE HOST PERSONA'S FACE, FOR A CHILD PERSONA THAT IS MOUNTED ON IT.
843
+ //
844
+ // `me`, `files` and `feed` render on every persona's host and have to wear that persona's colour,
845
+ // name and mark. Each of them wrote this fetch by hand, and the line has now moved THREE times —
846
+ // which is the argument for it living here rather than in a fourth copy:
847
+ //
848
+ // 1. `/api/personas` — serves five fields and none of the three needed. Every `if` was false, so
849
+ // every file room wore the platform's default blue. Nothing errored; a 200 is not a face.
850
+ // 2. `/api/catalog` — carries the face, and was right until a persona could be HIDDEN. The catalog
851
+ // filters `hidden` on purpose because it IS the storefront, so from 2026-08-02 a persona born
852
+ // from the template was invisible to its own child personas.
853
+ // 3. `/api/face?host=` — "who owns this address", which is the question this code was always
854
+ // asking. Only the storefront's question is about visibility.
855
+ //
856
+ // ── WHERE THE ACCENT HAS TO BE WRITTEN, WHICH IS BOTH PLACES ────────────────────────────────────
857
+ //
858
+ // A child scopes its whole token set under `.pp` — `--accent` included — so a value written only to
859
+ // `:root` is SHADOWED for everything inside it, which is the entire surface. It looks correct, it
860
+ // measures correct at `documentElement`, and it changes nothing a person can see. The root still
861
+ // gets it too, because a few rules live outside `.pp` (`::selection` is one) and read the document's.
862
+ //
863
+ // Learned by moving it off `.pp` "to be more correct" and undoing a shipped fix — so both, always.
864
+ export async function childFace(options) {
865
+ const o = options || {};
866
+ const host = o.host || (typeof location !== "undefined" ? location.hostname : "");
867
+ if (!host) return null;
868
+ const root = o.root || (typeof document !== "undefined" ? document.getElementById("pp") : null);
869
+ const base = o.api || "https://api.justai.pro";
870
+ let face = null;
871
+ try {
872
+ const r = await fetch(`${base}/api/face?host=${encodeURIComponent(host)}`);
873
+ face = r.ok ? await r.json() : null;
874
+ } catch {
875
+ // A child whose host cannot be resolved is a child wearing the platform's default, which is a
876
+ // legible state. It is not an error to report to somebody looking at their own files.
877
+ return null;
878
+ }
879
+ if (!face) return null;
880
+ if (face.accent && typeof document !== "undefined") {
881
+ document.documentElement.style.setProperty("--accent", face.accent);
882
+ if (root) root.style.setProperty("--accent", face.accent);
883
+ }
884
+ return face;
885
+ }