levix-bot 4.6.0 → 4.7.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/app.cjs +32 -7
- package/package.json +2 -2
- package/public/dashboard/assets/index-RnT7DAde.js +540 -0
- package/public/dashboard/assets/index-UcqCdCvG.css +2 -0
- package/public/dashboard/index.html +4 -3
- package/public/dashboard.css +123 -53
- package/public/gateway-i18n.js +295 -0
- package/public/gateway.js +30 -1
- package/public/ui-boot.js +71 -0
- package/src/bootstrap/core.js +9 -0
- package/src/db/store.cjs +8 -0
- package/src/diagnostics/crashReports.cjs +491 -0
- package/src/diagnostics/device.cjs +119 -0
- package/src/diagnostics/sanitize.cjs +90 -0
- package/src/index.js +9 -1
- package/src/panel/feedback.cjs +13 -1
- package/src/routes/dashboard.api.esm.js +112 -6
- package/src/services/autoDelete.cjs +3 -1
- package/src/utils/storage.cjs +1 -0
- package/src/utils/storage.esm.js +1 -0
- package/views/dashboard.ejs +2 -1
- package/views/login.ejs +102 -71
- package/views/qr.ejs +59 -30
- package/views/setup.ejs +34 -30
- package/public/dashboard/assets/index-Con1xdhN.js +0 -515
- package/public/dashboard/assets/index-De78KNvv.css +0 -2
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
// The gateway pages' bilingual text (login · setup · QR).
|
|
2
|
+
//
|
|
3
|
+
// The English copy is the markup's own default; this file carries both
|
|
4
|
+
// languages and rewrites the marked nodes as the DOM is parsed, so a page
|
|
5
|
+
// follows the shared <html lang> that ui-boot.js set — no client framework and
|
|
6
|
+
// no second render. It is the same idea as views/dashboard.ejs + dashboard.js,
|
|
7
|
+
// kept in its own file because the QR page loads neither.
|
|
8
|
+
//
|
|
9
|
+
// Markup contract:
|
|
10
|
+
// data-i18n="key" -> textContent
|
|
11
|
+
// data-i18n-html="key" -> innerHTML (the string may carry <strong>)
|
|
12
|
+
// data-i18n-placeholder="key" -> placeholder
|
|
13
|
+
// data-i18n-aria-label="key" -> aria-label
|
|
14
|
+
// data-i18n-title="key" -> title attribute
|
|
15
|
+
// data-i18n-error="code" -> the server-rendered error, translated by code
|
|
16
|
+
// data-i18n-n="8" -> the {n} in the string
|
|
17
|
+
// <html data-brand> -> the {brand} in the string
|
|
18
|
+
|
|
19
|
+
(function () {
|
|
20
|
+
var DICT = {
|
|
21
|
+
en: {
|
|
22
|
+
// Titles
|
|
23
|
+
titleLogin: "{brand} · Sign in",
|
|
24
|
+
titleSetup: "{brand} · First run",
|
|
25
|
+
titleQr: "{brand} · Link WhatsApp",
|
|
26
|
+
|
|
27
|
+
// Shared
|
|
28
|
+
tagline: "Personal WhatsApp Bot",
|
|
29
|
+
storyAbout: "About {brand}",
|
|
30
|
+
by: "by",
|
|
31
|
+
backToApp: "Back to app",
|
|
32
|
+
showPassword: "Show password",
|
|
33
|
+
hidePassword: "Hide password",
|
|
34
|
+
|
|
35
|
+
// Login
|
|
36
|
+
selfHosted: "Self-hosted by design",
|
|
37
|
+
loginHeadline: "The quiet control room behind every chat.",
|
|
38
|
+
loginLede:
|
|
39
|
+
"Connection, commands, memory, and moderation stay together—on your server and within reach.",
|
|
40
|
+
loginTrust: "<span></span> Private workspace · direct control",
|
|
41
|
+
secureAccess: "Secure access",
|
|
42
|
+
welcomeBack: "Welcome back",
|
|
43
|
+
loginSub: "Sign in to manage your {brand} workspace.",
|
|
44
|
+
passwordLabel: "Control panel password",
|
|
45
|
+
passwordPlaceholder: "Enter your password",
|
|
46
|
+
openWorkspace: "Open workspace",
|
|
47
|
+
forgotPassword: "Forgot password?",
|
|
48
|
+
|
|
49
|
+
// Password reset
|
|
50
|
+
backToSignIn: "Back to sign in",
|
|
51
|
+
resetEyebrow: "Password reset",
|
|
52
|
+
resetTitle: "Reset your password",
|
|
53
|
+
resetSubtitle:
|
|
54
|
+
"{brand} sends a one-time code to your WhatsApp — the linked account's own chat. The code works for 10 minutes.",
|
|
55
|
+
resetSend: "Send code to WhatsApp",
|
|
56
|
+
resetCodeLabel: "Reset code",
|
|
57
|
+
resetCodePlaceholder: "6 digits",
|
|
58
|
+
newPassword: "New password",
|
|
59
|
+
minLengthPlaceholder: "At least {n} characters",
|
|
60
|
+
repeatPassword: "Repeat password",
|
|
61
|
+
repeatPlaceholder: "Type it again",
|
|
62
|
+
resetSubmit: "Set new password",
|
|
63
|
+
resetErrThrottled: "Too many requests. Try again in {n} seconds.",
|
|
64
|
+
resetErrNoSession:
|
|
65
|
+
"WhatsApp isn't connected, so the code can't be sent. Sign in on the server and run `levix reset-password`, or start the WhatsApp session first.",
|
|
66
|
+
resetErrSendFailed: "Couldn't send the WhatsApp message. Try again in a minute.",
|
|
67
|
+
resetErrStart: "Couldn't start the reset. Try again.",
|
|
68
|
+
resetErrServer: "Couldn't reach the server. Try again.",
|
|
69
|
+
resetDone: "Password updated. Taking you to sign in…",
|
|
70
|
+
resetErrWrongCode: "Wrong code.",
|
|
71
|
+
resetErrAttemptsLeft: "{n} attempts left.",
|
|
72
|
+
resetErrExpired: "That code is no longer valid. Send a new one.",
|
|
73
|
+
resetErrMismatch: "The two passwords don't match.",
|
|
74
|
+
resetErrInvalidPassword: "That password isn't allowed.",
|
|
75
|
+
resetErrFailed: "Couldn't reset the password. Try again.",
|
|
76
|
+
|
|
77
|
+
// Setup
|
|
78
|
+
firstMinute: "Your first minute",
|
|
79
|
+
setupHeadline: "Make the workspace yours.",
|
|
80
|
+
setupLede:
|
|
81
|
+
"Choose one strong password, then manage the assistant from a single private control room.",
|
|
82
|
+
setupTrust: "<span></span> One setup · no configuration files",
|
|
83
|
+
createWorkspace: "Create your workspace",
|
|
84
|
+
setupWelcome: "Welcome to {brand}",
|
|
85
|
+
setupSub: "Protect the linked WhatsApp account with at least {n} characters.",
|
|
86
|
+
setupCodeLabel: "Setup code",
|
|
87
|
+
setupCodePlaceholder: "Printed in the bot's terminal",
|
|
88
|
+
setupCodeHint: "Confirms you can access the server running {brand}.",
|
|
89
|
+
setupPasswordLabel: "Password",
|
|
90
|
+
createWorkspaceBtn: "Create workspace",
|
|
91
|
+
|
|
92
|
+
// QR pairing
|
|
93
|
+
directLine: "A direct line",
|
|
94
|
+
qrHeadline: "Bring your assistant online.",
|
|
95
|
+
qrLede: "One scan securely links {brand} to the WhatsApp account you choose.",
|
|
96
|
+
qrTrust: "<span></span> Live pairing status",
|
|
97
|
+
linkDevice: "Link device",
|
|
98
|
+
qrScanTitle: "Scan with WhatsApp",
|
|
99
|
+
qrWaiting: "Waiting…",
|
|
100
|
+
qrStep1: "<span>Open</span> WhatsApp on the phone the bot should use.",
|
|
101
|
+
qrStep2: "<span>Choose</span> Settings → Linked devices → Link a device.",
|
|
102
|
+
qrStep3: "<span>Scan</span> the code shown above.",
|
|
103
|
+
qrCallout:
|
|
104
|
+
"No code yet? Press <strong>Start session</strong> on the dashboard's Connection screen.",
|
|
105
|
+
backToDashboard: "Back to dashboard",
|
|
106
|
+
qrScanMe: "Scan me",
|
|
107
|
+
qrWaitingCode: "Waiting for a code…",
|
|
108
|
+
qrConnected: "Connected",
|
|
109
|
+
qrLinked: "Linked ✓",
|
|
110
|
+
qrNotStarted: "Not started — start it from the dashboard",
|
|
111
|
+
qrConnecting: "Connecting…",
|
|
112
|
+
|
|
113
|
+
// Server-rendered errors, keyed by the code app.cjs passes beside them
|
|
114
|
+
tooManyAttempts: "Too many attempts. Try again later.",
|
|
115
|
+
incorrectPassword: "Incorrect Password",
|
|
116
|
+
wrongSetupCode: "Wrong setup code.",
|
|
117
|
+
passwordMismatch: "The two passwords don't match.",
|
|
118
|
+
invalidPassword: "Password must be at least {n} characters",
|
|
119
|
+
},
|
|
120
|
+
ar: {
|
|
121
|
+
// Titles
|
|
122
|
+
titleLogin: "{brand} · تسجيل الدخول",
|
|
123
|
+
titleSetup: "{brand} · التشغيل الأول",
|
|
124
|
+
titleQr: "{brand} · ربط واتساب",
|
|
125
|
+
|
|
126
|
+
// Shared
|
|
127
|
+
tagline: "بوت واتساب شخصي",
|
|
128
|
+
storyAbout: "عن {brand}",
|
|
129
|
+
by: "من",
|
|
130
|
+
backToApp: "العودة للتطبيق",
|
|
131
|
+
showPassword: "إظهار كلمة المرور",
|
|
132
|
+
hidePassword: "إخفاء كلمة المرور",
|
|
133
|
+
|
|
134
|
+
// Login
|
|
135
|
+
selfHosted: "استضافة ذاتية بالتصميم",
|
|
136
|
+
loginHeadline: "غرفة التحكم الهادئة خلف كل محادثة.",
|
|
137
|
+
loginLede: "الاتصال والأوامر والذاكرة والإشراف في مكان واحد — على خادمك وفي متناول يدك.",
|
|
138
|
+
loginTrust: "<span></span> مساحة عمل خاصة · تحكم مباشر",
|
|
139
|
+
secureAccess: "وصول آمن",
|
|
140
|
+
welcomeBack: "أهلاً بعودتك",
|
|
141
|
+
loginSub: "سجّل الدخول لإدارة مساحة عمل {brand}.",
|
|
142
|
+
passwordLabel: "كلمة مرور لوحة التحكم",
|
|
143
|
+
passwordPlaceholder: "أدخل كلمة المرور",
|
|
144
|
+
openWorkspace: "افتح مساحة العمل",
|
|
145
|
+
forgotPassword: "نسيت كلمة المرور؟",
|
|
146
|
+
|
|
147
|
+
// Password reset
|
|
148
|
+
backToSignIn: "العودة لتسجيل الدخول",
|
|
149
|
+
resetEyebrow: "إعادة تعيين كلمة المرور",
|
|
150
|
+
resetTitle: "أعِد تعيين كلمة المرور",
|
|
151
|
+
resetSubtitle:
|
|
152
|
+
"يرسل {brand} كوداً لمرة واحدة إلى واتساب الخاص بك — محادثة الحساب المرتبط نفسه. يصلح الكود لمدة 10 دقائق.",
|
|
153
|
+
resetSend: "أرسل الكود إلى واتساب",
|
|
154
|
+
resetCodeLabel: "كود إعادة التعيين",
|
|
155
|
+
resetCodePlaceholder: "6 أرقام",
|
|
156
|
+
newPassword: "كلمة المرور الجديدة",
|
|
157
|
+
minLengthPlaceholder: "لا تقل عن {n} خانات",
|
|
158
|
+
repeatPassword: "أعِد كتابة كلمة المرور",
|
|
159
|
+
repeatPlaceholder: "اكتبها مرة أخرى",
|
|
160
|
+
resetSubmit: "تعيين كلمة المرور الجديدة",
|
|
161
|
+
resetErrThrottled: "طلبات كثيرة جداً. حاول مرة أخرى خلال {n} ثانية.",
|
|
162
|
+
resetErrNoSession:
|
|
163
|
+
"واتساب غير متصل، لذا لا يمكن إرسال الكود. سجّل الدخول على الخادم ونفّذ `levix reset-password`، أو ابدأ جلسة واتساب أولاً.",
|
|
164
|
+
resetErrSendFailed: "تعذّر إرسال رسالة واتساب. حاول مرة أخرى خلال دقيقة.",
|
|
165
|
+
resetErrStart: "تعذّر بدء إعادة التعيين. حاول مرة أخرى.",
|
|
166
|
+
resetErrServer: "تعذّر الوصول إلى الخادم. حاول مرة أخرى.",
|
|
167
|
+
resetDone: "تم تحديث كلمة المرور. جارٍ تحويلك لتسجيل الدخول…",
|
|
168
|
+
resetErrWrongCode: "كود غير صحيح.",
|
|
169
|
+
resetErrAttemptsLeft: "{n} محاولات متبقية.",
|
|
170
|
+
resetErrExpired: "هذا الكود لم يعد صالحاً. أرسل كوداً جديداً.",
|
|
171
|
+
resetErrMismatch: "كلمتا المرور غير متطابقتين.",
|
|
172
|
+
resetErrInvalidPassword: "كلمة المرور غير مقبولة.",
|
|
173
|
+
resetErrFailed: "تعذّر إعادة تعيين كلمة المرور. حاول مرة أخرى.",
|
|
174
|
+
|
|
175
|
+
// Setup
|
|
176
|
+
firstMinute: "دقيقتك الأولى",
|
|
177
|
+
setupHeadline: "اجعل مساحة العمل ملكك.",
|
|
178
|
+
setupLede: "اختر كلمة مرور قوية واحدة، ثم أدِر المساعد من غرفة تحكم خاصة واحدة.",
|
|
179
|
+
setupTrust: "<span></span> إعداد واحد · بلا ملفات إعداد",
|
|
180
|
+
createWorkspace: "أنشئ مساحة عملك",
|
|
181
|
+
setupWelcome: "مرحباً بك في {brand}",
|
|
182
|
+
setupSub: "احمِ حساب واتساب المرتبط بكلمة مرور لا تقل عن {n} خانات.",
|
|
183
|
+
setupCodeLabel: "رمز الإعداد",
|
|
184
|
+
setupCodePlaceholder: "يُطبع في طرفية البوت",
|
|
185
|
+
setupCodeHint: "يتأكد من إمكانية وصولك إلى الخادم الذي يعمل عليه {brand}.",
|
|
186
|
+
setupPasswordLabel: "كلمة المرور",
|
|
187
|
+
createWorkspaceBtn: "إنشاء مساحة العمل",
|
|
188
|
+
|
|
189
|
+
// QR pairing
|
|
190
|
+
directLine: "خط مباشر",
|
|
191
|
+
qrHeadline: "اجعل مساعدك متصلاً.",
|
|
192
|
+
qrLede: "مسحة واحدة تربط {brand} بأمان بحساب واتساب الذي تختاره.",
|
|
193
|
+
qrTrust: "<span></span> حالة الربط المباشرة",
|
|
194
|
+
linkDevice: "ربط جهاز",
|
|
195
|
+
qrScanTitle: "امسح باستخدام واتساب",
|
|
196
|
+
qrWaiting: "بانتظار…",
|
|
197
|
+
qrStep1: "<span>افتح</span> واتساب على الهاتف الذي سيعمل عليه البوت.",
|
|
198
|
+
qrStep2: "<span>اختر</span> الإعدادات ← الأجهزة المرتبطة ← ربط جهاز.",
|
|
199
|
+
qrStep3: "<span>امسح</span> الرمز الظاهر بالأعلى.",
|
|
200
|
+
qrCallout: "لا يوجد رمز بعد؟ اضغط <strong>بدء الاتصال</strong> في شاشة الاتصال بلوحة التحكم.",
|
|
201
|
+
backToDashboard: "العودة إلى لوحة التحكم",
|
|
202
|
+
qrScanMe: "امسحني",
|
|
203
|
+
qrWaitingCode: "بانتظار رمز…",
|
|
204
|
+
qrConnected: "متصل",
|
|
205
|
+
qrLinked: "تم الربط ✓",
|
|
206
|
+
qrNotStarted: "لم تبدأ — ابدأها من لوحة التحكم",
|
|
207
|
+
qrConnecting: "جارٍ الاتصال…",
|
|
208
|
+
|
|
209
|
+
// Server-rendered errors, keyed by the code app.cjs passes beside them
|
|
210
|
+
tooManyAttempts: "محاولات كثيرة جداً. حاول مرة أخرى لاحقاً.",
|
|
211
|
+
incorrectPassword: "كلمة المرور غير صحيحة",
|
|
212
|
+
wrongSetupCode: "رمز الإعداد غير صحيح.",
|
|
213
|
+
passwordMismatch: "كلمتا المرور غير متطابقتين.",
|
|
214
|
+
invalidPassword: "يجب ألا تقل كلمة المرور عن {n} خانات",
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
var root = document.documentElement;
|
|
219
|
+
var lang = root.lang === "ar" ? "ar" : "en";
|
|
220
|
+
|
|
221
|
+
function t(key, vars) {
|
|
222
|
+
var value = (DICT[lang] && DICT[lang][key]) || DICT.en[key] || key;
|
|
223
|
+
if (vars) {
|
|
224
|
+
Object.keys(vars).forEach(function (name) {
|
|
225
|
+
value = value.split("{" + name + "}").join(vars[name] == null ? "" : String(vars[name]));
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return value;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function varsFor(el) {
|
|
232
|
+
return {
|
|
233
|
+
n: el.getAttribute("data-i18n-n"),
|
|
234
|
+
brand: root.getAttribute("data-brand") || "",
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function paint(el) {
|
|
239
|
+
var key = el.getAttribute("data-i18n");
|
|
240
|
+
if (key) el.textContent = t(key, varsFor(el));
|
|
241
|
+
var htmlKey = el.getAttribute("data-i18n-html");
|
|
242
|
+
if (htmlKey) el.innerHTML = t(htmlKey, varsFor(el));
|
|
243
|
+
var placeholder = el.getAttribute("data-i18n-placeholder");
|
|
244
|
+
if (placeholder) el.setAttribute("placeholder", t(placeholder, varsFor(el)));
|
|
245
|
+
var ariaLabel = el.getAttribute("data-i18n-aria-label");
|
|
246
|
+
if (ariaLabel) el.setAttribute("aria-label", t(ariaLabel, varsFor(el)));
|
|
247
|
+
var title = el.getAttribute("data-i18n-title");
|
|
248
|
+
if (title) el.setAttribute("title", t(title, varsFor(el)));
|
|
249
|
+
var errorCode = el.getAttribute("data-i18n-error");
|
|
250
|
+
if (errorCode && DICT[lang] && DICT[lang][errorCode]) {
|
|
251
|
+
el.textContent = t(errorCode, varsFor(el));
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function apply(scope) {
|
|
256
|
+
var nodes = (scope || document).querySelectorAll(
|
|
257
|
+
"[data-i18n],[data-i18n-html],[data-i18n-placeholder],[data-i18n-aria-label],[data-i18n-title],[data-i18n-error]",
|
|
258
|
+
);
|
|
259
|
+
for (var i = 0; i < nodes.length; i += 1) paint(nodes[i]);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function setLanguage(nextLang) {
|
|
263
|
+
if (nextLang !== "ar" && nextLang !== "en") return;
|
|
264
|
+
lang = nextLang;
|
|
265
|
+
root.lang = lang;
|
|
266
|
+
root.dir = lang === "ar" ? "rtl" : "ltr";
|
|
267
|
+
window.LevixGatewayI18n.lang = lang;
|
|
268
|
+
apply();
|
|
269
|
+
window.dispatchEvent(new CustomEvent("levix-gateway-lang", { detail: { lang: lang } }));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function setTheme(nextTheme) {
|
|
273
|
+
if (nextTheme === "dark" || nextTheme === "light") {
|
|
274
|
+
root.setAttribute("data-theme", nextTheme);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
window.addEventListener("levix-ui-prefs", function (event) {
|
|
279
|
+
var detail = event.detail || {};
|
|
280
|
+
if (detail.theme) setTheme(detail.theme);
|
|
281
|
+
if (detail.language) setLanguage(detail.language);
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
window.addEventListener("storage", function (event) {
|
|
285
|
+
if (event.key === "levix_theme" && (event.newValue === "dark" || event.newValue === "light")) {
|
|
286
|
+
setTheme(event.newValue);
|
|
287
|
+
}
|
|
288
|
+
if (event.key === "levix_lang" && (event.newValue === "ar" || event.newValue === "en")) {
|
|
289
|
+
setLanguage(event.newValue);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
window.LevixGatewayI18n = { lang: lang, t: t, apply: apply };
|
|
294
|
+
apply();
|
|
295
|
+
})();
|
package/public/gateway.js
CHANGED
|
@@ -4,6 +4,27 @@
|
|
|
4
4
|
// itself fails to load: the page works without either one.
|
|
5
5
|
|
|
6
6
|
(function () {
|
|
7
|
+
function updateEyeLabels() {
|
|
8
|
+
var i18n = window.LevixGatewayI18n;
|
|
9
|
+
var showLabel = i18n ? i18n.t("showPassword") : "Show password";
|
|
10
|
+
var hideLabel = i18n ? i18n.t("hidePassword") : "Hide password";
|
|
11
|
+
document.querySelectorAll(".eye-btn").forEach(function (btn) {
|
|
12
|
+
var isPressed = btn.getAttribute("aria-pressed") === "true";
|
|
13
|
+
btn.setAttribute("aria-label", isPressed ? hideLabel : showLabel);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
document.querySelectorAll(".eye-btn").forEach(function (btn) {
|
|
18
|
+
btn.setAttribute("aria-pressed", "false");
|
|
19
|
+
});
|
|
20
|
+
updateEyeLabels();
|
|
21
|
+
|
|
22
|
+
window.addEventListener("levix-gateway-lang", updateEyeLabels);
|
|
23
|
+
window.addEventListener("levix-ui-prefs", updateEyeLabels);
|
|
24
|
+
window.addEventListener("storage", function (e) {
|
|
25
|
+
if (e.key === "levix_lang") updateEyeLabels();
|
|
26
|
+
});
|
|
27
|
+
|
|
7
28
|
// Eye toggles. One delegated listener covers every password field on the
|
|
8
29
|
// page — the button carries two icons and swaps which one is visible.
|
|
9
30
|
document.addEventListener("click", function (event) {
|
|
@@ -13,12 +34,20 @@
|
|
|
13
34
|
var input = btn.parentElement ? btn.parentElement.querySelector("input") : null;
|
|
14
35
|
if (!input) return;
|
|
15
36
|
var show = input.type === "password";
|
|
37
|
+
var start = input.selectionStart;
|
|
38
|
+
var end = input.selectionEnd;
|
|
16
39
|
input.type = show ? "text" : "password";
|
|
40
|
+
input.focus({ preventScroll: true });
|
|
41
|
+
if (start !== null && end !== null) input.setSelectionRange(start, end);
|
|
17
42
|
var on = btn.querySelector(".eye-on");
|
|
18
43
|
var off = btn.querySelector(".eye-off");
|
|
19
44
|
if (on) on.style.display = show ? "none" : "";
|
|
20
45
|
if (off) off.style.display = show ? "" : "none";
|
|
21
|
-
|
|
46
|
+
var i18n = window.LevixGatewayI18n;
|
|
47
|
+
var showLabel = i18n ? i18n.t("showPassword") : "Show password";
|
|
48
|
+
var hideLabel = i18n ? i18n.t("hidePassword") : "Hide password";
|
|
49
|
+
btn.setAttribute("aria-label", show ? hideLabel : showLabel);
|
|
50
|
+
btn.setAttribute("aria-pressed", String(show));
|
|
22
51
|
});
|
|
23
52
|
|
|
24
53
|
// Blur the password screens whenever the page can't be watched: another
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Decides lang, dir and data-theme before first paint, for the panel and
|
|
2
|
+
// every gateway page. Order: the Android host's preference, then what this
|
|
3
|
+
// browser saved, then the OS. Every gateway page is bilingual now, so none
|
|
4
|
+
// passes data-page-lang; the attribute remains an escape hatch for a future
|
|
5
|
+
// page whose text exists in one language only.
|
|
6
|
+
(function () {
|
|
7
|
+
var root = document.documentElement;
|
|
8
|
+
var host = window.LevixHost;
|
|
9
|
+
var script = document.currentScript;
|
|
10
|
+
var pageLang = script && script.getAttribute("data-page-lang");
|
|
11
|
+
var savedLang, savedTheme, prefs;
|
|
12
|
+
try {
|
|
13
|
+
savedLang = localStorage.getItem("levix_lang");
|
|
14
|
+
savedTheme = localStorage.getItem("levix_theme");
|
|
15
|
+
} catch (_) {}
|
|
16
|
+
if (host && typeof host.getUiPrefs === "function") {
|
|
17
|
+
try { prefs = JSON.parse(host.getUiPrefs()); } catch (_) {}
|
|
18
|
+
}
|
|
19
|
+
var language = prefs && (prefs.language === "ar" || prefs.language === "en")
|
|
20
|
+
? prefs.language : (savedLang === "ar" || savedLang === "en" ? savedLang
|
|
21
|
+
: /^ar\b/i.test((navigator.languages && navigator.languages[0]) || navigator.language || "") ? "ar" : "en");
|
|
22
|
+
var dark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)");
|
|
23
|
+
var theme = prefs && (prefs.theme === "dark" || prefs.theme === "light")
|
|
24
|
+
? prefs.theme : (savedTheme === "dark" || savedTheme === "light" ? savedTheme
|
|
25
|
+
: dark && dark.matches ? "dark" : "light");
|
|
26
|
+
function apply(next) {
|
|
27
|
+
var lang = pageLang || next.language;
|
|
28
|
+
if (lang === "ar" || lang === "en") {
|
|
29
|
+
root.lang = lang;
|
|
30
|
+
root.dir = lang === "ar" ? "rtl" : "ltr";
|
|
31
|
+
}
|
|
32
|
+
if (next.theme === "dark" || next.theme === "light") root.setAttribute("data-theme", next.theme);
|
|
33
|
+
}
|
|
34
|
+
apply({ language: language, theme: theme });
|
|
35
|
+
if (prefs) {
|
|
36
|
+
try {
|
|
37
|
+
localStorage.setItem("levix_lang", language);
|
|
38
|
+
localStorage.setItem("levix_theme", theme);
|
|
39
|
+
} catch (_) {}
|
|
40
|
+
}
|
|
41
|
+
window.addEventListener("levix-ui-prefs", function (event) {
|
|
42
|
+
var next = event.detail || {};
|
|
43
|
+
apply(next);
|
|
44
|
+
if (host) {
|
|
45
|
+
try {
|
|
46
|
+
if (next.language === "ar" || next.language === "en") localStorage.setItem("levix_lang", next.language);
|
|
47
|
+
if (next.theme === "dark" || next.theme === "light") localStorage.setItem("levix_theme", next.theme);
|
|
48
|
+
} catch (_) {}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
window.addEventListener("storage", function (event) {
|
|
52
|
+
var next = {};
|
|
53
|
+
if (event.key === "levix_theme" && (event.newValue === "dark" || event.newValue === "light")) {
|
|
54
|
+
next.theme = event.newValue;
|
|
55
|
+
}
|
|
56
|
+
if (event.key === "levix_lang" && (event.newValue === "ar" || event.newValue === "en")) {
|
|
57
|
+
next.language = event.newValue;
|
|
58
|
+
}
|
|
59
|
+
if (next.theme || next.language) {
|
|
60
|
+
apply(next);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (!host && savedTheme !== "dark" && savedTheme !== "light" && dark) {
|
|
64
|
+
dark.addEventListener("change", function (event) {
|
|
65
|
+
try { if (localStorage.getItem("levix_theme")) return; } catch (_) {}
|
|
66
|
+
var next = { theme: event.matches ? "dark" : "light" };
|
|
67
|
+
apply(next);
|
|
68
|
+
window.dispatchEvent(new CustomEvent("levix-ui-prefs", { detail: next }));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
})();
|
package/src/bootstrap/core.js
CHANGED
|
@@ -45,6 +45,15 @@ export async function bootstrapCore({ autoStart = false } = {}) {
|
|
|
45
45
|
// bot's state, not next to the code.
|
|
46
46
|
ensureDataDir("media");
|
|
47
47
|
|
|
48
|
+
// Crash reports are local until the operator sends one. Sweep expired and
|
|
49
|
+
// over-cap files on boot so a device that crashed repeatedly does not keep
|
|
50
|
+
// them forever.
|
|
51
|
+
try {
|
|
52
|
+
require("../diagnostics/crashReports.cjs").sweep();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
logger.warn({ err: error }, "[crash-reports] boot sweep failed");
|
|
55
|
+
}
|
|
56
|
+
|
|
48
57
|
// A `creds` row alone is not enough: Baileys creates one before pairing.
|
|
49
58
|
// `me.id` is the durable proof that this install was actually linked.
|
|
50
59
|
const wasPaired = hasPairedCredentials(store.authRead("creds"));
|
package/src/db/store.cjs
CHANGED
|
@@ -1811,6 +1811,13 @@ function listAutoDeleteLog({ ruleId, limit = 50, offset = 0 } = {}) {
|
|
|
1811
1811
|
.map(autoDeleteLogRow);
|
|
1812
1812
|
}
|
|
1813
1813
|
|
|
1814
|
+
function countAutoDeleteLog({ ruleId } = {}) {
|
|
1815
|
+
if (ruleId != null) {
|
|
1816
|
+
return q("SELECT COUNT(*) AS n FROM auto_delete_log WHERE rule_id = ?").get(Number(ruleId)).n;
|
|
1817
|
+
}
|
|
1818
|
+
return q("SELECT COUNT(*) AS n FROM auto_delete_log").get().n;
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1814
1821
|
function clearAutoDeleteLog(ruleId) {
|
|
1815
1822
|
if (ruleId != null) {
|
|
1816
1823
|
const { changes } = q("DELETE FROM auto_delete_log WHERE rule_id = ?").run(Number(ruleId));
|
|
@@ -1972,6 +1979,7 @@ module.exports = {
|
|
|
1972
1979
|
resetAutoDeleteCounter,
|
|
1973
1980
|
insertAutoDeleteLog,
|
|
1974
1981
|
listAutoDeleteLog,
|
|
1982
|
+
countAutoDeleteLog,
|
|
1975
1983
|
clearAutoDeleteLog,
|
|
1976
1984
|
capAutoDeleteLog,
|
|
1977
1985
|
clearAutoDeleteOnUnlink,
|