@justai/core 0.34.1 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @justai/core/analytics — GA4: which stream a host reports into, and the head block that starts measuring. It knows the consent SIGNALS but not the consent DIALOG — the sheet lives in ./consent and calls `gtag`.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /**
8
+ * queries: which measurement id does this host use · wrong GA4 stream · a persona reports into the
9
+ * wrong property · G-13L3BP6XCW vs G-K2J4FQTQ8L · how does feed pick its analytics tag
10
+ *
11
+ * THE ECOSYSTEM'S STREAM LAYOUT, declared once.
12
+ *
13
+ * One GA4 property, two web streams: `G-13L3BP6XCW` for app.zone and its personas, `G-K2J4FQTQ8L`
14
+ * for justai.pro and its own sub-domains. A page reports into whichever stream ITS CODE loads, so
15
+ * "app.zone versus justai.pro" is a fact about our code rather than a rule the platform enforces —
16
+ * put a persona on the wrong one and nothing errors, nothing is missing, the numbers simply land in
17
+ * the wrong column. That is why the mapping is a function here and not a constant copied per repo.
18
+ *
19
+ * A STATIC persona cannot call this — it has no host at build time — so @justai/cuts keeps its own
20
+ * default and `justai` passes the override. A SERVER-rendered surface (feed) knows the Host header
21
+ * and must use this. The two must agree; if a third stream ever appears, this is the one place it
22
+ * is added.
23
+ */
24
+ export declare function measurementIdFor(host: string | null | undefined): string;
25
+ /**
26
+ * queries: analytics inline script · gtag block · consent defaults · why is dev traffic in GA4 ·
27
+ * non-production guard · localhost 127.0.0.1 in analytics · how does a page start measuring
28
+ *
29
+ * The whole analytics head block, for any framework, given a measurement id.
30
+ *
31
+ * Everything load-bearing about it, in the order it matters:
32
+ *
33
+ * A NON-PRODUCTION PAGE MEASURES NOTHING. Found by reading the property through the analytics MCP:
34
+ * `127.0.0.1` and `localhost` were its TOP "persona" — 546 sessions in four days, and on one of them
35
+ * 127.0.0.1 alone outranked every real persona. Local dev and every headless verification sweep
36
+ * loading built HTML. The guard also covers the edge's `dev-` preview hosts: previews are rehearsals,
37
+ * not visits. Everything before 2026-07-24 in that property is inflated by this.
38
+ *
39
+ * `gtag` GOES ON `window`, never `function gtag`. A framework that scopes an injected variable wraps
40
+ * this in an IIFE, and a function declaration would then be trapped inside it — while the consent
41
+ * dialog's own script, elsewhere on the page, calls `gtag`. The failure is silent and specific: a
42
+ * European visitor clicks Allow, "gtag is not defined", the choice is never applied and the sheet
43
+ * never closes. The stub is also assigned BEFORE the guard returns, so a silenced host still has a
44
+ * callable `gtag` and that same script cannot throw there either.
45
+ *
46
+ * CONSENT DEFAULTS, twice — REVISED 2026-07-25 with the founder, and the revision IS the doctrine:
47
+ * MEASUREMENT follows one rule everywhere (granted by default, EEA asks first), PROFILING is refused
48
+ * everywhere forever. Globally: analytics_storage + ad_storage + ad_user_data granted — counting the
49
+ * visit, and telling an ad its click worked; the dialog's question covers both, in the visitor's
50
+ * language. ad_personalization is DENIED with no path anywhere, which is what keeps "never who"
51
+ * true. The EEA + UK + CH region list denies everything until the dialog's answer — where consent is
52
+ * owed we ask first; where it is not, measurement is simply on (the founder's explicit instruction).
53
+ *
54
+ * STORED CHOICES ARE VERSIONED: "granted+ads" replays the full grant, a legacy "granted" replays
55
+ * analytics ONLY — a visitor who said yes to the narrower question is never silently upgraded to the
56
+ * wider one. "denied" denies the measurement trio.
57
+ *
58
+ * LEGAL POSTURE, noted with the founder: one sentence carries two purposes (counting + ad
59
+ * measurement), both stated plainly — defensible at today's traffic; when traffic grows, granular
60
+ * consent (two separate switches) should be revisited. ad_personalization staying dead is the
61
+ * strongest card in that file.
62
+ *
63
+ * The region list has a sibling: the timezone list in the consent dialog's script. Change one and
64
+ * the other must change, or a visitor is denied by region while never being offered the dialog.
65
+ *
66
+ * `page_title` IS PINNED at load. Only one persona mutates `document.title` today — time shows a live
67
+ * clock — and without this its analytics reports "13:32 · Amsterdam" as the page name. It costs every
68
+ * other persona nothing and removes a trap the next persona that animates its tab would walk into.
69
+ *
70
+ * The tag itself loads on idle after `load`: measurement must never compete with the kernel.
71
+ *
72
+ * WRAPPED IN AN IIFE, and it has to be. The Astro binding used to get one for free from `define:vars`;
73
+ * lifting the block out of the template removed it, and the locals became globals on every persona
74
+ * page — three names a persona could collide with, leaked by the shell, with nothing to notice it. A
75
+ * shared shell does not put anything in the global scope it did not mean to. `window.gtag` is still
76
+ * assigned explicitly on window, which is the one thing that MUST escape.
77
+ */
78
+ export declare function analyticsJs(gaId: string): string;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @justai/core/analytics — GA4: which stream a host reports into, and the head block that starts measuring. It knows the consent SIGNALS but not the consent DIALOG — the sheet lives in ./consent and calls `gtag`.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /**
8
+ * queries: which measurement id does this host use · wrong GA4 stream · a persona reports into the
9
+ * wrong property · G-13L3BP6XCW vs G-K2J4FQTQ8L · how does feed pick its analytics tag
10
+ *
11
+ * THE ECOSYSTEM'S STREAM LAYOUT, declared once.
12
+ *
13
+ * One GA4 property, two web streams: `G-13L3BP6XCW` for app.zone and its personas, `G-K2J4FQTQ8L`
14
+ * for justai.pro and its own sub-domains. A page reports into whichever stream ITS CODE loads, so
15
+ * "app.zone versus justai.pro" is a fact about our code rather than a rule the platform enforces —
16
+ * put a persona on the wrong one and nothing errors, nothing is missing, the numbers simply land in
17
+ * the wrong column. That is why the mapping is a function here and not a constant copied per repo.
18
+ *
19
+ * A STATIC persona cannot call this — it has no host at build time — so @justai/cuts keeps its own
20
+ * default and `justai` passes the override. A SERVER-rendered surface (feed) knows the Host header
21
+ * and must use this. The two must agree; if a third stream ever appears, this is the one place it
22
+ * is added.
23
+ */
24
+ export function measurementIdFor(host) {
25
+ const h = String(host || "").toLowerCase().split(":")[0];
26
+ return h === "justai.pro" || h.endsWith(".justai.pro") ? "G-K2J4FQTQ8L" : "G-13L3BP6XCW";
27
+ }
28
+ /**
29
+ * queries: analytics inline script · gtag block · consent defaults · why is dev traffic in GA4 ·
30
+ * non-production guard · localhost 127.0.0.1 in analytics · how does a page start measuring
31
+ *
32
+ * The whole analytics head block, for any framework, given a measurement id.
33
+ *
34
+ * Everything load-bearing about it, in the order it matters:
35
+ *
36
+ * A NON-PRODUCTION PAGE MEASURES NOTHING. Found by reading the property through the analytics MCP:
37
+ * `127.0.0.1` and `localhost` were its TOP "persona" — 546 sessions in four days, and on one of them
38
+ * 127.0.0.1 alone outranked every real persona. Local dev and every headless verification sweep
39
+ * loading built HTML. The guard also covers the edge's `dev-` preview hosts: previews are rehearsals,
40
+ * not visits. Everything before 2026-07-24 in that property is inflated by this.
41
+ *
42
+ * `gtag` GOES ON `window`, never `function gtag`. A framework that scopes an injected variable wraps
43
+ * this in an IIFE, and a function declaration would then be trapped inside it — while the consent
44
+ * dialog's own script, elsewhere on the page, calls `gtag`. The failure is silent and specific: a
45
+ * European visitor clicks Allow, "gtag is not defined", the choice is never applied and the sheet
46
+ * never closes. The stub is also assigned BEFORE the guard returns, so a silenced host still has a
47
+ * callable `gtag` and that same script cannot throw there either.
48
+ *
49
+ * CONSENT DEFAULTS, twice — REVISED 2026-07-25 with the founder, and the revision IS the doctrine:
50
+ * MEASUREMENT follows one rule everywhere (granted by default, EEA asks first), PROFILING is refused
51
+ * everywhere forever. Globally: analytics_storage + ad_storage + ad_user_data granted — counting the
52
+ * visit, and telling an ad its click worked; the dialog's question covers both, in the visitor's
53
+ * language. ad_personalization is DENIED with no path anywhere, which is what keeps "never who"
54
+ * true. The EEA + UK + CH region list denies everything until the dialog's answer — where consent is
55
+ * owed we ask first; where it is not, measurement is simply on (the founder's explicit instruction).
56
+ *
57
+ * STORED CHOICES ARE VERSIONED: "granted+ads" replays the full grant, a legacy "granted" replays
58
+ * analytics ONLY — a visitor who said yes to the narrower question is never silently upgraded to the
59
+ * wider one. "denied" denies the measurement trio.
60
+ *
61
+ * LEGAL POSTURE, noted with the founder: one sentence carries two purposes (counting + ad
62
+ * measurement), both stated plainly — defensible at today's traffic; when traffic grows, granular
63
+ * consent (two separate switches) should be revisited. ad_personalization staying dead is the
64
+ * strongest card in that file.
65
+ *
66
+ * The region list has a sibling: the timezone list in the consent dialog's script. Change one and
67
+ * the other must change, or a visitor is denied by region while never being offered the dialog.
68
+ *
69
+ * `page_title` IS PINNED at load. Only one persona mutates `document.title` today — time shows a live
70
+ * clock — and without this its analytics reports "13:32 · Amsterdam" as the page name. It costs every
71
+ * other persona nothing and removes a trap the next persona that animates its tab would walk into.
72
+ *
73
+ * The tag itself loads on idle after `load`: measurement must never compete with the kernel.
74
+ *
75
+ * WRAPPED IN AN IIFE, and it has to be. The Astro binding used to get one for free from `define:vars`;
76
+ * lifting the block out of the template removed it, and the locals became globals on every persona
77
+ * page — three names a persona could collide with, leaked by the shell, with nothing to notice it. A
78
+ * shared shell does not put anything in the global scope it did not mean to. `window.gtag` is still
79
+ * assigned explicitly on window, which is the one thing that MUST escape.
80
+ */
81
+ export function analyticsJs(gaId) {
82
+ return `(function(){
83
+ window.gtag=window.gtag||function(){(window.dataLayer=window.dataLayer||[]).push(arguments)};
84
+ var __h=location.hostname;
85
+ if(!(__h==="localhost"||__h==="127.0.0.1"||__h==="::1"||__h==="[::1]"||__h.indexOf("dev-")===0)){
86
+ var __g=${JSON.stringify(gaId)};
87
+ window.dataLayer=window.dataLayer||[];
88
+ window.gtag=window.gtag||function(){window.dataLayer.push(arguments)};
89
+ gtag("js",new Date());
90
+ gtag("consent","default",{ad_storage:"granted",ad_user_data:"granted",ad_personalization:"denied",analytics_storage:"granted"});
91
+ 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"});
92
+ try{var __c=localStorage.getItem("consent");
93
+ if(__c==="granted+ads")gtag("consent","update",{analytics_storage:"granted",ad_storage:"granted",ad_user_data:"granted"});
94
+ else if(__c==="granted")gtag("consent","update",{analytics_storage:"granted"});
95
+ else if(__c==="denied")gtag("consent","update",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied"})}catch(e){}
96
+ 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});
97
+ 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)})});
98
+ }})();`;
99
+ }
package/dist/boot.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @justai/core/boot — the first moments of a page — capture the token, admit that JS is running, hold the paint, let it go. It knows the head and the document, and nothing about analytics, consent or a persona's shape.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /**
8
+ * Capture the SSO token from the URL fragment, synchronously, and stash it for the deferred auth SDK.
9
+ *
10
+ * MUST run before anything else can touch `location.hash`. Two later scripts would otherwise take it:
11
+ * a scroll-spy that rewrites the hash to `#kernel` CLOBBERS `#auth_token` before the SDK reads it, and
12
+ * a language picker that copies the current hash onto the next locale's URL would PROPAGATE the raw
13
+ * token into history. Injecting this first, in the head, defeats both. Move it later and sign-in breaks
14
+ * SILENTLY — no error, the visitor simply lands back signed out.
15
+ */
16
+ export declare function authCapture(): void;
17
+ /** The capture as an injectable IIFE — derived from {@link authCapture}, never written twice. */
18
+ export declare const AUTH_CAPTURE_JS: string;
19
+ /**
20
+ * Mark that JavaScript is running, so the reveal below can hold paint only when JS can un-hold it.
21
+ *
22
+ * DELIBERATELY STILL A STRING, and it is the one that should be. It is a single expression with no
23
+ * name to leak, nothing to type and nothing to test — wrapping it in a function to derive an IIFE
24
+ * would add a closure around one statement and call it rigour. The pattern applies where behaviour
25
+ * has structure; knowing where it does not is the same judgement.
26
+ */
27
+ export declare const JS_CLASS_JS = "document.documentElement.classList.add(\"js\")";
28
+ /**
29
+ * Hold the paint until a page marks itself ready (`body.ready`), gated behind `.js` so the page is
30
+ * always visible with JS off and never flashes before positioning at the Kernel.
31
+ *
32
+ * This is a TRAP as much as a feature, and the warning belongs beside it: ANY page using this without a
33
+ * script that sets `body.ready` stays invisible FOREVER, and nothing errors — the page is simply never
34
+ * shown. A page with no kernel script (a 404, or a sub-persona like feed) must carry {@link READY_JS}.
35
+ */
36
+ export declare const REVEAL_CSS = "html.js body{opacity:0}html.js body.ready{opacity:1}";
37
+ /**
38
+ * The other half of {@link REVEAL_CSS}, for a page that has no kernel script to reveal it: set
39
+ * `body.ready` as soon as the body exists, and once more after load as a backstop. This is what keeps
40
+ * a sub-persona page (feed, a 404) from falling into the reveal trap.
41
+ */
42
+ export declare function ready(): void;
43
+ /**
44
+ * The reveal as an injectable IIFE — derived from {@link ready}.
45
+ *
46
+ * IT USED TO BE BARE STATEMENTS, and that leaked. `var r = …` injected at the top level of a script
47
+ * tag is a GLOBAL named `r` on every page that carries it — `cuts-next` injects this raw through
48
+ * `dangerouslySetInnerHTML`, so every feed page in the fleet had one. Nothing errored and nothing
49
+ * could have: a leaked global only breaks when something else wants the name. The framework's own
50
+ * law says a shared shell puts nothing in the global scope it did not mean to, and generating the
51
+ * string from a function is what makes that automatic rather than remembered.
52
+ */
53
+ export declare const READY_JS: string;
package/dist/boot.js ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @justai/core/boot — the first moments of a page — capture the token, admit that JS is running, hold the paint, let it go. It knows the head and the document, and nothing about analytics, consent or a persona's shape.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /**
8
+ * Capture the SSO token from the URL fragment, synchronously, and stash it for the deferred auth SDK.
9
+ *
10
+ * MUST run before anything else can touch `location.hash`. Two later scripts would otherwise take it:
11
+ * a scroll-spy that rewrites the hash to `#kernel` CLOBBERS `#auth_token` before the SDK reads it, and
12
+ * a language picker that copies the current hash onto the next locale's URL would PROPAGATE the raw
13
+ * token into history. Injecting this first, in the head, defeats both. Move it later and sign-in breaks
14
+ * SILENTLY — no error, the visitor simply lands back signed out.
15
+ */
16
+ export function authCapture() {
17
+ try {
18
+ const h = location.hash || "";
19
+ const m = h.match(/(?:^#|&)auth_token=([^&]+)/);
20
+ if (m) {
21
+ localStorage.setItem("justai_token", decodeURIComponent(m[1]));
22
+ }
23
+ else if (/(?:^#|&)auth_signout=1\b/.test(h)) {
24
+ localStorage.removeItem("justai_token");
25
+ }
26
+ else {
27
+ return;
28
+ }
29
+ history.replaceState(null, "", location.pathname + location.search);
30
+ }
31
+ catch (e) {
32
+ /* a storage the browser refuses is a visitor who stays signed out, not a page that breaks */
33
+ }
34
+ }
35
+ /** The capture as an injectable IIFE — derived from {@link authCapture}, never written twice. */
36
+ export const AUTH_CAPTURE_JS = "(" + authCapture.toString() + ")();";
37
+ /**
38
+ * Mark that JavaScript is running, so the reveal below can hold paint only when JS can un-hold it.
39
+ *
40
+ * DELIBERATELY STILL A STRING, and it is the one that should be. It is a single expression with no
41
+ * name to leak, nothing to type and nothing to test — wrapping it in a function to derive an IIFE
42
+ * would add a closure around one statement and call it rigour. The pattern applies where behaviour
43
+ * has structure; knowing where it does not is the same judgement.
44
+ */
45
+ export const JS_CLASS_JS = `document.documentElement.classList.add("js")`;
46
+ /**
47
+ * Hold the paint until a page marks itself ready (`body.ready`), gated behind `.js` so the page is
48
+ * always visible with JS off and never flashes before positioning at the Kernel.
49
+ *
50
+ * This is a TRAP as much as a feature, and the warning belongs beside it: ANY page using this without a
51
+ * script that sets `body.ready` stays invisible FOREVER, and nothing errors — the page is simply never
52
+ * shown. A page with no kernel script (a 404, or a sub-persona like feed) must carry {@link READY_JS}.
53
+ */
54
+ export const REVEAL_CSS = `html.js body{opacity:0}html.js body.ready{opacity:1}`;
55
+ /**
56
+ * The other half of {@link REVEAL_CSS}, for a page that has no kernel script to reveal it: set
57
+ * `body.ready` as soon as the body exists, and once more after load as a backstop. This is what keeps
58
+ * a sub-persona page (feed, a 404) from falling into the reveal trap.
59
+ */
60
+ export function ready() {
61
+ const show = () => {
62
+ if (document.body)
63
+ document.body.classList.add("ready");
64
+ };
65
+ if (document.readyState !== "loading")
66
+ show();
67
+ else
68
+ addEventListener("DOMContentLoaded", show);
69
+ // The backstop. A page that never fires the event it is waiting for must still become visible —
70
+ // an invisible page is the one failure mode of REVEAL_CSS and it reports nothing.
71
+ setTimeout(show, 400);
72
+ }
73
+ /**
74
+ * The reveal as an injectable IIFE — derived from {@link ready}.
75
+ *
76
+ * IT USED TO BE BARE STATEMENTS, and that leaked. `var r = …` injected at the top level of a script
77
+ * tag is a GLOBAL named `r` on every page that carries it — `cuts-next` injects this raw through
78
+ * `dangerouslySetInnerHTML`, so every feed page in the fleet had one. Nothing errored and nothing
79
+ * could have: a leaked global only breaks when something else wants the name. The framework's own
80
+ * law says a shared shell puts nothing in the global scope it did not mean to, and generating the
81
+ * string from a function is what makes that automatic rather than remembered.
82
+ */
83
+ export const READY_JS = "(" + ready.toString() + ")();";
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @justai/core/chrome — Cancel and Done, in thirteen languages. Pure data. It knows nothing — which is why it is not in ./consent beside the other dictionary: they are two vocabularies with two owners.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /**
8
+ * queries: the sheet says Cancel in English · Cancel is not translated · Done is not translated ·
9
+ * the picker's cancel stays English in Arabic · sheet chrome language · translate a cut ·
10
+ * who owns the word Cancel · CHROME_COPY · a component's own words
11
+ *
12
+ * THE CHROME WORDS — Cancel and Done, in thirteen languages, said once.
13
+ *
14
+ * The same argument as CONSENT_COPY above, and found the same way: a picker opened on an Arabic page
15
+ * with every word around it in Arabic and `Cancel` in English, sitting in the sheet's own bar.
16
+ *
17
+ * `<Sheet>` had defaulted its Done to the literal "Done" and reasoned, in a comment, that a label is
18
+ * a prop "because the fleet speaks thirteen languages, and a cut that hardcoded the English would be
19
+ * a component making its consumer's copy decisions". The reasoning was inverted. Handing the word to
20
+ * the consumer does not avoid the decision — it makes it THIRTEEN TIMES, in every repo, and the
21
+ * hardcoded English default proved it: the cut was already deciding, and deciding wrong.
22
+ *
23
+ * These are not a persona's copy. `Cancel` is not qr's word or files' word; it is the ecosystem's,
24
+ * the way the back chevron is the ecosystem's shape. Law 1 — a component brings its own ground,
25
+ * style AND text — is what says the cut must carry them.
26
+ *
27
+ * WHY HERE rather than in @justai/cuts: same reason the consent copy is here. Every face reaches
28
+ * core; only the Astro shell reaches cuts.
29
+ *
30
+ * LIFTED FROM `files`, BYTE FOR BYTE, and that is the point rather than an economy. The file kernel
31
+ * mounts INSIDE a host's sheet: the guest draws its own cancel in the body and the host draws one in
32
+ * the bar, and a person looking at one surface must not be shown two different words for the one
33
+ * way out. One word per meaning — the same rule the `nameTaken` string learned the hard way.
34
+ */
35
+ /** The two chrome words a component owns, for one language. */
36
+ export interface ChromeStrings {
37
+ cancel: string;
38
+ done: string;
39
+ }
40
+ export declare const CHROME_COPY: Record<string, ChromeStrings>;
41
+ /** The chrome words for a language, falling back to English. Never returns undefined. */
42
+ export declare function chromeCopy(lang: string | null | undefined): ChromeStrings;
package/dist/chrome.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @justai/core/chrome — Cancel and Done, in thirteen languages. Pure data. It knows nothing — which is why it is not in ./consent beside the other dictionary: they are two vocabularies with two owners.
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 const CHROME_COPY = {
8
+ "ar": { "cancel": "إلغاء", "done": "تم" },
9
+ "de": { "cancel": "Abbrechen", "done": "Fertig" },
10
+ "en": { "cancel": "Cancel", "done": "Done" },
11
+ "es": { "cancel": "Cancelar", "done": "Listo" },
12
+ "fr": { "cancel": "Annuler", "done": "OK" },
13
+ "hi": { "cancel": "रद्द करें", "done": "हो गया" },
14
+ "it": { "cancel": "Annulla", "done": "Fine" },
15
+ "ja": { "cancel": "キャンセル", "done": "完了" },
16
+ "nl": { "cancel": "Annuleren", "done": "Klaar" },
17
+ "pt": { "cancel": "Cancelar", "done": "Concluído" },
18
+ "ru": { "cancel": "Отмена", "done": "Готово" },
19
+ "tr": { "cancel": "Vazgeç", "done": "Bitti" },
20
+ "zh": { "cancel": "取消", "done": "完成" }
21
+ };
22
+ /** The chrome words for a language, falling back to English. Never returns undefined. */
23
+ export function chromeCopy(lang) {
24
+ return CHROME_COPY[String(lang || "en").toLowerCase().split("-")[0]] || CHROME_COPY.en;
25
+ }
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @justai/core/consent — the ecosystem's question to a visitor: the words in thirteen languages, and the flow that asks them. The words are pure data and can be read without a browser; the flow needs a document.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /**
8
+ * queries: where does the consent dialog text live · change the consent wording · consentText ·
9
+ * consentAllow consentDecline consentChoice · why is the consent copy not in the persona ·
10
+ * feed cannot show the consent sheet · translate the consent question
11
+ *
12
+ * THE CONSENT COPY — the ecosystem's question to a visitor, in thirteen languages, said once.
13
+ *
14
+ * It used to live in every persona's own dictionary: thirteen languages across thirteen repos, and
15
+ * measured before this moved, all 52 strings were byte-identical in all of them. That is the tell.
16
+ * A persona's dictionary holds what makes it that persona; this is the ECOSYSTEM speaking, and the
17
+ * same sentence copied into a hundred and sixty-nine files is not localisation, it is a maintenance
18
+ * bill. Changing one word meant thirteen pull requests, and getting twelve of them right meant a
19
+ * visitor somewhere read an older promise than the one we thought we were making.
20
+ *
21
+ * It is legally load-bearing text. There is exactly one place it may be edited, and this is it.
22
+ *
23
+ * WHY HERE rather than in @justai/cuts: `feed` renders on every persona's host and depends on core,
24
+ * not on cuts. Putting the copy where only the Astro shell could reach it is what kept feed from
25
+ * asking the question at all. Content, like behaviour, belongs at the layer every face can reach.
26
+ *
27
+ * REWRITTEN 2026-08-23, after a native Dutch speaker read it on app.zone and said the translations
28
+ * were bad. He was right, and the fault was not in the Dutch — it was in the ENGLISH, which was
29
+ * written in a way no translator could carry:
30
+ *
31
+ * "anonymously, never who" an elliptical construction with no equivalent in most languages. The
32
+ * Dutch became "nooit wie", which a native reads as a fragment.
33
+ * "let it know it worked" two pronouns with different referents and a dropped subject. The
34
+ * Dutch lost the subject entirely — nobody could tell who told whom.
35
+ * "Count me in" an idiom, calqued straight into "Tel me mee".
36
+ *
37
+ * So the source was fixed first: two nouns in parallel ("as a number, never a name") instead of the
38
+ * ellipsis, two whole questions instead of one clause hanging off another, and "that ad" naming its
39
+ * own antecedent. Only then were the twelve languages redone.
40
+ *
41
+ * THREE RULES CAME OUT OF DOING IT, and they are the reason this reads better than a translation:
42
+ *
43
+ * 1. The INTIMATE second person, everywhere the language has one — tu, du, je, sen, tú, ты. A
44
+ * persona is a friend who is glad you came; the formal form turns a small warm question into a
45
+ * terms-of-service notice, and three languages had silently drifted into it.
46
+ * 2. Every clause names who is doing what TO WHOM. The recurring failure across five languages was
47
+ * the advertisement sentence losing its recipient: "may I let it be known that it worked".
48
+ * 3. Carry the feeling, not the figure of speech. English personifies the advertisement — you can
49
+ * TELL an ad it worked. In Hindi and Chinese nobody speaks to an advertisement, so those two say
50
+ * the ad was RECORDED as having worked. Same promise, no English showing through.
51
+ *
52
+ * The register and recipient checks are mechanical and worth repeating on any future edit: a formal
53
+ * pronoun and a dropped indirect object are both invisible to a spell-check and both change what the
54
+ * sentence means.
55
+ *
56
+ * A locale with no entry falls back to English rather than rendering an empty sheet — a missing
57
+ * translation must never become a dialog with no question in it.
58
+ */
59
+ /** The consent question and its two answers, for one language. */
60
+ export interface ConsentStrings {
61
+ consentText: string;
62
+ consentAllow: string;
63
+ consentDecline: string;
64
+ consentChoice: string;
65
+ }
66
+ export declare const CONSENT_COPY: Record<string, ConsentStrings>;
67
+ /** The consent copy for a language, falling back to English. Never returns undefined. */
68
+ export declare function consentCopy(lang: string | null | undefined): ConsentStrings;
69
+ /**
70
+ * queries: consent dialog script · why does the sheet not appear on some pages · consent is asked
71
+ * per domain not per page · getElementById kernel · the sheet never opened on feed ·
72
+ * only a choice may be remembered · the change-your-mind door · consent timezone list
73
+ *
74
+ * The consent dialog's behaviour — one copy, for every surface on a persona's origin.
75
+ *
76
+ * CONSENT IS SCOPED TO THE ORIGIN, NOT TO A PAGE. Whichever page a visitor enters by, if this origin
77
+ * has never asked, it asks — once. That is what a consent flow IS, and it is worth stating because
78
+ * ours was accidentally page-scoped for three weeks: the script used to bail on
79
+ * `!document.getElementById("kernel")`, a DOM sniff added to avoid asking on a 404. Feed pages have
80
+ * no kernel either, so on every /feed/* page in the fleet the question was never asked — silently,
81
+ * with nothing to notice it. A trust decision must never be inferred from an unrelated layout
82
+ * detail; the check is gone, and any page that renders the sheet may ask.
83
+ *
84
+ * ONLY A CHOICE MAY BE REMEMBERED AS A CHOICE. "confirm" is the heart, "denied" is a chosen
85
+ * "Stay invisible". Anything else — Escape, a tap on the backdrop — is not an answer: nothing is
86
+ * stored, the regional default stands, and the ask returns next visit. The session flag only keeps
87
+ * THIS visit quiet, so one slip-away buys one visit of peace rather than an answer nobody gave.
88
+ *
89
+ * THE DOOR IS UNIVERSAL. The footer's hidden `[data-consent-open]` anchor is labelled, revealed and
90
+ * wired here for EVERY visitor in EVERY region — a non-EEA visitor gets a real opt-out they were
91
+ * never offered, and anyone can reverse either answer. Only the AUTO-ask has narrow gates.
92
+ *
93
+ * THE TIMEZONE LIST IS A PROXY for "consent is legally asked here", never the thing itself, and it is
94
+ * the sibling of the region array in {@link analyticsJs}. `Europe/` carries almost all of the EEA but
95
+ * not all of it: twelve zones sit on other continents. Change one list and you must change the other,
96
+ * or a visitor is denied by region while never being offered the dialog.
97
+ *
98
+ * `returnValue` survives a close, so it is reset before every open or a stale answer replays.
99
+ *
100
+ * FOCUS IS GIVEN AT OPEN, not by an autofocus attribute. Chrome refuses to process `autofocus` in
101
+ * any document whose URL carries a fragment and warns on every load — /me#profile met it first. So
102
+ * the sheet ships no attribute, and the opener places focus by the genre's law: the ask genre puts
103
+ * it on the invitation (here), the destructive genre on the cancel (that consumer's own open).
104
+ */
105
+ export declare const CONSENT_JS = "(function(){try{\nvar h=location.hostname;\nif(h===\"localhost\"||h===\"127.0.0.1\"||h===\"::1\"||h===\"[::1]\"||h.indexOf(\"dev-\")===0)return;\nvar el=document.getElementById(\"consent\");if(!el||!el.showModal)return;\nvar open=function(){if(!el.open){el.returnValue=\"\";el.showModal();var p=el.querySelector(\".preferred\");if(p)p.focus()}};\nel.addEventListener(\"close\",function(){\nvar rv=el.returnValue;\nvar v=rv===\"confirm\"?\"granted+ads\":rv===\"denied\"?\"denied\":null;\nif(v){var g=v===\"denied\"?\"denied\":\"granted\";\ngtag(\"consent\",\"update\",{analytics_storage:g,ad_storage:g,ad_user_data:g});\ntry{localStorage.setItem(\"consent\",v)}catch(_){}}\nelse{try{sessionStorage.setItem(\"consent-later\",\"1\")}catch(_){}}\n});\nvar doors=document.querySelectorAll(\"[data-consent-open]\");\nfor(var i=0;i<doors.length;i++){var a=doors[i];\nif(!a.textContent)a.textContent=el.getAttribute(\"data-choice-label\")||\"privacy choice\";\na.hidden=false;var w=a.closest(\"[data-consent-door]\");if(w)w.hidden=false;\na.addEventListener(\"click\",function(ev){ev.preventDefault();open()})}\nif(localStorage.getItem(\"consent\"))return;\ntry{if(sessionStorage.getItem(\"consent-later\"))return}catch(_){}\nvar tz=Intl.DateTimeFormat().resolvedOptions().timeZone||\"\";\nvar asked=tz.indexOf(\"Europe/\")===0||[\n\"Asia/Nicosia\",\"Asia/Famagusta\",\n\"Atlantic/Canary\",\"Atlantic/Azores\",\"Atlantic/Madeira\",\"Atlantic/Reykjavik\",\n\"Arctic/Longyearbyen\",\n\"America/Guadeloupe\",\"America/Martinique\",\"America/Cayenne\",\n\"Indian/Reunion\",\"Indian/Mayotte\"].indexOf(tz)>=0;\nif(!asked)return;\nsetTimeout(open,700);\n}catch(_){}})();";