kiosko 0.2.5 → 0.2.6
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/README.md +14 -1
- package/cli.js +925 -277
- package/kit.js +64 -7
- package/package.json +1 -1
- package/sdk.js +204 -37
- package/web/assets/app.js +3 -3
- package/web/assets/styles.css +1 -1
package/cli.js
CHANGED
|
@@ -44,15 +44,95 @@ var init_workday = __esm({
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
// packages/sdk/src/i18n.ts
|
|
47
|
+
function parseLocale(tag) {
|
|
48
|
+
if (!tag) return null;
|
|
49
|
+
let t2 = tag.trim();
|
|
50
|
+
const latin2 = /@latin\b/i.test(t2);
|
|
51
|
+
t2 = t2.replace(/[.@].*$/, "").replace(/_/g, "-");
|
|
52
|
+
if (!t2 || t2 === "C" || t2 === "POSIX") return null;
|
|
53
|
+
try {
|
|
54
|
+
let l = new Intl.Locale(Intl.getCanonicalLocales(t2)[0]);
|
|
55
|
+
const alias = ALIASES[l.language];
|
|
56
|
+
if (alias) l = new Intl.Locale(alias, { ...l.script ? { script: l.script } : {}, ...l.region ? { region: l.region } : {} });
|
|
57
|
+
if (latin2 && !l.script) l = new Intl.Locale(l.language, { script: "Latn", ...l.region ? { region: l.region } : {} });
|
|
58
|
+
return l;
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function pickLocale(available2, locale) {
|
|
64
|
+
if (!locale || !available2.length) return void 0;
|
|
65
|
+
const exact = available2.find((k) => k.toLowerCase() === locale.replace(/_/g, "-").toLowerCase());
|
|
66
|
+
if (exact) return exact;
|
|
67
|
+
const want = parseLocale(locale);
|
|
68
|
+
if (!want) return void 0;
|
|
69
|
+
const w = want.maximize();
|
|
70
|
+
const lang = READS[w.language] ?? w.language;
|
|
71
|
+
const fits = available2.map((k) => ({ k, l: parseLocale(k) })).filter((c) => !!c.l).map((c) => ({ ...c, m: c.l.maximize() })).filter((c) => (READS[c.m.language] ?? c.m.language) === lang && c.m.script === w.script);
|
|
72
|
+
if (!fits.length) return void 0;
|
|
73
|
+
const same3 = (a, b) => a.baseName === b.baseName;
|
|
74
|
+
const byTag = fits.find((c) => same3(c.l, want));
|
|
75
|
+
if (byTag) return byTag.k;
|
|
76
|
+
if (w.region) {
|
|
77
|
+
const byRegion = fits.find((c) => c.m.region === w.region && c.l.region);
|
|
78
|
+
if (byRegion) return byRegion.k;
|
|
79
|
+
const usual = (r) => lang === "es" && LATAM.has(w.region) ? ["419", "MX"].includes(r) : lang === "pt" && PT_PT.has(w.region) ? r === "PT" : false;
|
|
80
|
+
const variant = fits.find((c) => c.l.region && usual(c.l.region));
|
|
81
|
+
if (variant) return variant.k;
|
|
82
|
+
}
|
|
83
|
+
const plain = [...fits].sort((a, b) => a.l.baseName.split("-").length - b.l.baseName.split("-").length);
|
|
84
|
+
return plain[0].k;
|
|
85
|
+
}
|
|
86
|
+
function plural(n, forms, locale = "en") {
|
|
87
|
+
const key = pickLocale(Object.keys(forms), locale) ?? (forms.en ? "en" : Object.keys(forms)[0]);
|
|
88
|
+
const f = forms[key];
|
|
89
|
+
let rule = "other";
|
|
90
|
+
try {
|
|
91
|
+
rule = new Intl.PluralRules(key).select(n);
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
const text2 = f[rule] ?? f.other;
|
|
95
|
+
let num = String(n);
|
|
96
|
+
try {
|
|
97
|
+
num = new Intl.NumberFormat(key).format(n);
|
|
98
|
+
} catch {
|
|
99
|
+
}
|
|
100
|
+
return text2.replaceAll("{n}", num);
|
|
101
|
+
}
|
|
47
102
|
function localize(text2, locale = "en") {
|
|
48
103
|
if (text2 === void 0) return "";
|
|
49
104
|
if (typeof text2 === "string") return text2;
|
|
50
|
-
const
|
|
51
|
-
return
|
|
105
|
+
const key = pickLocale(Object.keys(text2), locale);
|
|
106
|
+
return (key ? text2[key] : void 0) ?? text2.en ?? Object.values(text2).find((v) => typeof v === "string") ?? "";
|
|
107
|
+
}
|
|
108
|
+
function hanScript(locale) {
|
|
109
|
+
const l = parseLocale(locale || "en");
|
|
110
|
+
if (!l) return null;
|
|
111
|
+
const full = l.maximize();
|
|
112
|
+
switch (READS[full.language] ?? full.language) {
|
|
113
|
+
case "zh":
|
|
114
|
+
if (full.script === "Hant") return full.region === "HK" || full.region === "MO" ? "Hant-HK" : "Hant";
|
|
115
|
+
return "Hans";
|
|
116
|
+
case "ja":
|
|
117
|
+
return "Jpan";
|
|
118
|
+
case "ko":
|
|
119
|
+
return "Kore";
|
|
120
|
+
default:
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function errorMessage(err, locale = "en") {
|
|
125
|
+
if (err instanceof Error && "text" in err && err.text !== void 0) return localize(err.text, locale);
|
|
126
|
+
return err instanceof Error ? err.message : String(err);
|
|
52
127
|
}
|
|
128
|
+
var ALIASES, READS, LATAM, PT_PT;
|
|
53
129
|
var init_i18n = __esm({
|
|
54
130
|
"packages/sdk/src/i18n.ts"() {
|
|
55
131
|
"use strict";
|
|
132
|
+
ALIASES = { iw: "he", in: "id", ji: "yi", tl: "fil", no: "nb", cmn: "zh" };
|
|
133
|
+
READS = { yue: "zh", nn: "nb" };
|
|
134
|
+
LATAM = /* @__PURE__ */ new Set(["419", "AR", "BO", "CL", "CO", "CR", "CU", "DO", "EC", "GT", "HN", "MX", "NI", "PA", "PE", "PR", "PY", "SV", "US", "UY", "VE"]);
|
|
135
|
+
PT_PT = /* @__PURE__ */ new Set(["PT", "AO", "MZ", "CV", "GW", "ST", "TL", "MO", "GQ", "LU", "CH"]);
|
|
56
136
|
}
|
|
57
137
|
});
|
|
58
138
|
|
|
@@ -183,7 +263,10 @@ var init_schema = __esm({
|
|
|
183
263
|
};
|
|
184
264
|
FILTER_HELP = {
|
|
185
265
|
en: "Empty: all. Names or patterns, comma-separated: * matches anything, a leading ! leaves out (web, acme/*, !*-old).",
|
|
186
|
-
es: "Vac\xEDo: todos. Nombres o patrones separados por comas: * vale por cualquier cosa y un ! delante excluye (web, acme/*, !*-old)."
|
|
266
|
+
es: "Vac\xEDo: todos. Nombres o patrones separados por comas: * vale por cualquier cosa y un ! delante excluye (web, acme/*, !*-old).",
|
|
267
|
+
de: "Leer: alle. Namen oder Muster, durch Kommas getrennt: * steht f\xFCr alles, ein ! davor schlie\xDFt aus (web, acme/*, !*-old).",
|
|
268
|
+
"zh-Hant": "\u7559\u7A7A\uFF1A\u5168\u90E8\u3002\u586B\u5165\u540D\u7A31\u6216\u6A21\u5F0F\uFF0C\u4EE5\u9017\u865F\u5206\u9694\uFF1A* \u4EE3\u8868\u4EFB\u610F\u5B57\u5143\uFF0C\u958B\u982D\u52A0 ! \u5247\u6392\u9664\uFF08web, acme/*, !*-old\uFF09\u3002",
|
|
269
|
+
"zh-Hans": "\u7559\u7A7A\uFF1A\u5168\u90E8\u3002\u586B\u5199\u540D\u79F0\u6216\u6A21\u5F0F\uFF0C\u7528\u9017\u53F7\u5206\u9694\uFF1A* \u5339\u914D\u4EFB\u610F\u5185\u5BB9\uFF0C\u5F00\u5934\u52A0 ! \u8868\u793A\u6392\u9664\uFF08web, acme/*, !*-old\uFF09\u3002"
|
|
187
270
|
};
|
|
188
271
|
SECRET_NOTE = 'Secret: leave it empty (or a placeholder such as "<token>"). Kiosko keeps the value it already has, or asks for it in the editor.';
|
|
189
272
|
}
|
|
@@ -268,7 +351,7 @@ function toMs(at) {
|
|
|
268
351
|
function createFormatters(o) {
|
|
269
352
|
const w = wordsFor(o.locale);
|
|
270
353
|
const hour12 = usesHour12(o.locale, o.timeFormat);
|
|
271
|
-
|
|
354
|
+
const fmt = {
|
|
272
355
|
hour12,
|
|
273
356
|
time(at, opts = {}) {
|
|
274
357
|
const d = new Date(toMs(at));
|
|
@@ -276,7 +359,15 @@ function createFormatters(o) {
|
|
|
276
359
|
const rest = `:${pad2(d.getMinutes())}${opts.seconds ? `:${pad2(d.getSeconds())}` : ""}`;
|
|
277
360
|
if (!hour12) return `${pad2(h)}${rest}`;
|
|
278
361
|
const base3 = `${h % 12 || 12}${rest}`;
|
|
279
|
-
|
|
362
|
+
if (opts.ampm === false) return base3;
|
|
363
|
+
const mark = h < 12 ? w.am : w.pm;
|
|
364
|
+
return w.ampmFirst ? `${mark} ${base3}` : `${base3} ${mark}`;
|
|
365
|
+
},
|
|
366
|
+
range(from, to, opts = {}) {
|
|
367
|
+
const a = new Date(toMs(from));
|
|
368
|
+
const b = new Date(toMs(to));
|
|
369
|
+
if (!hour12 || a.getHours() < 12 !== b.getHours() < 12) return `${fmt.time(a, opts)}\u2013${fmt.time(b, opts)}`;
|
|
370
|
+
return w.ampmFirst ? `${fmt.time(a, opts)}\u2013${fmt.time(b, { ...opts, ampm: false })}` : `${fmt.time(a, { ...opts, ampm: false })}\u2013${fmt.time(b, opts)}`;
|
|
280
371
|
},
|
|
281
372
|
ago(at, opts = {}) {
|
|
282
373
|
const suffix = opts.suffix !== false;
|
|
@@ -285,32 +376,69 @@ function createFormatters(o) {
|
|
|
285
376
|
if (!Number.isFinite(min) || min < 1) return suffix ? w.justNow : w.now;
|
|
286
377
|
const h = Math.floor(min / 60);
|
|
287
378
|
const d = Math.floor(h / 24);
|
|
288
|
-
const v = min < 60 ?
|
|
289
|
-
return suffix ? w.ago(v) : v;
|
|
379
|
+
const [v, n] = min < 60 ? [w.min(min), min] : h < 24 ? [w.h(h), h] : d < 14 ? [w.d(d), d] : d < 365 ? [w.wk(Math.floor(d / 7)), Math.floor(d / 7)] : [w.yr(Math.floor(d / 365)), Math.floor(d / 365)];
|
|
380
|
+
return suffix ? w.ago(v, n) : v;
|
|
290
381
|
},
|
|
291
382
|
duration(ms, opts = {}) {
|
|
292
383
|
const round2 = opts.round === "up" ? Math.ceil : opts.round === "nearest" ? Math.round : Math.floor;
|
|
293
384
|
const safe2 = Number.isFinite(ms) ? Math.max(0, ms) : 0;
|
|
294
|
-
if (opts.seconds && safe2 < 6e4) return
|
|
385
|
+
if (opts.seconds && safe2 < 6e4) return w.s(round2(safe2 / 1e3));
|
|
295
386
|
const min = round2(safe2 / 6e4);
|
|
296
|
-
if (min < 60) return
|
|
387
|
+
if (min < 60) return w.min(min);
|
|
297
388
|
const h = Math.floor(min / 60);
|
|
298
|
-
if (h < 24) return opts.compact && min % 60 === 0 ?
|
|
299
|
-
return opts.compact && h % 24 === 0 ?
|
|
389
|
+
if (h < 24) return opts.compact && min % 60 === 0 ? w.h(h) : w.hm(h, min % 60);
|
|
390
|
+
return opts.compact && h % 24 === 0 ? w.d(h / 24) : w.dh(Math.floor(h / 24), h % 24);
|
|
300
391
|
}
|
|
301
392
|
};
|
|
393
|
+
return fmt;
|
|
302
394
|
}
|
|
303
|
-
var TIME_FORMATS, WORDS,
|
|
395
|
+
var TIME_FORMATS, latin, german, chinese, WORDS, FORMAT_LANGUAGES, LANGS, wordsFor, pad2, cycles;
|
|
304
396
|
var init_format = __esm({
|
|
305
397
|
"packages/sdk/src/format.ts"() {
|
|
306
398
|
"use strict";
|
|
399
|
+
init_i18n();
|
|
307
400
|
TIME_FORMATS = ["auto", "24h", "12h"];
|
|
401
|
+
latin = (wk, yr) => ({
|
|
402
|
+
s: (n) => `${n} s`,
|
|
403
|
+
min: (n) => `${n} min`,
|
|
404
|
+
h: (n) => `${n} h`,
|
|
405
|
+
d: (n) => `${n} d`,
|
|
406
|
+
wk: (n) => `${n} ${wk}`,
|
|
407
|
+
yr: (n) => `${n} ${yr(n)}`,
|
|
408
|
+
hm: (h, m) => `${h} h ${pad2(m)}`,
|
|
409
|
+
dh: (d, h) => `${d} d ${h} h`
|
|
410
|
+
});
|
|
411
|
+
german = {
|
|
412
|
+
s: (n) => `${n} s`,
|
|
413
|
+
min: (n) => `${n} Min.`,
|
|
414
|
+
h: (n) => `${n} Std.`,
|
|
415
|
+
d: (n) => `${n} T.`,
|
|
416
|
+
wk: (n) => `${n} Wo.`,
|
|
417
|
+
yr: (n) => `${n} J.`,
|
|
418
|
+
hm: (h, m) => `${h}:${pad2(m)} h`,
|
|
419
|
+
dh: (d, h) => `${d} T. ${h} Std.`
|
|
420
|
+
};
|
|
421
|
+
chinese = (u) => ({
|
|
422
|
+
s: (n) => `${n} \u79D2`,
|
|
423
|
+
min: (n) => `${n} ${u.min}`,
|
|
424
|
+
h: (n) => `${n} ${u.h}`,
|
|
425
|
+
d: (n) => `${n} \u5929`,
|
|
426
|
+
wk: (n) => `${n} ${u.wk}`,
|
|
427
|
+
yr: (n) => `${n} \u5E74`,
|
|
428
|
+
// No leading zero in Chinese: 1 小時 5 分.
|
|
429
|
+
hm: (h, m) => `${h} ${u.h} ${m} \u5206`,
|
|
430
|
+
dh: (d, h) => `${d} \u5929 ${h} ${u.h}`
|
|
431
|
+
});
|
|
308
432
|
WORDS = {
|
|
309
|
-
en: { now: "now", justNow: "just now", ago: (v) => `${v} ago`,
|
|
310
|
-
es: { now: "ahora", justNow: "ahora mismo", ago: (v) => `hace ${v}`,
|
|
433
|
+
en: { now: "now", justNow: "just now", ago: (v) => `${v} ago`, am: "AM", pm: "PM", ...latin("wk", () => "yr") },
|
|
434
|
+
es: { now: "ahora", justNow: "ahora mismo", ago: (v) => `hace ${v}`, am: "a. m.", pm: "p. m.", ...latin("sem", (n) => n === 1 ? "a\xF1o" : "a\xF1os") },
|
|
435
|
+
de: { now: "jetzt", justNow: "gerade eben", ago: (v) => `vor ${v}`, am: "AM", pm: "PM", ...german },
|
|
436
|
+
"zh-Hant": { now: "\u73FE\u5728", justNow: "\u525B\u525B", ago: (v) => `${v}\u524D`, am: "\u4E0A\u5348", pm: "\u4E0B\u5348", ampmFirst: true, ...chinese({ min: "\u5206\u9418", h: "\u5C0F\u6642", wk: "\u9031" }) },
|
|
437
|
+
"zh-Hans": { now: "\u73B0\u5728", justNow: "\u521A\u521A", ago: (v) => `${v}\u524D`, am: "\u4E0A\u5348", pm: "\u4E0B\u5348", ampmFirst: true, ...chinese({ min: "\u5206\u949F", h: "\u5C0F\u65F6", wk: "\u5468" }) }
|
|
311
438
|
};
|
|
312
|
-
|
|
313
|
-
|
|
439
|
+
FORMAT_LANGUAGES = Object.keys(WORDS);
|
|
440
|
+
LANGS = Object.keys(WORDS);
|
|
441
|
+
wordsFor = (locale) => WORDS[pickLocale(LANGS, locale) ?? "en"] ?? WORDS.en;
|
|
314
442
|
pad2 = (n) => String(n).padStart(2, "0");
|
|
315
443
|
cycles = /* @__PURE__ */ new Map();
|
|
316
444
|
}
|
|
@@ -323,6 +451,8 @@ function createBaseContext(o) {
|
|
|
323
451
|
now: o.now,
|
|
324
452
|
locale,
|
|
325
453
|
t: (text2) => localize(text2, locale),
|
|
454
|
+
plural: (n, forms) => plural(n, forms, locale),
|
|
455
|
+
pickLanguage: (available2) => pickLocale(available2, locale) ?? (available2.includes("en") ? "en" : available2[0] ?? "en"),
|
|
326
456
|
fmt: createFormatters({ locale, timeFormat: o.timeFormat ?? "auto", now: o.now }),
|
|
327
457
|
log: o.log ?? (() => void 0),
|
|
328
458
|
dataDir: o.dataDir ?? "",
|
|
@@ -367,14 +497,47 @@ function widthOf(ctx, font, ch) {
|
|
|
367
497
|
function clearTextCache() {
|
|
368
498
|
widths.clear();
|
|
369
499
|
}
|
|
500
|
+
function hasCjk(text2) {
|
|
501
|
+
return CJK.test(text2);
|
|
502
|
+
}
|
|
503
|
+
function trackingOf(text2, o) {
|
|
504
|
+
return o.tracking && hasCjk(text2) ? 0 : o.tracking ?? 0;
|
|
505
|
+
}
|
|
506
|
+
function setMinCjkPx(px) {
|
|
507
|
+
if (px !== minCjkPx) widths.clear();
|
|
508
|
+
minCjkPx = Math.max(0, px);
|
|
509
|
+
}
|
|
510
|
+
function takeCjkEnlarged() {
|
|
511
|
+
const v = enlarged;
|
|
512
|
+
enlarged = Infinity;
|
|
513
|
+
return Number.isFinite(v) ? Math.round(v) : null;
|
|
514
|
+
}
|
|
515
|
+
function scaleOf(ctx) {
|
|
516
|
+
const t2 = ctx.getTransform?.();
|
|
517
|
+
return t2 ? Math.hypot(t2.a, t2.b) || 1 : 1;
|
|
518
|
+
}
|
|
370
519
|
function glyphs(ctx, text2, o) {
|
|
371
520
|
const family = o.family ?? defaultFamily;
|
|
372
|
-
const
|
|
521
|
+
const cjk = hasCjk(text2);
|
|
522
|
+
const small = o.smallCaps === true && !cjk;
|
|
373
523
|
const capSize = o.size * (o.capRatio ?? 0.76);
|
|
374
524
|
const out = [];
|
|
375
525
|
const font = `${o.size}px "${family}"`;
|
|
376
526
|
const capFont = `${capSize}px "${family}"`;
|
|
527
|
+
let cjkSize = o.size;
|
|
528
|
+
if (cjk && minCjkPx > 0) {
|
|
529
|
+
const scale = scaleOf(ctx);
|
|
530
|
+
if (o.size * scale < minCjkPx - 0.5) {
|
|
531
|
+
cjkSize = minCjkPx / scale;
|
|
532
|
+
enlarged = Math.min(enlarged, o.size * scale);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const cjkFont = `${cjkSize}px "${family}"`;
|
|
377
536
|
for (const ch of text2) {
|
|
537
|
+
if (cjkSize !== o.size && CJK.test(ch)) {
|
|
538
|
+
out.push({ ch, size: cjkSize, width: widthOf(ctx, cjkFont, ch) });
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
378
541
|
const isLower = small && ch !== ch.toUpperCase() && ch === ch.toLowerCase();
|
|
379
542
|
const size = isLower ? capSize : o.size;
|
|
380
543
|
const draw = small ? ch.toUpperCase() : ch;
|
|
@@ -387,11 +550,11 @@ function advance(gs, tracking) {
|
|
|
387
550
|
return gs.reduce((a, g) => a + g.width, 0) + tracking * (gs.length - 1);
|
|
388
551
|
}
|
|
389
552
|
function measureTracked(ctx, text2, o) {
|
|
390
|
-
return advance(glyphs(ctx, text2, o), o
|
|
553
|
+
return advance(glyphs(ctx, text2, o), trackingOf(text2, o));
|
|
391
554
|
}
|
|
392
555
|
function drawTracked(ctx, text2, x, y, o) {
|
|
393
556
|
const family = o.family ?? defaultFamily;
|
|
394
|
-
const tracking = o
|
|
557
|
+
const tracking = trackingOf(text2, o);
|
|
395
558
|
const gs = glyphs(ctx, text2, o);
|
|
396
559
|
const total = advance(gs, tracking);
|
|
397
560
|
let cursor = o.align === "right" ? x - total : o.align === "center" ? x - total / 2 : x;
|
|
@@ -431,15 +594,30 @@ function drawClipped(ctx, text2, x, y, maxWidth, o) {
|
|
|
431
594
|
}
|
|
432
595
|
function fitPrefix(ctx, text2, maxWidth, o) {
|
|
433
596
|
if (measureTracked(ctx, text2, o) <= maxWidth) return text2.length;
|
|
597
|
+
const chars = [...text2];
|
|
434
598
|
let lo = 1;
|
|
435
|
-
let hi =
|
|
599
|
+
let hi = chars.length;
|
|
436
600
|
while (lo < hi) {
|
|
437
601
|
const mid = Math.ceil((lo + hi) / 2);
|
|
438
|
-
if (measureTracked(ctx,
|
|
602
|
+
if (measureTracked(ctx, chars.slice(0, mid).join(""), o) <= maxWidth) lo = mid;
|
|
439
603
|
else hi = mid - 1;
|
|
440
604
|
}
|
|
441
|
-
const
|
|
442
|
-
|
|
605
|
+
const cjk = hasCjk(text2);
|
|
606
|
+
const fits = (i) => !NO_START.has(chars[i]) && !NO_END.has(chars[i - 1]);
|
|
607
|
+
let cut = 0;
|
|
608
|
+
for (let i = lo; i >= 1; i--) {
|
|
609
|
+
const before = chars[i - 1];
|
|
610
|
+
const after = chars[i];
|
|
611
|
+
if ((isSpace(before) || isSpace(after) || CJK.test(before) || CJK.test(after)) && fits(i)) {
|
|
612
|
+
cut = i;
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (!cut || cjk && cut < lo * 0.6) {
|
|
617
|
+
cut = lo;
|
|
618
|
+
while (cut > 1 && !fits(cut)) cut--;
|
|
619
|
+
}
|
|
620
|
+
return chars.slice(0, cut).join("").length;
|
|
443
621
|
}
|
|
444
622
|
function wrapLines(ctx, text2, maxWidth, maxLines, o) {
|
|
445
623
|
const clean = text2.replace(/\s+/g, " ").trim();
|
|
@@ -457,13 +635,19 @@ function wrapLines(ctx, text2, maxWidth, maxLines, o) {
|
|
|
457
635
|
}
|
|
458
636
|
return lines;
|
|
459
637
|
}
|
|
460
|
-
var defaultFamily, widths, MAX_FONTS;
|
|
638
|
+
var defaultFamily, widths, MAX_FONTS, CJK, minCjkPx, enlarged, NO_START, NO_END, isSpace;
|
|
461
639
|
var init_text = __esm({
|
|
462
640
|
"packages/lcd-canvas-kit/src/text.ts"() {
|
|
463
641
|
"use strict";
|
|
464
642
|
defaultFamily = "sans-serif";
|
|
465
643
|
widths = /* @__PURE__ */ new Map();
|
|
466
644
|
MAX_FONTS = 400;
|
|
645
|
+
CJK = /[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;
|
|
646
|
+
minCjkPx = 0;
|
|
647
|
+
enlarged = Infinity;
|
|
648
|
+
NO_START = /* @__PURE__ */ new Set([..."\u3001\u3002\uFF0C\uFF0E\uFF1A\uFF1B\uFF1F\uFF01\uFF09\u300D\u300F\u3011\u300B\u3009\u3015\uFF5D\u3017\u3019\u301B\u2019\u201D\u2026\u2025\u30FC\u3005\u309D\u309E\u30FD\u30FE\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE\u30F5\u30F6,.;:?!)]}%"]);
|
|
649
|
+
NO_END = /* @__PURE__ */ new Set([..."\uFF08\u300C\u300E\u3010\u300A\u3008\u3014\uFF5B\u3016\u3018\u301A\u2018\u201C([{$"]);
|
|
650
|
+
isSpace = (c) => /\s/.test(c);
|
|
467
651
|
}
|
|
468
652
|
});
|
|
469
653
|
|
|
@@ -784,6 +968,7 @@ __export(src_exports, {
|
|
|
784
968
|
drawWeatherIcon: () => drawWeatherIcon,
|
|
785
969
|
ellipse: () => ellipse,
|
|
786
970
|
fitSize: () => fitSize,
|
|
971
|
+
hasCjk: () => hasCjk,
|
|
787
972
|
hashString: () => hashString,
|
|
788
973
|
hex: () => hex,
|
|
789
974
|
linear: () => linear,
|
|
@@ -794,8 +979,10 @@ __export(src_exports, {
|
|
|
794
979
|
registerFontFiles: () => registerFontFiles,
|
|
795
980
|
rng: () => rng,
|
|
796
981
|
setDefaultFamily: () => setDefaultFamily,
|
|
982
|
+
setMinCjkPx: () => setMinCjkPx,
|
|
797
983
|
smooth: () => smooth,
|
|
798
984
|
sparkBars: () => sparkBars,
|
|
985
|
+
takeCjkEnlarged: () => takeCjkEnlarged,
|
|
799
986
|
truncate: () => truncate,
|
|
800
987
|
wrapLines: () => wrapLines
|
|
801
988
|
});
|
|
@@ -818,7 +1005,7 @@ __export(testing_exports, {
|
|
|
818
1005
|
renderWidget: () => renderWidget,
|
|
819
1006
|
widgetState: () => widgetState
|
|
820
1007
|
});
|
|
821
|
-
import { createCanvas as
|
|
1008
|
+
import { createCanvas as createCanvas6, loadImage as loadImage4 } from "@napi-rs/canvas";
|
|
822
1009
|
function resolve3(w, o) {
|
|
823
1010
|
const now = o.now ?? Date.UTC(2026, 10, 5, 9, 42);
|
|
824
1011
|
const locale = o.locale ?? "en";
|
|
@@ -835,7 +1022,7 @@ function renderWidget(w, o = {}) {
|
|
|
835
1022
|
const theme = typeof o.theme === "object" ? o.theme : themeById(o.theme);
|
|
836
1023
|
const texts = [];
|
|
837
1024
|
const spy = { ...src_exports, drawTracked: (...a) => (texts.push(a[1]), drawTracked(...a)) };
|
|
838
|
-
const canvas =
|
|
1025
|
+
const canvas = createCanvas6(size.w + 2 * MARGIN, size.h + 2 * MARGIN);
|
|
839
1026
|
const g = canvas.getContext("2d");
|
|
840
1027
|
const box = { x: MARGIN, y: MARGIN, w: size.w, h: size.h };
|
|
841
1028
|
const ctx = {
|
|
@@ -848,7 +1035,7 @@ function renderWidget(w, o = {}) {
|
|
|
848
1035
|
theme,
|
|
849
1036
|
fonts: theme.fonts,
|
|
850
1037
|
kit: spy,
|
|
851
|
-
canvas: { createCanvas:
|
|
1038
|
+
canvas: { createCanvas: createCanvas6, loadImage: loadImage4 },
|
|
852
1039
|
preview: !!o.preview
|
|
853
1040
|
};
|
|
854
1041
|
const t0 = performance.now();
|
|
@@ -876,7 +1063,7 @@ function renderWidget(w, o = {}) {
|
|
|
876
1063
|
ms,
|
|
877
1064
|
...error !== void 0 ? { error } : {},
|
|
878
1065
|
png() {
|
|
879
|
-
const out =
|
|
1066
|
+
const out = createCanvas6(box.w, box.h);
|
|
880
1067
|
out.getContext("2d").drawImage(canvas, -box.x, -box.y);
|
|
881
1068
|
return out.toBuffer("image/png");
|
|
882
1069
|
}
|
|
@@ -891,7 +1078,7 @@ function widgetState(w, hook, o = {}) {
|
|
|
891
1078
|
}
|
|
892
1079
|
function checkPlugin(p, o = {}) {
|
|
893
1080
|
const issues = [];
|
|
894
|
-
const locales = o.locales ?? ["en", "es"];
|
|
1081
|
+
const locales = o.locales ?? (p.languages?.length ? p.languages : ["en", "es"]);
|
|
895
1082
|
const themes = o.themes ?? THEMES.map((t2) => t2.id);
|
|
896
1083
|
const slow = o.slowMs ?? 50;
|
|
897
1084
|
for (const w of p.widgets ?? []) {
|
|
@@ -1007,6 +1194,8 @@ function zoomOf(inst) {
|
|
|
1007
1194
|
if (typeof z !== "number" || !Number.isFinite(z)) return 1;
|
|
1008
1195
|
return Math.round(Math.min(ZOOM.max, Math.max(ZOOM.min, z)) * 100) / 100;
|
|
1009
1196
|
}
|
|
1197
|
+
var READING_CM = { near: 40, normal: 60, far: 90 };
|
|
1198
|
+
var TEXT_SCALE = { min: 0.75, max: 2, step: 0.05 };
|
|
1010
1199
|
var DEFAULT_MAX_BYTES = 48e4;
|
|
1011
1200
|
var counter = 0;
|
|
1012
1201
|
function newId(prefix = "id") {
|
|
@@ -1053,15 +1242,30 @@ var DEFAULT_CONFIG = {
|
|
|
1053
1242
|
server: { host: "127.0.0.1", port: 7420 }
|
|
1054
1243
|
};
|
|
1055
1244
|
var PANEL_PRESETS = [
|
|
1056
|
-
{ id: "trofeo-916", name: "Trofeo Vision 9.16\u2033", width: 1920, height: 462 },
|
|
1057
|
-
{ id: "
|
|
1058
|
-
|
|
1059
|
-
{ id: "wide-
|
|
1060
|
-
{ id: "
|
|
1061
|
-
{ id: "
|
|
1062
|
-
{ id: "
|
|
1063
|
-
{ id: "
|
|
1245
|
+
{ id: "trofeo-916", name: "Trofeo Vision 9.16\u2033", width: 1920, height: 462, diagonalIn: 9.16, maker: "Thermalright", tested: true },
|
|
1246
|
+
{ id: "trofeo-113", name: "Trofeo Vision 11.3\u2033", width: 1920, height: 400, diagonalIn: 11.3, maker: "Thermalright" },
|
|
1247
|
+
// The id of the size it was before it had its model's name: kept.
|
|
1248
|
+
{ id: "wide-1280x480", name: "Trofeo Vision 6.86\u2033", width: 1280, height: 480, diagonalIn: 6.86, maker: "Thermalright" },
|
|
1249
|
+
{ id: "fan-bracket-vision-1", name: "Fan Bracket Vision-1", width: 854, height: 480, diagonalIn: 5.66, maker: "Thermalright" },
|
|
1250
|
+
{ id: "gpu-bracket-458", name: "GPU Bracket LCD 4.58\u2033", width: 320, height: 960, diagonalIn: 4.58, maker: "Thermalright" },
|
|
1251
|
+
{ id: "fan-frame-vision-1", name: "Fan Frame Vision-1 3.69\u2033", width: 640, height: 172, diagonalIn: 3.69, maker: "Thermalright" },
|
|
1252
|
+
{ id: "wide-1920x480", name: "Wide bar 1920\xD7480", width: 1920, height: 480, diagonalIn: 9.16 },
|
|
1253
|
+
{ id: "wide-1600x720", name: "1600\xD7720", width: 1600, height: 720, diagonalIn: 8.8 },
|
|
1254
|
+
{ id: "square-480", name: "Square 480\xD7480", width: 480, height: 480, diagonalIn: 3.4 },
|
|
1255
|
+
{ id: "square-320", name: "Square 320\xD7320", width: 320, height: 320, diagonalIn: 2.1 },
|
|
1256
|
+
{ id: "small-320x240", name: "Small 320\xD7240", width: 320, height: 240, diagonalIn: 2.4 },
|
|
1257
|
+
{ id: "round-480", name: "Round 480\xD7480 (AIO)", width: 480, height: 480, diagonalIn: 2.8 }
|
|
1064
1258
|
];
|
|
1259
|
+
function mmPerPx(s) {
|
|
1260
|
+
const known = PANEL_PRESETS.find((p) => p.width === s.width && p.height === s.height || p.width === s.height && p.height === s.width);
|
|
1261
|
+
const diag = s.diagonalIn ?? known?.diagonalIn;
|
|
1262
|
+
if (!diag) return 25.4 / 200;
|
|
1263
|
+
return diag * 25.4 / Math.hypot(s.width, s.height);
|
|
1264
|
+
}
|
|
1265
|
+
function legibleCjkPx(s) {
|
|
1266
|
+
const mm = READING_CM[s.readingDistance ?? "normal"] * 10 * Math.tan(10 / 60 * Math.PI / 180);
|
|
1267
|
+
return Math.round(mm / 0.88 / mmPerPx(s));
|
|
1268
|
+
}
|
|
1065
1269
|
function isWorking(workday, now) {
|
|
1066
1270
|
return isWorkingAt(workday, now);
|
|
1067
1271
|
}
|
|
@@ -1127,17 +1331,17 @@ import { homedir as homedir2, platform } from "node:os";
|
|
|
1127
1331
|
|
|
1128
1332
|
// packages/sdk/src/plugin.ts
|
|
1129
1333
|
var CATEGORIES = [
|
|
1130
|
-
{ id: "agents", label: { en: "AI agents", es: "Agentes IA" } },
|
|
1131
|
-
{ id: "system", label: { en: "System", es: "Sistema" } },
|
|
1132
|
-
{ id: "time", label: { en: "Time & calendar", es: "Tiempo y agenda" } },
|
|
1133
|
-
{ id: "productivity", label: { en: "Productivity", es: "Productividad" } },
|
|
1134
|
-
{ id: "dev", label: { en: "Development", es: "Desarrollo" } },
|
|
1135
|
-
{ id: "info", label: { en: "News & world", es: "Noticias y mundo" } },
|
|
1136
|
-
{ id: "media", label: { en: "Media", es: "Multimedia" } },
|
|
1137
|
-
{ id: "scene", label: { en: "Scenes", es: "Escenas" } },
|
|
1138
|
-
{ id: "fun", label: { en: "Fun", es: "Diversi\xF3n" } }
|
|
1334
|
+
{ id: "agents", label: { en: "AI agents", es: "Agentes IA", de: "KI-Agenten", "zh-Hant": "AI \u4EE3\u7406", "zh-Hans": "AI \u667A\u80FD\u4F53" } },
|
|
1335
|
+
{ id: "system", label: { en: "System", es: "Sistema", de: "System", "zh-Hant": "\u7CFB\u7D71", "zh-Hans": "\u7CFB\u7EDF" } },
|
|
1336
|
+
{ id: "time", label: { en: "Time & calendar", es: "Tiempo y agenda", de: "Zeit & Kalender", "zh-Hant": "\u6642\u9593\u8207\u884C\u4E8B\u66C6", "zh-Hans": "\u65F6\u95F4\u4E0E\u65E5\u5386" } },
|
|
1337
|
+
{ id: "productivity", label: { en: "Productivity", es: "Productividad", de: "Produktivit\xE4t", "zh-Hant": "\u751F\u7522\u529B", "zh-Hans": "\u6548\u7387" } },
|
|
1338
|
+
{ id: "dev", label: { en: "Development", es: "Desarrollo", de: "Entwicklung", "zh-Hant": "\u958B\u767C", "zh-Hans": "\u5F00\u53D1" } },
|
|
1339
|
+
{ id: "info", label: { en: "News & world", es: "Noticias y mundo", de: "Nachrichten & Welt", "zh-Hant": "\u65B0\u805E\u8207\u4E16\u754C", "zh-Hans": "\u65B0\u95FB\u4E0E\u4E16\u754C" } },
|
|
1340
|
+
{ id: "media", label: { en: "Media", es: "Multimedia", de: "Medien", "zh-Hant": "\u591A\u5A92\u9AD4", "zh-Hans": "\u591A\u5A92\u4F53" } },
|
|
1341
|
+
{ id: "scene", label: { en: "Scenes", es: "Escenas", de: "Szenen", "zh-Hant": "\u5834\u666F", "zh-Hans": "\u573A\u666F" } },
|
|
1342
|
+
{ id: "fun", label: { en: "Fun", es: "Diversi\xF3n", de: "Spa\xDF", "zh-Hant": "\u8DA3\u5473", "zh-Hans": "\u8DA3\u5473" } }
|
|
1139
1343
|
];
|
|
1140
|
-
var SDK_VERSION = "0.2.
|
|
1344
|
+
var SDK_VERSION = "0.2.6";
|
|
1141
1345
|
function defineWidget(w) {
|
|
1142
1346
|
return w;
|
|
1143
1347
|
}
|
|
@@ -1149,24 +1353,47 @@ function definePlugin(p) {
|
|
|
1149
1353
|
init_schema();
|
|
1150
1354
|
init_theme();
|
|
1151
1355
|
init_i18n();
|
|
1356
|
+
|
|
1357
|
+
// packages/sdk/src/languages.ts
|
|
1358
|
+
var MAINLAND_CHINA = {
|
|
1359
|
+
without: ["agents", "cats", "usage"],
|
|
1360
|
+
first: ["llm", "gpu"],
|
|
1361
|
+
instead: { "agents/summary": "llm/status", "agents/sessions": "llm/models", "usage/rail": "gpu/cards", "cats/room": "gpu/history" }
|
|
1362
|
+
};
|
|
1363
|
+
var LANGUAGES = [
|
|
1364
|
+
{ id: "en", name: "English", panel: "en", ogLocale: "en_US", hreflang: ["en", "x-default"], dir: "ltr" },
|
|
1365
|
+
{ id: "es", name: "Espa\xF1ol", panel: "es", ogLocale: "es_ES", hreflang: ["es"], dir: "ltr" },
|
|
1366
|
+
{ id: "de", name: "Deutsch", panel: "de", ogLocale: "de_DE", hreflang: ["de"], dir: "ltr" },
|
|
1367
|
+
{ id: "zh-Hant", name: "\u7E41\u9AD4\u4E2D\u6587", panel: "zh-TW", ogLocale: "zh_TW", hreflang: ["zh-Hant", "zh-TW", "zh-HK"], dir: "ltr" },
|
|
1368
|
+
{ id: "zh-Hans", name: "\u7B80\u4F53\u4E2D\u6587", panel: "zh-CN", ogLocale: "zh_CN", hreflang: ["zh-Hans", "zh-CN"], dir: "ltr", plugins: MAINLAND_CHINA }
|
|
1369
|
+
];
|
|
1370
|
+
var LANGUAGE_IDS = LANGUAGES.map((l) => l.id);
|
|
1371
|
+
function languageById(id) {
|
|
1372
|
+
return LANGUAGES.find((l) => l.id === id);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
// packages/sdk/src/index.ts
|
|
1152
1376
|
init_format();
|
|
1153
1377
|
init_workday();
|
|
1154
1378
|
|
|
1155
1379
|
// packages/sdk/src/list.ts
|
|
1156
1380
|
init_schema();
|
|
1157
1381
|
var LAYOUT_LABELS = {
|
|
1158
|
-
auto: { en: "Automatic", es: "Autom\xE1tico" },
|
|
1159
|
-
"one-line": { en: "One line", es: "Una l\xEDnea" },
|
|
1160
|
-
detailed: { en: "Detailed", es: "Detallado" }
|
|
1382
|
+
auto: { en: "Automatic", es: "Autom\xE1tico", de: "Automatisch", "zh-Hant": "\u81EA\u52D5", "zh-Hans": "\u81EA\u52A8" },
|
|
1383
|
+
"one-line": { en: "One line", es: "Una l\xEDnea", de: "Eine Zeile", "zh-Hant": "\u55AE\u884C", "zh-Hans": "\u5355\u884C" },
|
|
1384
|
+
detailed: { en: "Detailed", es: "Detallado", de: "Ausf\xFChrlich", "zh-Hant": "\u8A73\u7D30", "zh-Hans": "\u8BE6\u7EC6" }
|
|
1161
1385
|
};
|
|
1162
1386
|
var rowsField = (def) => t.integer({
|
|
1163
1387
|
default: def,
|
|
1164
1388
|
min: 0,
|
|
1165
1389
|
max: 30,
|
|
1166
|
-
label: { en: "Rows", es: "Filas" },
|
|
1390
|
+
label: { en: "Rows", es: "Filas", de: "Zeilen", "zh-Hant": "\u5217\u6578", "zh-Hans": "\u884C\u6570" },
|
|
1167
1391
|
help: {
|
|
1168
1392
|
en: '0 = as many as fit. A number shows that many, in rows of a readable size (fewer when the tile is too small for them); the rest are counted in "+N more".',
|
|
1169
|
-
es: "0 = las que quepan. Con un n\xFAmero se ven esas, en filas de un tama\xF1o legible (menos si la tesela no da para ellas); el resto se cuenta en \xAB+N m\xE1s\xBB."
|
|
1393
|
+
es: "0 = las que quepan. Con un n\xFAmero se ven esas, en filas de un tama\xF1o legible (menos si la tesela no da para ellas); el resto se cuenta en \xAB+N m\xE1s\xBB.",
|
|
1394
|
+
de: "0 = so viele, wie passen. Eine Zahl zeigt so viele, in Zeilen lesbarer Gr\xF6\xDFe (weniger, wenn die Kachel daf\xFCr zu klein ist); der Rest wird als \u201E+N weitere\u201C gez\xE4hlt.",
|
|
1395
|
+
"zh-Hant": "0 = \u76E1\u91CF\u653E\u6EFF\u3002\u586B\u6578\u5B57\u5247\u986F\u793A\u8A72\u6578\u91CF\uFF0C\u4E26\u4EE5\u6613\u8B80\u7684\u5927\u5C0F\u6392\u5217\uFF08\u65B9\u683C\u592A\u5C0F\u6642\u6703\u6E1B\u5C11\uFF09\uFF1B\u5176\u9918\u7684\u8A08\u5165\u300C\u9084\u6709 N \u500B\u300D\u3002",
|
|
1396
|
+
"zh-Hans": "0 = \u5C3D\u91CF\u653E\u6EE1\u3002\u586B\u6570\u5B57\u5219\u663E\u793A\u8BE5\u6570\u91CF\uFF0C\u5E76\u4EE5\u6613\u8BFB\u7684\u5927\u5C0F\u6392\u5217\uFF08\u683C\u5B50\u592A\u5C0F\u65F6\u4F1A\u51CF\u5C11\uFF09\uFF1B\u5176\u4F59\u7684\u8BA1\u5165\u201C\u8FD8\u6709 N \u4E2A\u201D\u3002"
|
|
1170
1397
|
}
|
|
1171
1398
|
});
|
|
1172
1399
|
function listOptions(o = {}) {
|
|
@@ -1177,9 +1404,9 @@ function listOptions(o = {}) {
|
|
|
1177
1404
|
rows,
|
|
1178
1405
|
layout: t.enum(values, {
|
|
1179
1406
|
default: o.layout ?? "auto",
|
|
1180
|
-
label: { en: "Row layout", es: "Formato de fila" },
|
|
1407
|
+
label: { en: "Row layout", es: "Formato de fila", de: "Zeilenlayout", "zh-Hant": "\u5217\u7248\u9762", "zh-Hans": "\u884C\u5E03\u5C40" },
|
|
1181
1408
|
labels: Object.fromEntries(values.map((v) => [v, LAYOUT_LABELS[v]])),
|
|
1182
|
-
help: { en: "Automatic: the widget picks by the tile's shape.", es: "Autom\xE1tico: el widget elige seg\xFAn la forma de la tesela." }
|
|
1409
|
+
help: { en: "Automatic: the widget picks by the tile's shape.", es: "Autom\xE1tico: el widget elige seg\xFAn la forma de la tesela.", de: "Automatisch: Das Widget w\xE4hlt nach der Form der Kachel.", "zh-Hant": "\u81EA\u52D5\uFF1A\u5C0F\u5DE5\u5177\u4F9D\u65B9\u683C\u5F62\u72C0\u9078\u64C7\u3002", "zh-Hans": "\u81EA\u52A8\uFF1A\u5C0F\u7EC4\u4EF6\u6839\u636E\u683C\u5B50\u5F62\u72B6\u9009\u62E9\u3002" }
|
|
1183
1410
|
})
|
|
1184
1411
|
};
|
|
1185
1412
|
}
|
|
@@ -1225,7 +1452,7 @@ function listLayout(box, count, options2, spec) {
|
|
|
1225
1452
|
return { layout, rowH, rows, shown, hidden: n - shown, more, ...text2(rowH) };
|
|
1226
1453
|
}
|
|
1227
1454
|
function moreLabel(n, tr) {
|
|
1228
|
-
return tr({ en: `+${n} more`, es: `+${n} m\xE1s` });
|
|
1455
|
+
return tr({ en: `+${n} more`, es: `+${n} m\xE1s`, de: `+${n} weitere`, "zh-Hant": `\u9084\u6709 ${n} \u500B`, "zh-Hans": `\u8FD8\u6709 ${n} \u4E2A` });
|
|
1229
1456
|
}
|
|
1230
1457
|
function drawMore(g, ctx, plan, o = {}) {
|
|
1231
1458
|
const m = plan.more;
|
|
@@ -1530,7 +1757,10 @@ function normalizeScreen(s, i) {
|
|
|
1530
1757
|
sleepWhenIdle: s.sleepWhenIdle ?? false,
|
|
1531
1758
|
jpegQuality: s.jpegQuality ?? 90,
|
|
1532
1759
|
maxBytes: Math.max(0, Math.round(s.maxBytes ?? DEFAULT_MAX_BYTES)),
|
|
1533
|
-
maxFps: s.maxFps ?? 12
|
|
1760
|
+
maxFps: s.maxFps ?? 12,
|
|
1761
|
+
...s.readingDistance === "near" || s.readingDistance === "far" ? { readingDistance: s.readingDistance } : {},
|
|
1762
|
+
...typeof s.textScale === "number" && Number.isFinite(s.textScale) && s.textScale !== 1 ? { textScale: Math.min(TEXT_SCALE.max, Math.max(TEXT_SCALE.min, s.textScale)) } : {},
|
|
1763
|
+
...typeof s.diagonalIn === "number" && s.diagonalIn > 0 ? { diagonalIn: s.diagonalIn } : {}
|
|
1534
1764
|
};
|
|
1535
1765
|
}
|
|
1536
1766
|
|
|
@@ -1586,16 +1816,16 @@ function sourceCommonFields(def) {
|
|
|
1586
1816
|
default: intervalMs,
|
|
1587
1817
|
min: minIntervalMs,
|
|
1588
1818
|
max: Math.max(MAX_INTERVAL_MS, intervalMs),
|
|
1589
|
-
label: { en: "Read every", es: "Leer cada" },
|
|
1590
|
-
help: { en: `How often Kiosko reads it while a widget uses it. At least ${human(minIntervalMs)}.`, es: `Cada cu\xE1nto lo lee Kiosko mientras alg\xFAn widget lo usa. Como m\xEDnimo, ${human(minIntervalMs)}
|
|
1819
|
+
label: { en: "Read every", es: "Leer cada", de: "Lesen alle", "zh-Hant": "\u8B80\u53D6\u9593\u9694", "zh-Hans": "\u8BFB\u53D6\u95F4\u9694" },
|
|
1820
|
+
help: { en: `How often Kiosko reads it while a widget uses it. At least ${human(minIntervalMs)}.`, es: `Cada cu\xE1nto lo lee Kiosko mientras alg\xFAn widget lo usa. Como m\xEDnimo, ${human(minIntervalMs)}.`, de: `Wie oft Kiosko sie liest, solange ein Widget sie verwendet. Mindestens ${human(minIntervalMs)}.`, "zh-Hant": `\u5C0F\u5DE5\u5177\u4F7F\u7528\u6642\uFF0CKiosko \u8B80\u53D6\u5B83\u7684\u983B\u7387\u3002\u6700\u5C11 ${human(minIntervalMs)}\u3002`, "zh-Hans": `\u6709\u5C0F\u7EC4\u4EF6\u4F7F\u7528\u65F6 Kiosko \u8BFB\u53D6\u5B83\u7684\u9891\u7387\u3002\u6700\u5C11 ${human(minIntervalMs)}\u3002` }
|
|
1591
1821
|
}),
|
|
1592
1822
|
timeoutMs: t.duration({
|
|
1593
1823
|
default: timeoutMs,
|
|
1594
1824
|
min: MIN_TIMEOUT_MS,
|
|
1595
1825
|
max: Math.max(MAX_TIMEOUT_MS, timeoutMs),
|
|
1596
1826
|
advanced: true,
|
|
1597
|
-
label: { en: "Give up a reading after", es: "Abandonar una lectura tras" },
|
|
1598
|
-
help: { en: "A reading that takes longer is cancelled and counts as failed; the next try comes sooner.", es: "Una lectura que tarde m\xE1s se cancela y cuenta como fallida; el siguiente intento llega antes." }
|
|
1827
|
+
label: { en: "Give up a reading after", es: "Abandonar una lectura tras", de: "Lesen abbrechen nach", "zh-Hant": "\u8B80\u53D6\u903E\u6642", "zh-Hans": "\u8BFB\u53D6\u8D85\u65F6" },
|
|
1828
|
+
help: { en: "A reading that takes longer is cancelled and counts as failed; the next try comes sooner.", es: "Una lectura que tarde m\xE1s se cancela y cuenta como fallida; el siguiente intento llega antes.", de: "Ein Lesevorgang, der l\xE4nger dauert, wird abgebrochen und z\xE4hlt als fehlgeschlagen; der n\xE4chste Versuch kommt fr\xFCher.", "zh-Hant": "\u8D85\u904E\u6B64\u6642\u9593\u7684\u8B80\u53D6\u6703\u88AB\u53D6\u6D88\u4E26\u8996\u70BA\u5931\u6557\uFF1B\u4E0B\u6B21\u6703\u63D0\u65E9\u91CD\u8A66\u3002", "zh-Hans": "\u8D85\u8FC7\u6B64\u65F6\u95F4\u7684\u8BFB\u53D6\u4F1A\u88AB\u53D6\u6D88\u5E76\u89C6\u4E3A\u5931\u8D25\uFF1B\u4E0B\u6B21\u4F1A\u63D0\u524D\u91CD\u8BD5\u3002" }
|
|
1599
1829
|
})
|
|
1600
1830
|
};
|
|
1601
1831
|
const own = def.options?.props ?? {};
|
|
@@ -1626,12 +1856,12 @@ var ID_PATTERN = "^[A-Za-z0-9_.-]{1,80}$";
|
|
|
1626
1856
|
var TAKE_OVER = {
|
|
1627
1857
|
type: "boolean",
|
|
1628
1858
|
description: "Keep the tile while the widget is urgent (a meeting about to start, a permission waiting), even if others share it. Off: it takes its turn like the rest.",
|
|
1629
|
-
"x-ui": { label: { en: "Keep the tile while urgent", es: "Quedarse la tesela mientras sea urgente" } }
|
|
1859
|
+
"x-ui": { label: { en: "Keep the tile while urgent", es: "Quedarse la tesela mientras sea urgente", de: "Kachel behalten, wenn dringend", "zh-Hant": "\u7DCA\u6025\u6642\u4FDD\u7559\u65B9\u683C", "zh-Hans": "\u7D27\u6025\u65F6\u72EC\u5360\u683C\u5B50" } }
|
|
1630
1860
|
};
|
|
1631
1861
|
var HIDE_WHEN_EMPTY = {
|
|
1632
1862
|
type: "boolean",
|
|
1633
1863
|
description: "Skip the widget in its tile's rotation while it has nothing to list, instead of showing its empty message.",
|
|
1634
|
-
"x-ui": { label: { en: "Hide when empty", es: "Ocultar si est\xE1 vac\xEDo" } }
|
|
1864
|
+
"x-ui": { label: { en: "Hide when empty", es: "Ocultar si est\xE1 vac\xEDo", de: "Ausblenden, wenn leer", "zh-Hant": "\u6C92\u6709\u5167\u5BB9\u6642\u96B1\u85CF", "zh-Hans": "\u6CA1\u6709\u5185\u5BB9\u65F6\u9690\u85CF" } }
|
|
1635
1865
|
};
|
|
1636
1866
|
var TIME_PATTERN = "^([01][0-9]|2[0-3]):[0-5][0-9]$";
|
|
1637
1867
|
function options(f, what) {
|
|
@@ -1737,7 +1967,7 @@ function configSchema(plugins) {
|
|
|
1737
1967
|
enum: [...TIME_FORMATS],
|
|
1738
1968
|
default: DEFAULT_CONFIG.timeFormat,
|
|
1739
1969
|
description: 'How widgets write clock times: "24h" (14:05), "12h" (2:05 PM), or "auto", the habit of the language (24 h in Spanish and British English, 12 h in US English).',
|
|
1740
|
-
"x-ui": { label: { en: "Time format", es: "Formato de hora" }, labels: { auto: { en: "As the language", es: "Seg\xFAn el idioma" }, "24h": { en: "24 hours", es: "24 horas" }, "12h": { en: "12 hours", es: "12 horas" } } }
|
|
1970
|
+
"x-ui": { label: { en: "Time format", es: "Formato de hora", de: "Zeitformat", "zh-Hant": "\u6642\u9593\u683C\u5F0F", "zh-Hans": "\u65F6\u95F4\u683C\u5F0F" }, labels: { auto: { en: "As the language", es: "Seg\xFAn el idioma", de: "Wie die Sprache", "zh-Hant": "\u4F9D\u7167\u8A9E\u8A00", "zh-Hans": "\u8DDF\u968F\u8BED\u8A00" }, "24h": { en: "24 hours", es: "24 horas", de: "24 Stunden", "zh-Hant": "24 \u5C0F\u6642\u5236", "zh-Hans": "24 \u5C0F\u65F6\u5236" }, "12h": { en: "12 hours", es: "12 horas", de: "12 Stunden", "zh-Hant": "12 \u5C0F\u6642\u5236", "zh-Hans": "12 \u5C0F\u65F6\u5236" } } }
|
|
1741
1971
|
},
|
|
1742
1972
|
theme: { enum: THEMES.map((t2) => t2.id), default: DEFAULT_CONFIG.theme, description: `Colour theme: ${THEMES.map((t2) => `${t2.id} (${t2.name})`).join(", ")}.` },
|
|
1743
1973
|
location: { $ref: "#/$defs/location" },
|
|
@@ -1815,7 +2045,7 @@ function configSchema(plugins) {
|
|
|
1815
2045
|
maximum: ZOOM.max,
|
|
1816
2046
|
default: 1,
|
|
1817
2047
|
description: `Text density: the widget is painted this many times bigger, in the same tile: 1.25 gives bigger letters and fewer rows, 0.8 a denser widget. From ${ZOOM.min} to ${ZOOM.max} (the editor moves in steps of ${ZOOM.step}). The tile must be at least the widget's minimum size times the zoom.`,
|
|
1818
|
-
"x-ui": { label: { en: "Zoom", es: "Zoom" }, unit: "\xD7", step: ZOOM.step, slider: true }
|
|
2048
|
+
"x-ui": { label: { en: "Zoom", es: "Zoom", de: "Zoom", "zh-Hant": "\u7E2E\u653E", "zh-Hans": "\u7F29\u653E" }, unit: "\xD7", step: ZOOM.step, slider: true }
|
|
1819
2049
|
},
|
|
1820
2050
|
location: {
|
|
1821
2051
|
type: "object",
|
|
@@ -1957,7 +2187,10 @@ function configSchema(plugins) {
|
|
|
1957
2187
|
sleepWhenIdle: { type: "boolean", default: false, description: "Black panel while every widget of the page has nothing worth showing." },
|
|
1958
2188
|
jpegQuality: { type: "integer", minimum: 0, maximum: 100, default: 90, description: "JPEG quality of the frames; 0 = PNG." },
|
|
1959
2189
|
maxBytes: { type: "integer", minimum: 0, maximum: 2e7, default: 48e4, description: "Largest frame to send, in bytes: a bigger one is re-encoded at a lower JPEG quality until it fits. LY panels (Trofeo Vision\u2026) drop frames over ~500 KB. 0 = no limit." },
|
|
1960
|
-
maxFps: { type: "integer", minimum: 1, maximum: 30, default: 12, description: "Frames per second ceiling for animations." }
|
|
2190
|
+
maxFps: { type: "integer", minimum: 1, maximum: 30, default: 12, description: "Frames per second ceiling for animations." },
|
|
2191
|
+
readingDistance: { enum: ["near", "normal", "far"], default: "normal", description: "How far the readers sit (40, 60, 90 cm): with the pixel size it sets the smallest Chinese, Japanese or Korean text painted." },
|
|
2192
|
+
textScale: { type: "number", minimum: 0.75, maximum: 2, default: 1, description: "Every widget's text size times this." },
|
|
2193
|
+
diagonalIn: { type: "number", minimum: 0.5, maximum: 60, description: "The panel's diagonal in inches, when it isn't a known model." }
|
|
1961
2194
|
}
|
|
1962
2195
|
}
|
|
1963
2196
|
},
|
|
@@ -2373,7 +2606,7 @@ var short = (v) => {
|
|
|
2373
2606
|
const s = v === void 0 ? "unset" : JSON.stringify(v);
|
|
2374
2607
|
return s.length > 60 ? `${s.slice(0, 57)}...` : s;
|
|
2375
2608
|
};
|
|
2376
|
-
var
|
|
2609
|
+
var plural2 = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
2377
2610
|
function match(before, after, alt) {
|
|
2378
2611
|
const pairs = [];
|
|
2379
2612
|
const left = [...before];
|
|
@@ -2397,7 +2630,7 @@ var tileText = (t2) => `tile ${rect(t2)}: ${types(t2)}`;
|
|
|
2397
2630
|
var pageTypes = (p) => [...new Set(p.tiles.flatMap((t2) => t2.widgets.map((w) => w.type)))];
|
|
2398
2631
|
var pageText = (p) => {
|
|
2399
2632
|
const ts = pageTypes(p);
|
|
2400
|
-
return `page ${q2(p.name)}: ${
|
|
2633
|
+
return `page ${q2(p.name)}: ${plural2(p.tiles.length, "tile")}${ts.length ? ` (${ts.slice(0, 6).join(", ")}${ts.length > 6 ? `, +${ts.length - 6} more` : ""})` : ""}`;
|
|
2401
2634
|
};
|
|
2402
2635
|
var deviceText = (d) => d.driver === "trcc" ? `trcc ${d.url}` : d.driver === "file" ? `file ${d.dir}` : d.driver === "usb" ? `usb${d.serial ? ` ${d.serial}` : ""}` : d.driver;
|
|
2403
2636
|
var changedKeys = (a, b) => [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])].filter((k) => !same(a[k], b[k]));
|
|
@@ -2448,7 +2681,7 @@ function diffConfigs(before, after) {
|
|
|
2448
2681
|
else if (a && b && !same(a, b)) out.push({ depth: 0, op: "~", kind: "source", text: `source ${k}: ${changedKeys(b, a).join(", ")} changed` });
|
|
2449
2682
|
}
|
|
2450
2683
|
const m = match(before.screens, after.screens, (s) => s.name);
|
|
2451
|
-
for (const s of m.removed) out.push({ depth: 0, op: "-", kind: "screen", text: `screen ${q2(s.name)} ${s.width}\xD7${s.height} (${
|
|
2684
|
+
for (const s of m.removed) out.push({ depth: 0, op: "-", kind: "screen", text: `screen ${q2(s.name)} ${s.width}\xD7${s.height} (${plural2(s.pages.length, "page")})` });
|
|
2452
2685
|
for (const s of m.added) {
|
|
2453
2686
|
out.push({ depth: 0, op: "+", kind: "screen", text: `screen ${q2(s.name)} ${s.width}\xD7${s.height}, ${deviceText(s.device)}` });
|
|
2454
2687
|
for (const p of s.pages) out.push({ depth: 1, op: "+", kind: "page", text: pageText(p) });
|
|
@@ -2476,7 +2709,7 @@ function summarizeDiff(lines) {
|
|
|
2476
2709
|
for (const l of lines) counts.set(`${l.kind} ${l.op}`, (counts.get(`${l.kind} ${l.op}`) ?? 0) + 1);
|
|
2477
2710
|
const parts = [...counts].map(([k, n]) => {
|
|
2478
2711
|
const [kind, op] = k.split(" ");
|
|
2479
|
-
return `${
|
|
2712
|
+
return `${plural2(n, kind)} ${verb[op]}`;
|
|
2480
2713
|
});
|
|
2481
2714
|
return parts.length ? parts.join(", ") : "no changes";
|
|
2482
2715
|
}
|
|
@@ -2713,6 +2946,41 @@ function planImport(incoming, current, plugins, schema = configSchema(plugins))
|
|
|
2713
2946
|
return { report, config: config2, carried, diff: diffConfigs(current, config2), risks: listRisks(config2, schema, current), secrets };
|
|
2714
2947
|
}
|
|
2715
2948
|
|
|
2949
|
+
// packages/core/src/config/sample.ts
|
|
2950
|
+
var SAMPLE_PAGE_NAMES = {
|
|
2951
|
+
Dashboard: { en: "Dashboard", de: "\xDCbersicht", es: "Panel", "zh-Hant": "\u7E3D\u89BD", "zh-Hans": "\u603B\u89C8" },
|
|
2952
|
+
Cats: { en: "Cats", de: "Katzen", es: "Gatos", "zh-Hant": "\u8C93\u54AA", "zh-Hans": "\u672C\u5730\u6A21\u578B" },
|
|
2953
|
+
News: { en: "News", de: "Nachrichten", es: "Noticias", "zh-Hant": "\u65B0\u805E", "zh-Hans": "\u65B0\u95FB" },
|
|
2954
|
+
Home: { en: "Home", de: "Zuhause", es: "Casa", "zh-Hant": "\u5C45\u5BB6", "zh-Hans": "\u5BB6\u5C45" }
|
|
2955
|
+
};
|
|
2956
|
+
var SAMPLE_PLACES = {
|
|
2957
|
+
de: { latitude: 52.52, longitude: 13.405, name: "Berlin" },
|
|
2958
|
+
"zh-Hant": { latitude: 25.033, longitude: 121.5654, name: "\u53F0\u5317" },
|
|
2959
|
+
"zh-Hans": { latitude: 31.2304, longitude: 121.4737, name: "\u4E0A\u6D77" }
|
|
2960
|
+
};
|
|
2961
|
+
function localizeSample(cfg, locale) {
|
|
2962
|
+
const lang = pickLocale(LANGUAGE_IDS, locale) ?? "en";
|
|
2963
|
+
if (lang === "en") return cfg;
|
|
2964
|
+
const place = SAMPLE_PLACES[lang];
|
|
2965
|
+
const market = languageById(lang)?.plugins;
|
|
2966
|
+
const instead = market?.instead;
|
|
2967
|
+
return {
|
|
2968
|
+
...cfg,
|
|
2969
|
+
// Nor are those plugins offered there: not in the library nor in the templates.
|
|
2970
|
+
...market ? { plugins: { ...cfg.plugins, disabled: [.../* @__PURE__ */ new Set([...cfg.plugins?.disabled ?? [], ...market.without])] } } : {},
|
|
2971
|
+
...place ? { location: place } : {},
|
|
2972
|
+
screens: (cfg.screens ?? []).map((s) => ({
|
|
2973
|
+
...s,
|
|
2974
|
+
pages: s.pages.map((p) => ({
|
|
2975
|
+
...p,
|
|
2976
|
+
name: SAMPLE_PAGE_NAMES[p.name]?.[lang] ?? p.name,
|
|
2977
|
+
// Widgets whose service is not offered where the language is read give way to others (languages.ts).
|
|
2978
|
+
tiles: p.tiles.map((t2) => ({ ...t2, widgets: t2.widgets.map(({ title: _title, ...w }) => instead?.[w.type] ? { ...w, type: instead[w.type], options: {} } : w) }))
|
|
2979
|
+
}))
|
|
2980
|
+
}))
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2716
2984
|
// packages/core/src/layout/stack.ts
|
|
2717
2985
|
function pickInStack(entries, now, rotateMs) {
|
|
2718
2986
|
const urgent = entries.find((e) => e.visible && e.urgent);
|
|
@@ -2747,7 +3015,7 @@ function pickPage(pages, now, pinned) {
|
|
|
2747
3015
|
|
|
2748
3016
|
// packages/core/src/compositor.ts
|
|
2749
3017
|
init_src();
|
|
2750
|
-
import { createCanvas as
|
|
3018
|
+
import { createCanvas as createCanvas5, loadImage as loadImage3 } from "@napi-rs/canvas";
|
|
2751
3019
|
|
|
2752
3020
|
// packages/core/src/env.ts
|
|
2753
3021
|
init_src();
|
|
@@ -2891,10 +3159,108 @@ function baseContext(cfg, plugin, log, now) {
|
|
|
2891
3159
|
}
|
|
2892
3160
|
|
|
2893
3161
|
// packages/core/src/fonts.ts
|
|
2894
|
-
|
|
3162
|
+
init_src();
|
|
3163
|
+
import { existsSync as existsSync3, readdirSync } from "node:fs";
|
|
2895
3164
|
import { createRequire as createRequire2 } from "node:module";
|
|
2896
3165
|
import { dirname as dirname2, join as join3 } from "node:path";
|
|
2897
|
-
import { GlobalFonts as GlobalFonts2 } from "@napi-rs/canvas";
|
|
3166
|
+
import { createCanvas as createCanvas4, GlobalFonts as GlobalFonts2 } from "@napi-rs/canvas";
|
|
3167
|
+
|
|
3168
|
+
// packages/core/src/font-fallback.ts
|
|
3169
|
+
var CJK_FAMILIES = {
|
|
3170
|
+
Hant: ["Noto Sans CJK TC", "Noto Sans TC", "Source Han Sans TC", "Source Han Sans TW", "Microsoft JhengHei", "Microsoft JhengHei UI", "PingFang TC", "Heiti TC", "Sarasa Gothic TC", "AR PL UMing TW", "AR PL UKai TW", "PMingLiU", "MingLiU"],
|
|
3171
|
+
"Hant-HK": ["Noto Sans CJK HK", "Noto Sans HK", "Source Han Sans HK", "Microsoft JhengHei", "PingFang HK", "Sarasa Gothic HC", "AR PL UMing HK", "Noto Sans CJK TC", "Noto Sans TC", "PingFang TC", "MingLiU_HKSCS"],
|
|
3172
|
+
Hans: ["Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", "Source Han Sans CN", "Microsoft YaHei", "Microsoft YaHei UI", "PingFang SC", "Heiti SC", "Hiragino Sans GB", "STHeiti", "HarmonyOS Sans SC", "Sarasa Gothic SC", "WenQuanYi Zen Hei", "WenQuanYi Micro Hei", "AR PL UMing CN", "SimHei", "SimSun", "Droid Sans Fallback"],
|
|
3173
|
+
Jpan: ["Noto Sans CJK JP", "Noto Sans JP", "Source Han Sans JP", "Source Han Sans", "Yu Gothic", "Meiryo", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "IPAexGothic", "IPAGothic", "TakaoGothic", "VL Gothic"],
|
|
3174
|
+
Kore: ["Noto Sans CJK KR", "Noto Sans KR", "Source Han Sans KR", "Source Han Sans K", "Malgun Gothic", "Apple SD Gothic Neo", "NanumGothic", "UnDotum"]
|
|
3175
|
+
};
|
|
3176
|
+
var OTHER_SCRIPTS = [
|
|
3177
|
+
{ script: "Thai", probe: "\u0E01", families: ["Noto Sans Thai", "Noto Sans Thai UI", "Leelawadee UI", "Leelawadee", "Thonburi", "Tlwg Typo", "Garuda"] },
|
|
3178
|
+
{ script: "Deva", probe: "\u0915", families: ["Noto Sans Devanagari", "Nirmala UI", "Kohinoor Devanagari", "Lohit Devanagari", "Mangal"] },
|
|
3179
|
+
{ script: "Beng", probe: "\u0995", families: ["Noto Sans Bengali", "Nirmala UI", "Kohinoor Bangla", "Lohit Bengali"] },
|
|
3180
|
+
{ script: "Taml", probe: "\u0B95", families: ["Noto Sans Tamil", "Nirmala UI", "Tamil Sangam MN", "Lohit Tamil"] },
|
|
3181
|
+
{ script: "Arab", probe: "\u0639", families: ["Noto Sans Arabic", "Noto Naskh Arabic", "Segoe UI", "Geeza Pro", "DejaVu Sans"] },
|
|
3182
|
+
{ script: "Hebr", probe: "\u05D0", families: ["Noto Sans Hebrew", "Segoe UI", "Arial Hebrew", "DejaVu Sans"] },
|
|
3183
|
+
{ script: "Geor", probe: "\u10D0", families: ["Noto Sans Georgian", "Sylfaen", "DejaVu Sans"] },
|
|
3184
|
+
{ script: "Armn", probe: "\u0531", families: ["Noto Sans Armenian", "Sylfaen", "DejaVu Sans"] },
|
|
3185
|
+
{ script: "Ethi", probe: "\u12A0", families: ["Noto Sans Ethiopic", "Ebrima", "Kefa"] }
|
|
3186
|
+
];
|
|
3187
|
+
function scriptOrder(own) {
|
|
3188
|
+
const rest = ["Hans", "Hant", "Jpan", "Kore"];
|
|
3189
|
+
if (!own) return rest;
|
|
3190
|
+
const first = own === "Hant-HK" ? ["Hant-HK", "Hant"] : [own];
|
|
3191
|
+
return [...first, ...rest.filter((s) => !first.includes(s))];
|
|
3192
|
+
}
|
|
3193
|
+
function cjkFamiliesFor(locale, available2, own = []) {
|
|
3194
|
+
const out = [...own];
|
|
3195
|
+
for (const s of scriptOrder(hanScript(locale))) {
|
|
3196
|
+
const found = CJK_FAMILIES[s].find((f) => !out.includes(f) && available2(f));
|
|
3197
|
+
if (found) out.push(found);
|
|
3198
|
+
}
|
|
3199
|
+
return [...new Set(out)];
|
|
3200
|
+
}
|
|
3201
|
+
var BOLD_FAMILIES = [FONT_FAMILIES.sansBold, FONT_FAMILIES.monoBold];
|
|
3202
|
+
var FontFallback = class {
|
|
3203
|
+
tail = "";
|
|
3204
|
+
memo = /* @__PURE__ */ new Map();
|
|
3205
|
+
/** Sets the families; true if they changed (callers then forget measured widths). */
|
|
3206
|
+
setFamilies(families) {
|
|
3207
|
+
const tail = families.map((f) => `, "${f.replace(/"/g, "")}"`).join("");
|
|
3208
|
+
if (tail === this.tail) return false;
|
|
3209
|
+
this.tail = tail;
|
|
3210
|
+
this.memo.clear();
|
|
3211
|
+
return true;
|
|
3212
|
+
}
|
|
3213
|
+
/**
|
|
3214
|
+
* `font` with the families behind it. Kiosko's bold families are DejaVu
|
|
3215
|
+
* Bold files under their own name, so the string asks for no weight and
|
|
3216
|
+
* the CJK font would come out regular: ask for bold too, which the DejaVu
|
|
3217
|
+
* Bold face already is.
|
|
3218
|
+
*/
|
|
3219
|
+
apply(font) {
|
|
3220
|
+
if (!this.tail) return font;
|
|
3221
|
+
let out = this.memo.get(font);
|
|
3222
|
+
if (out === void 0) {
|
|
3223
|
+
out = font;
|
|
3224
|
+
if (!font.endsWith(this.tail)) {
|
|
3225
|
+
out = font + this.tail;
|
|
3226
|
+
const size = /\d*\.?\d+(px|pt|em|rem)\b/.exec(font);
|
|
3227
|
+
const before = size ? font.slice(0, size.index) : "";
|
|
3228
|
+
const after = size ? font.slice(size.index) : font;
|
|
3229
|
+
if (BOLD_FAMILIES.some((f) => after.includes(f)) && !/\b(bold|bolder|[1-9]00)\b/.test(before)) out = `bold ${out}`;
|
|
3230
|
+
}
|
|
3231
|
+
if (this.memo.size > 2e3) this.memo.clear();
|
|
3232
|
+
this.memo.set(font, out);
|
|
3233
|
+
}
|
|
3234
|
+
return out;
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
var SET = Symbol("kiosko.fontSet");
|
|
3238
|
+
var GOT = Symbol("kiosko.fontGot");
|
|
3239
|
+
function hookFont(proto, apply) {
|
|
3240
|
+
const desc = Object.getOwnPropertyDescriptor(proto, "font");
|
|
3241
|
+
if (!desc?.set || !desc.get || !desc.configurable) return null;
|
|
3242
|
+
const { get, set } = desc;
|
|
3243
|
+
Object.defineProperty(proto, "font", {
|
|
3244
|
+
configurable: true,
|
|
3245
|
+
enumerable: desc.enumerable ?? false,
|
|
3246
|
+
get() {
|
|
3247
|
+
const now = get.call(this);
|
|
3248
|
+
return now === this[GOT] ? this[SET] : now;
|
|
3249
|
+
},
|
|
3250
|
+
set(value) {
|
|
3251
|
+
const before = get.call(this);
|
|
3252
|
+
set.call(this, apply(String(value)));
|
|
3253
|
+
const after = get.call(this);
|
|
3254
|
+
if (after !== before || this[GOT] === void 0 || this[SET] === String(value)) {
|
|
3255
|
+
this[SET] = String(value);
|
|
3256
|
+
this[GOT] = after;
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
});
|
|
3260
|
+
return desc;
|
|
3261
|
+
}
|
|
3262
|
+
|
|
3263
|
+
// packages/core/src/fonts.ts
|
|
2898
3264
|
var require2 = createRequire2(import.meta.url);
|
|
2899
3265
|
var done = false;
|
|
2900
3266
|
function ttfDir() {
|
|
@@ -2912,14 +3278,125 @@ var FILES = [
|
|
|
2912
3278
|
];
|
|
2913
3279
|
function registerFonts(extra = []) {
|
|
2914
3280
|
if (done && !extra.length) return;
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
const
|
|
2918
|
-
|
|
3281
|
+
if (!done) {
|
|
3282
|
+
const dir = ttfDir();
|
|
3283
|
+
for (const [family, file, fallback2] of FILES) {
|
|
3284
|
+
const p = dir && existsSync3(join3(dir, file)) ? join3(dir, file) : fallback2;
|
|
3285
|
+
if (existsSync3(p)) GlobalFonts2.registerFromPath(p, family);
|
|
3286
|
+
}
|
|
3287
|
+
installFallbackHook();
|
|
2919
3288
|
}
|
|
2920
3289
|
for (const f of extra) if (existsSync3(f.path)) GlobalFonts2.registerFromPath(f.path, f.family);
|
|
2921
3290
|
done = true;
|
|
2922
3291
|
}
|
|
3292
|
+
var PROBE = "\u9AD4";
|
|
3293
|
+
var missingPixels = /* @__PURE__ */ new Map();
|
|
3294
|
+
var available = /* @__PURE__ */ new Map();
|
|
3295
|
+
var probeCanvas = null;
|
|
3296
|
+
function pixelsOf(font, probe = PROBE) {
|
|
3297
|
+
probeCanvas ??= createCanvas4(40, 40);
|
|
3298
|
+
const g = probeCanvas.getContext("2d");
|
|
3299
|
+
g.clearRect(0, 0, 40, 40);
|
|
3300
|
+
if (nativeFont?.set) nativeFont.set.call(g, font);
|
|
3301
|
+
else g.font = font;
|
|
3302
|
+
g.fillStyle = "#000";
|
|
3303
|
+
g.textBaseline = "top";
|
|
3304
|
+
g.fillText(probe, 4, 4);
|
|
3305
|
+
return Buffer.from(g.getImageData(0, 0, 40, 40).data.buffer).toString("base64");
|
|
3306
|
+
}
|
|
3307
|
+
function hasFontFamily(family, probe = PROBE) {
|
|
3308
|
+
const key = `${family}\0${probe}`;
|
|
3309
|
+
let yes = available.get(key);
|
|
3310
|
+
if (yes === void 0) {
|
|
3311
|
+
let missing = missingPixels.get(probe);
|
|
3312
|
+
if (missing === void 0) missingPixels.set(probe, missing = pixelsOf('28px "Kiosko Missing Font"', probe));
|
|
3313
|
+
yes = pixelsOf(`28px "${family.replace(/"/g, "")}"`, probe) !== missing;
|
|
3314
|
+
available.set(key, yes);
|
|
3315
|
+
}
|
|
3316
|
+
return yes;
|
|
3317
|
+
}
|
|
3318
|
+
var userFamilies = null;
|
|
3319
|
+
function loadUserFonts() {
|
|
3320
|
+
if (userFamilies) return userFamilies;
|
|
3321
|
+
userFamilies = [];
|
|
3322
|
+
const dir = join3(paths.home, "fonts");
|
|
3323
|
+
if (!existsSync3(dir)) return userFamilies;
|
|
3324
|
+
const before = new Set(GlobalFonts2.families.map((f) => f.family));
|
|
3325
|
+
let files = [];
|
|
3326
|
+
try {
|
|
3327
|
+
files = readdirSync(dir).filter((f) => /\.(otf|ttf|ttc|woff2?)$/i.test(f));
|
|
3328
|
+
} catch {
|
|
3329
|
+
return userFamilies;
|
|
3330
|
+
}
|
|
3331
|
+
for (const f of files.sort()) GlobalFonts2.registerFromPath(join3(dir, f));
|
|
3332
|
+
userFamilies = GlobalFonts2.families.map((f) => f.family).filter((f) => !before.has(f));
|
|
3333
|
+
return userFamilies;
|
|
3334
|
+
}
|
|
3335
|
+
var chosen = /* @__PURE__ */ new Map();
|
|
3336
|
+
function cjkFonts(locale) {
|
|
3337
|
+
const script = hanScript(locale);
|
|
3338
|
+
const key = script ?? "-";
|
|
3339
|
+
let out = chosen.get(key);
|
|
3340
|
+
if (!out) {
|
|
3341
|
+
const fromUser = loadUserFonts().filter((f) => hasFontFamily(f));
|
|
3342
|
+
const families = cjkFamiliesFor(locale, hasFontFamily, fromUser);
|
|
3343
|
+
out = { script, families, fromUser };
|
|
3344
|
+
chosen.set(key, out);
|
|
3345
|
+
}
|
|
3346
|
+
return out;
|
|
3347
|
+
}
|
|
3348
|
+
function userFontsDir() {
|
|
3349
|
+
return join3(paths.home, "fonts");
|
|
3350
|
+
}
|
|
3351
|
+
var fallback = new FontFallback();
|
|
3352
|
+
function setFontLocale(locale) {
|
|
3353
|
+
if (fallback.setFamilies([.../* @__PURE__ */ new Set([...cjkFonts(locale).families, ...otherScriptFonts().map((f) => f.family)])])) clearTextCache();
|
|
3354
|
+
}
|
|
3355
|
+
var others = null;
|
|
3356
|
+
function otherScriptFonts() {
|
|
3357
|
+
if (!others) {
|
|
3358
|
+
registerFonts();
|
|
3359
|
+
others = [];
|
|
3360
|
+
for (const o of OTHER_SCRIPTS) {
|
|
3361
|
+
const family = o.families.find((f) => hasFontFamily(f, o.probe));
|
|
3362
|
+
if (family) others.push({ script: o.script, family });
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
return others;
|
|
3366
|
+
}
|
|
3367
|
+
function scriptFontStatus(locale) {
|
|
3368
|
+
let script;
|
|
3369
|
+
try {
|
|
3370
|
+
script = new Intl.Locale(locale.replace(/_/g, "-").replace(/[.@].*$/, "")).maximize().script;
|
|
3371
|
+
} catch {
|
|
3372
|
+
return null;
|
|
3373
|
+
}
|
|
3374
|
+
const wanted = OTHER_SCRIPTS.find((o) => o.script === script);
|
|
3375
|
+
if (!wanted) return null;
|
|
3376
|
+
const found = otherScriptFonts().find((f) => f.script === script);
|
|
3377
|
+
if (found) return { ok: true, line: `${script} text drawn with ${found.family}` };
|
|
3378
|
+
return { ok: false, line: `no font for ${script} text: it would show as empty boxes; install ${wanted.families[0]} (Debian/Ubuntu: fonts-noto-core), or put an .otf in ${userFontsDir()}` };
|
|
3379
|
+
}
|
|
3380
|
+
function withFallback(font) {
|
|
3381
|
+
return fallback.apply(font);
|
|
3382
|
+
}
|
|
3383
|
+
var nativeFont = null;
|
|
3384
|
+
function installFallbackHook() {
|
|
3385
|
+
if (nativeFont) return;
|
|
3386
|
+
nativeFont = hookFont(Object.getPrototypeOf(createCanvas4(1, 1).getContext("2d")), withFallback);
|
|
3387
|
+
}
|
|
3388
|
+
function cjkFontHint() {
|
|
3389
|
+
const install = process.platform === "win32" ? "Microsoft JhengHei and YaHei come with Windows: if they are missing, add the Chinese supplemental fonts in Settings \u203A Apps \u203A Optional features" : process.platform === "darwin" ? "macOS ships PingFang; reinstall it from Font Book" : "install Noto Sans CJK (Debian/Ubuntu: fonts-noto-cjk, Fedora: google-noto-sans-cjk-fonts, Arch: noto-fonts-cjk)";
|
|
3390
|
+
return `${install}, or put an .otf such as Noto Sans TC or SC in ${userFontsDir()}`;
|
|
3391
|
+
}
|
|
3392
|
+
function cjkFontStatus(locale) {
|
|
3393
|
+
registerFonts();
|
|
3394
|
+
const { script, families, fromUser } = cjkFonts(locale);
|
|
3395
|
+
if (!families.length) return { ok: false, line: `no Chinese/Japanese/Korean font: those characters would show as empty boxes; ${cjkFontHint()}` };
|
|
3396
|
+
const first = families[0];
|
|
3397
|
+
const more = families.length > 1 ? ` (+${families.length - 1} for other scripts)` : "";
|
|
3398
|
+
return { ok: true, line: `CJK text drawn with ${first}${fromUser.includes(first) ? " (yours)" : ""}${script ? ` for ${script}` : ""}${more}` };
|
|
3399
|
+
}
|
|
2923
3400
|
|
|
2924
3401
|
// packages/core/src/compositor.ts
|
|
2925
3402
|
var images = /* @__PURE__ */ new Map();
|
|
@@ -2961,12 +3438,12 @@ function tileState(def, inst, state) {
|
|
|
2961
3438
|
const urgent = takeOver && safe(() => def.urgent?.(state) ?? false, false);
|
|
2962
3439
|
return { visible, urgent };
|
|
2963
3440
|
}
|
|
2964
|
-
function safe(fn,
|
|
2965
|
-
if (!fn) return
|
|
3441
|
+
function safe(fn, fallback2) {
|
|
3442
|
+
if (!fn) return fallback2;
|
|
2966
3443
|
try {
|
|
2967
3444
|
return fn();
|
|
2968
3445
|
} catch {
|
|
2969
|
-
return
|
|
3446
|
+
return fallback2;
|
|
2970
3447
|
}
|
|
2971
3448
|
}
|
|
2972
3449
|
function redrawStep(def, state) {
|
|
@@ -3043,7 +3520,7 @@ function paintTile(g, input, tile, rect2, out, nextAt, idles, animatable) {
|
|
|
3043
3520
|
const [plugin] = r.inst.type.split("/");
|
|
3044
3521
|
safe(() => r.def.animationEnded?.({ ...baseContext(input.cfg, plugin, input.log ?? (() => void 0), input.now), options: r.options, plan, completed, data: r.data }), void 0);
|
|
3045
3522
|
},
|
|
3046
|
-
ask: (trigger, rnd, prev) => safe(() => animation({ ...state, box: tileBoxes(theme, input.screen.height, r.inst, rect2, chrome).box, trigger, rnd, ...prev !== void 0 ? { prev } : {} }), null)
|
|
3523
|
+
ask: (trigger, rnd, prev) => safe(() => animation({ ...state, box: tileBoxes(theme, input.screen.height, r.inst, rect2, chrome, input.screen.textScale).box, trigger, rnd, ...prev !== void 0 ? { prev } : {} }), null)
|
|
3047
3524
|
});
|
|
3048
3525
|
}
|
|
3049
3526
|
const frame = input.animate?.find((a) => a.tileId === tile.id && a.instanceId === r.inst.id)?.frame;
|
|
@@ -3053,7 +3530,7 @@ function paintTile(g, input, tile, rect2, out, nextAt, idles, animatable) {
|
|
|
3053
3530
|
return;
|
|
3054
3531
|
}
|
|
3055
3532
|
const cfg = input.cfg;
|
|
3056
|
-
const key = JSON.stringify([r.inst.id, r.inst.type, r.inst.options, r.inst.title ?? "", zoomOf(r.inst), chrome, rect2, theme.id, step ? Math.floor(now / step) : 0, cfg.locale, cfg.timeFormat, cfg.workday, cfg.location ?? null, working]);
|
|
3533
|
+
const key = JSON.stringify([r.inst.id, r.inst.type, r.inst.options, r.inst.title ?? "", zoomOf(r.inst), input.screen.textScale ?? 1, legibleCjkPx(input.screen), chrome, rect2, theme.id, step ? Math.floor(now / step) : 0, cfg.locale, cfg.timeFormat, cfg.workday, cfg.location ?? null, working]);
|
|
3057
3534
|
const refs = [r.data, ...(r.def.sources ?? []).map((s) => r.sources[s])];
|
|
3058
3535
|
const hit = input.cache.get(tile.id);
|
|
3059
3536
|
if (hit && hit.key === key && hit.refs.length === refs.length && hit.refs.every((x, i) => x === refs[i])) {
|
|
@@ -3061,19 +3538,19 @@ function paintTile(g, input, tile, rect2, out, nextAt, idles, animatable) {
|
|
|
3061
3538
|
if (hit.error) out.error = hit.error;
|
|
3062
3539
|
return;
|
|
3063
3540
|
}
|
|
3064
|
-
const canvas =
|
|
3541
|
+
const canvas = createCanvas5(rect2.w, rect2.h);
|
|
3065
3542
|
const tg = canvas.getContext("2d");
|
|
3066
3543
|
tg.translate(-rect2.x, -rect2.y);
|
|
3067
3544
|
draw(tg);
|
|
3068
3545
|
g.drawImage(canvas, rect2.x, rect2.y);
|
|
3069
3546
|
input.cache.set(tile.id, { key, refs, canvas, ...out.error ? { error: out.error } : {} });
|
|
3070
3547
|
}
|
|
3071
|
-
function tileBoxes(theme, screenH, inst, rect2, chrome) {
|
|
3548
|
+
function tileBoxes(theme, screenH, inst, rect2, chrome, textScale = 1) {
|
|
3072
3549
|
const m = chromeMetrics(theme, screenH, rect2);
|
|
3073
3550
|
const pad = chrome === "card" ? m.pad : 0;
|
|
3074
3551
|
const top = rect2.y + pad + (inst.title?.trim() && chrome === "card" ? m.titleBar : 0);
|
|
3075
3552
|
const outer = { x: rect2.x + pad, y: top, w: Math.max(1, rect2.w - 2 * pad), h: Math.max(1, rect2.y + rect2.h - pad - top) };
|
|
3076
|
-
const zoom = zoomOf(inst);
|
|
3553
|
+
const zoom = Math.round(zoomOf(inst) * textScale * 100) / 100;
|
|
3077
3554
|
const box = zoom === 1 ? outer : { x: outer.x, y: outer.y, w: Math.max(1, outer.w / zoom), h: Math.max(1, outer.h / zoom) };
|
|
3078
3555
|
return { outer, box, zoom };
|
|
3079
3556
|
}
|
|
@@ -3089,7 +3566,7 @@ function drawTileContent(g, input, r, rect2, chrome, out, anim) {
|
|
|
3089
3566
|
g.textBaseline = "alphabetic";
|
|
3090
3567
|
g.fillText(fitText(g, title, rect2.w - 2 * pad), rect2.x + pad, rect2.y + pad + m.title * 0.8);
|
|
3091
3568
|
}
|
|
3092
|
-
const { outer, box, zoom } = tileBoxes(theme, input.screen.height, r.inst, rect2, chrome);
|
|
3569
|
+
const { outer, box, zoom } = tileBoxes(theme, input.screen.height, r.inst, rect2, chrome, input.screen.textScale);
|
|
3093
3570
|
const [plugin] = r.inst.type.split("/");
|
|
3094
3571
|
const ctx = {
|
|
3095
3572
|
...baseContext(input.cfg, plugin, input.log ?? (() => void 0), now),
|
|
@@ -3111,10 +3588,13 @@ function drawTileContent(g, input, r, rect2, chrome, out, anim) {
|
|
|
3111
3588
|
}
|
|
3112
3589
|
const t0 = performance.now();
|
|
3113
3590
|
try {
|
|
3591
|
+
src_exports.takeCjkEnlarged();
|
|
3114
3592
|
r.def.render(g, ctx);
|
|
3115
3593
|
out.renderMs = performance.now() - t0;
|
|
3594
|
+
const small = src_exports.takeCjkEnlarged();
|
|
3595
|
+
if (small !== null) out.cjkEnlarged = small;
|
|
3116
3596
|
} catch (err) {
|
|
3117
|
-
out.error = err
|
|
3597
|
+
out.error = errorMessage(err, ctx.locale);
|
|
3118
3598
|
input.log?.(r.inst.type, `render failed: ${out.error}`);
|
|
3119
3599
|
const size = Math.max(12, Math.min(20, box.h / 4));
|
|
3120
3600
|
src_exports.drawTracked(g, src_exports.truncate(g, `\u26A0 ${localize(r.def.name, ctx.locale)}: ${out.error}`, box.w, { size, family: theme.fonts.mono }), box.x, box.y + size * 1.2, { size, family: theme.fonts.mono, color: theme.colors.alert });
|
|
@@ -3123,9 +3603,18 @@ function drawTileContent(g, input, r, rect2, chrome, out, anim) {
|
|
|
3123
3603
|
}
|
|
3124
3604
|
function composePage(input) {
|
|
3125
3605
|
registerFonts();
|
|
3606
|
+
setFontLocale(resolveLocale(input.cfg));
|
|
3607
|
+
src_exports.setMinCjkPx(legibleCjkPx(input.screen));
|
|
3126
3608
|
const { screen, page, theme, now } = input;
|
|
3127
|
-
const
|
|
3609
|
+
const rotate = ((input.rotate ?? 0) % 360 + 360) % 360;
|
|
3610
|
+
const swap = rotate === 90 || rotate === 270;
|
|
3611
|
+
const canvas = createCanvas5(swap ? screen.height : screen.width, swap ? screen.width : screen.height);
|
|
3128
3612
|
const g = canvas.getContext("2d");
|
|
3613
|
+
if (rotate) {
|
|
3614
|
+
g.translate(canvas.width / 2, canvas.height / 2);
|
|
3615
|
+
g.rotate(rotate * Math.PI / 180);
|
|
3616
|
+
g.translate(-screen.width / 2, -screen.height / 2);
|
|
3617
|
+
}
|
|
3129
3618
|
g.fillStyle = page.background.color || theme.colors.bg;
|
|
3130
3619
|
g.fillRect(0, 0, screen.width, screen.height);
|
|
3131
3620
|
if (page.background.image) {
|
|
@@ -3158,7 +3647,7 @@ function composePage(input) {
|
|
|
3158
3647
|
function rotateCanvas(src, rotate) {
|
|
3159
3648
|
if (!rotate) return src;
|
|
3160
3649
|
const swap = rotate === 90 || rotate === 270;
|
|
3161
|
-
const out =
|
|
3650
|
+
const out = createCanvas5(swap ? src.height : src.width, swap ? src.width : src.height);
|
|
3162
3651
|
const g = out.getContext("2d");
|
|
3163
3652
|
g.translate(out.width / 2, out.height / 2);
|
|
3164
3653
|
g.rotate(rotate * Math.PI / 180);
|
|
@@ -3349,7 +3838,7 @@ var SourceHub = class {
|
|
|
3349
3838
|
try {
|
|
3350
3839
|
st.stop = def.watch(this.ctx(cfg, st), (data) => this.set(st, data));
|
|
3351
3840
|
} catch (err) {
|
|
3352
|
-
st.error = msg(err);
|
|
3841
|
+
st.error = msg(err, cfg);
|
|
3353
3842
|
this.log(type, `watch failed: ${st.error}`);
|
|
3354
3843
|
}
|
|
3355
3844
|
}
|
|
@@ -3381,7 +3870,7 @@ var SourceHub = class {
|
|
|
3381
3870
|
st.inflight = true;
|
|
3382
3871
|
const d = deadline(st.abort.signal, st.timeoutMs);
|
|
3383
3872
|
const fail = (err) => {
|
|
3384
|
-
st.error = d.timedOut() ? timedOutMsg(st.timeoutMs) : msg(err);
|
|
3873
|
+
st.error = d.timedOut() ? timedOutMsg(st.timeoutMs) : msg(err, cfg);
|
|
3385
3874
|
this.log(st.type, `read failed: ${st.error}`);
|
|
3386
3875
|
st.nextAt = Date.now() + Math.min(RETRY_MS, st.intervalMs);
|
|
3387
3876
|
};
|
|
@@ -3496,7 +3985,7 @@ var FetchHost = class {
|
|
|
3496
3985
|
}
|
|
3497
3986
|
}).catch((err) => {
|
|
3498
3987
|
if (st.abort.signal.aborted) return;
|
|
3499
|
-
st.error = d.timedOut() ? timedOutMsg(st.timeoutMs) : msg(err);
|
|
3988
|
+
st.error = d.timedOut() ? timedOutMsg(st.timeoutMs) : msg(err, cfg);
|
|
3500
3989
|
this.log(st.type, `fetch failed: ${st.error}`);
|
|
3501
3990
|
st.nextAt = Date.now() + Math.min(RETRY_MS, st.intervalMs);
|
|
3502
3991
|
}).finally(() => {
|
|
@@ -3529,8 +4018,8 @@ var FetchHost = class {
|
|
|
3529
4018
|
}
|
|
3530
4019
|
}
|
|
3531
4020
|
};
|
|
3532
|
-
function msg(err) {
|
|
3533
|
-
return err
|
|
4021
|
+
function msg(err, cfg) {
|
|
4022
|
+
return errorMessage(err, resolveLocale(cfg));
|
|
3534
4023
|
}
|
|
3535
4024
|
|
|
3536
4025
|
// packages/core/src/devices.ts
|
|
@@ -3796,11 +4285,11 @@ var LyPanel = class _LyPanel {
|
|
|
3796
4285
|
};
|
|
3797
4286
|
|
|
3798
4287
|
// packages/trcc-client/src/client.ts
|
|
3799
|
-
import { readdirSync, readFileSync as readFileSync2 } from "node:fs";
|
|
4288
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
3800
4289
|
function usbPathForSerial(serial, root = "/sys/bus/usb/devices") {
|
|
3801
4290
|
let entries = [];
|
|
3802
4291
|
try {
|
|
3803
|
-
entries =
|
|
4292
|
+
entries = readdirSync2(root);
|
|
3804
4293
|
} catch {
|
|
3805
4294
|
return null;
|
|
3806
4295
|
}
|
|
@@ -3981,13 +4470,25 @@ function pinFrame(o, key, intervalS, onError) {
|
|
|
3981
4470
|
}
|
|
3982
4471
|
|
|
3983
4472
|
// packages/core/src/devices.ts
|
|
4473
|
+
function coded(message, code, params) {
|
|
4474
|
+
return Object.assign(new Error(message), { code, params });
|
|
4475
|
+
}
|
|
4476
|
+
function statusOfError(err) {
|
|
4477
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
4478
|
+
const e = err;
|
|
4479
|
+
if (e && typeof e.code === "string" && /^[a-z][A-Za-z]+$/.test(e.code)) return { message, code: e.code, params: e.params };
|
|
4480
|
+
if (e?.name === "PanelNotFound" || /no LY panel found|no panel with serial/.test(message)) return { message, code: "usbNotFound" };
|
|
4481
|
+
if (/LIBUSB_ERROR_ACCESS|EACCES|access denied/i.test(message)) return { message, code: "usbAccess" };
|
|
4482
|
+
if (e?.name === "UsbUnavailable" || /cannot load the "usb" package/.test(message)) return { message, code: "usbUnavailable" };
|
|
4483
|
+
return { message, code: "error", params: { error: message } };
|
|
4484
|
+
}
|
|
3984
4485
|
function encodeFor(device, jpegQuality) {
|
|
3985
4486
|
if (device.driver === "file") return device.format ?? "jpeg";
|
|
3986
4487
|
if (device.driver === "usb") return "jpeg";
|
|
3987
4488
|
return jpegQuality > 0 ? "jpeg" : "png";
|
|
3988
4489
|
}
|
|
3989
4490
|
var VirtualDevice = class {
|
|
3990
|
-
status = { driver: "virtual", ok: true, message: "virtual: shown only in the editor", framesSent: 0, lastSentAt: null };
|
|
4491
|
+
status = { driver: "virtual", ok: true, message: "virtual: shown only in the editor", code: "virtual", framesSent: 0, lastSentAt: null };
|
|
3991
4492
|
async send() {
|
|
3992
4493
|
this.status.framesSent++;
|
|
3993
4494
|
this.status.lastSentAt = Date.now();
|
|
@@ -4012,7 +4513,7 @@ var FileDevice = class {
|
|
|
4012
4513
|
dir;
|
|
4013
4514
|
constructor(cfg) {
|
|
4014
4515
|
this.dir = expandPath(cfg.dir);
|
|
4015
|
-
this.status = { driver: "file", ok: true, message: `writing ${join4(this.dir, "frame.jpg")}`, framesSent: 0, lastSentAt: null };
|
|
4516
|
+
this.status = { driver: "file", ok: true, message: `writing ${join4(this.dir, "frame.jpg")}`, code: "fileWriting", params: { path: join4(this.dir, "frame.jpg") }, framesSent: 0, lastSentAt: null };
|
|
4016
4517
|
}
|
|
4017
4518
|
async send(frame) {
|
|
4018
4519
|
try {
|
|
@@ -4025,14 +4526,15 @@ var FileDevice = class {
|
|
|
4025
4526
|
this.status.lastSentAt = Date.now();
|
|
4026
4527
|
} catch (err) {
|
|
4027
4528
|
this.status.ok = false;
|
|
4028
|
-
|
|
4529
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
4530
|
+
Object.assign(this.status, { message: `cannot write in ${this.dir}: ${error}`, code: "fileError", params: { dir: this.dir, error } });
|
|
4029
4531
|
}
|
|
4030
4532
|
}
|
|
4031
4533
|
close() {
|
|
4032
4534
|
}
|
|
4033
4535
|
};
|
|
4034
4536
|
var TrccDevice = class {
|
|
4035
|
-
status = { driver: "trcc", ok: false, message: "connecting\u2026", framesSent: 0, lastSentAt: null };
|
|
4537
|
+
status = { driver: "trcc", ok: false, message: "connecting\u2026", code: "connecting", framesSent: 0, lastSentAt: null };
|
|
4036
4538
|
key = null;
|
|
4037
4539
|
connecting = null;
|
|
4038
4540
|
stopPin = null;
|
|
@@ -4045,13 +4547,13 @@ var TrccDevice = class {
|
|
|
4045
4547
|
this.o = { url: cfg.url, ...cfg.tokenFile ? { tokenFile: expandPath(cfg.tokenFile) } : {}, timeoutMs: 2e4, deviceKey: cfg.deviceKey ?? "", ...cfg.serial ? { serial: cfg.serial } : {} };
|
|
4046
4548
|
}
|
|
4047
4549
|
async connect() {
|
|
4048
|
-
if (!await serverAlive(this.o)) throw
|
|
4550
|
+
if (!await serverAlive(this.o)) throw coded(`trcc serve is not answering at ${this.cfg.url}`, "trccDown", { url: this.cfg.url });
|
|
4049
4551
|
const panel = await detectPanel(this.o);
|
|
4050
|
-
if (!panel) throw
|
|
4552
|
+
if (!panel) throw coded("trcc serve sees no panel", "trccNoPanel");
|
|
4051
4553
|
await connectPanel(this.o, panel.key);
|
|
4052
4554
|
this.key = panel.key;
|
|
4053
4555
|
this.status.detected = { width: panel.width, height: panel.height };
|
|
4054
|
-
this.status
|
|
4556
|
+
Object.assign(this.status, { message: `panel ${panel.key} ${panel.width}\xD7${panel.height}`, code: "trccPanel", params: { key: panel.key, width: panel.width, height: panel.height } });
|
|
4055
4557
|
if (this.cfg.keepalive !== false) this.stopPin = pinFrame(this.o, panel.key, 30, (m) => this.log(m));
|
|
4056
4558
|
}
|
|
4057
4559
|
async send(frame) {
|
|
@@ -4069,7 +4571,7 @@ var TrccDevice = class {
|
|
|
4069
4571
|
this.stopPin?.();
|
|
4070
4572
|
this.stopPin = null;
|
|
4071
4573
|
this.status.ok = false;
|
|
4072
|
-
this.status
|
|
4574
|
+
Object.assign(this.status, statusOfError(err));
|
|
4073
4575
|
}
|
|
4074
4576
|
}
|
|
4075
4577
|
close() {
|
|
@@ -4077,7 +4579,7 @@ var TrccDevice = class {
|
|
|
4077
4579
|
}
|
|
4078
4580
|
};
|
|
4079
4581
|
var UsbDevice = class {
|
|
4080
|
-
status = { driver: "usb", ok: false, message: "connecting\u2026", framesSent: 0, lastSentAt: null };
|
|
4582
|
+
status = { driver: "usb", ok: false, message: "connecting\u2026", code: "connecting", framesSent: 0, lastSentAt: null };
|
|
4081
4583
|
cfg;
|
|
4082
4584
|
log;
|
|
4083
4585
|
rotate;
|
|
@@ -4103,9 +4605,11 @@ var UsbDevice = class {
|
|
|
4103
4605
|
this.timer = setInterval(() => void this.pump(), Math.min(every, 250));
|
|
4104
4606
|
this.timer.unref();
|
|
4105
4607
|
}
|
|
4106
|
-
say(message, ok) {
|
|
4608
|
+
say(message, ok, code, params) {
|
|
4107
4609
|
this.status.ok = ok;
|
|
4108
4610
|
this.status.message = message;
|
|
4611
|
+
this.status.code = code;
|
|
4612
|
+
this.status.params = params;
|
|
4109
4613
|
if (message !== this.lastMessage) {
|
|
4110
4614
|
this.lastMessage = message;
|
|
4111
4615
|
this.log(message);
|
|
@@ -4128,8 +4632,9 @@ var UsbDevice = class {
|
|
|
4128
4632
|
this.failures = 0;
|
|
4129
4633
|
this.status.framesSent++;
|
|
4130
4634
|
this.status.lastSentAt = this.lastWrite;
|
|
4131
|
-
|
|
4132
|
-
|
|
4635
|
+
const kb2 = Math.round(frame.length / 1024), limit = Math.round(MAX_FRAME_BYTES / 1024);
|
|
4636
|
+
if (!kept) this.say(`the panel dropped a ${kb2} KB frame (limit ${limit} KB): lower the JPEG quality`, false, "usbDropped", { kb: kb2, limit });
|
|
4637
|
+
else if (!this.status.ok) this.say(this.describe(), true, "usbConnected", { panel: this.describe() });
|
|
4133
4638
|
} catch (err) {
|
|
4134
4639
|
this.fresh = true;
|
|
4135
4640
|
const p = this.panel;
|
|
@@ -4138,7 +4643,9 @@ var UsbDevice = class {
|
|
|
4138
4643
|
this.failures++;
|
|
4139
4644
|
this.retryAt = Date.now() + Math.min(30 * this.retryMs, this.retryMs * 2 ** Math.min(this.failures, 5));
|
|
4140
4645
|
const why = err instanceof Error ? err.message : String(err);
|
|
4141
|
-
this.
|
|
4646
|
+
const serial = this.cfg.serial && !why.includes(this.cfg.serial) ? ` (serial ${this.cfg.serial})` : "";
|
|
4647
|
+
const known = statusOfError(err);
|
|
4648
|
+
this.say(`${why}${serial}; retrying`, false, "usbRetrying", { why, reason: known.code && known.code !== "error" ? known.code : "", serial: this.cfg.serial ?? "" });
|
|
4142
4649
|
}
|
|
4143
4650
|
}
|
|
4144
4651
|
};
|
|
@@ -4158,7 +4665,7 @@ var UsbDevice = class {
|
|
|
4158
4665
|
this.status.detected = { width: m.width, height: m.height, rotate: m.rotate };
|
|
4159
4666
|
if (this.rotate !== void 0 && ((this.rotate - m.rotate) % 360 + 360) % 360 === 180) this.log(`the panel's firmware expects rotation ${m.rotate}\xB0 but this screen has ${this.rotate}\xB0: the picture may come out upside down`);
|
|
4160
4667
|
}
|
|
4161
|
-
this.say(this.describe(), true);
|
|
4668
|
+
this.say(this.describe(), true, "usbConnected", { panel: this.describe() });
|
|
4162
4669
|
}
|
|
4163
4670
|
async send(frame) {
|
|
4164
4671
|
this.latest = frame;
|
|
@@ -4228,9 +4735,9 @@ async function discoverTrcc(url2 = "http://127.0.0.1:8099", tokenFile) {
|
|
|
4228
4735
|
|
|
4229
4736
|
// packages/core/src/runtime.ts
|
|
4230
4737
|
var TICK_MS = 250;
|
|
4231
|
-
function lazyJpeg(c) {
|
|
4738
|
+
function lazyJpeg(c, turned = 0) {
|
|
4232
4739
|
let b = null;
|
|
4233
|
-
return () => b ??= c.toBuffer("image/jpeg", 88);
|
|
4740
|
+
return () => b ??= (turned ? rotateCanvas(c, (360 - turned) % 360) : c).toBuffer("image/jpeg", 88);
|
|
4234
4741
|
}
|
|
4235
4742
|
function encode(c, kind, quality) {
|
|
4236
4743
|
return kind === "jpeg" ? c.encode("jpeg", Math.max(1, Math.min(100, quality || 90))) : c.encode("png");
|
|
@@ -4368,7 +4875,8 @@ var ScreenRunner = class {
|
|
|
4368
4875
|
sourcesOf: (types2) => this.rt.hub.pick(types2),
|
|
4369
4876
|
log: this.rt.log,
|
|
4370
4877
|
demo: this.rt.demoMode,
|
|
4371
|
-
cache: this.tiles
|
|
4878
|
+
cache: this.tiles,
|
|
4879
|
+
rotate: screen.rotate
|
|
4372
4880
|
});
|
|
4373
4881
|
canvas = result.canvas;
|
|
4374
4882
|
this.animatable = result.animatable;
|
|
@@ -4379,22 +4887,23 @@ var ScreenRunner = class {
|
|
|
4379
4887
|
this.rt.paintTimes.record(t2.shown, type, t2.renderMs, now, this.rt.log);
|
|
4380
4888
|
}
|
|
4381
4889
|
} else {
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
g.fillStyle = "#000";
|
|
4385
|
-
g.fillRect(0, 0, screen.width, screen.height);
|
|
4890
|
+
const swap = screen.rotate === 90 || screen.rotate === 270;
|
|
4891
|
+
canvas = CANVAS.createCanvas(swap ? screen.height : screen.width, swap ? screen.width : screen.height);
|
|
4386
4892
|
this.animatable = [];
|
|
4387
4893
|
this.nextAt = now + 6e4;
|
|
4388
4894
|
}
|
|
4389
4895
|
const sleeping = this.off || !!(screen.sleepWhenIdle && result?.idle);
|
|
4390
|
-
if (sleeping) {
|
|
4896
|
+
if (sleeping || !result) {
|
|
4391
4897
|
const g = canvas.getContext("2d");
|
|
4898
|
+
g.save();
|
|
4899
|
+
g.setTransform(1, 0, 0, 1, 0, 0);
|
|
4392
4900
|
g.fillStyle = "#000";
|
|
4393
|
-
g.fillRect(0, 0,
|
|
4901
|
+
g.fillRect(0, 0, canvas.width, canvas.height);
|
|
4902
|
+
g.restore();
|
|
4394
4903
|
}
|
|
4395
4904
|
const kind = encodeFor(screen.device, screen.jpegQuality);
|
|
4396
|
-
const out = await this.fit(
|
|
4397
|
-
this.lastInfo = { screenId: screen.id, pageId: page?.id ?? null, at: now, image: lazyJpeg(canvas), tiles: result?.tiles ?? [], interlude: null, sleeping };
|
|
4905
|
+
const out = await this.fit(canvas, kind, screen.jpegQuality, screen);
|
|
4906
|
+
this.lastInfo = { screenId: screen.id, pageId: page?.id ?? null, at: now, image: lazyJpeg(canvas, screen.rotate), tiles: result?.tiles ?? [], interlude: null, sleeping };
|
|
4398
4907
|
this.rt.emit("frame", this.lastInfo);
|
|
4399
4908
|
if (this.last?.equals(out)) return;
|
|
4400
4909
|
this.last = out;
|
|
@@ -4534,9 +5043,10 @@ var ScreenRunner = class {
|
|
|
4534
5043
|
log: this.rt.log,
|
|
4535
5044
|
demo: this.rt.demoMode,
|
|
4536
5045
|
cache: this.tiles,
|
|
4537
|
-
animate
|
|
5046
|
+
animate,
|
|
5047
|
+
rotate: screen.rotate
|
|
4538
5048
|
});
|
|
4539
|
-
sent.push({ out: this.fit(
|
|
5049
|
+
sent.push({ out: this.fit(result.canvas, kind, screen.jpegQuality || 85, screen), snap: s % 3 === 1 ? result.canvas : null });
|
|
4540
5050
|
await new Promise((r) => setImmediate(r));
|
|
4541
5051
|
}
|
|
4542
5052
|
const outs = await Promise.all(sent.map((x) => x.out));
|
|
@@ -4551,7 +5061,7 @@ var ScreenRunner = class {
|
|
|
4551
5061
|
await this.device.send(outs[k]);
|
|
4552
5062
|
const snap = sent[k].snap;
|
|
4553
5063
|
if (snap) {
|
|
4554
|
-
this.lastInfo = { screenId: screen.id, pageId: page.id, at: Date.now(), image: lazyJpeg(snap), tiles: [], interlude: null, animation: items.map((x) => x.animatable.type).join(", "), sleeping: false };
|
|
5064
|
+
this.lastInfo = { screenId: screen.id, pageId: page.id, at: Date.now(), image: lazyJpeg(snap, screen.rotate), tiles: [], interlude: null, animation: items.map((x) => x.animatable.type).join(", "), sleeping: false };
|
|
4555
5065
|
this.rt.emit("frame", this.lastInfo);
|
|
4556
5066
|
}
|
|
4557
5067
|
if (hold && k === holdAt) {
|
|
@@ -4831,7 +5341,7 @@ function withLook(cfg, look) {
|
|
|
4831
5341
|
}
|
|
4832
5342
|
|
|
4833
5343
|
// packages/core/src/registry.ts
|
|
4834
|
-
import { existsSync as existsSync5, readdirSync as
|
|
5344
|
+
import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync3, statSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
4835
5345
|
import { join as join6 } from "node:path";
|
|
4836
5346
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
4837
5347
|
|
|
@@ -4851,6 +5361,8 @@ function packageMeta(pkg) {
|
|
|
4851
5361
|
const deny = os.filter((x) => x.startsWith("!")).map((x) => x.slice(1));
|
|
4852
5362
|
out.platforms = PLATFORMS.filter((p) => (!allow.length || allow.includes(p)) && !deny.includes(p));
|
|
4853
5363
|
}
|
|
5364
|
+
const langs = pkg.kiosko?.languages;
|
|
5365
|
+
if (Array.isArray(langs) && langs.length) out.languages = langs.filter((x) => typeof x === "string");
|
|
4854
5366
|
return out;
|
|
4855
5367
|
}
|
|
4856
5368
|
function incompatibility(o, env = { sdk: SDK_VERSION, platform: process.platform }) {
|
|
@@ -4861,6 +5373,17 @@ function incompatibility(o, env = { sdk: SDK_VERSION, platform: process.platform
|
|
|
4861
5373
|
var platformName = (p) => p === "darwin" ? "macOS" : p === "win32" ? "Windows" : p === "linux" ? "Linux" : p;
|
|
4862
5374
|
var pluginOf = (type) => type.split("/")[0] ?? type;
|
|
4863
5375
|
var fullType = (pluginId, type) => type.includes("/") ? type : `${pluginId}/${type}`;
|
|
5376
|
+
function isLanguageTag(k) {
|
|
5377
|
+
if (!/^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(k)) return false;
|
|
5378
|
+
try {
|
|
5379
|
+
return Intl.getCanonicalLocales(k).length === 1;
|
|
5380
|
+
} catch {
|
|
5381
|
+
return false;
|
|
5382
|
+
}
|
|
5383
|
+
}
|
|
5384
|
+
function declaredLanguages(def, meta = {}) {
|
|
5385
|
+
return def.languages?.length ? [...def.languages] : meta.languages?.length ? [...meta.languages] : languagesOf(def);
|
|
5386
|
+
}
|
|
4864
5387
|
function languagesOf(def) {
|
|
4865
5388
|
const out = /* @__PURE__ */ new Set();
|
|
4866
5389
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
@@ -4870,7 +5393,7 @@ function languagesOf(def) {
|
|
|
4870
5393
|
if (Array.isArray(v)) return void v.forEach((x) => walk(x));
|
|
4871
5394
|
const o = v;
|
|
4872
5395
|
const keys = Object.keys(o);
|
|
4873
|
-
if (keys.includes("en") && keys.every((k) =>
|
|
5396
|
+
if (keys.includes("en") && keys.every((k) => isLanguageTag(k) && typeof o[k] === "string")) {
|
|
4874
5397
|
for (const k of keys) out.add(k);
|
|
4875
5398
|
return;
|
|
4876
5399
|
}
|
|
@@ -4920,7 +5443,7 @@ function pluginManifest(def, o = {}) {
|
|
|
4920
5443
|
...def.icon ? { icon: def.icon } : {},
|
|
4921
5444
|
...sdk ? { sdk } : {},
|
|
4922
5445
|
platforms: def.platforms ?? meta.platforms ?? [...PLATFORMS],
|
|
4923
|
-
languages:
|
|
5446
|
+
languages: declaredLanguages(def, meta),
|
|
4924
5447
|
categories: [...new Set(widgets.map((w) => w.category ?? "info"))],
|
|
4925
5448
|
tags: [...new Set(widgets.flatMap((w) => w.tags ?? []))],
|
|
4926
5449
|
permissions: def.permissions ?? {},
|
|
@@ -5134,15 +5657,15 @@ var Registry = class {
|
|
|
5134
5657
|
}
|
|
5135
5658
|
}
|
|
5136
5659
|
const candidates = [];
|
|
5137
|
-
for (const name of
|
|
5660
|
+
for (const name of readdirSync3(dir)) {
|
|
5138
5661
|
if (name === "node_modules" || name.startsWith(".")) continue;
|
|
5139
5662
|
candidates.push(join6(dir, name));
|
|
5140
5663
|
}
|
|
5141
5664
|
const nm = join6(dir, "node_modules");
|
|
5142
5665
|
if (existsSync5(nm)) {
|
|
5143
|
-
for (const name of
|
|
5666
|
+
for (const name of readdirSync3(nm)) {
|
|
5144
5667
|
if (name.startsWith("@")) {
|
|
5145
|
-
for (const sub of
|
|
5668
|
+
for (const sub of readdirSync3(join6(nm, name))) if (sub.startsWith("kiosko-plugin-")) candidates.push(join6(nm, name, sub));
|
|
5146
5669
|
} else if (name.startsWith("kiosko-plugin-")) candidates.push(join6(nm, name));
|
|
5147
5670
|
}
|
|
5148
5671
|
}
|
|
@@ -5221,6 +5744,8 @@ var Registry = class {
|
|
|
5221
5744
|
icon: def.icon,
|
|
5222
5745
|
sdk: def.sdk ?? null,
|
|
5223
5746
|
platforms: def.platforms ?? null,
|
|
5747
|
+
/** The languages its texts come in (declared, or read from its texts). */
|
|
5748
|
+
languages: declaredLanguages(def),
|
|
5224
5749
|
permissions: def.permissions ?? {},
|
|
5225
5750
|
/** What it needs from other plugins, and whether that is here (installed and on). */
|
|
5226
5751
|
requires: (def.requires ?? []).map((type) => ({ type, plugin: pluginOf(type), ok: has(type) })),
|
|
@@ -5240,6 +5765,8 @@ var Registry = class {
|
|
|
5240
5765
|
icon: w.icon,
|
|
5241
5766
|
category: w.category ?? "info",
|
|
5242
5767
|
tags: w.tags ?? [],
|
|
5768
|
+
/** Its name and description in every language it has, so a search in any of them finds it. */
|
|
5769
|
+
searchText: [w.name, w.description].flatMap((x) => x === void 0 ? [] : typeof x === "string" ? [x] : Object.values(x)).join(" "),
|
|
5243
5770
|
size: w.size ?? {},
|
|
5244
5771
|
chrome: w.chrome ?? "card",
|
|
5245
5772
|
options: w.options ? toJsonSchema(w.options) : null,
|
|
@@ -5307,6 +5834,15 @@ function missingLanguages(text2, langs) {
|
|
|
5307
5834
|
if (typeof text2 === "string") return langs.filter((l) => l !== "en");
|
|
5308
5835
|
return langs.filter((l) => !(l in text2));
|
|
5309
5836
|
}
|
|
5837
|
+
function knownLanguage(tag) {
|
|
5838
|
+
try {
|
|
5839
|
+
const lang = new Intl.Locale(tag).language;
|
|
5840
|
+
return new Intl.DisplayNames(["en"], { type: "language", fallback: "none" }).of(lang) !== void 0;
|
|
5841
|
+
} catch {
|
|
5842
|
+
return false;
|
|
5843
|
+
}
|
|
5844
|
+
}
|
|
5845
|
+
var bare = (x) => ({ ...x, options: void 0 });
|
|
5310
5846
|
function lintPlugin(def) {
|
|
5311
5847
|
const out = [];
|
|
5312
5848
|
const add = (level, where, message) => out.push({ level, where, message });
|
|
@@ -5317,10 +5853,39 @@ function lintPlugin(def) {
|
|
|
5317
5853
|
if (reaches && !def.permissions) add("warn", "plugin", "it reads data: declare `permissions` (hosts, programs, files, devices) so people know before installing");
|
|
5318
5854
|
if (!def.description) add("warn", "plugin", "a description, for the Plugins page and the store");
|
|
5319
5855
|
for (const r of [...def.requires ?? [], ...def.optional ?? []]) if (!/^[a-z0-9][a-z0-9-]*\/[a-zA-Z0-9-]+$/.test(r)) add("error", "plugin", `requires/optional ${JSON.stringify(r)}: a type, plugin/thing`);
|
|
5320
|
-
const
|
|
5856
|
+
const used = languagesOf(def);
|
|
5857
|
+
const declared = def.languages;
|
|
5858
|
+
if (!declared?.length) add("warn", "plugin", `declare the languages its texts come in: \`languages: [${used.map((l) => `'${l}'`).join(", ")}]\` (and "kiosko": { "languages": [...] } in package.json)`);
|
|
5859
|
+
else {
|
|
5860
|
+
for (const tag of declared) {
|
|
5861
|
+
let canon;
|
|
5862
|
+
try {
|
|
5863
|
+
canon = Intl.getCanonicalLocales(tag)[0];
|
|
5864
|
+
} catch {
|
|
5865
|
+
add("error", "plugin", `languages: "${tag}" is not a language tag (en, es, zh-Hant\u2026)`);
|
|
5866
|
+
continue;
|
|
5867
|
+
}
|
|
5868
|
+
if (canon !== tag) add("warn", "plugin", `languages: write "${tag}" as "${canon}"`);
|
|
5869
|
+
else if (!knownLanguage(tag)) add("warn", "plugin", `languages: "${tag}" is not a language Intl knows`);
|
|
5870
|
+
}
|
|
5871
|
+
if (!declared.includes("en")) add("error", "plugin", "languages: English (`en`) is the one every text falls back to: list it, and write every text in it");
|
|
5872
|
+
if (new Set(declared).size !== declared.length) add("warn", "plugin", "languages: a language is listed twice");
|
|
5873
|
+
const own = languagesOf({ ...def, widgets: def.widgets?.map(bare), sources: def.sources?.map(bare), interludes: def.interludes?.map(bare) });
|
|
5874
|
+
const unlisted = own.filter((l) => !declared.includes(l));
|
|
5875
|
+
if (unlisted.length) add("warn", "plugin", `its texts come in ${unlisted.join(", ")} too, which \`languages\` doesn't list`);
|
|
5876
|
+
}
|
|
5877
|
+
const langs = declared?.length ? declared : used;
|
|
5878
|
+
if (langs.includes("zh") || used.includes("zh")) add("warn", "plugin", "a bare `zh` is read as Simplified and never shown in Taiwan or Hong Kong: write `zh-Hans` (mainland China) and `zh-Hant` (Taiwan, Hong Kong)");
|
|
5879
|
+
const valid = langs.filter((l) => {
|
|
5880
|
+
try {
|
|
5881
|
+
return Intl.getCanonicalLocales(l)[0] === l && knownLanguage(l);
|
|
5882
|
+
} catch {
|
|
5883
|
+
return false;
|
|
5884
|
+
}
|
|
5885
|
+
});
|
|
5321
5886
|
const texts = (where, ...ts) => {
|
|
5322
5887
|
for (const tx of ts) {
|
|
5323
|
-
const miss = missingLanguages(tx,
|
|
5888
|
+
const miss = missingLanguages(tx, valid);
|
|
5324
5889
|
if (miss.length) add("warn", where, `"${typeof tx === "string" ? tx : tx?.en}" has no ${miss.join(", ")} (the plugin speaks ${langs.join(", ")})`);
|
|
5325
5890
|
}
|
|
5326
5891
|
};
|
|
@@ -5335,6 +5900,15 @@ function lintPlugin(def) {
|
|
|
5335
5900
|
if (!x.description) add("warn", where, "a description, for the library and the store");
|
|
5336
5901
|
return where;
|
|
5337
5902
|
};
|
|
5903
|
+
const optionTexts = (where, f) => {
|
|
5904
|
+
for (const [path, x] of fieldsOf(f)) {
|
|
5905
|
+
const o = x;
|
|
5906
|
+
texts(`${where} options.${path}`, ...[o.label, o.help, ...Object.values(o.labels ?? {})].filter((x2) => typeof x2 !== "string"));
|
|
5907
|
+
}
|
|
5908
|
+
};
|
|
5909
|
+
for (const w of def.widgets ?? []) optionTexts(`${def.id}/${w.id}`, w.options);
|
|
5910
|
+
for (const s of def.sources ?? []) optionTexts(`${def.id}/${s.id}`, s.options);
|
|
5911
|
+
for (const i of def.interludes ?? []) optionTexts(`${def.id}/${i.id}`, i.options);
|
|
5338
5912
|
for (const w of def.widgets ?? []) {
|
|
5339
5913
|
const where = part("widget", w);
|
|
5340
5914
|
out.push(...lintOptions(where, w.options, "widget"));
|
|
@@ -5441,31 +6015,31 @@ function wallClock(now, timeZone) {
|
|
|
5441
6015
|
}
|
|
5442
6016
|
var clock = defineWidget({
|
|
5443
6017
|
id: "clock",
|
|
5444
|
-
name: { en: "Clock", es: "Reloj" },
|
|
5445
|
-
description: { en: "Big digital clock, with optional seconds and date.", es: "Reloj digital grande, con segundos y fecha opcionales." },
|
|
6018
|
+
name: { en: "Clock", es: "Reloj", de: "Uhr", "zh-Hant": "\u6642\u9418", "zh-Hans": "\u65F6\u949F" },
|
|
6019
|
+
description: { en: "Big digital clock, with optional seconds and date.", es: "Reloj digital grande, con segundos y fecha opcionales.", de: "Gro\xDFe Digitaluhr, wahlweise mit Sekunden und Datum.", "zh-Hant": "\u5927\u578B\u6578\u4F4D\u6642\u9418\uFF0C\u53EF\u9078\u64C7\u986F\u793A\u79D2\u6578\u548C\u65E5\u671F\u3002", "zh-Hans": "\u5927\u53F7\u6570\u5B57\u65F6\u949F\uFF0C\u53EF\u9009\u663E\u793A\u79D2\u6570\u548C\u65E5\u671F\u3002" },
|
|
5446
6020
|
icon: "clock",
|
|
5447
6021
|
category: "time",
|
|
5448
6022
|
chrome: "bare",
|
|
5449
6023
|
size: { min: { w: 120, h: 60 }, preferred: { w: 320, h: 200 } },
|
|
5450
6024
|
options: t.object({
|
|
5451
|
-
showSeconds: t.boolean({ label: { en: "Show seconds", es: "Mostrar segundos" } }),
|
|
6025
|
+
showSeconds: t.boolean({ label: { en: "Show seconds", es: "Mostrar segundos", de: "Sekunden anzeigen", "zh-Hant": "\u986F\u793A\u79D2\u6578", "zh-Hans": "\u663E\u793A\u79D2\u6570" } }),
|
|
5452
6026
|
timeFormat: t.enum(["inherit", "24h", "12h"], {
|
|
5453
|
-
label: { en: "Time format", es: "Formato de hora" },
|
|
5454
|
-
labels: { inherit: { en: "As in Settings", es: "Como en Ajustes" }, "24h": { en: "24 hours", es: "24 horas" }, "12h": { en: "12 hours", es: "12 horas" } }
|
|
6027
|
+
label: { en: "Time format", es: "Formato de hora", de: "Zeitformat", "zh-Hant": "\u6642\u9593\u683C\u5F0F", "zh-Hans": "\u65F6\u95F4\u683C\u5F0F" },
|
|
6028
|
+
labels: { inherit: { en: "As in Settings", es: "Como en Ajustes", de: "Wie in den Einstellungen", "zh-Hant": "\u4F9D\u7167\u8A2D\u5B9A", "zh-Hans": "\u8DDF\u968F\u8BBE\u7F6E" }, "24h": { en: "24 hours", es: "24 horas", de: "24 Stunden", "zh-Hant": "24 \u5C0F\u6642\u5236", "zh-Hans": "24 \u5C0F\u65F6\u5236" }, "12h": { en: "12 hours", es: "12 horas", de: "12 Stunden", "zh-Hant": "12 \u5C0F\u6642\u5236", "zh-Hans": "12 \u5C0F\u65F6\u5236" } }
|
|
5455
6029
|
}),
|
|
5456
|
-
showDate: t.boolean({ default: true, label: { en: "Show the date below", es: "Fecha debajo" } }),
|
|
6030
|
+
showDate: t.boolean({ default: true, label: { en: "Show the date below", es: "Fecha debajo", de: "Datum darunter anzeigen", "zh-Hant": "\u5728\u4E0B\u65B9\u986F\u793A\u65E5\u671F", "zh-Hans": "\u5728\u4E0B\u65B9\u663E\u793A\u65E5\u671F" } }),
|
|
5457
6031
|
dateFormat: t.enum(["long", "short", "numeric"], {
|
|
5458
|
-
label: { en: "Date format", es: "Formato de la fecha" },
|
|
5459
|
-
labels: { long: { en: "Long: Monday, 10 November", es: "Larga: lunes, 10 de noviembre" }, short: { en: "Short: Mon, 10 Nov", es: "Corta: lun, 10 nov" }, numeric: { en: "Numbers: 10/11/2026", es: "En cifras: 10/11/2026" } },
|
|
5460
|
-
help: { en: "The long one gets small on a narrow tile.", es: "La larga se queda peque\xF1a en una tesela estrecha." }
|
|
6032
|
+
label: { en: "Date format", es: "Formato de la fecha", de: "Datumsformat", "zh-Hant": "\u65E5\u671F\u683C\u5F0F", "zh-Hans": "\u65E5\u671F\u683C\u5F0F" },
|
|
6033
|
+
labels: { long: { en: "Long: Monday, 10 November", es: "Larga: lunes, 10 de noviembre", de: "Lang: Montag, 10. November", "zh-Hant": "\u9577\uFF1A11\u670810\u65E5\u661F\u671F\u4E00", "zh-Hans": "\u957F\uFF1A11\u670810\u65E5\u661F\u671F\u4E00" }, short: { en: "Short: Mon, 10 Nov", es: "Corta: lun, 10 nov", de: "Kurz: Mo., 10. Nov.", "zh-Hant": "\u77ED\uFF1A11\u670810\u65E5\u9031\u4E00", "zh-Hans": "\u77ED\uFF1A11\u670810\u65E5\u5468\u4E00" }, numeric: { en: "Numbers: 10/11/2026", es: "En cifras: 10/11/2026", de: "Zahlen: 10.11.2026", "zh-Hant": "\u6578\u5B57\uFF1A2026/11/10", "zh-Hans": "\u6570\u5B57\uFF1A2026/11/10" } },
|
|
6034
|
+
help: { en: "The long one gets small on a narrow tile.", es: "La larga se queda peque\xF1a en una tesela estrecha.", de: "Das lange wird auf einer schmalen Kachel klein.", "zh-Hant": "\u65B9\u683C\u8F03\u7A84\u6642\uFF0C\u9577\u683C\u5F0F\u6703\u8B8A\u5F97\u5F88\u5C0F\u3002", "zh-Hans": "\u683C\u5B50\u8F83\u7A84\u65F6\uFF0C\u957F\u683C\u5F0F\u4F1A\u53D8\u5F97\u5F88\u5C0F\u3002" }
|
|
5461
6035
|
}),
|
|
5462
6036
|
timeZone: t.string({
|
|
5463
6037
|
placeholder: "America/New_York",
|
|
5464
|
-
label: { en: "Time zone", es: "Zona horaria" },
|
|
5465
|
-
help: { en: "Empty: this computer's. A zone name (Europe/London, Asia/Tokyo) makes it the clock of another office; give the widget a title.", es: "Vac\xEDa: la de este ordenador. Con el nombre de una zona (Europe/London, Asia/Tokyo) es el reloj de otra oficina; ponle un t\xEDtulo al widget." }
|
|
6038
|
+
label: { en: "Time zone", es: "Zona horaria", de: "Zeitzone", "zh-Hant": "\u6642\u5340", "zh-Hans": "\u65F6\u533A" },
|
|
6039
|
+
help: { en: "Empty: this computer's. A zone name (Europe/London, Asia/Tokyo) makes it the clock of another office; give the widget a title.", es: "Vac\xEDa: la de este ordenador. Con el nombre de una zona (Europe/London, Asia/Tokyo) es el reloj de otra oficina; ponle un t\xEDtulo al widget.", de: "Leer: die dieses Computers. Ein Zonenname (Europe/London, Asia/Tokyo) macht sie zur Uhr eines anderen B\xFCros; gib dem Widget einen Titel.", "zh-Hant": "\u7559\u7A7A\uFF1A\u4F7F\u7528\u9019\u53F0\u96FB\u8166\u7684\u6642\u5340\u3002\u586B\u5165\u6642\u5340\u540D\u7A31\uFF08Europe/London\u3001Asia/Tokyo\uFF09\u5C31\u6210\u4E86\u53E6\u4E00\u9593\u8FA6\u516C\u5BA4\u7684\u6642\u9418\uFF1B\u8A18\u5F97\u5E6B\u5C0F\u5DE5\u5177\u52A0\u4E0A\u6A19\u984C\u3002", "zh-Hans": "\u7559\u7A7A\uFF1A\u4F7F\u7528\u8FD9\u53F0\u7535\u8111\u7684\u65F6\u533A\u3002\u586B\u5199\u65F6\u533A\u540D\u79F0\uFF08Europe/London\u3001Asia/Tokyo\uFF09\u5C31\u6210\u4E86\u53E6\u4E00\u4E2A\u529E\u516C\u5BA4\u7684\u65F6\u949F\uFF1B\u8BB0\u5F97\u7ED9\u5C0F\u7EC4\u4EF6\u52A0\u4E2A\u6807\u9898\u3002" }
|
|
5466
6040
|
}),
|
|
5467
|
-
color: t.enum(["ink", "accent", "dim"], { label: { en: "Colour", es: "Color" }, labels: { ink: { en: "Text", es: "Texto" }, accent: { en: "Accent", es: "Acento" }, dim: { en: "Dim", es: "Tenue" } } }),
|
|
5468
|
-
align: t.enum(["center", "left", "right"], { label: { en: "Alignment", es: "Alineaci\xF3n" } })
|
|
6041
|
+
color: t.enum(["ink", "accent", "dim"], { label: { en: "Colour", es: "Color", de: "Farbe", "zh-Hant": "\u984F\u8272", "zh-Hans": "\u989C\u8272" }, labels: { ink: { en: "Text", es: "Texto", de: "Text", "zh-Hant": "\u6587\u5B57", "zh-Hans": "\u6587\u5B57" }, accent: { en: "Accent", es: "Acento", de: "Akzent", "zh-Hant": "\u5F37\u8ABF\u8272", "zh-Hans": "\u5F3A\u8C03\u8272" }, dim: { en: "Dim", es: "Tenue", de: "Ged\xE4mpft", "zh-Hant": "\u6DE1\u8272", "zh-Hans": "\u6697\u6DE1" } } }),
|
|
6042
|
+
align: t.enum(["center", "left", "right"], { label: { en: "Alignment", es: "Alineaci\xF3n", de: "Ausrichtung", "zh-Hant": "\u5C0D\u9F4A", "zh-Hans": "\u5BF9\u9F50" } })
|
|
5469
6043
|
}),
|
|
5470
6044
|
redraw: "second",
|
|
5471
6045
|
render(g, { box, now, options: options2, theme, locale, fmt }) {
|
|
@@ -5494,24 +6068,24 @@ var clock = defineWidget({
|
|
|
5494
6068
|
});
|
|
5495
6069
|
var date = defineWidget({
|
|
5496
6070
|
id: "date",
|
|
5497
|
-
name: { en: "Calendar day", es: "D\xEDa del calendario" },
|
|
5498
|
-
description: { en: "Day of the month, weekday and week number, like a desk calendar.", es: "El d\xEDa del mes, de la semana y el n\xFAmero de semana, como un taco de calendario." },
|
|
6071
|
+
name: { en: "Calendar day", es: "D\xEDa del calendario", de: "Kalendertag", "zh-Hant": "\u65E5\u66C6", "zh-Hans": "\u65E5\u5386" },
|
|
6072
|
+
description: { en: "Day of the month, weekday and week number, like a desk calendar.", es: "El d\xEDa del mes, de la semana y el n\xFAmero de semana, como un taco de calendario.", de: "Tag des Monats, Wochentag und Kalenderwoche, wie ein Tischkalender.", "zh-Hant": "\u7576\u6708\u65E5\u671F\u3001\u661F\u671F\u548C\u9031\u6578\uFF0C\u5C31\u50CF\u684C\u66C6\u4E00\u6A23\u3002", "zh-Hans": "\u5F53\u6708\u65E5\u671F\u3001\u661F\u671F\u548C\u5468\u6570\uFF0C\u5C31\u50CF\u53F0\u5386\u4E00\u6837\u3002" },
|
|
5499
6073
|
icon: "calendar",
|
|
5500
6074
|
category: "time",
|
|
5501
6075
|
size: { min: { w: 120, h: 120 }, preferred: { w: 220, h: 300 } },
|
|
5502
6076
|
options: t.object({
|
|
5503
6077
|
weekdayColor: t.enum(["accent", "ink", "dim", "alert"], {
|
|
5504
|
-
label: { en: "Weekday colour", es: "Color del d\xEDa de la semana" },
|
|
5505
|
-
labels: { accent: { en: "Accent", es: "Acento" }, ink: { en: "Text", es: "Texto" }, dim: { en: "Dim", es: "Tenue" }, alert: { en: "Red, like a tear-off calendar", es: "Rojo, como un taco de calendario" } },
|
|
5506
|
-
help: { en: 'On the panel red means "needs you"; a red weekday spends it every day.', es: "En el panel el rojo significa \xABte necesita\xBB; un d\xEDa de la semana en rojo lo gasta a diario." }
|
|
6078
|
+
label: { en: "Weekday colour", es: "Color del d\xEDa de la semana", de: "Farbe des Wochentags", "zh-Hant": "\u661F\u671F\u984F\u8272", "zh-Hans": "\u661F\u671F\u989C\u8272" },
|
|
6079
|
+
labels: { accent: { en: "Accent", es: "Acento", de: "Akzent", "zh-Hant": "\u5F37\u8ABF\u8272", "zh-Hans": "\u5F3A\u8C03\u8272" }, ink: { en: "Text", es: "Texto", de: "Text", "zh-Hant": "\u6587\u5B57", "zh-Hans": "\u6587\u5B57" }, dim: { en: "Dim", es: "Tenue", de: "Ged\xE4mpft", "zh-Hant": "\u6DE1\u8272", "zh-Hans": "\u6697\u6DE1" }, alert: { en: "Red, like a tear-off calendar", es: "Rojo, como un taco de calendario", de: "Rot, wie ein Abrei\xDFkalender", "zh-Hant": "\u7D05\u8272\uFF0C\u50CF\u6495\u9801\u65E5\u66C6", "zh-Hans": "\u7EA2\u8272\uFF0C\u50CF\u624B\u6495\u65E5\u5386" } },
|
|
6080
|
+
help: { en: 'On the panel red means "needs you"; a red weekday spends it every day.', es: "En el panel el rojo significa \xABte necesita\xBB; un d\xEDa de la semana en rojo lo gasta a diario.", de: "Auf dem Panel hei\xDFt Rot \u201Ebraucht dich\u201C; ein roter Wochentag verbraucht das jeden Tag.", "zh-Hant": "\u5728\u9762\u677F\u4E0A\uFF0C\u7D05\u8272\u4EE3\u8868\u300C\u9700\u8981\u4F60\u300D\uFF1B\u661F\u671F\u7528\u7D05\u8272\u7B49\u65BC\u6BCF\u5929\u90FD\u5728\u6D88\u8017\u5B83\u3002", "zh-Hans": "\u5728\u5C4F\u5E55\u4E0A\uFF0C\u7EA2\u8272\u4EE3\u8868\u201C\u9700\u8981\u4F60\u201D\uFF1B\u661F\u671F\u7528\u7EA2\u8272\u7B49\u4E8E\u6BCF\u5929\u90FD\u5728\u6D88\u8017\u5B83\u3002" }
|
|
5507
6081
|
}),
|
|
5508
|
-
showWeekNumber: t.boolean({ default: true, label: { en: "Show week number", es: "N\xFAmero de semana" } })
|
|
6082
|
+
showWeekNumber: t.boolean({ default: true, label: { en: "Show week number", es: "N\xFAmero de semana", de: "Kalenderwoche anzeigen", "zh-Hant": "\u986F\u793A\u9031\u6578", "zh-Hans": "\u663E\u793A\u5468\u6570" } })
|
|
5509
6083
|
}),
|
|
5510
6084
|
redraw: "minute",
|
|
5511
6085
|
render(g, { box, now, options: options2, theme, kit, locale, t: tr }) {
|
|
5512
6086
|
const d = new Date(now);
|
|
5513
6087
|
const weekday = d.toLocaleDateString(locale, { weekday: "long" });
|
|
5514
|
-
const month = d.toLocaleDateString(locale, { month: "long" });
|
|
6088
|
+
const month = d.toLocaleDateString(locale, { month: hanScript(locale) ? "short" : "long" });
|
|
5515
6089
|
const top = Math.min(box.h * 0.16, 36);
|
|
5516
6090
|
const c = theme.colors;
|
|
5517
6091
|
const weekdayColor = { accent: c.accent, ink: c.ink, dim: c.inkDim, alert: c.alert }[options2.weekdayColor];
|
|
@@ -5526,7 +6100,7 @@ var date = defineWidget({
|
|
|
5526
6100
|
const bottom = box.y + box.h - 4;
|
|
5527
6101
|
const ms = Math.min(top, box.h * 0.13);
|
|
5528
6102
|
let line = month;
|
|
5529
|
-
if (options2.showWeekNumber) line += ` \xB7 ${tr({ en: "wk", es: "sem" })}
|
|
6103
|
+
if (options2.showWeekNumber) line += ` \xB7 ${tr({ en: "wk {n}", es: "sem {n}", de: "KW {n}", "zh-Hant": "\u7B2C {n} \u9031", "zh-Hans": "\u7B2C {n} \u5468" }).replace("{n}", String(isoWeek(d)))}`;
|
|
5530
6104
|
const ls = Math.min(ms, fit2(g, line, theme.fonts.sans, box.w * 0.96, ms));
|
|
5531
6105
|
g.font = `${ls}px "${theme.fonts.sans}"`;
|
|
5532
6106
|
g.fillStyle = theme.colors.inkDim;
|
|
@@ -5541,34 +6115,37 @@ function expandHome(path) {
|
|
|
5541
6115
|
var MAX_FILE_CHARS = 2e4;
|
|
5542
6116
|
var text = defineWidget({
|
|
5543
6117
|
id: "text",
|
|
5544
|
-
name: { en: "Text note", es: "Nota de texto" },
|
|
5545
|
-
description: { en: "A note or a motto, auto-sized to fill its tile; or the contents of a file a script writes.", es: "Una nota o un lema, con la letra ajustada a la tesela; o lo que un script escribe en un fichero." },
|
|
6118
|
+
name: { en: "Text note", es: "Nota de texto", de: "Textnotiz", "zh-Hant": "\u6587\u5B57\u4FBF\u689D", "zh-Hans": "\u6587\u5B57\u4FBF\u7B7E" },
|
|
6119
|
+
description: { en: "A note or a motto, auto-sized to fill its tile; or the contents of a file a script writes.", es: "Una nota o un lema, con la letra ajustada a la tesela; o lo que un script escribe en un fichero.", de: "Eine Notiz oder ein Motto, in der Gr\xF6\xDFe an die Kachel angepasst; oder der Inhalt einer Datei, die ein Skript schreibt.", "zh-Hant": "\u4E00\u5247\u4FBF\u689D\u6216\u5EA7\u53F3\u9298\uFF0C\u5B57\u9AD4\u81EA\u52D5\u7E2E\u653E\u586B\u6EFF\u65B9\u683C\uFF1B\u6216\u662F\u986F\u793A\u8173\u672C\u5BEB\u5165\u6A94\u6848\u7684\u5167\u5BB9\u3002", "zh-Hans": "\u4E00\u6761\u4FBF\u7B7E\u6216\u5EA7\u53F3\u94ED\uFF0C\u5B57\u53F7\u81EA\u52A8\u7F29\u653E\u586B\u6EE1\u683C\u5B50\uFF1B\u6216\u8005\u663E\u793A\u811A\u672C\u5199\u5165\u6587\u4EF6\u7684\u5185\u5BB9\u3002" },
|
|
5546
6120
|
icon: "type",
|
|
5547
6121
|
category: "productivity",
|
|
5548
6122
|
size: { min: { w: 120, h: 60 }, preferred: { w: 400, h: 160 } },
|
|
5549
6123
|
options: t.object({
|
|
5550
|
-
text: t.string({ default: "Hello, panel!", multiline: true, label: { en: "Text", es: "Texto" }, help: { en: "With a file, shown until the file can be read.", es: "Con un fichero, se ve hasta que se pueda leer." } }),
|
|
6124
|
+
text: t.string({ default: "Hello, panel!", multiline: true, label: { en: "Text", es: "Texto", de: "Text", "zh-Hant": "\u6587\u5B57", "zh-Hans": "\u6587\u5B57" }, help: { en: "With a file, shown until the file can be read.", es: "Con un fichero, se ve hasta que se pueda leer.", de: "Mit einer Datei: angezeigt, bis die Datei gelesen werden kann.", "zh-Hant": "\u4F7F\u7528\u6A94\u6848\u6642\uFF0C\u5728\u6A94\u6848\u53EF\u8B80\u53D6\u4E4B\u524D\u986F\u793A\u9019\u6BB5\u6587\u5B57\u3002", "zh-Hans": "\u4F7F\u7528\u6587\u4EF6\u65F6\uFF0C\u5728\u6587\u4EF6\u53EF\u8BFB\u53D6\u4E4B\u524D\u663E\u793A\u8FD9\u6BB5\u6587\u5B57\u3002" } }),
|
|
5551
6125
|
file: t.string({
|
|
5552
6126
|
format: "path",
|
|
5553
6127
|
risk: "path",
|
|
5554
6128
|
placeholder: "~/status.txt",
|
|
5555
|
-
label: { en: "Text file", es: "Fichero de texto" },
|
|
6129
|
+
label: { en: "Text file", es: "Fichero de texto", de: "Textdatei", "zh-Hant": "\u6587\u5B57\u6A94", "zh-Hans": "\u6587\u672C\u6587\u4EF6" },
|
|
5556
6130
|
help: {
|
|
5557
6131
|
en: "Paints what a script writes there (on call, a deploy, the last backup), read again on every refresh. Empty: the text above.",
|
|
5558
|
-
es: "Pinta lo que un script escribe ah\xED (guardia, despliegue, \xFAltima copia), rele\xEDdo en cada refresco. Vac\xEDo: el texto de arriba."
|
|
6132
|
+
es: "Pinta lo que un script escribe ah\xED (guardia, despliegue, \xFAltima copia), rele\xEDdo en cada refresco. Vac\xEDo: el texto de arriba.",
|
|
6133
|
+
de: "Zeigt, was ein Skript dort hineinschreibt (Bereitschaft, ein Deployment, das letzte Backup), bei jeder Aktualisierung neu gelesen. Leer: der Text oben.",
|
|
6134
|
+
"zh-Hant": "\u986F\u793A\u8173\u672C\u5BEB\u5165\u7684\u5167\u5BB9\uFF08\u503C\u73ED\u3001\u90E8\u7F72\u3001\u4E0A\u6B21\u5099\u4EFD\uFF09\uFF0C\u6BCF\u6B21\u91CD\u65B0\u6574\u7406\u6642\u91CD\u65B0\u8B80\u53D6\u3002\u7559\u7A7A\uFF1A\u4F7F\u7528\u4E0A\u65B9\u7684\u6587\u5B57\u3002",
|
|
6135
|
+
"zh-Hans": "\u663E\u793A\u811A\u672C\u5199\u5165\u7684\u5185\u5BB9\uFF08\u503C\u73ED\u3001\u90E8\u7F72\u3001\u4E0A\u6B21\u5907\u4EFD\uFF09\uFF0C\u6BCF\u6B21\u5237\u65B0\u65F6\u91CD\u65B0\u8BFB\u53D6\u3002\u7559\u7A7A\uFF1A\u4F7F\u7528\u4E0A\u65B9\u7684\u6587\u5B57\u3002"
|
|
5559
6136
|
}
|
|
5560
6137
|
}),
|
|
5561
|
-
maxSize: t.integer({ default: 64, min: 10, max: 300, unit: "px", slider: true, label: { en: "Largest letter size", es: "Tama\xF1o m\xE1ximo de letra" } }),
|
|
6138
|
+
maxSize: t.integer({ default: 64, min: 10, max: 300, unit: "px", slider: true, label: { en: "Largest letter size", es: "Tama\xF1o m\xE1ximo de letra", de: "Gr\xF6\xDFte Schriftgr\xF6\xDFe", "zh-Hant": "\u6700\u5927\u5B57\u9AD4\u5927\u5C0F", "zh-Hans": "\u6700\u5927\u5B57\u53F7" } }),
|
|
5562
6139
|
font: t.enum(["sans", "bold", "mono"], {
|
|
5563
|
-
label: { en: "Font", es: "Letra" },
|
|
5564
|
-
labels: { sans: { en: "Regular", es: "Normal" }, bold: { en: "Bold", es: "Negrita" }, mono: { en: "Monospaced", es: "Monoespaciada" } }
|
|
6140
|
+
label: { en: "Font", es: "Letra", de: "Schrift", "zh-Hant": "\u5B57\u578B", "zh-Hans": "\u5B57\u4F53" },
|
|
6141
|
+
labels: { sans: { en: "Regular", es: "Normal", de: "Normal", "zh-Hant": "\u4E00\u822C", "zh-Hans": "\u5E38\u89C4" }, bold: { en: "Bold", es: "Negrita", de: "Fett", "zh-Hant": "\u7C97\u9AD4", "zh-Hans": "\u7C97\u4F53" }, mono: { en: "Monospaced", es: "Monoespaciada", de: "Festbreite", "zh-Hant": "\u7B49\u5BEC", "zh-Hans": "\u7B49\u5BBD" } }
|
|
5565
6142
|
}),
|
|
5566
|
-
align: t.enum(["left", "center", "right"], { label: { en: "Alignment", es: "Alineaci\xF3n" }, labels: { left: { en: "Left", es: "Izquierda" }, center: { en: "Centre", es: "Centro" }, right: { en: "Right", es: "Derecha" } } }),
|
|
6143
|
+
align: t.enum(["left", "center", "right"], { label: { en: "Alignment", es: "Alineaci\xF3n", de: "Ausrichtung", "zh-Hant": "\u5C0D\u9F4A", "zh-Hans": "\u5BF9\u9F50" }, labels: { left: { en: "Left", es: "Izquierda", de: "Links", "zh-Hant": "\u9760\u5DE6", "zh-Hans": "\u5DE6\u5BF9\u9F50" }, center: { en: "Centre", es: "Centro", de: "Mitte", "zh-Hant": "\u7F6E\u4E2D", "zh-Hans": "\u5C45\u4E2D" }, right: { en: "Right", es: "Derecha", de: "Rechts", "zh-Hant": "\u9760\u53F3", "zh-Hans": "\u53F3\u5BF9\u9F50" } } }),
|
|
5567
6144
|
valign: t.enum(["middle", "top", "bottom"], {
|
|
5568
|
-
label: { en: "Vertical alignment", es: "Alineaci\xF3n vertical" },
|
|
5569
|
-
labels: { middle: { en: "Middle", es: "En medio" }, top: { en: "Top", es: "Arriba" }, bottom: { en: "Bottom", es: "Abajo" } }
|
|
6145
|
+
label: { en: "Vertical alignment", es: "Alineaci\xF3n vertical", de: "Vertikale Ausrichtung", "zh-Hant": "\u5782\u76F4\u5C0D\u9F4A", "zh-Hans": "\u5782\u76F4\u5BF9\u9F50" },
|
|
6146
|
+
labels: { middle: { en: "Middle", es: "En medio", de: "Mitte", "zh-Hant": "\u7F6E\u4E2D", "zh-Hans": "\u5C45\u4E2D" }, top: { en: "Top", es: "Arriba", de: "Oben", "zh-Hant": "\u9760\u4E0A", "zh-Hans": "\u9876\u90E8" }, bottom: { en: "Bottom", es: "Abajo", de: "Unten", "zh-Hant": "\u9760\u4E0B", "zh-Hans": "\u5E95\u90E8" } }
|
|
5570
6147
|
}),
|
|
5571
|
-
color: t.color({ default: "", label: { en: "Colour (empty = theme)", es: "Color (vac\xEDo = el del tema)" } })
|
|
6148
|
+
color: t.color({ default: "", label: { en: "Colour (empty = theme)", es: "Color (vac\xEDo = el del tema)", de: "Farbe (leer = Design)", "zh-Hant": "\u984F\u8272\uFF08\u7559\u7A7A = \u4E3B\u984C\u8272\uFF09", "zh-Hans": "\u989C\u8272\uFF08\u7559\u7A7A = \u4E3B\u9898\u8272\uFF09" } })
|
|
5572
6149
|
}),
|
|
5573
6150
|
intervalMs: 6e4,
|
|
5574
6151
|
timeoutMs: 1e4,
|
|
@@ -5605,8 +6182,8 @@ function parseItems(text2) {
|
|
|
5605
6182
|
}
|
|
5606
6183
|
var list = defineWidget({
|
|
5607
6184
|
id: "list",
|
|
5608
|
-
name: { en: "List", es: "Lista" },
|
|
5609
|
-
description: { en: "A list you write: to-dos, reminders, the shopping. Shows what fits and how many more.", es: "Una lista que escribes t\xFA: pendientes, recordatorios, la compra. Muestra lo que cabe y cu\xE1ntas m\xE1s hay." },
|
|
6185
|
+
name: { en: "List", es: "Lista", de: "Liste", "zh-Hant": "\u6E05\u55AE", "zh-Hans": "\u5217\u8868" },
|
|
6186
|
+
description: { en: "A list you write: to-dos, reminders, the shopping. Shows what fits and how many more.", es: "Una lista que escribes t\xFA: pendientes, recordatorios, la compra. Muestra lo que cabe y cu\xE1ntas m\xE1s hay.", de: "Eine Liste, die du schreibst: Aufgaben, Erinnerungen, der Einkauf. Zeigt, was passt, und wie viele noch fehlen.", "zh-Hant": "\u4F60\u81EA\u5DF1\u5BEB\u7684\u6E05\u55AE\uFF1A\u5F85\u8FA6\u4E8B\u9805\u3001\u63D0\u9192\u3001\u8CFC\u7269\u6E05\u55AE\u3002\u986F\u793A\u653E\u5F97\u4E0B\u7684\u9805\u76EE\uFF0C\u4EE5\u53CA\u9084\u6709\u591A\u5C11\u9805\u3002", "zh-Hans": "\u4F60\u81EA\u5DF1\u5199\u7684\u5217\u8868\uFF1A\u5F85\u529E\u4E8B\u9879\u3001\u63D0\u9192\u3001\u8D2D\u7269\u6E05\u5355\u3002\u663E\u793A\u653E\u5F97\u4E0B\u7684\u6761\u76EE\uFF0C\u4EE5\u53CA\u8FD8\u6709\u591A\u5C11\u6761\u3002" },
|
|
5610
6187
|
icon: "list",
|
|
5611
6188
|
category: "productivity",
|
|
5612
6189
|
size: { min: { w: 160, h: 80 }, preferred: { w: 360, h: 240 } },
|
|
@@ -5614,8 +6191,8 @@ var list = defineWidget({
|
|
|
5614
6191
|
items: t.string({
|
|
5615
6192
|
default: "Water the plants\nCall the bank | before 14:00\nBook the dentist | Dr. Ruiz, any morning\nBuy coffee",
|
|
5616
6193
|
multiline: true,
|
|
5617
|
-
label: { en: "Items", es: "Elementos" },
|
|
5618
|
-
help: { en: 'One per line. Text after a "|" is a detail, shown under the item in the detailed layout.', es: "Uno por l\xEDnea. Lo que va tras una \xAB|\xBB es un detalle, que se ve debajo en el formato detallado." }
|
|
6194
|
+
label: { en: "Items", es: "Elementos", de: "Eintr\xE4ge", "zh-Hant": "\u9805\u76EE", "zh-Hans": "\u6761\u76EE" },
|
|
6195
|
+
help: { en: 'One per line. Text after a "|" is a detail, shown under the item in the detailed layout.', es: "Uno por l\xEDnea. Lo que va tras una \xAB|\xBB es un detalle, que se ve debajo en el formato detallado.", de: "Einer pro Zeile. Text nach einem \u201E|\u201C ist ein Detail, das im ausf\xFChrlichen Layout unter dem Eintrag steht.", "zh-Hant": "\u6BCF\u884C\u4E00\u9805\u3002\u300C|\u300D\u5F8C\u9762\u7684\u6587\u5B57\u662F\u7D30\u7BC0\uFF0C\u5728\u8A73\u7D30\u7248\u9762\u4E2D\u986F\u793A\u65BC\u9805\u76EE\u4E0B\u65B9\u3002", "zh-Hans": "\u6BCF\u884C\u4E00\u6761\u3002\u201C|\u201D\u540E\u9762\u7684\u6587\u5B57\u662F\u8BE6\u60C5\uFF0C\u5728\u8BE6\u7EC6\u5E03\u5C40\u4E2D\u663E\u793A\u5728\u6761\u76EE\u4E0B\u65B9\u3002" }
|
|
5619
6196
|
}),
|
|
5620
6197
|
...listOptions({ layouts: ["one-line", "detailed"] })
|
|
5621
6198
|
}),
|
|
@@ -5623,7 +6200,7 @@ var list = defineWidget({
|
|
|
5623
6200
|
render(g, ctx) {
|
|
5624
6201
|
const { box, options: options2, theme, kit } = ctx;
|
|
5625
6202
|
const items = parseItems(options2.items);
|
|
5626
|
-
if (!items.length) return drawEmpty(g, ctx, ctx.t({ en: "Nothing on the list", es: "Nada en la lista" }));
|
|
6203
|
+
if (!items.length) return drawEmpty(g, ctx, ctx.t({ en: "Nothing on the list", es: "Nada en la lista", de: "Nichts auf der Liste", "zh-Hant": "\u6E05\u55AE\u662F\u7A7A\u7684", "zh-Hans": "\u5217\u8868\u4E3A\u7A7A" }));
|
|
5627
6204
|
const plan = listLayout(box, items.length, options2, {
|
|
5628
6205
|
sizes: { "one-line": { min: 18, max: 44 }, detailed: { min: 36, max: 76 } },
|
|
5629
6206
|
// Two lines only when some item has a detail and every row has room for them.
|
|
@@ -5678,8 +6255,8 @@ function placeImage(box, w, h, fit3, position) {
|
|
|
5678
6255
|
var load = (canvas, src) => canvas.loadImageScaled ? canvas.loadImageScaled(src, { width: 1920, height: 1080, fit: "cover" }) : canvas.loadImage(src);
|
|
5679
6256
|
var image = defineWidget({
|
|
5680
6257
|
id: "image",
|
|
5681
|
-
name: { en: "Picture", es: "Imagen" },
|
|
5682
|
-
description: { en: "A local image, a folder of them in turn, or a URL (refreshed every few minutes, good for webcams and charts).", es: "Una imagen local, una carpeta de ellas por turnos o una URL (se refresca cada pocos minutos: webcams, gr\xE1ficas)." },
|
|
6258
|
+
name: { en: "Picture", es: "Imagen", de: "Bild", "zh-Hant": "\u5716\u7247", "zh-Hans": "\u56FE\u7247" },
|
|
6259
|
+
description: { en: "A local image, a folder of them in turn, or a URL (refreshed every few minutes, good for webcams and charts).", es: "Una imagen local, una carpeta de ellas por turnos o una URL (se refresca cada pocos minutos: webcams, gr\xE1ficas).", de: "Ein lokales Bild, ein Ordner voller Bilder im Wechsel oder eine URL (alle paar Minuten aktualisiert, gut f\xFCr Webcams und Diagramme).", "zh-Hant": "\u672C\u6A5F\u5716\u7247\u3001\u8F2A\u6D41\u986F\u793A\u7684\u5716\u7247\u8CC7\u6599\u593E\uFF0C\u6216 URL\uFF08\u6BCF\u9694\u5E7E\u5206\u9418\u91CD\u65B0\u6574\u7406\uFF0C\u9069\u5408\u7DB2\u8DEF\u651D\u5F71\u6A5F\u548C\u5716\u8868\uFF09\u3002", "zh-Hans": "\u672C\u5730\u56FE\u7247\u3001\u8F6E\u6D41\u663E\u793A\u7684\u56FE\u7247\u6587\u4EF6\u5939\uFF0C\u6216 URL\uFF08\u6BCF\u9694\u51E0\u5206\u949F\u5237\u65B0\u4E00\u6B21\uFF0C\u9002\u5408\u7F51\u7EDC\u6444\u50CF\u5934\u548C\u56FE\u8868\uFF09\u3002" },
|
|
5683
6260
|
icon: "image",
|
|
5684
6261
|
category: "media",
|
|
5685
6262
|
chrome: "bare",
|
|
@@ -5689,26 +6266,32 @@ var image = defineWidget({
|
|
|
5689
6266
|
format: "url",
|
|
5690
6267
|
risk: ["network", "path"],
|
|
5691
6268
|
placeholder: "https://\u2026 or /path/to/image.png",
|
|
5692
|
-
label: { en: "Image (path, folder or URL)", es: "Imagen (ruta, carpeta o URL)" },
|
|
6269
|
+
label: { en: "Image (path, folder or URL)", es: "Imagen (ruta, carpeta o URL)", de: "Bild (Pfad, Ordner oder URL)", "zh-Hant": "\u5716\u7247\uFF08\u8DEF\u5F91\u3001\u8CC7\u6599\u593E\u6216 URL\uFF09", "zh-Hans": "\u56FE\u7247\uFF08\u8DEF\u5F84\u3001\u6587\u4EF6\u5939\u6216 URL\uFF09" },
|
|
5693
6270
|
help: {
|
|
5694
6271
|
en: "A folder shows its pictures by name, the next one on every refresh. In a URL, {now} and {unix} become the current time (milliseconds, seconds).",
|
|
5695
|
-
es: "Una carpeta ense\xF1a sus im\xE1genes por orden de nombre, la siguiente en cada refresco. En una URL, {now} y {unix} se cambian por la hora actual (milisegundos, segundos)."
|
|
6272
|
+
es: "Una carpeta ense\xF1a sus im\xE1genes por orden de nombre, la siguiente en cada refresco. En una URL, {now} y {unix} se cambian por la hora actual (milisegundos, segundos).",
|
|
6273
|
+
de: "Ein Ordner zeigt seine Bilder nach Namen, bei jeder Aktualisierung das n\xE4chste. In einer URL werden {now} und {unix} durch die aktuelle Zeit ersetzt (Millisekunden, Sekunden).",
|
|
6274
|
+
"zh-Hant": "\u8CC7\u6599\u593E\u6703\u4F9D\u6A94\u540D\u986F\u793A\u5716\u7247\uFF0C\u6BCF\u6B21\u91CD\u65B0\u6574\u7406\u63DB\u4E0B\u4E00\u5F35\u3002\u5728 URL \u4E2D\uFF0C{now} \u548C {unix} \u6703\u63DB\u6210\u76EE\u524D\u6642\u9593\uFF08\u6BEB\u79D2\u3001\u79D2\uFF09\u3002",
|
|
6275
|
+
"zh-Hans": "\u6587\u4EF6\u5939\u4F1A\u6309\u6587\u4EF6\u540D\u663E\u793A\u56FE\u7247\uFF0C\u6BCF\u6B21\u5237\u65B0\u6362\u4E0B\u4E00\u5F20\u3002\u5728 URL \u4E2D\uFF0C{now} \u548C {unix} \u4F1A\u66FF\u6362\u4E3A\u5F53\u524D\u65F6\u95F4\uFF08\u6BEB\u79D2\u3001\u79D2\uFF09\u3002"
|
|
5696
6276
|
}
|
|
5697
6277
|
}),
|
|
5698
6278
|
addTimestamp: t.boolean({
|
|
5699
|
-
label: { en: "Add a timestamp to the URL", es: "A\xF1adir marca de tiempo a la URL" },
|
|
6279
|
+
label: { en: "Add a timestamp to the URL", es: "A\xF1adir marca de tiempo a la URL", de: "Zeitstempel an die URL anh\xE4ngen", "zh-Hant": "\u5728 URL \u52A0\u4E0A\u6642\u9593\u6233\u8A18", "zh-Hans": "\u5728 URL \u4E2D\u6DFB\u52A0\u65F6\u95F4\u6233" },
|
|
5700
6280
|
help: {
|
|
5701
6281
|
en: "Appends t=<now> on every refresh, for webcams that would otherwise be served from a cache.",
|
|
5702
|
-
es: "A\xF1ade t=<ahora> en cada refresco, para webcams que si no se sirven desde una cach\xE9."
|
|
6282
|
+
es: "A\xF1ade t=<ahora> en cada refresco, para webcams que si no se sirven desde una cach\xE9.",
|
|
6283
|
+
de: "H\xE4ngt bei jeder Aktualisierung t=<jetzt> an, f\xFCr Webcams, die sonst aus einem Cache k\xE4men.",
|
|
6284
|
+
"zh-Hant": "\u6BCF\u6B21\u91CD\u65B0\u6574\u7406\u6642\u9644\u52A0 t=<now>\uFF0C\u4EE5\u514D\u7DB2\u8DEF\u651D\u5F71\u6A5F\u7684\u756B\u9762\u4F86\u81EA\u5FEB\u53D6\u3002",
|
|
6285
|
+
"zh-Hans": "\u6BCF\u6B21\u5237\u65B0\u65F6\u9644\u52A0 t=<now>\uFF0C\u907F\u514D\u7F51\u7EDC\u6444\u50CF\u5934\u7684\u753B\u9762\u6765\u81EA\u7F13\u5B58\u3002"
|
|
5703
6286
|
}
|
|
5704
6287
|
}),
|
|
5705
|
-
fit: t.enum(["cover", "contain"], { label: { en: "Fit", es: "Ajuste" }, labels: { cover: { en: "Fill (crop)", es: "Llenar (recorta)" }, contain: { en: "Whole image", es: "Imagen entera" } } }),
|
|
6288
|
+
fit: t.enum(["cover", "contain"], { label: { en: "Fit", es: "Ajuste", de: "Einpassen", "zh-Hant": "\u7E2E\u653E\u65B9\u5F0F", "zh-Hans": "\u7F29\u653E\u65B9\u5F0F" }, labels: { cover: { en: "Fill (crop)", es: "Llenar (recorta)", de: "F\xFCllen (zuschneiden)", "zh-Hant": "\u586B\u6EFF\uFF08\u88C1\u5207\uFF09", "zh-Hans": "\u586B\u6EE1\uFF08\u88C1\u526A\uFF09" }, contain: { en: "Whole image", es: "Imagen entera", de: "Ganzes Bild", "zh-Hant": "\u5B8C\u6574\u5716\u7247", "zh-Hans": "\u5B8C\u6574\u56FE\u7247" } } }),
|
|
5706
6289
|
position: t.enum(["center", "top", "bottom", "left", "right"], {
|
|
5707
|
-
label: { en: "Keep in view", es: "Mantener a la vista" },
|
|
5708
|
-
labels: { center: { en: "The centre", es: "El centro" }, top: { en: "The top", es: "La parte de arriba" }, bottom: { en: "The bottom", es: "La parte de abajo" }, left: { en: "The left", es: "La izquierda" }, right: { en: "The right", es: "La derecha" } },
|
|
5709
|
-
help: { en: "What filling crops last: the sky of a webcam, the axis of a chart.", es: "Lo \xFAltimo que recorta al llenar: el cielo de una webcam, el eje de una gr\xE1fica." }
|
|
6290
|
+
label: { en: "Keep in view", es: "Mantener a la vista", de: "Im Blick behalten", "zh-Hant": "\u4FDD\u7559\u53EF\u898B", "zh-Hans": "\u4FDD\u6301\u53EF\u89C1" },
|
|
6291
|
+
labels: { center: { en: "The centre", es: "El centro", de: "Die Mitte", "zh-Hant": "\u4E2D\u592E", "zh-Hans": "\u4E2D\u95F4" }, top: { en: "The top", es: "La parte de arriba", de: "Oben", "zh-Hant": "\u4E0A\u65B9", "zh-Hans": "\u9876\u90E8" }, bottom: { en: "The bottom", es: "La parte de abajo", de: "Unten", "zh-Hant": "\u4E0B\u65B9", "zh-Hans": "\u5E95\u90E8" }, left: { en: "The left", es: "La izquierda", de: "Links", "zh-Hant": "\u5DE6\u5074", "zh-Hans": "\u5DE6\u4FA7" }, right: { en: "The right", es: "La derecha", de: "Rechts", "zh-Hant": "\u53F3\u5074", "zh-Hans": "\u53F3\u4FA7" } },
|
|
6292
|
+
help: { en: "What filling crops last: the sky of a webcam, the axis of a chart.", es: "Lo \xFAltimo que recorta al llenar: el cielo de una webcam, el eje de una gr\xE1fica.", de: "Was beim F\xFCllen zuletzt abgeschnitten wird: der Himmel einer Webcam, die Achse eines Diagramms.", "zh-Hant": "\u586B\u6EFF\u6642\u6700\u5F8C\u624D\u88C1\u5207\u7684\u90E8\u5206\uFF1A\u4F8B\u5982\u7DB2\u8DEF\u651D\u5F71\u6A5F\u7684\u5929\u7A7A\u3001\u5716\u8868\u7684\u5EA7\u6A19\u8EF8\u3002", "zh-Hans": "\u586B\u6EE1\u65F6\u6700\u540E\u624D\u88C1\u526A\u7684\u90E8\u5206\uFF1A\u4F8B\u5982\u7F51\u7EDC\u6444\u50CF\u5934\u7684\u5929\u7A7A\u3001\u56FE\u8868\u7684\u5750\u6807\u8F74\u3002" }
|
|
5710
6293
|
}),
|
|
5711
|
-
dim: t.integer({ default: 0, min: 0, max: 90, step: 5, unit: "%", slider: true, label: { en: "Darken", es: "Oscurecer" }, help: { en: "Keeps a photo from outshining everything else.", es: "Para que una foto no deslumbre al resto." } })
|
|
6294
|
+
dim: t.integer({ default: 0, min: 0, max: 90, step: 5, unit: "%", slider: true, label: { en: "Darken", es: "Oscurecer", de: "Abdunkeln", "zh-Hant": "\u8ABF\u6697", "zh-Hans": "\u8C03\u6697" }, help: { en: "Keeps a photo from outshining everything else.", es: "Para que una foto no deslumbre al resto.", de: "Damit ein Foto nicht alles andere \xFCberstrahlt.", "zh-Hant": "\u907F\u514D\u7167\u7247\u6436\u8D70\u5176\u4ED6\u5167\u5BB9\u7684\u98A8\u91C7\u3002", "zh-Hans": "\u907F\u514D\u7167\u7247\u62A2\u4E86\u5176\u4ED6\u5185\u5BB9\u7684\u98CE\u5934\u3002" } })
|
|
5712
6295
|
}),
|
|
5713
6296
|
intervalMs: 5 * 6e4,
|
|
5714
6297
|
async fetch({ options: options2, canvas, signal }) {
|
|
@@ -5727,7 +6310,7 @@ var image = defineWidget({
|
|
|
5727
6310
|
if (!img) {
|
|
5728
6311
|
g.fillStyle = theme.colors.surface;
|
|
5729
6312
|
g.fillRect(box.x, box.y, box.w, box.h);
|
|
5730
|
-
kit.drawTracked(g, options2.src ? "\u2026" : tr({ en: "No image", es: "Sin imagen" }), box.x + box.w / 2, box.y + box.h / 2, { size: Math.min(28, box.h / 4), family: theme.fonts.sans, color: theme.colors.inkFaint, align: "center" });
|
|
6313
|
+
kit.drawTracked(g, options2.src ? "\u2026" : tr({ en: "No image", es: "Sin imagen", de: "Kein Bild", "zh-Hant": "\u6C92\u6709\u5716\u7247", "zh-Hans": "\u6CA1\u6709\u56FE\u7247" }), box.x + box.w / 2, box.y + box.h / 2, { size: Math.min(28, box.h / 4), family: theme.fonts.sans, color: theme.colors.inkFaint, align: "center" });
|
|
5731
6314
|
return;
|
|
5732
6315
|
}
|
|
5733
6316
|
const at = placeImage(box, img.width, img.height, options2.fit, options2.position);
|
|
@@ -5745,12 +6328,13 @@ var image = defineWidget({
|
|
|
5745
6328
|
});
|
|
5746
6329
|
var src_default = definePlugin({
|
|
5747
6330
|
id: "core",
|
|
5748
|
-
name: { en: "Essentials", es: "B\xE1sicos" },
|
|
5749
|
-
version: "0.2.
|
|
6331
|
+
name: { en: "Essentials", es: "B\xE1sicos", de: "Grundlagen", "zh-Hant": "\u57FA\u672C\u5DE5\u5177", "zh-Hans": "\u57FA\u7840\u7EC4\u4EF6" },
|
|
6332
|
+
version: "0.2.6",
|
|
6333
|
+
languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
|
|
5750
6334
|
sdk: "^0.2.0",
|
|
5751
6335
|
// The picture widget reads the image (or folder, or URL) you give it.
|
|
5752
6336
|
permissions: { files: ["user"], network: ["user"] },
|
|
5753
|
-
description: { en: "Clock, date, notes, lists and pictures.", es: "Reloj, fecha, notas, listas e im\xE1genes." },
|
|
6337
|
+
description: { en: "Clock, date, notes, lists and pictures.", es: "Reloj, fecha, notas, listas e im\xE1genes.", de: "Uhr, Datum, Notizen, Listen und Bilder.", "zh-Hant": "\u6642\u9418\u3001\u65E5\u671F\u3001\u4FBF\u689D\u3001\u6E05\u55AE\u548C\u5716\u7247\u3002", "zh-Hans": "\u65F6\u949F\u3001\u65E5\u671F\u3001\u4FBF\u7B7E\u3001\u5217\u8868\u548C\u56FE\u7247\u3002" },
|
|
5754
6338
|
author: "Kiosko",
|
|
5755
6339
|
license: "MIT",
|
|
5756
6340
|
icon: "box",
|
|
@@ -5785,10 +6369,10 @@ function legacyLook(theme) {
|
|
|
5785
6369
|
};
|
|
5786
6370
|
}
|
|
5787
6371
|
var optionsSchema = t.object({
|
|
5788
|
-
module: t.string({ risk: "exec", label: { en: "Module (name or path)", es: "M\xF3dulo (nombre o ruta)" }, placeholder: "pizarra", help: { en: "Looked up in the folder below unless absolute.", es: "Se busca en la carpeta de abajo salvo que sea absoluta." } }),
|
|
5789
|
-
dir: t.string({ default: "~/.aimonitor/modules", format: "path", risk: "exec", label: { en: "Modules folder", es: "Carpeta de m\xF3dulos" }, advanced: true }),
|
|
5790
|
-
config: t.map({ label: { en: "Module config (key \u2192 value)", es: "Config del m\xF3dulo (clave \u2192 valor)" }, help: { en: "Simple values only; numbers and true/false are converted.", es: "S\xF3lo valores simples; n\xFAmeros y true/false se convierten." } }),
|
|
5791
|
-
json: t.string({ multiline: true, label: { en: "Module config as JSON", es: "Config del m\xF3dulo en JSON" }, help: { en: "For lists and nested values. Wins over the table above.", es: "Para listas y valores anidados. Manda sobre la tabla de arriba." }, advanced: true })
|
|
6372
|
+
module: t.string({ risk: "exec", label: { en: "Module (name or path)", es: "M\xF3dulo (nombre o ruta)", de: "Modul (Name oder Pfad)", "zh-Hant": "\u6A21\u7D44\uFF08\u540D\u7A31\u6216\u8DEF\u5F91\uFF09", "zh-Hans": "\u6A21\u5757\uFF08\u540D\u79F0\u6216\u8DEF\u5F84\uFF09" }, placeholder: "pizarra", help: { en: "Looked up in the folder below unless absolute.", es: "Se busca en la carpeta de abajo salvo que sea absoluta.", de: "Wird im Ordner unten gesucht, au\xDFer der Pfad ist absolut.", "zh-Hant": "\u82E5\u4E0D\u662F\u7D55\u5C0D\u8DEF\u5F91\uFF0C\u6703\u5728\u4E0B\u65B9\u7684\u8CC7\u6599\u593E\u4E2D\u5C0B\u627E\u3002", "zh-Hans": "\u5982\u679C\u4E0D\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4F1A\u5728\u4E0B\u65B9\u7684\u6587\u4EF6\u5939\u4E2D\u67E5\u627E\u3002" } }),
|
|
6373
|
+
dir: t.string({ default: "~/.aimonitor/modules", format: "path", risk: "exec", label: { en: "Modules folder", es: "Carpeta de m\xF3dulos", de: "Modulordner", "zh-Hant": "\u6A21\u7D44\u8CC7\u6599\u593E", "zh-Hans": "\u6A21\u5757\u6587\u4EF6\u5939" }, advanced: true }),
|
|
6374
|
+
config: t.map({ label: { en: "Module config (key \u2192 value)", es: "Config del m\xF3dulo (clave \u2192 valor)", de: "Modulkonfiguration (Schl\xFCssel \u2192 Wert)", "zh-Hant": "\u6A21\u7D44\u8A2D\u5B9A\uFF08\u9375 \u2192 \u503C\uFF09", "zh-Hans": "\u6A21\u5757\u914D\u7F6E\uFF08\u952E \u2192 \u503C\uFF09" }, help: { en: "Simple values only; numbers and true/false are converted.", es: "S\xF3lo valores simples; n\xFAmeros y true/false se convierten.", de: "Nur einfache Werte; Zahlen und true/false werden umgewandelt.", "zh-Hant": "\u50C5\u9650\u7C21\u55AE\u503C\uFF1B\u6578\u5B57\u548C true/false \u6703\u81EA\u52D5\u8F49\u63DB\u3002", "zh-Hans": "\u4EC5\u9650\u7B80\u5355\u503C\uFF1B\u6570\u5B57\u548C true/false \u4F1A\u81EA\u52A8\u8F6C\u6362\u3002" } }),
|
|
6375
|
+
json: t.string({ multiline: true, label: { en: "Module config as JSON", es: "Config del m\xF3dulo en JSON", de: "Modulkonfiguration als JSON", "zh-Hant": "JSON \u683C\u5F0F\u7684\u6A21\u7D44\u8A2D\u5B9A", "zh-Hans": "JSON \u683C\u5F0F\u7684\u6A21\u5757\u914D\u7F6E" }, help: { en: "For lists and nested values. Wins over the table above.", es: "Para listas y valores anidados. Manda sobre la tabla de arriba.", de: "F\xFCr Listen und verschachtelte Werte. Hat Vorrang vor der Tabelle oben.", "zh-Hant": "\u7528\u65BC\u6E05\u55AE\u548C\u5DE2\u72C0\u503C\uFF0C\u512A\u5148\u65BC\u4E0A\u65B9\u7684\u8868\u683C\u3002", "zh-Hans": "\u7528\u4E8E\u5217\u8868\u548C\u5D4C\u5957\u503C\uFF0C\u4F18\u5148\u4E8E\u4E0A\u65B9\u7684\u8868\u683C\u3002" }, advanced: true })
|
|
5792
6376
|
});
|
|
5793
6377
|
function moduleConfig(mod, o) {
|
|
5794
6378
|
const kv = Object.fromEntries(Object.entries(o.config).map(([k, v]) => [k, v === "true" ? true : v === "false" ? false : v.trim() !== "" && !Number.isNaN(Number(v)) ? Number(v) : v]));
|
|
@@ -5801,8 +6385,8 @@ function moduleConfig(mod, o) {
|
|
|
5801
6385
|
}
|
|
5802
6386
|
var module2 = defineWidget({
|
|
5803
6387
|
id: "module",
|
|
5804
|
-
name: { en: "aimonitor module", es: "M\xF3dulo de aimonitor" },
|
|
5805
|
-
description: { en: "Runs a custom card written for aimonitor (defineModule) unchanged.", es: "Ejecuta sin cambios una tarjeta propia escrita para aimonitor (defineModule)." },
|
|
6388
|
+
name: { en: "aimonitor module", es: "M\xF3dulo de aimonitor", de: "aimonitor-Modul", "zh-Hant": "aimonitor \u6A21\u7D44", "zh-Hans": "aimonitor \u6A21\u5757" },
|
|
6389
|
+
description: { en: "Runs a custom card written for aimonitor (defineModule) unchanged.", es: "Ejecuta sin cambios una tarjeta propia escrita para aimonitor (defineModule).", de: "F\xFChrt eine f\xFCr aimonitor geschriebene eigene Karte (defineModule) unver\xE4ndert aus.", "zh-Hant": "\u539F\u5C01\u4E0D\u52D5\u57F7\u884C\u70BA aimonitor \u64B0\u5BEB\u7684\u81EA\u8A02\u5361\u7247\uFF08defineModule\uFF09\u3002", "zh-Hans": "\u539F\u6837\u8FD0\u884C\u4E3A aimonitor \u7F16\u5199\u7684\u81EA\u5B9A\u4E49\u5361\u7247\uFF08defineModule\uFF09\u3002" },
|
|
5806
6390
|
icon: "puzzle",
|
|
5807
6391
|
category: "productivity",
|
|
5808
6392
|
size: { min: { w: 200, h: 120 }, preferred: { w: 600, h: 440 } },
|
|
@@ -5822,7 +6406,7 @@ var module2 = defineWidget({
|
|
|
5822
6406
|
render(g, ctx) {
|
|
5823
6407
|
const mod = ctx.data ? loaded.get(ctx.data.path) : void 0;
|
|
5824
6408
|
if (!mod) {
|
|
5825
|
-
ctx.kit.drawTracked(g, ctx.options.module ? "\u2026" : ctx.t({ en: "Pick a module in the options", es: "Elige un m\xF3dulo en las opciones" }), ctx.box.x, ctx.box.y + 30, { size: 22, family: ctx.theme.fonts.sans, color: ctx.theme.colors.inkDim });
|
|
6409
|
+
ctx.kit.drawTracked(g, ctx.options.module ? "\u2026" : ctx.t({ en: "Pick a module in the options", es: "Elige un m\xF3dulo en las opciones", de: "W\xE4hle ein Modul in den Optionen", "zh-Hant": "\u8ACB\u5728\u9078\u9805\u4E2D\u9078\u64C7\u6A21\u7D44", "zh-Hans": "\u8BF7\u5728\u9009\u9879\u4E2D\u9009\u62E9\u6A21\u5757" }), ctx.box.x, ctx.box.y + 30, { size: 22, family: ctx.theme.fonts.sans, color: ctx.theme.colors.inkDim });
|
|
5826
6410
|
return;
|
|
5827
6411
|
}
|
|
5828
6412
|
const box = ctx.box;
|
|
@@ -5840,21 +6424,30 @@ var module2 = defineWidget({
|
|
|
5840
6424
|
});
|
|
5841
6425
|
var src_default2 = definePlugin({
|
|
5842
6426
|
id: "legacy",
|
|
5843
|
-
name: { en: "aimonitor compatibility", es: "Compatibilidad aimonitor" },
|
|
5844
|
-
version: "0.2.
|
|
6427
|
+
name: { en: "aimonitor compatibility", es: "Compatibilidad aimonitor", de: "aimonitor-Kompatibilit\xE4t", "zh-Hant": "aimonitor \u76F8\u5BB9\u6027", "zh-Hans": "aimonitor \u517C\u5BB9" },
|
|
6428
|
+
version: "0.2.6",
|
|
6429
|
+
languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
|
|
5845
6430
|
sdk: "^0.2.0",
|
|
5846
6431
|
// Runs the aimonitor modules you point it at, and reads their folder.
|
|
5847
6432
|
permissions: { exec: ["user"], files: ["user"] },
|
|
5848
|
-
description: { en: "Run your aimonitor custom modules as widgets.", es: "Tus m\xF3dulos propios de aimonitor, como widgets." },
|
|
6433
|
+
description: { en: "Run your aimonitor custom modules as widgets.", es: "Tus m\xF3dulos propios de aimonitor, como widgets.", de: "Deine eigenen aimonitor-Module als Widgets.", "zh-Hant": "\u5C07\u4F60\u7684 aimonitor \u81EA\u8A02\u6A21\u7D44\u7576\u4F5C\u5C0F\u5DE5\u5177\u57F7\u884C\u3002", "zh-Hans": "\u628A\u4F60\u7684 aimonitor \u81EA\u5B9A\u4E49\u6A21\u5757\u4F5C\u4E3A\u5C0F\u7EC4\u4EF6\u8FD0\u884C\u3002" },
|
|
5849
6434
|
author: "Kiosko",
|
|
5850
6435
|
license: "MIT",
|
|
5851
6436
|
icon: "puzzle",
|
|
5852
6437
|
widgets: [module2]
|
|
5853
6438
|
});
|
|
5854
6439
|
|
|
6440
|
+
// packages/server/src/official.ts
|
|
6441
|
+
var BUNDLED_PLUGIN_IDS = ["agents", "cats", "system", "vitals", "usage", "weather", "calendar", "news", "mirror", "gitlab", "github", "calls", "timesheet", "llm", "gpu", "homeassistant"];
|
|
6442
|
+
var OPTIONAL_PLUGIN_IDS = ["doom"];
|
|
6443
|
+
var OFFICIAL_PLUGINS = [
|
|
6444
|
+
...BUNDLED_PLUGIN_IDS.map((id) => ({ id, npm: `kiosko-plugin-${id}`, bundled: true })),
|
|
6445
|
+
...OPTIONAL_PLUGIN_IDS.map((id) => ({ id, npm: `kiosko-plugin-${id}`, bundled: false }))
|
|
6446
|
+
];
|
|
6447
|
+
var BUNDLED_PLUGINS = OFFICIAL_PLUGINS.filter((o) => o.bundled);
|
|
6448
|
+
|
|
5855
6449
|
// packages/server/src/builtin.ts
|
|
5856
6450
|
var BUILTIN_PLUGINS = [src_default, src_default2];
|
|
5857
|
-
var OFFICIAL_PLUGINS = ["agents", "cats", "system", "vitals", "usage", "weather", "calendar", "news", "mirror", "gitlab", "github", "calls", "timesheet", "llm", "gpu", "homeassistant"].map((id) => ({ id, npm: `kiosko-plugin-${id}` }));
|
|
5858
6451
|
|
|
5859
6452
|
// packages/server/src/config-cli.ts
|
|
5860
6453
|
import { copyFileSync as copyFileSync2, existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync6 } from "node:fs";
|
|
@@ -5916,7 +6509,7 @@ var red = paint("31");
|
|
|
5916
6509
|
var yellow = paint("33");
|
|
5917
6510
|
var green = paint("32");
|
|
5918
6511
|
var dim = paint("2");
|
|
5919
|
-
var
|
|
6512
|
+
var plural3 = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
|
|
5920
6513
|
function issueLine(i) {
|
|
5921
6514
|
const ctx = i.context && !i.message.includes(i.context) && !i.path.includes(i.context) ? ` (${i.context})` : "";
|
|
5922
6515
|
return `${i.path}${ctx}: ${i.message}`;
|
|
@@ -5976,7 +6569,7 @@ async function schemaCommand(ctx, opts) {
|
|
|
5976
6569
|
mkdirSync5(dirname4(resolve2(out)), { recursive: true });
|
|
5977
6570
|
writeFileSync6(out, text2);
|
|
5978
6571
|
const count = (k) => plugins.reduce((n, p) => n + (p[k]?.length ?? 0), 0);
|
|
5979
|
-
console.error(`${out}: schema of config.json with ${
|
|
6572
|
+
console.error(`${out}: schema of config.json with ${plural3(count("widgets"), "widget")}, ${plural3(count("sources"), "source")} and ${plural3(count("interludes"), "interlude")} from ${plural3(plugins.length, "plugin")}`);
|
|
5980
6573
|
const rel = relative(dirname4(resolve2(ctx.configPath)), resolve2(out));
|
|
5981
6574
|
console.error(`The published schema (official plugins) is ${CONFIG_SCHEMA_ID}. With plugins of your own, point the config at this file instead:
|
|
5982
6575
|
"$schema": ${JSON.stringify(isAbsolute2(rel) || rel.startsWith("..") ? resolve2(out) : rel)}`);
|
|
@@ -6007,7 +6600,7 @@ async function validateCommand(ctx, file, flags) {
|
|
|
6007
6600
|
console.log(`${input.name}: ${green("valid")}`);
|
|
6008
6601
|
return 0;
|
|
6009
6602
|
}
|
|
6010
|
-
console.log(`${input.name}: ${ok ? green("valid") : red(
|
|
6603
|
+
console.log(`${input.name}: ${ok ? green("valid") : red(plural3(report.errors.length, "error"))}${report.warnings.length ? `, ${yellow(plural3(report.warnings.length, "warning"))}` : ""}`);
|
|
6011
6604
|
if (report.errors.length) console.log(`
|
|
6012
6605
|
${bold("Errors")} (Kiosko would misread these):
|
|
6013
6606
|
${report.errors.map((i) => ` ${issueLine(i)}`).join("\n")}`);
|
|
@@ -6076,7 +6669,7 @@ async function importCommand(ctx, file, flags, opts) {
|
|
|
6076
6669
|
const { errors, warnings } = plan.report;
|
|
6077
6670
|
if (errors.length) {
|
|
6078
6671
|
console.log(`
|
|
6079
|
-
${red(
|
|
6672
|
+
${red(plural3(errors.length, "error"))}${warnings.length ? `, ${yellow(plural3(warnings.length, "warning"))}` : ""}: fix these first (if an AI wrote the file, paste them back to it)`);
|
|
6080
6673
|
for (const i of errors) console.log(` ${issueLine(i)}`);
|
|
6081
6674
|
for (const i of warnings) console.log(` ${dim("warning")} ${issueLine(i)}`);
|
|
6082
6675
|
console.log(dim("\nNothing was written."));
|
|
@@ -6086,7 +6679,7 @@ ${red(plural2(errors.length, "error"))}${warnings.length ? `, ${yellow(plural2(w
|
|
|
6086
6679
|
const pages = c.screens.reduce((n, s) => n + s.pages.length, 0);
|
|
6087
6680
|
const tiles = c.screens.reduce((n, s) => n + s.pages.reduce((m, p) => m + p.tiles.length, 0), 0);
|
|
6088
6681
|
console.log(`
|
|
6089
|
-
${green("valid")}: ${
|
|
6682
|
+
${green("valid")}: ${plural3(c.screens.length, "screen")}, ${plural3(pages, "page")}, ${plural3(tiles, "tile")}${warnings.length ? `; ${yellow(plural3(warnings.length, "warning"))}` : ""}`);
|
|
6090
6683
|
for (const i of warnings) console.log(` ${dim("warning")} ${issueLine(i)}`);
|
|
6091
6684
|
console.log(`
|
|
6092
6685
|
${bold("Changes")}: ${summarizeDiff(plan.diff)}`);
|
|
@@ -6143,7 +6736,7 @@ ${green("Written")} ${path}${saved}.`);
|
|
|
6143
6736
|
if (running) console.log(dim(`The Kiosko at ${running.base} uses another config (${running.servedPath}); it was not touched.`));
|
|
6144
6737
|
else console.log(dim("No running Kiosko answered for this config: it will use the new one when it starts."));
|
|
6145
6738
|
}
|
|
6146
|
-
if (plan.secrets.toFill.length) console.log(`Fill in ${
|
|
6739
|
+
if (plan.secrets.toFill.length) console.log(`Fill in ${plural3(plan.secrets.toFill.length, "secret")} in the editor (Settings \u2192 Data sources, or the widget's options).`);
|
|
6147
6740
|
if (JSON.stringify(current.server) !== JSON.stringify(c.server)) console.log(yellow(`The editor moves to ${c.server.host}:${c.server.port} after a restart.`));
|
|
6148
6741
|
return 0;
|
|
6149
6742
|
}
|
|
@@ -6166,7 +6759,7 @@ async function configCommand(argv2, ctx) {
|
|
|
6166
6759
|
|
|
6167
6760
|
// packages/server/src/plugins-cli.ts
|
|
6168
6761
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6169
|
-
import { existsSync as existsSync9, lstatSync, mkdirSync as mkdirSync6, readdirSync as
|
|
6762
|
+
import { existsSync as existsSync9, lstatSync, mkdirSync as mkdirSync6, readdirSync as readdirSync4, readFileSync as readFileSync5, rmSync, symlinkSync, watch, writeFileSync as writeFileSync7 } from "node:fs";
|
|
6170
6763
|
import { basename, join as join11, resolve as resolve4 } from "node:path";
|
|
6171
6764
|
import { pathToFileURL as pathToFileURL4 } from "node:url";
|
|
6172
6765
|
var npmName = (s) => /^[a-z0-9][\w.-]*$/.test(s) && !s.startsWith("kiosko-plugin-") && !s.includes("/") ? `kiosko-plugin-${s}` : s;
|
|
@@ -6197,6 +6790,12 @@ async function loadPluginDir(dir, o = {}) {
|
|
|
6197
6790
|
var flagOf = (argv2, name) => argv2.includes(name);
|
|
6198
6791
|
var optOf = (argv2, name) => argv2.includes(name) ? argv2[argv2.indexOf(name) + 1] : void 0;
|
|
6199
6792
|
var positional = (argv2) => argv2.filter((a, i) => !a.startsWith("--") && !["--out", "--port"].includes(argv2[i - 1] ?? ""));
|
|
6793
|
+
function lookList(looks) {
|
|
6794
|
+
const parts = looks.map((l) => l.split(" "));
|
|
6795
|
+
const langs = [...new Set(parts.map((p) => p.at(-1)).filter(Boolean))];
|
|
6796
|
+
const themes = new Set(parts.map((p) => p[0]));
|
|
6797
|
+
return looks.length === 1 ? looks[0] : `in ${langs.join(", ")}; ${themes.size} theme${themes.size === 1 ? "" : "s"}`;
|
|
6798
|
+
}
|
|
6200
6799
|
async function check2(dir, argv2) {
|
|
6201
6800
|
const { def, pkg, entry } = await loadPluginDir(dir, { src: flagOf(argv2, "--src") });
|
|
6202
6801
|
console.log(`${def.id} v${def.version} (${entry})`);
|
|
@@ -6204,12 +6803,14 @@ async function check2(dir, argv2) {
|
|
|
6204
6803
|
const meta = packageMeta(pkg);
|
|
6205
6804
|
if (!meta.sdk) issues.push({ level: "warn", where: "package.json", message: 'add "kiosko": { "sdk": "^x.y.z" } so an incompatible Kiosko refuses it before running it' });
|
|
6206
6805
|
else if (def.sdk && meta.sdk !== def.sdk) issues.push({ level: "warn", where: "package.json", message: `kiosko.sdk ${meta.sdk} differs from the definition's sdk ${def.sdk}` });
|
|
6806
|
+
if (def.languages?.length && !meta.languages) issues.push({ level: "warn", where: "package.json", message: `add "kiosko": { "languages": ${JSON.stringify(def.languages)} } so a catalogue knows them without running it` });
|
|
6807
|
+
else if (def.languages && meta.languages && def.languages.join() !== meta.languages.join()) issues.push({ level: "warn", where: "package.json", message: `kiosko.languages ${JSON.stringify(meta.languages)} differs from the definition's ${JSON.stringify(def.languages)}` });
|
|
6207
6808
|
const why = incompatibility({ sdk: def.sdk ?? meta.sdk, platforms: def.platforms ?? meta.platforms });
|
|
6208
6809
|
if (why) issues.push({ level: "warn", where: "plugin", message: `this Kiosko can't run it: ${why}` });
|
|
6209
6810
|
if (pkg.version && pkg.version !== def.version) issues.push({ level: "warn", where: "package.json", message: `version ${pkg.version} differs from the definition's ${def.version}` });
|
|
6210
6811
|
const { checkPlugin: checkPlugin2 } = await Promise.resolve().then(() => (init_testing(), testing_exports));
|
|
6211
6812
|
const painted = /* @__PURE__ */ new Map();
|
|
6212
|
-
for (const p of checkPlugin2(def, { locales:
|
|
6813
|
+
for (const p of checkPlugin2(def, { locales: declaredLanguages(def, meta) })) {
|
|
6213
6814
|
const [size = "", ...look] = p.where.split(" ");
|
|
6214
6815
|
const problem = p.problem.replace(/\d+ px/, "N px").replace(/\d+ ms/, "N ms");
|
|
6215
6816
|
const key = `${p.type}|${size}|${problem}`;
|
|
@@ -6217,12 +6818,12 @@ async function check2(dir, argv2) {
|
|
|
6217
6818
|
g.looks.push(look.join(" "));
|
|
6218
6819
|
painted.set(key, g);
|
|
6219
6820
|
}
|
|
6220
|
-
for (const g of painted.values()) issues.push({ level: /threw/.test(g.problem) ? "error" : "warn", where: `${g.type} ${g.size}`, message: `${g.problem}${g.looks.length
|
|
6821
|
+
for (const g of painted.values()) issues.push({ level: /threw/.test(g.problem) ? "error" : "warn", where: `${g.type} ${g.size}`, message: `${g.problem}${g.looks.length ? ` (${lookList(g.looks)})` : ""}` });
|
|
6221
6822
|
const errors = issues.filter((i) => i.level === "error");
|
|
6222
6823
|
for (const i of [...errors, ...issues.filter((i2) => i2.level === "warn")]) console.log(`${i.level === "error" ? "\u2717" : "!"} ${i.where}: ${i.message}`);
|
|
6223
6824
|
console.log(issues.length ? `
|
|
6224
6825
|
${errors.length} errors, ${issues.length - errors.length} warnings` : "\u2713 no problems found");
|
|
6225
|
-
return errors.length;
|
|
6826
|
+
return { errors: errors.length, warnings: issues.length - errors.length };
|
|
6226
6827
|
}
|
|
6227
6828
|
async function manifest(dir, argv2) {
|
|
6228
6829
|
const root = resolve4(dir);
|
|
@@ -6268,7 +6869,7 @@ function newPluginFiles(id) {
|
|
|
6268
6869
|
license: "MIT",
|
|
6269
6870
|
keywords: ["kiosko", "kiosko-plugin", "lcd", "widgets"],
|
|
6270
6871
|
exports: { ".": { source: "./src/index.ts", default: "./dist/index.js" } },
|
|
6271
|
-
kiosko: { plugin: "./dist/index.js", id, sdk, manifest: "./kiosko-manifest.json" },
|
|
6872
|
+
kiosko: { plugin: "./dist/index.js", id, sdk, languages: ["en", "es"], manifest: "./kiosko-manifest.json" },
|
|
6272
6873
|
files: ["dist", "docs", "kiosko-manifest.json", "README.md", "LICENSE"],
|
|
6273
6874
|
engines: { node: ">=22.18" },
|
|
6274
6875
|
scripts: {
|
|
@@ -6346,6 +6947,8 @@ export default definePlugin({
|
|
|
6346
6947
|
version: '0.1.0',
|
|
6347
6948
|
description: { en: '${name} for Kiosko.', es: '${name} para Kiosko.' },
|
|
6348
6949
|
sdk: '${sdk}',
|
|
6950
|
+
// The languages its texts come in (Chinese by script: 'zh-Hant', 'zh-Hans').
|
|
6951
|
+
languages: ['en', 'es'],
|
|
6349
6952
|
// What it does on the machine, shown before anyone installs it.
|
|
6350
6953
|
permissions: { network: ['user'] },
|
|
6351
6954
|
widgets: [card],
|
|
@@ -6413,8 +7016,8 @@ async function pluginsCommand(argv2, registry2) {
|
|
|
6413
7016
|
const [sub = "list", ...names] = argv2;
|
|
6414
7017
|
switch (sub) {
|
|
6415
7018
|
case "check": {
|
|
6416
|
-
const errors = await check2(positional(names)[0] ?? ".", names);
|
|
6417
|
-
if (errors) process.exitCode = 1;
|
|
7019
|
+
const { errors, warnings } = await check2(positional(names)[0] ?? ".", names);
|
|
7020
|
+
if (errors || flagOf(names, "--strict") && warnings) process.exitCode = 1;
|
|
6418
7021
|
return;
|
|
6419
7022
|
}
|
|
6420
7023
|
case "manifest":
|
|
@@ -6425,7 +7028,7 @@ async function pluginsCommand(argv2, registry2) {
|
|
|
6425
7028
|
const [id, where] = positional(names);
|
|
6426
7029
|
if (!id || !/^[a-z0-9][a-z0-9-]*$/.test(id)) throw new Error("usage: kiosko plugins new <id> [folder] (id: lowercase letters, digits and dashes)");
|
|
6427
7030
|
const dir = resolve4(where ?? `kiosko-plugin-${id}`);
|
|
6428
|
-
if (existsSync9(dir) &&
|
|
7031
|
+
if (existsSync9(dir) && readdirSync4(dir).length) throw new Error(`${dir} is not empty`);
|
|
6429
7032
|
for (const [file, body2] of Object.entries(newPluginFiles(id))) {
|
|
6430
7033
|
mkdirSync6(join11(dir, file, ".."), { recursive: true });
|
|
6431
7034
|
writeFileSync7(join11(dir, file), body2);
|
|
@@ -6512,47 +7115,76 @@ plugins folder: ${paths.plugins}`);
|
|
|
6512
7115
|
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync8 } from "node:fs";
|
|
6513
7116
|
import { join as join12 } from "node:path";
|
|
6514
7117
|
var HOME_URL = "https://kioskolcd.dev/";
|
|
6515
|
-
var DEMO_URL = "https://kioskolcd.dev/demo/";
|
|
6516
7118
|
var RELEASES_URL = "https://github.com/kiosko-lcd/kiosko/releases/latest";
|
|
6517
|
-
var
|
|
7119
|
+
var MADRID = { latitude: 40.4168, longitude: -3.7038, name: "Madrid" };
|
|
7120
|
+
var T = {
|
|
7121
|
+
title: { en: "Kiosko widget gallery", es: "Galer\xEDa de widgets de Kiosko", de: "Kiosko-Widget-Galerie", "zh-Hant": "Kiosko \u5C0F\u5DE5\u5177\u5C55\u793A", "zh-Hans": "Kiosko \u5C0F\u7EC4\u4EF6\u5C55\u793A" },
|
|
7122
|
+
lede: { en: "{n} widgets, painted with their demo data by the same code that drives the panels.", es: "{n} widgets, pintados con sus datos de muestra por el mismo c\xF3digo que mueve los paneles.", de: "{n} Widgets, mit ihren Demodaten gezeichnet, vom selben Code, der die Panels steuert.", "zh-Hant": "{n} \u500B\u5C0F\u5DE5\u5177\uFF0C\u4EE5\u7BC4\u4F8B\u8CC7\u6599\u7E6A\u88FD\uFF0C\u7528\u7684\u6B63\u662F\u9A45\u52D5\u9762\u677F\u7684\u540C\u4E00\u5957\u7A0B\u5F0F\u78BC\u3002", "zh-Hans": "{n} \u4E2A\u5C0F\u7EC4\u4EF6\uFF0C\u7528\u793A\u4F8B\u6570\u636E\u7ED8\u5236\uFF0C\u7528\u7684\u6B63\u662F\u9A71\u52A8\u526F\u5C4F\u7684\u540C\u4E00\u5957\u4EE3\u7801\u3002" },
|
|
7123
|
+
github: { en: "Kiosko on GitHub", es: "Kiosko en GitHub", de: "Kiosko auf GitHub", "zh-Hant": "GitHub \u4E0A\u7684 Kiosko", "zh-Hans": "GitHub \u4E0A\u7684 Kiosko" },
|
|
7124
|
+
editor: { en: "Try the editor in your browser \u2192", es: "Prueba el editor en tu navegador \u2192", de: "Den Editor im Browser ausprobieren \u2192", "zh-Hant": "\u5728\u700F\u89BD\u5668\u4E2D\u8A66\u7528\u7DE8\u8F2F\u5668 \u2192", "zh-Hans": "\u5728\u6D4F\u89C8\u5668\u4E2D\u8BD5\u7528\u7F16\u8F91\u5668 \u2192" },
|
|
7125
|
+
in3d: { en: "See a panel in 3D \u2192", es: "Ver un panel en 3D \u2192", de: "Ein Panel in 3D ansehen \u2192", "zh-Hant": "\u4EE5 3D \u6AA2\u8996\u9762\u677F \u2192", "zh-Hans": "\u67E5\u770B 3D \u526F\u5C4F \u2192" },
|
|
7126
|
+
os: {
|
|
7127
|
+
en: '<b>On Linux, macOS and Windows.</b> Windows has an installer, no Node.js needed: <a href="{releases}">download Kiosko for Windows</a>. USB panels talk to Kiosko directly: <a href="{usb}">how to connect one</a>.',
|
|
7128
|
+
es: '<b>En Linux, macOS y Windows.</b> Windows tiene instalador, sin necesidad de Node.js: <a href="{releases}">descarga Kiosko para Windows</a>. Los paneles USB hablan directamente con Kiosko: <a href="{usb}">c\xF3mo conectar uno</a>.',
|
|
7129
|
+
de: '<b>Unter Linux, macOS und Windows.</b> F\xFCr Windows gibt es einen Installer, kein Node.js n\xF6tig: <a href="{releases}">Kiosko f\xFCr Windows herunterladen</a>. USB-Panels sprechen direkt mit Kiosko: <a href="{usb}">so schlie\xDFt du eins an</a>.',
|
|
7130
|
+
"zh-Hant": '<b>\u652F\u63F4 Linux\u3001macOS \u8207 Windows\u3002</b>Windows \u6709\u5B89\u88DD\u7A0B\u5F0F\uFF0C\u4E0D\u9700\u8981 Node.js\uFF1A<a href="{releases}">\u4E0B\u8F09 Windows \u7248 Kiosko</a>\u3002USB \u9762\u677F\u76F4\u63A5\u8207 Kiosko \u6E9D\u901A\uFF1A<a href="{usb}">\u5982\u4F55\u9023\u63A5\u9762\u677F</a>\u3002',
|
|
7131
|
+
"zh-Hans": '<b>\u652F\u6301 Linux\u3001macOS \u548C Windows\u3002</b>Windows \u6709\u5B89\u88C5\u7A0B\u5E8F\uFF0C\u65E0\u9700 Node.js\uFF1A<a href="{releases}">\u4E0B\u8F7D Windows \u7248 Kiosko</a>\u3002USB \u526F\u5C4F\u76F4\u63A5\u4E0E Kiosko \u901A\u4FE1\uFF1A<a href="{usb}">\u5982\u4F55\u8FDE\u63A5\u526F\u5C4F</a>\u3002'
|
|
7132
|
+
}
|
|
7133
|
+
};
|
|
6518
7134
|
var esc = (s) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
6519
7135
|
var slug2 = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "page";
|
|
6520
7136
|
function buildGallery(registry2, o) {
|
|
6521
|
-
const locale = o.locale ?? "en";
|
|
6522
7137
|
const theme = themeById(o.theme);
|
|
6523
7138
|
const now = o.now ?? Date.now();
|
|
6524
|
-
const
|
|
6525
|
-
|
|
6526
|
-
const
|
|
6527
|
-
const both = (x) => (
|
|
6528
|
-
const data = { count: 0, plugins: [], pages: [] };
|
|
6529
|
-
const sections = [];
|
|
7139
|
+
const langs = o.languages ? LANGUAGES.map((l) => ({ id: l.id, locale: l.panel, dir: l.dir })) : [{ id: o.locale ?? "en", locale: o.locale ?? "en", dir: "ltr" }];
|
|
7140
|
+
const first = langs[0].id;
|
|
7141
|
+
const folder = (id) => id === first ? "" : `${id}/`;
|
|
7142
|
+
const both = (x) => Object.fromEntries(langs.map((l) => [l.id, localize(x, l.locale)]));
|
|
7143
|
+
const data = { count: 0, languages: langs.map((l) => l.id), plugins: [], pages: [] };
|
|
6530
7144
|
let count = 0;
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
const
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
7145
|
+
const pluginsOf = registry2.list().filter(({ def, enabled }) => enabled && def.widgets?.length);
|
|
7146
|
+
for (const lang of langs) {
|
|
7147
|
+
mkdirSync7(join12(o.out, "img", folder(lang.id)), { recursive: true });
|
|
7148
|
+
const cfg = normalize({ locale: lang.locale, theme: theme.id, location: SAMPLE_PLACES[lang.id] ?? MADRID });
|
|
7149
|
+
const L = (x) => localize(x, lang.locale);
|
|
7150
|
+
const up = folder(lang.id) ? "../" : "";
|
|
7151
|
+
const sections = [];
|
|
7152
|
+
const without = languageById(lang.id)?.plugins?.without ?? [];
|
|
7153
|
+
const listedHere = pluginsOf.filter(({ def }) => !without.includes(def.id));
|
|
7154
|
+
for (const { def } of pluginsOf) {
|
|
7155
|
+
let listed = data.plugins.find((p) => p.id === def.id);
|
|
7156
|
+
if (!listed) data.plugins.push(listed = { id: def.id, version: def.version, name: both(def.name), description: both(def.description), widgets: [] });
|
|
7157
|
+
const cards = def.widgets.map((w) => {
|
|
7158
|
+
const pref = w.size?.preferred ?? { w: 480, h: 300 };
|
|
7159
|
+
const width = Math.min(1920, pref.w);
|
|
7160
|
+
const height = Math.min(720, pref.h);
|
|
7161
|
+
const file = `img/${folder(lang.id)}${def.id}-${w.id}.png`;
|
|
7162
|
+
const r = composeWidget({ cfg, registry: registry2, theme, type: `${def.id}/${w.id}`, width, height, now, ...w.chrome === "bare" ? {} : { title: L(w.name) } });
|
|
7163
|
+
writeFileSync8(join12(o.out, file), r.canvas.toBuffer("image/png"));
|
|
7164
|
+
let shot = listed.widgets.find((x) => x.type === `${def.id}/${w.id}`);
|
|
7165
|
+
if (!shot) {
|
|
7166
|
+
count++;
|
|
7167
|
+
listed.widgets.push(shot = { type: `${def.id}/${w.id}`, name: both(w.name), description: both(w.description), file: {}, width, height });
|
|
7168
|
+
}
|
|
7169
|
+
shot.file[lang.id] = file;
|
|
7170
|
+
const wide = width >= 900;
|
|
7171
|
+
return `<figure class="${wide ? "wide" : ""}"><div class="shot"><img src="${up}${file}" width="${width}" height="${height}" loading="lazy" alt="${esc(L(w.name))}"></div><figcaption><b>${esc(L(w.name))}</b> <code>${def.id}/${w.id}</code><span>${esc(L(w.description))}</span></figcaption></figure>`;
|
|
7172
|
+
});
|
|
7173
|
+
if (!without.includes(def.id)) sections.push(`<section><h2>${esc(L(def.name))} <small>${esc(def.id)} \xB7 v${esc(def.version)}</small></h2><p>${esc(L(def.description))}</p><div class="grid">${cards.join("")}</div></section>`);
|
|
7174
|
+
}
|
|
7175
|
+
const home = `${HOME_URL}${folder(lang.id)}`;
|
|
7176
|
+
const usb = `https://github.com/kiosko-lcd/kiosko/blob/main/docs/${lang.id.startsWith("zh") ? `${lang.id}/` : ""}usb.md`;
|
|
7177
|
+
mkdirSync7(join12(o.out, folder(lang.id)), { recursive: true });
|
|
7178
|
+
writeFileSync8(
|
|
7179
|
+
join12(o.out, folder(lang.id), "index.html"),
|
|
7180
|
+
`<!doctype html><html lang="${lang.id}" dir="${lang.dir}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(L(T.title))}</title>
|
|
6552
7181
|
<style>
|
|
6553
7182
|
:root{color-scheme:dark;--bg:#0a0d13;--panel:#121722;--line:rgba(255,255,255,.08);--text:#e7ecf4;--dim:#a3adbf}
|
|
6554
7183
|
body{margin:0;background:var(--bg);color:var(--text);font:15px/1.5 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
|
|
7184
|
+
html:lang(zh-Hant) body{font-family:"PingFang TC","Microsoft JhengHei","Noto Sans TC","Noto Sans CJK TC",ui-sans-serif,system-ui,sans-serif}
|
|
7185
|
+
html:lang(zh-Hans) body{font-family:"PingFang SC","Microsoft YaHei","Noto Sans SC","Noto Sans CJK SC",ui-sans-serif,system-ui,sans-serif}
|
|
6555
7186
|
header{padding:40px 24px 8px;max-width:1240px;margin:auto}h1{margin:0;font-size:32px;letter-spacing:-.02em}
|
|
7187
|
+
html:lang(zh) h1{letter-spacing:0}
|
|
6556
7188
|
header p{color:var(--dim);margin:6px 0 0}main{max-width:1240px;margin:auto;padding:0 24px 60px}
|
|
6557
7189
|
h2{margin:36px 0 4px;font-size:20px}h2 small{color:var(--dim);font-weight:500;font-size:13px;margin-left:8px}section>p{color:var(--dim);margin:0 0 14px}
|
|
6558
7190
|
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:16px;align-items:start}
|
|
@@ -6562,21 +7194,24 @@ figcaption code{color:#22d3ee;font-size:12px}figcaption span{flex-basis:100%;col
|
|
|
6562
7194
|
a{color:#22d3ee}
|
|
6563
7195
|
p.os{margin-top:14px}p.os b{color:var(--text)}
|
|
6564
7196
|
a.try{display:inline-block;margin-top:10px;padding:8px 14px;border-radius:10px;background:linear-gradient(135deg,#8b5cf6,#22d3ee);color:#fff;font-weight:600;text-decoration:none}
|
|
6565
|
-
</style></head><body><header><p><a href="${
|
|
6566
|
-
|
|
7197
|
+
</style></head><body><header><p><a href="${home}">\u2190 Kiosko</a></p><h1>${esc(L(T.title))}</h1><p>${esc(L(T.lede).replace("{n}", String(listedHere.reduce((n, p) => n + p.def.widgets.length, 0))))} <a href="https://github.com/kiosko-lcd/kiosko">${esc(L(T.github))}</a></p><p><a class="try" href="${HOME_URL}demo/?lang=${lang.locale}">${esc(L(T.editor))}</a> <a class="try" href="${HOME_URL}demo/3d/?lang=${lang.locale}">${esc(L(T.in3d))}</a></p><p class="os">${L(T.os).replace("{releases}", RELEASES_URL).replace("{usb}", usb)}</p></header><main>${sections.join("")}</main></body></html>`
|
|
7198
|
+
);
|
|
7199
|
+
}
|
|
6567
7200
|
if (o.pages) {
|
|
6568
7201
|
const sample = normalize(o.pages);
|
|
6569
7202
|
const screen = [...sample.screens].sort((a, b) => b.width / b.height - a.width / a.height)[0];
|
|
6570
7203
|
for (const page of screen?.pages.filter((p) => p.enabled !== false) ?? []) {
|
|
6571
7204
|
const name = `img/page-${slug2(page.name || page.id)}`;
|
|
6572
|
-
data.pages.push({ id: page.id, name: page.name, file:
|
|
7205
|
+
data.pages.push({ id: page.id, name: page.name, file: Object.fromEntries(langs.map((l) => [l.id, l.id === first ? `${name}.jpg` : `${name}.${l.id}.jpg`])), width: screen.width, height: screen.height });
|
|
6573
7206
|
}
|
|
6574
|
-
for (const
|
|
6575
|
-
const
|
|
7207
|
+
for (const l of langs) {
|
|
7208
|
+
const local = normalize({ ...localizeSample(sample, l.locale), locale: l.locale });
|
|
7209
|
+
const shown = local.screens.find((s) => s.id === screen.id);
|
|
7210
|
+
const rt = new Runtime(registry2, local, { demo: true });
|
|
6576
7211
|
try {
|
|
6577
7212
|
for (const listed of data.pages) {
|
|
6578
|
-
const page =
|
|
6579
|
-
writeFileSync8(join12(o.out, listed.file[
|
|
7213
|
+
const page = shown.pages.find((p) => p.id === listed.id);
|
|
7214
|
+
writeFileSync8(join12(o.out, listed.file[l.id]), rt.preview(shown, page, { now, demo: true }).canvas.toBuffer("image/jpeg", 88));
|
|
6580
7215
|
}
|
|
6581
7216
|
} finally {
|
|
6582
7217
|
rt.stop();
|
|
@@ -6670,19 +7305,19 @@ function importAimonitor(old, reg, modeOverride, o = {}) {
|
|
|
6670
7305
|
const device = trcc.frameDir ? { driver: "file", dir: trcc.frameDir, format: "jpeg" } : { driver: "trcc", url: trcc.api?.url ?? "http://127.0.0.1:8099", ...trcc.api?.tokenFile ? { tokenFile: trcc.api.tokenFile } : {}, ...trcc.serial ? { serial: trcc.serial } : {}, ...trcc.deviceKey ? { deviceKey: trcc.deviceKey } : {} };
|
|
6671
7306
|
const grid = { cols: 24, rows: 6, gap: 10, padding: 10 };
|
|
6672
7307
|
const W = (type, options2 = {}, title) => ({ id: newId("w"), type, options: options2, ...title ? { title } : {} });
|
|
6673
|
-
const
|
|
7308
|
+
const T2 = (x, y, w, h, widgets, chrome = "auto", rotateMs = 3e4) => ({ id: newId("tile"), x, y, w, h, widgets, rotateMs, chrome });
|
|
6674
7309
|
const railOn = old.rail?.enabled !== false && old.usage?.enabled !== false;
|
|
6675
7310
|
const sysOn = old.system?.enabled !== false;
|
|
6676
7311
|
const sessionsOpts = { ...old.tile ? { tileMin: old.tile.min, tileMax: old.tile.max, gap: old.tile.gap, detailLines: old.tile.detailLines } : {}, ...old.spineWidth ? { spineWidth: old.spineWidth } : {} };
|
|
6677
|
-
const dashTiles = [
|
|
6678
|
-
if (sysOn) dashTiles.push(
|
|
6679
|
-
if (railOn) dashTiles.push(
|
|
7312
|
+
const dashTiles = [T2(0, 0, 24, 1, [W("agents/summary")], "bare"), T2(0, 1, railOn ? sysOn ? 13 : 19 : sysOn ? 18 : 24, 5, [W("agents/sessions", sessionsOpts)], "bare")];
|
|
7313
|
+
if (sysOn) dashTiles.push(T2(railOn ? 13 : 18, 1, 6, 5, [W("vitals/vitals")], "bare"));
|
|
7314
|
+
if (railOn) dashTiles.push(T2(19, 1, 5, 5, [W("usage/rail")], "bare"));
|
|
6680
7315
|
const dashboard = { id: newId("page"), name: "Dashboard", enabled: true, durationMs: old.scene?.alternateMs ?? 10 * 6e4, when: "always", grid, gravity: "none", background: {}, tiles: dashTiles };
|
|
6681
7316
|
const cardWidgets = (old.modules ?? []).map((m) => widgetFor(m, reg, notes, modulesDir)).filter((w) => !!w);
|
|
6682
7317
|
if (railOn) cardWidgets.push(W("usage/rail", {}, "Consumo"));
|
|
6683
7318
|
const side = old.scene?.side === "izquierda" ? "left" : "right";
|
|
6684
|
-
const catsTiles = [
|
|
6685
|
-
if (cardWidgets.length) catsTiles.push(
|
|
7319
|
+
const catsTiles = [T2(side === "right" ? 0 : 7, 0, 17, 6, [W("cats/room", { room: old.scene?.room === "rotar" || !old.scene?.room ? "rotate" : old.scene.room })], "bare")];
|
|
7320
|
+
if (cardWidgets.length) catsTiles.push(T2(side === "right" ? 17 : 0, 0, 7, 6, cardWidgets, "card", old.timesheet?.alternateMs || 3e4));
|
|
6686
7321
|
const cats = { id: newId("page"), name: "Cats", enabled: true, durationMs: old.scene?.alternateMs ?? 10 * 6e4, when: "always", grid, gravity: "none", background: {}, tiles: catsTiles };
|
|
6687
7322
|
const override = (modeOverride ?? "").trim().toLowerCase();
|
|
6688
7323
|
const mode = ["gatos", "tablero", "alternar"].includes(override) ? override : old.scene?.mode ?? "tablero";
|
|
@@ -7172,12 +7807,12 @@ var MqttClient = class extends EventEmitter2 {
|
|
|
7172
7807
|
};
|
|
7173
7808
|
|
|
7174
7809
|
// packages/server/src/homeassistant.ts
|
|
7175
|
-
var AUTO = { en: "Auto", es: "Autom\xE1tica" };
|
|
7810
|
+
var AUTO = { en: "Auto", es: "Autom\xE1tica", de: "Automatisch", "zh-Hant": "\u81EA\u52D5", "zh-Hans": "\u81EA\u52A8" };
|
|
7176
7811
|
var NAMES = {
|
|
7177
|
-
page: { en: "Page", es: "P\xE1gina" },
|
|
7178
|
-
shown: { en: "Page shown", es: "P\xE1gina en pantalla" },
|
|
7179
|
-
display: { en: "Display", es: "Pantalla" },
|
|
7180
|
-
interlude: { en: "Play", es: "Reproducir" }
|
|
7812
|
+
page: { en: "Page", es: "P\xE1gina", de: "Seite", "zh-Hant": "\u9801\u9762", "zh-Hans": "\u9875\u9762" },
|
|
7813
|
+
shown: { en: "Page shown", es: "P\xE1gina en pantalla", de: "Angezeigte Seite", "zh-Hant": "\u76EE\u524D\u9801\u9762", "zh-Hans": "\u5F53\u524D\u9875\u9762" },
|
|
7814
|
+
display: { en: "Display", es: "Pantalla", de: "Anzeige", "zh-Hant": "\u87A2\u5E55", "zh-Hans": "\u5C4F\u5E55" },
|
|
7815
|
+
interlude: { en: "Play", es: "Reproducir", de: "Abspielen", "zh-Hant": "\u64AD\u653E", "zh-Hans": "\u64AD\u653E" }
|
|
7181
7816
|
};
|
|
7182
7817
|
var slug3 = (s) => s.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "x";
|
|
7183
7818
|
function pageOptions(screen, auto) {
|
|
@@ -7227,7 +7862,7 @@ var HomeAssistantBridge = class {
|
|
|
7227
7862
|
return `kiosko/${this.link.nodeId}`;
|
|
7228
7863
|
}
|
|
7229
7864
|
loc(l) {
|
|
7230
|
-
return resolveLocale(this.runtime.config)
|
|
7865
|
+
return localize(l, resolveLocale(this.runtime.config));
|
|
7231
7866
|
}
|
|
7232
7867
|
/** A new config: connect, reconnect (other broker or login) or just announce again. */
|
|
7233
7868
|
apply(cfg) {
|
|
@@ -7328,7 +7963,7 @@ var HomeAssistantBridge = class {
|
|
|
7328
7963
|
});
|
|
7329
7964
|
for (const slot of screen.interludes) {
|
|
7330
7965
|
const def = this.runtime.registry.interlude(slot.type);
|
|
7331
|
-
const name = def ?
|
|
7966
|
+
const name = def ? this.loc(def.name) || slot.type : slot.type;
|
|
7332
7967
|
put("button", `${sid}_${slug3(slot.id)}`, {
|
|
7333
7968
|
name: `${this.loc(NAMES.interlude)}: ${name}`,
|
|
7334
7969
|
unique_id: id(slug3(slot.id)),
|
|
@@ -7496,7 +8131,7 @@ data: ${JSON.stringify(data)}
|
|
|
7496
8131
|
if (p === "/api/config" && m === "PUT") {
|
|
7497
8132
|
const b = await body(req);
|
|
7498
8133
|
const raw = b && typeof b === "object" && "config" in b ? b.config : b;
|
|
7499
|
-
if (typeof b?.baseRev === "number" && b.baseRev !== rev) return json(res, 409, { error: "the configuration changed elsewhere", rev, config: runtime.config });
|
|
8134
|
+
if (typeof b?.baseRev === "number" && b.baseRev !== rev) return json(res, 409, { error: "the configuration changed elsewhere", code: "conflict", rev, config: runtime.config });
|
|
7500
8135
|
const cfg = normalize(raw);
|
|
7501
8136
|
saveConfig(cfg, o.configPath);
|
|
7502
8137
|
rev++;
|
|
@@ -7521,7 +8156,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7521
8156
|
let mm = /^\/api\/screens\/([^/]+)\/frame\.(?:jpg|png)$/.exec(p);
|
|
7522
8157
|
if (mm && m === "GET") {
|
|
7523
8158
|
const f = runtime.lastFrame(decodeURIComponent(mm[1]));
|
|
7524
|
-
if (!f) return json(res, 404, { error: "no frame yet" });
|
|
8159
|
+
if (!f) return json(res, 404, { error: "no frame yet", code: "noFrame" });
|
|
7525
8160
|
const buf = f.image();
|
|
7526
8161
|
res.writeHead(200, { "content-type": "image/jpeg", "cache-control": "no-store", "content-length": String(buf.length), "x-kiosko-at": String(f.at) });
|
|
7527
8162
|
return void res.end(buf);
|
|
@@ -7531,7 +8166,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7531
8166
|
const cfg = normalize({ screens: [b.screen] });
|
|
7532
8167
|
const screen = cfg.screens[0];
|
|
7533
8168
|
const page = screen.pages.find((x) => x.id === b.pageId) ?? screen.pages[0];
|
|
7534
|
-
if (!page) return json(res, 400, { error: "no page" });
|
|
8169
|
+
if (!page) return json(res, 400, { error: "no page", code: "noPage" });
|
|
7535
8170
|
const r = runtime.preview(screen, page, { ...b.forceShown ? { forceShown: b.forceShown } : {}, demo: b.demo ?? true });
|
|
7536
8171
|
return png(res, r.canvas.toBuffer("image/png"), { "x-kiosko-tiles": encodeURIComponent(JSON.stringify(r.tiles)) });
|
|
7537
8172
|
}
|
|
@@ -7543,7 +8178,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7543
8178
|
const key = `${look.theme ?? runtime.config.theme}|${type}|${w}x${h}|${look.locale ?? runtime.config.locale}`;
|
|
7544
8179
|
let buf = thumbs.get(key);
|
|
7545
8180
|
if (!buf) {
|
|
7546
|
-
if (!runtime.registry.widget(type)) return json(res, 404, { error: "unknown widget" });
|
|
8181
|
+
if (!runtime.registry.widget(type)) return json(res, 404, { error: "unknown widget", code: "unknownWidget" });
|
|
7547
8182
|
buf = runtime.thumbnail(type, w, h, {}, void 0, look);
|
|
7548
8183
|
thumbs.set(key, buf);
|
|
7549
8184
|
}
|
|
@@ -7596,7 +8231,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7596
8231
|
const id = decodeURIComponent(mm[1]);
|
|
7597
8232
|
try {
|
|
7598
8233
|
const r = await removePlugin(id, { registry: runtime.registry, runtime });
|
|
7599
|
-
if (!r.removed) return json(res, 409, { error: `can't remove "${id}": ${r.reason}
|
|
8234
|
+
if (!r.removed) return json(res, 409, { error: `can't remove "${id}": ${r.reason}`, code: "cantRemove", params: { id, why: r.reason } });
|
|
7600
8235
|
rev++;
|
|
7601
8236
|
send("config", { rev, by: null });
|
|
7602
8237
|
return json(res, 200, state());
|
|
@@ -7618,7 +8253,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7618
8253
|
if (mm && m === "POST") {
|
|
7619
8254
|
const id = decodeURIComponent(mm[1]);
|
|
7620
8255
|
const u = updates?.plugins.find((x) => x.id === id);
|
|
7621
|
-
if (!u?.version) return json(res, 409,
|
|
8256
|
+
if (!u?.version) return json(res, 409, u?.blocked ? { error: `can't update "${id}": ${u.blocked}`, code: "cantUpdate", params: { id, why: u.blocked } } : { error: `no update for "${id}"`, code: "noUpdate", params: { id } });
|
|
7622
8257
|
try {
|
|
7623
8258
|
const r = await installPlugin(`${u.package}@${u.version}`, { registry: runtime.registry, runtime });
|
|
7624
8259
|
if (!r.problem && updates) updates = { ...updates, plugins: updates.plugins.filter((x) => x.id !== id) };
|
|
@@ -7634,7 +8269,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7634
8269
|
if (mm && m === "POST") {
|
|
7635
8270
|
const id = decodeURIComponent(mm[1]);
|
|
7636
8271
|
const problem = await reloadPlugin(id, { registry: runtime.registry, runtime });
|
|
7637
|
-
if (problem) return json(res, 409, { error: problem });
|
|
8272
|
+
if (problem) return json(res, 409, { error: problem, code: "reloadFailed", params: { id, why: problem } });
|
|
7638
8273
|
rev++;
|
|
7639
8274
|
send("config", { rev, by: null });
|
|
7640
8275
|
return json(res, 200, state());
|
|
@@ -7656,11 +8291,11 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7656
8291
|
if (p === "/api/screens/export" && m === "GET") {
|
|
7657
8292
|
const id = url2.searchParams.get("id") ?? "";
|
|
7658
8293
|
const s = findScreen(runtime.config, id);
|
|
7659
|
-
if (!s || !safeId(id)) return json(res, 404, { error: "unknown screen" });
|
|
8294
|
+
if (!s || !safeId(id)) return json(res, 404, { error: "unknown screen", code: "unknownScreen" });
|
|
7660
8295
|
res.writeHead(200, { "content-type": "application/json", "content-disposition": `attachment; filename="kiosko-${id}.json"` });
|
|
7661
8296
|
return void res.end(JSON.stringify({ kiosko: "screen", version: 1, screen: { ...s, device: { driver: "virtual" } } }, null, 2));
|
|
7662
8297
|
}
|
|
7663
|
-
return json(res, 404, { error: "not found" });
|
|
8298
|
+
return json(res, 404, { error: "not found", code: "notFound" });
|
|
7664
8299
|
}
|
|
7665
8300
|
function serveStatic(res, pathname) {
|
|
7666
8301
|
const rel = normPath(decodeURIComponent(pathname)).replace(/^([/\\])+/, "");
|
|
@@ -7711,10 +8346,10 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7711
8346
|
function starterConfig(registry2, o = {}) {
|
|
7712
8347
|
const width = o.width ?? 1920;
|
|
7713
8348
|
const height = o.height ?? 462;
|
|
7714
|
-
const
|
|
7715
|
-
const screen = newScreen(
|
|
8349
|
+
const L = (t2) => localize(t2, o.locale ?? "en");
|
|
8350
|
+
const screen = newScreen(L({ en: "My panel", es: "Mi panel", de: "Mein Panel", "zh-Hant": "\u6211\u7684\u9762\u677F", "zh-Hans": "\u6211\u7684\u5C4F\u5E55" }), width, height);
|
|
7716
8351
|
const has = (t2) => !!registry2.widget(t2);
|
|
7717
|
-
const page = newPage(
|
|
8352
|
+
const page = newPage(L({ en: "Home", es: "Inicio", de: "Start", "zh-Hant": "\u9996\u9801", "zh-Hans": "\u9996\u9875" }), width, height);
|
|
7718
8353
|
page.grid = { cols: 24, rows: 6, gap: 10, padding: 10 };
|
|
7719
8354
|
page.gravity = "left";
|
|
7720
8355
|
const tiles = [];
|
|
@@ -7723,13 +8358,13 @@ function starterConfig(registry2, o = {}) {
|
|
|
7723
8358
|
if (ws.length) tiles.push(newTile(r, ws));
|
|
7724
8359
|
};
|
|
7725
8360
|
if (has("agents/sessions")) add({ x: 0, y: 0, w: 11, h: 6 }, ["agents/sessions"]);
|
|
7726
|
-
else add({ x: 0, y: 0, w: 11, h: 6 }, ["core/text"],
|
|
8361
|
+
else add({ x: 0, y: 0, w: 11, h: 6 }, ["core/text"], L({ en: "Welcome", es: "Bienvenida", de: "Willkommen", "zh-Hant": "\u6B61\u8FCE", "zh-Hans": "\u6B22\u8FCE" }));
|
|
7727
8362
|
add({ x: 11, y: 0, w: 5, h: 4 }, ["core/clock"]);
|
|
7728
8363
|
add({ x: 11, y: 4, w: 5, h: 2 }, ["weather/forecast", "mirror/compliments"]);
|
|
7729
8364
|
add({ x: 16, y: 0, w: 8, h: 6 }, ["usage/rail", "vitals/vitals", "system/health", "mirror/countdown"].filter(has).slice(0, 3));
|
|
7730
8365
|
if (!has("agents/sessions")) {
|
|
7731
8366
|
const welcome = tiles[0]?.widgets[0];
|
|
7732
|
-
if (welcome) welcome.options = { text:
|
|
8367
|
+
if (welcome) welcome.options = { text: L({ en: "Hi there.\nDrag widgets from the library to build your panel.", es: "Hola.\nArrastra widgets desde la biblioteca para montar tu panel.", de: "Hallo!\nZieh Widgets aus der Bibliothek, um dein Panel zu gestalten.", "zh-Hant": "\u4F60\u597D\u3002\n\u5F9E\u5C0F\u5DE5\u5177\u5EAB\u62D6\u66F3\u5C0F\u5DE5\u5177\uFF0C\u6253\u9020\u4F60\u7684\u9762\u677F\u3002", "zh-Hans": "\u4F60\u597D\u3002\n\u4ECE\u7EC4\u4EF6\u5E93\u62D6\u52A8\u5C0F\u7EC4\u4EF6\uFF0C\u642D\u5EFA\u4F60\u7684\u5C4F\u5E55\u3002" }), maxSize: 54 };
|
|
7733
8368
|
}
|
|
7734
8369
|
page.tiles = tiles;
|
|
7735
8370
|
if (height > width) transposePage(page, width, height);
|
|
@@ -7744,7 +8379,7 @@ function starterConfig(registry2, o = {}) {
|
|
|
7744
8379
|
}
|
|
7745
8380
|
|
|
7746
8381
|
// packages/server/src/cli.ts
|
|
7747
|
-
var VERSION = "0.2.
|
|
8382
|
+
var VERSION = "0.2.6";
|
|
7748
8383
|
var USAGE2 = `Kiosko ${VERSION}: a widget mosaic for USB LCD panels
|
|
7749
8384
|
|
|
7750
8385
|
kiosko start [--port 7420] [--host 127.0.0.1] [--config file] [--open] [--demo]
|
|
@@ -7757,13 +8392,13 @@ var USAGE2 = `Kiosko ${VERSION}: a widget mosaic for USB LCD panels
|
|
|
7757
8392
|
kiosko usb [list] the LY panels libusb sees, with their serial numbers
|
|
7758
8393
|
kiosko usb test [--serial S] [--seconds 10] [--size 1920x462] [--rotate 180]
|
|
7759
8394
|
drive a panel with the sample screen (experimental)
|
|
7760
|
-
kiosko gallery [--out gallery] [--locale en] [--theme midnight] [--pages config.json]
|
|
8395
|
+
kiosko gallery [--out gallery] [--locale en | --all-languages] [--theme midnight] [--pages config.json]
|
|
7761
8396
|
kiosko plugins [list|add <id>\u2026|link <folder>\u2026|remove <id>\u2026]
|
|
7762
8397
|
kiosko service install|uninstall|print (start with your session)
|
|
7763
8398
|
kiosko version`;
|
|
7764
8399
|
var argv = process.argv.slice(2);
|
|
7765
8400
|
var FLAG_COMMANDS = /* @__PURE__ */ new Set(["--help", "-h", "--version", "-v"]);
|
|
7766
|
-
var cmd = argv[0] && (!argv[0].startsWith("-") || FLAG_COMMANDS.has(argv[0])) ? argv[0] : "start";
|
|
8401
|
+
var cmd = argv.includes("--help") || argv.includes("-h") ? "help" : argv[0] && (!argv[0].startsWith("-") || FLAG_COMMANDS.has(argv[0])) ? argv[0] : "start";
|
|
7767
8402
|
var flag = (name) => argv.includes(name);
|
|
7768
8403
|
var opt = (name) => {
|
|
7769
8404
|
const i = argv.indexOf(name);
|
|
@@ -7819,6 +8454,13 @@ async function main() {
|
|
|
7819
8454
|
const url2 = `http://${host === "0.0.0.0" ? "127.0.0.1" : host}:${port}/`;
|
|
7820
8455
|
console.log(`Kiosko ${VERSION} \u2014 editor at ${url2}`);
|
|
7821
8456
|
console.log(`config: ${path}`);
|
|
8457
|
+
const locale = resolveLocale(cfg);
|
|
8458
|
+
if (hanScript(locale)) {
|
|
8459
|
+
const fonts = cjkFontStatus(locale);
|
|
8460
|
+
if (!fonts.ok) console.warn(`fonts: ${fonts.line}`);
|
|
8461
|
+
}
|
|
8462
|
+
const other = scriptFontStatus(locale);
|
|
8463
|
+
if (other && !other.ok) console.warn(`fonts: ${other.line}`);
|
|
7822
8464
|
if (flag("--open")) openBrowser(url2);
|
|
7823
8465
|
const stop = () => {
|
|
7824
8466
|
rt.stop();
|
|
@@ -7911,6 +8553,10 @@ async function main() {
|
|
|
7911
8553
|
console.log(`Kiosko ${VERSION} on ${process.platform}/${process.arch}, Node ${process.version}`);
|
|
7912
8554
|
console.log(`config ${path} ${exists ? error ? `INVALID: ${error}` : "ok" : "(not created yet)"}`);
|
|
7913
8555
|
console.log(`plugins ${reg.list().map((p) => p.def.id).join(", ")}`);
|
|
8556
|
+
const fonts = cjkFontStatus(resolveLocale(cfg));
|
|
8557
|
+
console.log(`fonts ${fonts.ok ? "" : "\u2717 "}${fonts.line}`);
|
|
8558
|
+
const other = scriptFontStatus(resolveLocale(cfg));
|
|
8559
|
+
if (other) console.log(`fonts ${other.ok ? "" : "\u2717 "}${other.line}`);
|
|
7914
8560
|
for (const p of reg.problems) console.log(` \u2717 ${p.origin}: ${p.message}`);
|
|
7915
8561
|
const usb = await listUsb();
|
|
7916
8562
|
if (!usb.ok) console.log(`usb not available: ${usb.error}`);
|
|
@@ -7925,6 +8571,8 @@ async function main() {
|
|
|
7925
8571
|
case "service": {
|
|
7926
8572
|
const pass = ["--port", "--host", "--config"].flatMap((f) => opt(f) ? [f, opt(f)] : []);
|
|
7927
8573
|
const env = process.env.KIOSKO_HOME ? { KIOSKO_HOME: process.env.KIOSKO_HOME } : {};
|
|
8574
|
+
const lang = process.env.LC_ALL || process.env.LANG || `${systemLocale().replace(/-/g, "_")}.UTF-8`;
|
|
8575
|
+
if (lang && !/^(C|POSIX)(\.|$)/.test(lang)) env.LANG = lang;
|
|
7928
8576
|
runService(argv[1] ?? "print", servicePlan({ args: pass, env }));
|
|
7929
8577
|
return;
|
|
7930
8578
|
}
|
|
@@ -7933,7 +8581,7 @@ async function main() {
|
|
|
7933
8581
|
const reg = await registry();
|
|
7934
8582
|
const out = opt("--out") ?? "gallery";
|
|
7935
8583
|
const sample = opt("--pages");
|
|
7936
|
-
const n = buildGallery(reg, { out, locale: opt("--locale") ?? "en", theme: opt("--theme") ?? "midnight", ...sample ? { pages: JSON.parse(readFileSync8(sample, "utf8")) } : {} });
|
|
8584
|
+
const n = buildGallery(reg, { out, locale: opt("--locale") ?? "en", languages: flag("--all-languages"), theme: opt("--theme") ?? "midnight", ...sample ? { pages: JSON.parse(readFileSync8(sample, "utf8")) } : {} });
|
|
7937
8585
|
console.log(`${n} widgets \u2192 ${out}/index.html`);
|
|
7938
8586
|
return;
|
|
7939
8587
|
}
|