@justai/core 0.2.0 → 0.3.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 +1 -1
- package/src/index.d.ts +6 -0
- package/src/index.js +119 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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
|
@@ -15,3 +15,9 @@ export declare function measurementIdFor(host: string | null | undefined): strin
|
|
|
15
15
|
|
|
16
16
|
/** The whole analytics head block for a measurement id — non-production guard, consent defaults, config, deferred loader. */
|
|
17
17
|
export declare function analyticsJs(gaId: string): string;
|
|
18
|
+
|
|
19
|
+
/** The consent question in thirteen languages — the ecosystem's promise, said once. */
|
|
20
|
+
export declare const CONSENT_COPY: Record<string, { consentText: string; consentAllow: string; consentDecline: string; consentChoice: string }>;
|
|
21
|
+
|
|
22
|
+
/** The consent copy for a language, falling back to English. */
|
|
23
|
+
export declare function consentCopy(lang: string): { consentText: string; consentAllow: string; consentDecline: string; consentChoice: string };
|
package/src/index.js
CHANGED
|
@@ -112,9 +112,16 @@ export function measurementIdFor(host) {
|
|
|
112
112
|
* other persona nothing and removes a trap the next persona that animates its tab would walk into.
|
|
113
113
|
*
|
|
114
114
|
* The tag itself loads on idle after `load`: measurement must never compete with the kernel.
|
|
115
|
+
*
|
|
116
|
+
* WRAPPED IN AN IIFE, and it has to be. The Astro binding used to get one for free from `define:vars`;
|
|
117
|
+
* lifting the block out of the template removed it, and the locals became globals on every persona
|
|
118
|
+
* page — three names a persona could collide with, leaked by the shell, with nothing to notice it. A
|
|
119
|
+
* shared shell does not put anything in the global scope it did not mean to. `window.gtag` is still
|
|
120
|
+
* assigned explicitly on window, which is the one thing that MUST escape.
|
|
115
121
|
*/
|
|
116
122
|
export function analyticsJs(gaId) {
|
|
117
|
-
return `
|
|
123
|
+
return `(function(){
|
|
124
|
+
window.gtag=window.gtag||function(){(window.dataLayer=window.dataLayer||[]).push(arguments)};
|
|
118
125
|
var __h=location.hostname;
|
|
119
126
|
if(!(__h==="localhost"||__h==="127.0.0.1"||__h==="::1"||__h==="[::1]"||__h.indexOf("dev-")===0)){
|
|
120
127
|
var __g=${JSON.stringify(gaId)};
|
|
@@ -126,5 +133,115 @@ gtag("consent","default",{region:["AT","BE","BG","HR","CY","CZ","DK","EE","FI","
|
|
|
126
133
|
try{var __c=localStorage.getItem("consent");if(__c)gtag("consent","update",{analytics_storage:__c})}catch(e){}
|
|
127
134
|
gtag("config",__g,{cookie_expires:60*60*24*60,page_title:document.title,allow_google_signals:false,allow_ad_personalization_signals:false});
|
|
128
135
|
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)})});
|
|
129
|
-
}
|
|
136
|
+
}})();`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* queries: where does the consent dialog text live · change the consent wording · consentText ·
|
|
142
|
+
* consentAllow consentDecline consentChoice · why is the consent copy not in the persona ·
|
|
143
|
+
* feed cannot show the consent sheet · translate the consent question
|
|
144
|
+
*
|
|
145
|
+
* THE CONSENT COPY — the ecosystem's question to a visitor, in thirteen languages, said once.
|
|
146
|
+
*
|
|
147
|
+
* It used to live in every persona's own dictionary: thirteen languages across thirteen repos, and
|
|
148
|
+
* measured before this moved, all 52 strings were byte-identical in all of them. That is the tell.
|
|
149
|
+
* A persona's dictionary holds what makes it that persona; this is the ECOSYSTEM speaking, and the
|
|
150
|
+
* same sentence copied into a hundred and sixty-nine files is not localisation, it is a maintenance
|
|
151
|
+
* bill. Changing one word meant thirteen pull requests, and getting twelve of them right meant a
|
|
152
|
+
* visitor somewhere read an older promise than the one we thought we were making.
|
|
153
|
+
*
|
|
154
|
+
* It is legally load-bearing text. There is exactly one place it may be edited, and this is it.
|
|
155
|
+
*
|
|
156
|
+
* WHY HERE rather than in @justai/cuts: `feed` renders on every persona's host and depends on core,
|
|
157
|
+
* not on cuts. Putting the copy where only the Astro shell could reach it is what kept feed from
|
|
158
|
+
* asking the question at all. Content, like behaviour, belongs at the layer every face can reach.
|
|
159
|
+
*
|
|
160
|
+
* A locale with no entry falls back to English rather than rendering an empty sheet — a missing
|
|
161
|
+
* translation must never become a dialog with no question in it.
|
|
162
|
+
*/
|
|
163
|
+
export const CONSENT_COPY = {
|
|
164
|
+
"ar": {
|
|
165
|
+
"consentText": "أودّ أن أعرف أن أحدهم مرّ من هنا — بشكل مجهول، ولا أعرف من هو أبدًا. هل لي أن أحسب زيارتك؟",
|
|
166
|
+
"consentAllow": "احسبني ❤️",
|
|
167
|
+
"consentDecline": "أبقِني خفيًّا",
|
|
168
|
+
"consentChoice": "خيار الخصوصية"
|
|
169
|
+
},
|
|
170
|
+
"de": {
|
|
171
|
+
"consentText": "Ich wüsste gern, dass jemand da war — anonym, nie wer. Darf ich deinen Besuch zählen?",
|
|
172
|
+
"consentAllow": "Zähl mich mit ❤️",
|
|
173
|
+
"consentDecline": "Unsichtbar bleiben",
|
|
174
|
+
"consentChoice": "Privatsphäre-Wahl"
|
|
175
|
+
},
|
|
176
|
+
"en": {
|
|
177
|
+
"consentText": "I'd love to know someone was here — anonymously, never who. May I count your visit?",
|
|
178
|
+
"consentAllow": "Count me in ❤️",
|
|
179
|
+
"consentDecline": "Stay invisible",
|
|
180
|
+
"consentChoice": "privacy choice"
|
|
181
|
+
},
|
|
182
|
+
"es": {
|
|
183
|
+
"consentText": "Me encantaría saber que alguien pasó por aquí — de forma anónima, nunca quién. ¿Puedo contar tu visita?",
|
|
184
|
+
"consentAllow": "Cuenta conmigo ❤️",
|
|
185
|
+
"consentDecline": "Seguir invisible",
|
|
186
|
+
"consentChoice": "elección de privacidad"
|
|
187
|
+
},
|
|
188
|
+
"fr": {
|
|
189
|
+
"consentText": "J'aimerais savoir que quelqu'un est passé — anonymement, jamais qui. Puis-je compter ta visite ?",
|
|
190
|
+
"consentAllow": "Compte ma visite ❤️",
|
|
191
|
+
"consentDecline": "Rester invisible",
|
|
192
|
+
"consentChoice": "choix de confidentialité"
|
|
193
|
+
},
|
|
194
|
+
"hi": {
|
|
195
|
+
"consentText": "मुझे बस यह जानना अच्छा लगेगा कि कोई आया था — गुमनाम रूप से, कभी नहीं कि कौन। क्या मैं आपकी विज़िट गिन सकता हूँ?",
|
|
196
|
+
"consentAllow": "मुझे गिनो ❤️",
|
|
197
|
+
"consentDecline": "अदृश्य रहूँ",
|
|
198
|
+
"consentChoice": "गोपनीयता विकल्प"
|
|
199
|
+
},
|
|
200
|
+
"it": {
|
|
201
|
+
"consentText": "Mi piacerebbe sapere che qualcuno è passato — in modo anonimo, mai chi. Posso contare la tua visita?",
|
|
202
|
+
"consentAllow": "Contami ❤️",
|
|
203
|
+
"consentDecline": "Resta invisibile",
|
|
204
|
+
"consentChoice": "scelta privacy"
|
|
205
|
+
},
|
|
206
|
+
"ja": {
|
|
207
|
+
"consentText": "誰かが来てくれたことだけ知りたいのです — 匿名で、誰かは決して分かりません。訪問を数えてもいいですか?",
|
|
208
|
+
"consentAllow": "数えていいよ ❤️",
|
|
209
|
+
"consentDecline": "見えないままで",
|
|
210
|
+
"consentChoice": "プライバシー設定"
|
|
211
|
+
},
|
|
212
|
+
"nl": {
|
|
213
|
+
"consentText": "Ik zou graag weten dat er iemand langskwam — anoniem, nooit wie. Mag ik je bezoek meetellen?",
|
|
214
|
+
"consentAllow": "Tel me mee ❤️",
|
|
215
|
+
"consentDecline": "Onzichtbaar blijven",
|
|
216
|
+
"consentChoice": "privacykeuze"
|
|
217
|
+
},
|
|
218
|
+
"pt": {
|
|
219
|
+
"consentText": "Adoraria saber que alguém passou por aqui — anonimamente, nunca quem. Posso contar a tua visita?",
|
|
220
|
+
"consentAllow": "Conta comigo ❤️",
|
|
221
|
+
"consentDecline": "Ficar invisível",
|
|
222
|
+
"consentChoice": "escolha de privacidade"
|
|
223
|
+
},
|
|
224
|
+
"ru": {
|
|
225
|
+
"consentText": "Мне бы хотелось знать, что кто-то заходил — анонимно, и никогда кто именно. Можно посчитать твой визит?",
|
|
226
|
+
"consentAllow": "Посчитай меня ❤️",
|
|
227
|
+
"consentDecline": "Остаться невидимым",
|
|
228
|
+
"consentChoice": "выбор приватности"
|
|
229
|
+
},
|
|
230
|
+
"tr": {
|
|
231
|
+
"consentText": "Birinin uğradığını bilmek isterim — anonim olarak, asla kim olduğunu değil. Ziyaretini sayabilir miyim?",
|
|
232
|
+
"consentAllow": "Beni say ❤️",
|
|
233
|
+
"consentDecline": "Görünmez kalayım",
|
|
234
|
+
"consentChoice": "gizlilik tercihi"
|
|
235
|
+
},
|
|
236
|
+
"zh": {
|
|
237
|
+
"consentText": "我只想知道有人来过 — 完全匿名,永远不知道是谁。可以把你的访问算上吗?",
|
|
238
|
+
"consentAllow": "算上我 ❤️",
|
|
239
|
+
"consentDecline": "保持隐身",
|
|
240
|
+
"consentChoice": "隐私选择"
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/** The consent copy for a language, falling back to English. Never returns undefined. */
|
|
245
|
+
export function consentCopy(lang) {
|
|
246
|
+
return CONSENT_COPY[String(lang || "en").toLowerCase()] || CONSENT_COPY.en;
|
|
130
247
|
}
|