kiosko 0.2.4 → 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 +1059 -290
- package/kit.js +94 -10
- 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 ?? "",
|
|
@@ -346,19 +476,72 @@ function setDefaultFamily(family) {
|
|
|
346
476
|
defaultFamily = family;
|
|
347
477
|
}
|
|
348
478
|
function registerFontFiles(fonts) {
|
|
479
|
+
widths.clear();
|
|
349
480
|
return Object.entries(fonts).filter(([family, path]) => !GlobalFonts.registerFromPath(path, family)).map(([, path]) => path);
|
|
350
481
|
}
|
|
482
|
+
function widthOf(ctx, font, ch) {
|
|
483
|
+
let byChar = widths.get(font);
|
|
484
|
+
if (!byChar) {
|
|
485
|
+
if (widths.size >= MAX_FONTS) widths.clear();
|
|
486
|
+
byChar = /* @__PURE__ */ new Map();
|
|
487
|
+
widths.set(font, byChar);
|
|
488
|
+
}
|
|
489
|
+
let w = byChar.get(ch);
|
|
490
|
+
if (w === void 0) {
|
|
491
|
+
if (ctx.font !== font) ctx.font = font;
|
|
492
|
+
w = ctx.measureText(ch).width;
|
|
493
|
+
byChar.set(ch, w);
|
|
494
|
+
}
|
|
495
|
+
return w;
|
|
496
|
+
}
|
|
497
|
+
function clearTextCache() {
|
|
498
|
+
widths.clear();
|
|
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
|
+
}
|
|
351
519
|
function glyphs(ctx, text2, o) {
|
|
352
520
|
const family = o.family ?? defaultFamily;
|
|
353
|
-
const
|
|
521
|
+
const cjk = hasCjk(text2);
|
|
522
|
+
const small = o.smallCaps === true && !cjk;
|
|
354
523
|
const capSize = o.size * (o.capRatio ?? 0.76);
|
|
355
524
|
const out = [];
|
|
525
|
+
const font = `${o.size}px "${family}"`;
|
|
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}"`;
|
|
356
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
|
+
}
|
|
357
541
|
const isLower = small && ch !== ch.toUpperCase() && ch === ch.toLowerCase();
|
|
358
542
|
const size = isLower ? capSize : o.size;
|
|
359
543
|
const draw = small ? ch.toUpperCase() : ch;
|
|
360
|
-
|
|
361
|
-
out.push({ ch: draw, size, width: ctx.measureText(draw).width });
|
|
544
|
+
out.push({ ch: draw, size, width: widthOf(ctx, isLower ? capFont : font, draw) });
|
|
362
545
|
}
|
|
363
546
|
return out;
|
|
364
547
|
}
|
|
@@ -367,18 +550,22 @@ function advance(gs, tracking) {
|
|
|
367
550
|
return gs.reduce((a, g) => a + g.width, 0) + tracking * (gs.length - 1);
|
|
368
551
|
}
|
|
369
552
|
function measureTracked(ctx, text2, o) {
|
|
370
|
-
return advance(glyphs(ctx, text2, o), o
|
|
553
|
+
return advance(glyphs(ctx, text2, o), trackingOf(text2, o));
|
|
371
554
|
}
|
|
372
555
|
function drawTracked(ctx, text2, x, y, o) {
|
|
373
556
|
const family = o.family ?? defaultFamily;
|
|
374
|
-
const tracking = o
|
|
557
|
+
const tracking = trackingOf(text2, o);
|
|
375
558
|
const gs = glyphs(ctx, text2, o);
|
|
376
559
|
const total = advance(gs, tracking);
|
|
377
560
|
let cursor = o.align === "right" ? x - total : o.align === "center" ? x - total / 2 : x;
|
|
378
561
|
if (o.color) ctx.fillStyle = o.color;
|
|
379
562
|
ctx.textBaseline = "alphabetic";
|
|
563
|
+
let size = -1;
|
|
380
564
|
for (const g of gs) {
|
|
381
|
-
|
|
565
|
+
if (g.size !== size) {
|
|
566
|
+
ctx.font = `${g.size}px "${family}"`;
|
|
567
|
+
size = g.size;
|
|
568
|
+
}
|
|
382
569
|
ctx.fillText(g.ch, cursor, y);
|
|
383
570
|
cursor += g.width + tracking;
|
|
384
571
|
}
|
|
@@ -407,15 +594,30 @@ function drawClipped(ctx, text2, x, y, maxWidth, o) {
|
|
|
407
594
|
}
|
|
408
595
|
function fitPrefix(ctx, text2, maxWidth, o) {
|
|
409
596
|
if (measureTracked(ctx, text2, o) <= maxWidth) return text2.length;
|
|
597
|
+
const chars = [...text2];
|
|
410
598
|
let lo = 1;
|
|
411
|
-
let hi =
|
|
599
|
+
let hi = chars.length;
|
|
412
600
|
while (lo < hi) {
|
|
413
601
|
const mid = Math.ceil((lo + hi) / 2);
|
|
414
|
-
if (measureTracked(ctx,
|
|
602
|
+
if (measureTracked(ctx, chars.slice(0, mid).join(""), o) <= maxWidth) lo = mid;
|
|
415
603
|
else hi = mid - 1;
|
|
416
604
|
}
|
|
417
|
-
const
|
|
418
|
-
|
|
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;
|
|
419
621
|
}
|
|
420
622
|
function wrapLines(ctx, text2, maxWidth, maxLines, o) {
|
|
421
623
|
const clean = text2.replace(/\s+/g, " ").trim();
|
|
@@ -433,11 +635,19 @@ function wrapLines(ctx, text2, maxWidth, maxLines, o) {
|
|
|
433
635
|
}
|
|
434
636
|
return lines;
|
|
435
637
|
}
|
|
436
|
-
var defaultFamily;
|
|
638
|
+
var defaultFamily, widths, MAX_FONTS, CJK, minCjkPx, enlarged, NO_START, NO_END, isSpace;
|
|
437
639
|
var init_text = __esm({
|
|
438
640
|
"packages/lcd-canvas-kit/src/text.ts"() {
|
|
439
641
|
"use strict";
|
|
440
642
|
defaultFamily = "sans-serif";
|
|
643
|
+
widths = /* @__PURE__ */ new Map();
|
|
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);
|
|
441
651
|
}
|
|
442
652
|
});
|
|
443
653
|
|
|
@@ -750,6 +960,7 @@ __export(src_exports, {
|
|
|
750
960
|
TAU: () => TAU,
|
|
751
961
|
bezierPts: () => bezierPts,
|
|
752
962
|
clamp: () => clamp3,
|
|
963
|
+
clearTextCache: () => clearTextCache,
|
|
753
964
|
css: () => css,
|
|
754
965
|
drawClipped: () => drawClipped,
|
|
755
966
|
drawMoonPhase: () => drawMoonPhase,
|
|
@@ -757,6 +968,7 @@ __export(src_exports, {
|
|
|
757
968
|
drawWeatherIcon: () => drawWeatherIcon,
|
|
758
969
|
ellipse: () => ellipse,
|
|
759
970
|
fitSize: () => fitSize,
|
|
971
|
+
hasCjk: () => hasCjk,
|
|
760
972
|
hashString: () => hashString,
|
|
761
973
|
hex: () => hex,
|
|
762
974
|
linear: () => linear,
|
|
@@ -767,8 +979,10 @@ __export(src_exports, {
|
|
|
767
979
|
registerFontFiles: () => registerFontFiles,
|
|
768
980
|
rng: () => rng,
|
|
769
981
|
setDefaultFamily: () => setDefaultFamily,
|
|
982
|
+
setMinCjkPx: () => setMinCjkPx,
|
|
770
983
|
smooth: () => smooth,
|
|
771
984
|
sparkBars: () => sparkBars,
|
|
985
|
+
takeCjkEnlarged: () => takeCjkEnlarged,
|
|
772
986
|
truncate: () => truncate,
|
|
773
987
|
wrapLines: () => wrapLines
|
|
774
988
|
});
|
|
@@ -791,7 +1005,7 @@ __export(testing_exports, {
|
|
|
791
1005
|
renderWidget: () => renderWidget,
|
|
792
1006
|
widgetState: () => widgetState
|
|
793
1007
|
});
|
|
794
|
-
import { createCanvas as
|
|
1008
|
+
import { createCanvas as createCanvas6, loadImage as loadImage4 } from "@napi-rs/canvas";
|
|
795
1009
|
function resolve3(w, o) {
|
|
796
1010
|
const now = o.now ?? Date.UTC(2026, 10, 5, 9, 42);
|
|
797
1011
|
const locale = o.locale ?? "en";
|
|
@@ -808,7 +1022,7 @@ function renderWidget(w, o = {}) {
|
|
|
808
1022
|
const theme = typeof o.theme === "object" ? o.theme : themeById(o.theme);
|
|
809
1023
|
const texts = [];
|
|
810
1024
|
const spy = { ...src_exports, drawTracked: (...a) => (texts.push(a[1]), drawTracked(...a)) };
|
|
811
|
-
const canvas =
|
|
1025
|
+
const canvas = createCanvas6(size.w + 2 * MARGIN, size.h + 2 * MARGIN);
|
|
812
1026
|
const g = canvas.getContext("2d");
|
|
813
1027
|
const box = { x: MARGIN, y: MARGIN, w: size.w, h: size.h };
|
|
814
1028
|
const ctx = {
|
|
@@ -821,7 +1035,7 @@ function renderWidget(w, o = {}) {
|
|
|
821
1035
|
theme,
|
|
822
1036
|
fonts: theme.fonts,
|
|
823
1037
|
kit: spy,
|
|
824
|
-
canvas: { createCanvas:
|
|
1038
|
+
canvas: { createCanvas: createCanvas6, loadImage: loadImage4 },
|
|
825
1039
|
preview: !!o.preview
|
|
826
1040
|
};
|
|
827
1041
|
const t0 = performance.now();
|
|
@@ -849,7 +1063,7 @@ function renderWidget(w, o = {}) {
|
|
|
849
1063
|
ms,
|
|
850
1064
|
...error !== void 0 ? { error } : {},
|
|
851
1065
|
png() {
|
|
852
|
-
const out =
|
|
1066
|
+
const out = createCanvas6(box.w, box.h);
|
|
853
1067
|
out.getContext("2d").drawImage(canvas, -box.x, -box.y);
|
|
854
1068
|
return out.toBuffer("image/png");
|
|
855
1069
|
}
|
|
@@ -864,7 +1078,7 @@ function widgetState(w, hook, o = {}) {
|
|
|
864
1078
|
}
|
|
865
1079
|
function checkPlugin(p, o = {}) {
|
|
866
1080
|
const issues = [];
|
|
867
|
-
const locales = o.locales ?? ["en", "es"];
|
|
1081
|
+
const locales = o.locales ?? (p.languages?.length ? p.languages : ["en", "es"]);
|
|
868
1082
|
const themes = o.themes ?? THEMES.map((t2) => t2.id);
|
|
869
1083
|
const slow = o.slowMs ?? 50;
|
|
870
1084
|
for (const w of p.widgets ?? []) {
|
|
@@ -980,6 +1194,8 @@ function zoomOf(inst) {
|
|
|
980
1194
|
if (typeof z !== "number" || !Number.isFinite(z)) return 1;
|
|
981
1195
|
return Math.round(Math.min(ZOOM.max, Math.max(ZOOM.min, z)) * 100) / 100;
|
|
982
1196
|
}
|
|
1197
|
+
var READING_CM = { near: 40, normal: 60, far: 90 };
|
|
1198
|
+
var TEXT_SCALE = { min: 0.75, max: 2, step: 0.05 };
|
|
983
1199
|
var DEFAULT_MAX_BYTES = 48e4;
|
|
984
1200
|
var counter = 0;
|
|
985
1201
|
function newId(prefix = "id") {
|
|
@@ -1026,15 +1242,30 @@ var DEFAULT_CONFIG = {
|
|
|
1026
1242
|
server: { host: "127.0.0.1", port: 7420 }
|
|
1027
1243
|
};
|
|
1028
1244
|
var PANEL_PRESETS = [
|
|
1029
|
-
{ id: "trofeo-916", name: "Trofeo Vision 9.16\u2033", width: 1920, height: 462 },
|
|
1030
|
-
{ id: "
|
|
1031
|
-
|
|
1032
|
-
{ id: "wide-
|
|
1033
|
-
{ id: "
|
|
1034
|
-
{ id: "
|
|
1035
|
-
{ id: "
|
|
1036
|
-
{ 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 }
|
|
1037
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
|
+
}
|
|
1038
1269
|
function isWorking(workday, now) {
|
|
1039
1270
|
return isWorkingAt(workday, now);
|
|
1040
1271
|
}
|
|
@@ -1100,17 +1331,17 @@ import { homedir as homedir2, platform } from "node:os";
|
|
|
1100
1331
|
|
|
1101
1332
|
// packages/sdk/src/plugin.ts
|
|
1102
1333
|
var CATEGORIES = [
|
|
1103
|
-
{ id: "agents", label: { en: "AI agents", es: "Agentes IA" } },
|
|
1104
|
-
{ id: "system", label: { en: "System", es: "Sistema" } },
|
|
1105
|
-
{ id: "time", label: { en: "Time & calendar", es: "Tiempo y agenda" } },
|
|
1106
|
-
{ id: "productivity", label: { en: "Productivity", es: "Productividad" } },
|
|
1107
|
-
{ id: "dev", label: { en: "Development", es: "Desarrollo" } },
|
|
1108
|
-
{ id: "info", label: { en: "News & world", es: "Noticias y mundo" } },
|
|
1109
|
-
{ id: "media", label: { en: "Media", es: "Multimedia" } },
|
|
1110
|
-
{ id: "scene", label: { en: "Scenes", es: "Escenas" } },
|
|
1111
|
-
{ 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" } }
|
|
1112
1343
|
];
|
|
1113
|
-
var SDK_VERSION = "0.2.
|
|
1344
|
+
var SDK_VERSION = "0.2.6";
|
|
1114
1345
|
function defineWidget(w) {
|
|
1115
1346
|
return w;
|
|
1116
1347
|
}
|
|
@@ -1122,24 +1353,47 @@ function definePlugin(p) {
|
|
|
1122
1353
|
init_schema();
|
|
1123
1354
|
init_theme();
|
|
1124
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
|
|
1125
1376
|
init_format();
|
|
1126
1377
|
init_workday();
|
|
1127
1378
|
|
|
1128
1379
|
// packages/sdk/src/list.ts
|
|
1129
1380
|
init_schema();
|
|
1130
1381
|
var LAYOUT_LABELS = {
|
|
1131
|
-
auto: { en: "Automatic", es: "Autom\xE1tico" },
|
|
1132
|
-
"one-line": { en: "One line", es: "Una l\xEDnea" },
|
|
1133
|
-
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" }
|
|
1134
1385
|
};
|
|
1135
1386
|
var rowsField = (def) => t.integer({
|
|
1136
1387
|
default: def,
|
|
1137
1388
|
min: 0,
|
|
1138
1389
|
max: 30,
|
|
1139
|
-
label: { en: "Rows", es: "Filas" },
|
|
1390
|
+
label: { en: "Rows", es: "Filas", de: "Zeilen", "zh-Hant": "\u5217\u6578", "zh-Hans": "\u884C\u6570" },
|
|
1140
1391
|
help: {
|
|
1141
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".',
|
|
1142
|
-
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"
|
|
1143
1397
|
}
|
|
1144
1398
|
});
|
|
1145
1399
|
function listOptions(o = {}) {
|
|
@@ -1150,9 +1404,9 @@ function listOptions(o = {}) {
|
|
|
1150
1404
|
rows,
|
|
1151
1405
|
layout: t.enum(values, {
|
|
1152
1406
|
default: o.layout ?? "auto",
|
|
1153
|
-
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" },
|
|
1154
1408
|
labels: Object.fromEntries(values.map((v) => [v, LAYOUT_LABELS[v]])),
|
|
1155
|
-
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" }
|
|
1156
1410
|
})
|
|
1157
1411
|
};
|
|
1158
1412
|
}
|
|
@@ -1198,7 +1452,7 @@ function listLayout(box, count, options2, spec) {
|
|
|
1198
1452
|
return { layout, rowH, rows, shown, hidden: n - shown, more, ...text2(rowH) };
|
|
1199
1453
|
}
|
|
1200
1454
|
function moreLabel(n, tr) {
|
|
1201
|
-
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` });
|
|
1202
1456
|
}
|
|
1203
1457
|
function drawMore(g, ctx, plan, o = {}) {
|
|
1204
1458
|
const m = plan.more;
|
|
@@ -1503,7 +1757,10 @@ function normalizeScreen(s, i) {
|
|
|
1503
1757
|
sleepWhenIdle: s.sleepWhenIdle ?? false,
|
|
1504
1758
|
jpegQuality: s.jpegQuality ?? 90,
|
|
1505
1759
|
maxBytes: Math.max(0, Math.round(s.maxBytes ?? DEFAULT_MAX_BYTES)),
|
|
1506
|
-
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 } : {}
|
|
1507
1764
|
};
|
|
1508
1765
|
}
|
|
1509
1766
|
|
|
@@ -1559,16 +1816,16 @@ function sourceCommonFields(def) {
|
|
|
1559
1816
|
default: intervalMs,
|
|
1560
1817
|
min: minIntervalMs,
|
|
1561
1818
|
max: Math.max(MAX_INTERVAL_MS, intervalMs),
|
|
1562
|
-
label: { en: "Read every", es: "Leer cada" },
|
|
1563
|
-
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` }
|
|
1564
1821
|
}),
|
|
1565
1822
|
timeoutMs: t.duration({
|
|
1566
1823
|
default: timeoutMs,
|
|
1567
1824
|
min: MIN_TIMEOUT_MS,
|
|
1568
1825
|
max: Math.max(MAX_TIMEOUT_MS, timeoutMs),
|
|
1569
1826
|
advanced: true,
|
|
1570
|
-
label: { en: "Give up a reading after", es: "Abandonar una lectura tras" },
|
|
1571
|
-
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" }
|
|
1572
1829
|
})
|
|
1573
1830
|
};
|
|
1574
1831
|
const own = def.options?.props ?? {};
|
|
@@ -1599,12 +1856,12 @@ var ID_PATTERN = "^[A-Za-z0-9_.-]{1,80}$";
|
|
|
1599
1856
|
var TAKE_OVER = {
|
|
1600
1857
|
type: "boolean",
|
|
1601
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.",
|
|
1602
|
-
"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" } }
|
|
1603
1860
|
};
|
|
1604
1861
|
var HIDE_WHEN_EMPTY = {
|
|
1605
1862
|
type: "boolean",
|
|
1606
1863
|
description: "Skip the widget in its tile's rotation while it has nothing to list, instead of showing its empty message.",
|
|
1607
|
-
"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" } }
|
|
1608
1865
|
};
|
|
1609
1866
|
var TIME_PATTERN = "^([01][0-9]|2[0-3]):[0-5][0-9]$";
|
|
1610
1867
|
function options(f, what) {
|
|
@@ -1710,7 +1967,7 @@ function configSchema(plugins) {
|
|
|
1710
1967
|
enum: [...TIME_FORMATS],
|
|
1711
1968
|
default: DEFAULT_CONFIG.timeFormat,
|
|
1712
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).',
|
|
1713
|
-
"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" } } }
|
|
1714
1971
|
},
|
|
1715
1972
|
theme: { enum: THEMES.map((t2) => t2.id), default: DEFAULT_CONFIG.theme, description: `Colour theme: ${THEMES.map((t2) => `${t2.id} (${t2.name})`).join(", ")}.` },
|
|
1716
1973
|
location: { $ref: "#/$defs/location" },
|
|
@@ -1788,7 +2045,7 @@ function configSchema(plugins) {
|
|
|
1788
2045
|
maximum: ZOOM.max,
|
|
1789
2046
|
default: 1,
|
|
1790
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.`,
|
|
1791
|
-
"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 }
|
|
1792
2049
|
},
|
|
1793
2050
|
location: {
|
|
1794
2051
|
type: "object",
|
|
@@ -1930,7 +2187,10 @@ function configSchema(plugins) {
|
|
|
1930
2187
|
sleepWhenIdle: { type: "boolean", default: false, description: "Black panel while every widget of the page has nothing worth showing." },
|
|
1931
2188
|
jpegQuality: { type: "integer", minimum: 0, maximum: 100, default: 90, description: "JPEG quality of the frames; 0 = PNG." },
|
|
1932
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." },
|
|
1933
|
-
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." }
|
|
1934
2194
|
}
|
|
1935
2195
|
}
|
|
1936
2196
|
},
|
|
@@ -2346,7 +2606,7 @@ var short = (v) => {
|
|
|
2346
2606
|
const s = v === void 0 ? "unset" : JSON.stringify(v);
|
|
2347
2607
|
return s.length > 60 ? `${s.slice(0, 57)}...` : s;
|
|
2348
2608
|
};
|
|
2349
|
-
var
|
|
2609
|
+
var plural2 = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
2350
2610
|
function match(before, after, alt) {
|
|
2351
2611
|
const pairs = [];
|
|
2352
2612
|
const left = [...before];
|
|
@@ -2370,7 +2630,7 @@ var tileText = (t2) => `tile ${rect(t2)}: ${types(t2)}`;
|
|
|
2370
2630
|
var pageTypes = (p) => [...new Set(p.tiles.flatMap((t2) => t2.widgets.map((w) => w.type)))];
|
|
2371
2631
|
var pageText = (p) => {
|
|
2372
2632
|
const ts = pageTypes(p);
|
|
2373
|
-
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` : ""})` : ""}`;
|
|
2374
2634
|
};
|
|
2375
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;
|
|
2376
2636
|
var changedKeys = (a, b) => [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])].filter((k) => !same(a[k], b[k]));
|
|
@@ -2421,7 +2681,7 @@ function diffConfigs(before, after) {
|
|
|
2421
2681
|
else if (a && b && !same(a, b)) out.push({ depth: 0, op: "~", kind: "source", text: `source ${k}: ${changedKeys(b, a).join(", ")} changed` });
|
|
2422
2682
|
}
|
|
2423
2683
|
const m = match(before.screens, after.screens, (s) => s.name);
|
|
2424
|
-
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")})` });
|
|
2425
2685
|
for (const s of m.added) {
|
|
2426
2686
|
out.push({ depth: 0, op: "+", kind: "screen", text: `screen ${q2(s.name)} ${s.width}\xD7${s.height}, ${deviceText(s.device)}` });
|
|
2427
2687
|
for (const p of s.pages) out.push({ depth: 1, op: "+", kind: "page", text: pageText(p) });
|
|
@@ -2449,7 +2709,7 @@ function summarizeDiff(lines) {
|
|
|
2449
2709
|
for (const l of lines) counts.set(`${l.kind} ${l.op}`, (counts.get(`${l.kind} ${l.op}`) ?? 0) + 1);
|
|
2450
2710
|
const parts = [...counts].map(([k, n]) => {
|
|
2451
2711
|
const [kind, op] = k.split(" ");
|
|
2452
|
-
return `${
|
|
2712
|
+
return `${plural2(n, kind)} ${verb[op]}`;
|
|
2453
2713
|
});
|
|
2454
2714
|
return parts.length ? parts.join(", ") : "no changes";
|
|
2455
2715
|
}
|
|
@@ -2686,6 +2946,41 @@ function planImport(incoming, current, plugins, schema = configSchema(plugins))
|
|
|
2686
2946
|
return { report, config: config2, carried, diff: diffConfigs(current, config2), risks: listRisks(config2, schema, current), secrets };
|
|
2687
2947
|
}
|
|
2688
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
|
+
|
|
2689
2984
|
// packages/core/src/layout/stack.ts
|
|
2690
2985
|
function pickInStack(entries, now, rotateMs) {
|
|
2691
2986
|
const urgent = entries.find((e) => e.visible && e.urgent);
|
|
@@ -2720,13 +3015,106 @@ function pickPage(pages, now, pinned) {
|
|
|
2720
3015
|
|
|
2721
3016
|
// packages/core/src/compositor.ts
|
|
2722
3017
|
init_src();
|
|
2723
|
-
import { createCanvas as
|
|
3018
|
+
import { createCanvas as createCanvas5, loadImage as loadImage3 } from "@napi-rs/canvas";
|
|
2724
3019
|
|
|
2725
3020
|
// packages/core/src/env.ts
|
|
2726
3021
|
init_src();
|
|
2727
3022
|
import { mkdirSync as mkdirSync2 } from "node:fs";
|
|
3023
|
+
import { createCanvas as createCanvas3, loadImage as loadImage2 } from "@napi-rs/canvas";
|
|
3024
|
+
|
|
3025
|
+
// packages/core/src/scaled-images.ts
|
|
3026
|
+
import { createRequire } from "node:module";
|
|
3027
|
+
import { Worker } from "node:worker_threads";
|
|
2728
3028
|
import { createCanvas as createCanvas2, loadImage } from "@napi-rs/canvas";
|
|
2729
|
-
|
|
3029
|
+
function scaledSize(w, h, size) {
|
|
3030
|
+
const sx = size.width / w, sy = size.height / h;
|
|
3031
|
+
const s = Math.min(1, (size.fit ?? "cover") === "cover" ? Math.max(sx, sy) : Math.min(sx, sy));
|
|
3032
|
+
return { width: Math.max(1, Math.round(w * s)), height: Math.max(1, Math.round(h * s)) };
|
|
3033
|
+
}
|
|
3034
|
+
var WORKER = `
|
|
3035
|
+
const { parentPort, workerData } = require('node:worker_threads');
|
|
3036
|
+
const { readFile } = require('node:fs/promises');
|
|
3037
|
+
const { createCanvas, loadImage } = require(workerData.canvas);
|
|
3038
|
+
const scaledSize = ${scaledSize.toString()};
|
|
3039
|
+
parentPort.on('message', async (job) => {
|
|
3040
|
+
try {
|
|
3041
|
+
const src = typeof job.src === 'string' ? await readFile(job.src) : Buffer.from(job.src);
|
|
3042
|
+
const img = await loadImage(src);
|
|
3043
|
+
const to = scaledSize(img.width, img.height, job.size);
|
|
3044
|
+
if (to.width >= img.width && to.height >= img.height) {
|
|
3045
|
+
// Already small enough: the bytes as they are.
|
|
3046
|
+
parentPort.postMessage({ id: job.id, ok: true, same: true });
|
|
3047
|
+
return;
|
|
3048
|
+
}
|
|
3049
|
+
const c = createCanvas(to.width, to.height);
|
|
3050
|
+
const g = c.getContext('2d');
|
|
3051
|
+
g.imageSmoothingQuality = 'high';
|
|
3052
|
+
g.drawImage(img, 0, 0, to.width, to.height);
|
|
3053
|
+
const png = src[0] === 0x89 && src[1] === 0x50;
|
|
3054
|
+
const out = png ? await c.encode('png') : await c.encode('jpeg', 90);
|
|
3055
|
+
const ab = out.buffer.slice(out.byteOffset, out.byteOffset + out.byteLength);
|
|
3056
|
+
parentPort.postMessage({ id: job.id, ok: true, bytes: ab }, [ab]);
|
|
3057
|
+
} catch (err) {
|
|
3058
|
+
parentPort.postMessage({ id: job.id, ok: false, error: err && err.message ? err.message : String(err) });
|
|
3059
|
+
}
|
|
3060
|
+
});
|
|
3061
|
+
`;
|
|
3062
|
+
var worker = null;
|
|
3063
|
+
var broken = false;
|
|
3064
|
+
var nextId = 1;
|
|
3065
|
+
var pending = /* @__PURE__ */ new Map();
|
|
3066
|
+
function startWorker() {
|
|
3067
|
+
if (worker) return worker;
|
|
3068
|
+
if (broken) return null;
|
|
3069
|
+
try {
|
|
3070
|
+
const canvas = createRequire(import.meta.url).resolve("@napi-rs/canvas");
|
|
3071
|
+
const w = new Worker(WORKER, { eval: true, workerData: { canvas } });
|
|
3072
|
+
w.on("message", (m) => {
|
|
3073
|
+
const p = pending.get(m.id);
|
|
3074
|
+
if (!p) return;
|
|
3075
|
+
pending.delete(m.id);
|
|
3076
|
+
if (!pending.size) w.unref();
|
|
3077
|
+
if (m.ok) p.resolve(m);
|
|
3078
|
+
else p.reject(new Error(m.error ?? "could not scale the image"));
|
|
3079
|
+
});
|
|
3080
|
+
const gone = (err) => {
|
|
3081
|
+
if (worker === w) worker = null;
|
|
3082
|
+
for (const [id, p] of pending) {
|
|
3083
|
+
pending.delete(id);
|
|
3084
|
+
p.reject(err ?? new Error("the image thread stopped"));
|
|
3085
|
+
}
|
|
3086
|
+
};
|
|
3087
|
+
w.on("error", gone);
|
|
3088
|
+
w.on("exit", () => gone());
|
|
3089
|
+
w.unref();
|
|
3090
|
+
worker = w;
|
|
3091
|
+
return w;
|
|
3092
|
+
} catch {
|
|
3093
|
+
broken = true;
|
|
3094
|
+
return null;
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
function warm(img) {
|
|
3098
|
+
const w = Math.max(1, Math.round(img.width / 3)), h = Math.max(1, Math.round(img.height / 3));
|
|
3099
|
+
createCanvas2(w, h).getContext("2d").drawImage(img, 0, 0, w, h);
|
|
3100
|
+
return img;
|
|
3101
|
+
}
|
|
3102
|
+
async function loadImageScaled(src, size) {
|
|
3103
|
+
if (!(size.width > 0) || !(size.height > 0)) throw new Error("loadImageScaled: width and height must be over 0");
|
|
3104
|
+
const w = startWorker();
|
|
3105
|
+
if (!w) return warm(await loadImage(src));
|
|
3106
|
+
const id = nextId++;
|
|
3107
|
+
const job = typeof src === "string" ? src : src.buffer.slice(src.byteOffset, src.byteOffset + src.byteLength);
|
|
3108
|
+
const r = await new Promise((resolve8, reject) => {
|
|
3109
|
+
pending.set(id, { resolve: resolve8, reject });
|
|
3110
|
+
w.ref();
|
|
3111
|
+
w.postMessage({ id, src: job, size });
|
|
3112
|
+
});
|
|
3113
|
+
return warm(await loadImage(r.same || !r.bytes ? src : Buffer.from(r.bytes)));
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
// packages/core/src/env.ts
|
|
3117
|
+
var CANVAS = { createCanvas: createCanvas3, loadImage: loadImage2, loadImageScaled };
|
|
2730
3118
|
function systemLocale() {
|
|
2731
3119
|
try {
|
|
2732
3120
|
return Intl.DateTimeFormat().resolvedOptions().locale || "en";
|
|
@@ -2771,11 +3159,109 @@ function baseContext(cfg, plugin, log, now) {
|
|
|
2771
3159
|
}
|
|
2772
3160
|
|
|
2773
3161
|
// packages/core/src/fonts.ts
|
|
2774
|
-
|
|
2775
|
-
import {
|
|
3162
|
+
init_src();
|
|
3163
|
+
import { existsSync as existsSync3, readdirSync } from "node:fs";
|
|
3164
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
2776
3165
|
import { dirname as dirname2, join as join3 } from "node:path";
|
|
2777
|
-
import { GlobalFonts as GlobalFonts2 } from "@napi-rs/canvas";
|
|
2778
|
-
|
|
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
|
|
3264
|
+
var require2 = createRequire2(import.meta.url);
|
|
2779
3265
|
var done = false;
|
|
2780
3266
|
function ttfDir() {
|
|
2781
3267
|
try {
|
|
@@ -2792,21 +3278,132 @@ var FILES = [
|
|
|
2792
3278
|
];
|
|
2793
3279
|
function registerFonts(extra = []) {
|
|
2794
3280
|
if (done && !extra.length) return;
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
const
|
|
2798
|
-
|
|
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();
|
|
2799
3288
|
}
|
|
2800
3289
|
for (const f of extra) if (existsSync3(f.path)) GlobalFonts2.registerFromPath(f.path, f.family);
|
|
2801
3290
|
done = true;
|
|
2802
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
|
+
}
|
|
2803
3400
|
|
|
2804
3401
|
// packages/core/src/compositor.ts
|
|
2805
3402
|
var images = /* @__PURE__ */ new Map();
|
|
2806
3403
|
function backgroundImage(path) {
|
|
2807
3404
|
if (!images.has(path)) {
|
|
2808
3405
|
images.set(path, null);
|
|
2809
|
-
|
|
3406
|
+
loadImage3(path).then((img) => images.set(path, img)).catch(() => void 0);
|
|
2810
3407
|
}
|
|
2811
3408
|
return images.get(path) ?? null;
|
|
2812
3409
|
}
|
|
@@ -2841,12 +3438,12 @@ function tileState(def, inst, state) {
|
|
|
2841
3438
|
const urgent = takeOver && safe(() => def.urgent?.(state) ?? false, false);
|
|
2842
3439
|
return { visible, urgent };
|
|
2843
3440
|
}
|
|
2844
|
-
function safe(fn,
|
|
2845
|
-
if (!fn) return
|
|
3441
|
+
function safe(fn, fallback2) {
|
|
3442
|
+
if (!fn) return fallback2;
|
|
2846
3443
|
try {
|
|
2847
3444
|
return fn();
|
|
2848
3445
|
} catch {
|
|
2849
|
-
return
|
|
3446
|
+
return fallback2;
|
|
2850
3447
|
}
|
|
2851
3448
|
}
|
|
2852
3449
|
function redrawStep(def, state) {
|
|
@@ -2923,7 +3520,7 @@ function paintTile(g, input, tile, rect2, out, nextAt, idles, animatable) {
|
|
|
2923
3520
|
const [plugin] = r.inst.type.split("/");
|
|
2924
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);
|
|
2925
3522
|
},
|
|
2926
|
-
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)
|
|
2927
3524
|
});
|
|
2928
3525
|
}
|
|
2929
3526
|
const frame = input.animate?.find((a) => a.tileId === tile.id && a.instanceId === r.inst.id)?.frame;
|
|
@@ -2933,7 +3530,7 @@ function paintTile(g, input, tile, rect2, out, nextAt, idles, animatable) {
|
|
|
2933
3530
|
return;
|
|
2934
3531
|
}
|
|
2935
3532
|
const cfg = input.cfg;
|
|
2936
|
-
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]);
|
|
2937
3534
|
const refs = [r.data, ...(r.def.sources ?? []).map((s) => r.sources[s])];
|
|
2938
3535
|
const hit = input.cache.get(tile.id);
|
|
2939
3536
|
if (hit && hit.key === key && hit.refs.length === refs.length && hit.refs.every((x, i) => x === refs[i])) {
|
|
@@ -2941,19 +3538,19 @@ function paintTile(g, input, tile, rect2, out, nextAt, idles, animatable) {
|
|
|
2941
3538
|
if (hit.error) out.error = hit.error;
|
|
2942
3539
|
return;
|
|
2943
3540
|
}
|
|
2944
|
-
const canvas =
|
|
3541
|
+
const canvas = createCanvas5(rect2.w, rect2.h);
|
|
2945
3542
|
const tg = canvas.getContext("2d");
|
|
2946
3543
|
tg.translate(-rect2.x, -rect2.y);
|
|
2947
3544
|
draw(tg);
|
|
2948
3545
|
g.drawImage(canvas, rect2.x, rect2.y);
|
|
2949
3546
|
input.cache.set(tile.id, { key, refs, canvas, ...out.error ? { error: out.error } : {} });
|
|
2950
3547
|
}
|
|
2951
|
-
function tileBoxes(theme, screenH, inst, rect2, chrome) {
|
|
3548
|
+
function tileBoxes(theme, screenH, inst, rect2, chrome, textScale = 1) {
|
|
2952
3549
|
const m = chromeMetrics(theme, screenH, rect2);
|
|
2953
3550
|
const pad = chrome === "card" ? m.pad : 0;
|
|
2954
3551
|
const top = rect2.y + pad + (inst.title?.trim() && chrome === "card" ? m.titleBar : 0);
|
|
2955
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) };
|
|
2956
|
-
const zoom = zoomOf(inst);
|
|
3553
|
+
const zoom = Math.round(zoomOf(inst) * textScale * 100) / 100;
|
|
2957
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) };
|
|
2958
3555
|
return { outer, box, zoom };
|
|
2959
3556
|
}
|
|
@@ -2969,7 +3566,7 @@ function drawTileContent(g, input, r, rect2, chrome, out, anim) {
|
|
|
2969
3566
|
g.textBaseline = "alphabetic";
|
|
2970
3567
|
g.fillText(fitText(g, title, rect2.w - 2 * pad), rect2.x + pad, rect2.y + pad + m.title * 0.8);
|
|
2971
3568
|
}
|
|
2972
|
-
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);
|
|
2973
3570
|
const [plugin] = r.inst.type.split("/");
|
|
2974
3571
|
const ctx = {
|
|
2975
3572
|
...baseContext(input.cfg, plugin, input.log ?? (() => void 0), now),
|
|
@@ -2991,10 +3588,13 @@ function drawTileContent(g, input, r, rect2, chrome, out, anim) {
|
|
|
2991
3588
|
}
|
|
2992
3589
|
const t0 = performance.now();
|
|
2993
3590
|
try {
|
|
3591
|
+
src_exports.takeCjkEnlarged();
|
|
2994
3592
|
r.def.render(g, ctx);
|
|
2995
3593
|
out.renderMs = performance.now() - t0;
|
|
3594
|
+
const small = src_exports.takeCjkEnlarged();
|
|
3595
|
+
if (small !== null) out.cjkEnlarged = small;
|
|
2996
3596
|
} catch (err) {
|
|
2997
|
-
out.error = err
|
|
3597
|
+
out.error = errorMessage(err, ctx.locale);
|
|
2998
3598
|
input.log?.(r.inst.type, `render failed: ${out.error}`);
|
|
2999
3599
|
const size = Math.max(12, Math.min(20, box.h / 4));
|
|
3000
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 });
|
|
@@ -3003,9 +3603,18 @@ function drawTileContent(g, input, r, rect2, chrome, out, anim) {
|
|
|
3003
3603
|
}
|
|
3004
3604
|
function composePage(input) {
|
|
3005
3605
|
registerFonts();
|
|
3606
|
+
setFontLocale(resolveLocale(input.cfg));
|
|
3607
|
+
src_exports.setMinCjkPx(legibleCjkPx(input.screen));
|
|
3006
3608
|
const { screen, page, theme, now } = input;
|
|
3007
|
-
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);
|
|
3008
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
|
+
}
|
|
3009
3618
|
g.fillStyle = page.background.color || theme.colors.bg;
|
|
3010
3619
|
g.fillRect(0, 0, screen.width, screen.height);
|
|
3011
3620
|
if (page.background.image) {
|
|
@@ -3038,7 +3647,7 @@ function composePage(input) {
|
|
|
3038
3647
|
function rotateCanvas(src, rotate) {
|
|
3039
3648
|
if (!rotate) return src;
|
|
3040
3649
|
const swap = rotate === 90 || rotate === 270;
|
|
3041
|
-
const out =
|
|
3650
|
+
const out = createCanvas5(swap ? src.height : src.width, swap ? src.width : src.height);
|
|
3042
3651
|
const g = out.getContext("2d");
|
|
3043
3652
|
g.translate(out.width / 2, out.height / 2);
|
|
3044
3653
|
g.rotate(rotate * Math.PI / 180);
|
|
@@ -3229,7 +3838,7 @@ var SourceHub = class {
|
|
|
3229
3838
|
try {
|
|
3230
3839
|
st.stop = def.watch(this.ctx(cfg, st), (data) => this.set(st, data));
|
|
3231
3840
|
} catch (err) {
|
|
3232
|
-
st.error = msg(err);
|
|
3841
|
+
st.error = msg(err, cfg);
|
|
3233
3842
|
this.log(type, `watch failed: ${st.error}`);
|
|
3234
3843
|
}
|
|
3235
3844
|
}
|
|
@@ -3261,7 +3870,7 @@ var SourceHub = class {
|
|
|
3261
3870
|
st.inflight = true;
|
|
3262
3871
|
const d = deadline(st.abort.signal, st.timeoutMs);
|
|
3263
3872
|
const fail = (err) => {
|
|
3264
|
-
st.error = d.timedOut() ? timedOutMsg(st.timeoutMs) : msg(err);
|
|
3873
|
+
st.error = d.timedOut() ? timedOutMsg(st.timeoutMs) : msg(err, cfg);
|
|
3265
3874
|
this.log(st.type, `read failed: ${st.error}`);
|
|
3266
3875
|
st.nextAt = Date.now() + Math.min(RETRY_MS, st.intervalMs);
|
|
3267
3876
|
};
|
|
@@ -3376,7 +3985,7 @@ var FetchHost = class {
|
|
|
3376
3985
|
}
|
|
3377
3986
|
}).catch((err) => {
|
|
3378
3987
|
if (st.abort.signal.aborted) return;
|
|
3379
|
-
st.error = d.timedOut() ? timedOutMsg(st.timeoutMs) : msg(err);
|
|
3988
|
+
st.error = d.timedOut() ? timedOutMsg(st.timeoutMs) : msg(err, cfg);
|
|
3380
3989
|
this.log(st.type, `fetch failed: ${st.error}`);
|
|
3381
3990
|
st.nextAt = Date.now() + Math.min(RETRY_MS, st.intervalMs);
|
|
3382
3991
|
}).finally(() => {
|
|
@@ -3409,8 +4018,8 @@ var FetchHost = class {
|
|
|
3409
4018
|
}
|
|
3410
4019
|
}
|
|
3411
4020
|
};
|
|
3412
|
-
function msg(err) {
|
|
3413
|
-
return err
|
|
4021
|
+
function msg(err, cfg) {
|
|
4022
|
+
return errorMessage(err, resolveLocale(cfg));
|
|
3414
4023
|
}
|
|
3415
4024
|
|
|
3416
4025
|
// packages/core/src/devices.ts
|
|
@@ -3676,11 +4285,11 @@ var LyPanel = class _LyPanel {
|
|
|
3676
4285
|
};
|
|
3677
4286
|
|
|
3678
4287
|
// packages/trcc-client/src/client.ts
|
|
3679
|
-
import { readdirSync, readFileSync as readFileSync2 } from "node:fs";
|
|
4288
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
3680
4289
|
function usbPathForSerial(serial, root = "/sys/bus/usb/devices") {
|
|
3681
4290
|
let entries = [];
|
|
3682
4291
|
try {
|
|
3683
|
-
entries =
|
|
4292
|
+
entries = readdirSync2(root);
|
|
3684
4293
|
} catch {
|
|
3685
4294
|
return null;
|
|
3686
4295
|
}
|
|
@@ -3861,13 +4470,25 @@ function pinFrame(o, key, intervalS, onError) {
|
|
|
3861
4470
|
}
|
|
3862
4471
|
|
|
3863
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
|
+
}
|
|
3864
4485
|
function encodeFor(device, jpegQuality) {
|
|
3865
4486
|
if (device.driver === "file") return device.format ?? "jpeg";
|
|
3866
4487
|
if (device.driver === "usb") return "jpeg";
|
|
3867
4488
|
return jpegQuality > 0 ? "jpeg" : "png";
|
|
3868
4489
|
}
|
|
3869
4490
|
var VirtualDevice = class {
|
|
3870
|
-
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 };
|
|
3871
4492
|
async send() {
|
|
3872
4493
|
this.status.framesSent++;
|
|
3873
4494
|
this.status.lastSentAt = Date.now();
|
|
@@ -3892,7 +4513,7 @@ var FileDevice = class {
|
|
|
3892
4513
|
dir;
|
|
3893
4514
|
constructor(cfg) {
|
|
3894
4515
|
this.dir = expandPath(cfg.dir);
|
|
3895
|
-
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 };
|
|
3896
4517
|
}
|
|
3897
4518
|
async send(frame) {
|
|
3898
4519
|
try {
|
|
@@ -3905,14 +4526,15 @@ var FileDevice = class {
|
|
|
3905
4526
|
this.status.lastSentAt = Date.now();
|
|
3906
4527
|
} catch (err) {
|
|
3907
4528
|
this.status.ok = false;
|
|
3908
|
-
|
|
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 } });
|
|
3909
4531
|
}
|
|
3910
4532
|
}
|
|
3911
4533
|
close() {
|
|
3912
4534
|
}
|
|
3913
4535
|
};
|
|
3914
4536
|
var TrccDevice = class {
|
|
3915
|
-
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 };
|
|
3916
4538
|
key = null;
|
|
3917
4539
|
connecting = null;
|
|
3918
4540
|
stopPin = null;
|
|
@@ -3925,13 +4547,13 @@ var TrccDevice = class {
|
|
|
3925
4547
|
this.o = { url: cfg.url, ...cfg.tokenFile ? { tokenFile: expandPath(cfg.tokenFile) } : {}, timeoutMs: 2e4, deviceKey: cfg.deviceKey ?? "", ...cfg.serial ? { serial: cfg.serial } : {} };
|
|
3926
4548
|
}
|
|
3927
4549
|
async connect() {
|
|
3928
|
-
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 });
|
|
3929
4551
|
const panel = await detectPanel(this.o);
|
|
3930
|
-
if (!panel) throw
|
|
4552
|
+
if (!panel) throw coded("trcc serve sees no panel", "trccNoPanel");
|
|
3931
4553
|
await connectPanel(this.o, panel.key);
|
|
3932
4554
|
this.key = panel.key;
|
|
3933
4555
|
this.status.detected = { width: panel.width, height: panel.height };
|
|
3934
|
-
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 } });
|
|
3935
4557
|
if (this.cfg.keepalive !== false) this.stopPin = pinFrame(this.o, panel.key, 30, (m) => this.log(m));
|
|
3936
4558
|
}
|
|
3937
4559
|
async send(frame) {
|
|
@@ -3949,7 +4571,7 @@ var TrccDevice = class {
|
|
|
3949
4571
|
this.stopPin?.();
|
|
3950
4572
|
this.stopPin = null;
|
|
3951
4573
|
this.status.ok = false;
|
|
3952
|
-
this.status
|
|
4574
|
+
Object.assign(this.status, statusOfError(err));
|
|
3953
4575
|
}
|
|
3954
4576
|
}
|
|
3955
4577
|
close() {
|
|
@@ -3957,7 +4579,7 @@ var TrccDevice = class {
|
|
|
3957
4579
|
}
|
|
3958
4580
|
};
|
|
3959
4581
|
var UsbDevice = class {
|
|
3960
|
-
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 };
|
|
3961
4583
|
cfg;
|
|
3962
4584
|
log;
|
|
3963
4585
|
rotate;
|
|
@@ -3983,9 +4605,11 @@ var UsbDevice = class {
|
|
|
3983
4605
|
this.timer = setInterval(() => void this.pump(), Math.min(every, 250));
|
|
3984
4606
|
this.timer.unref();
|
|
3985
4607
|
}
|
|
3986
|
-
say(message, ok) {
|
|
4608
|
+
say(message, ok, code, params) {
|
|
3987
4609
|
this.status.ok = ok;
|
|
3988
4610
|
this.status.message = message;
|
|
4611
|
+
this.status.code = code;
|
|
4612
|
+
this.status.params = params;
|
|
3989
4613
|
if (message !== this.lastMessage) {
|
|
3990
4614
|
this.lastMessage = message;
|
|
3991
4615
|
this.log(message);
|
|
@@ -4008,8 +4632,9 @@ var UsbDevice = class {
|
|
|
4008
4632
|
this.failures = 0;
|
|
4009
4633
|
this.status.framesSent++;
|
|
4010
4634
|
this.status.lastSentAt = this.lastWrite;
|
|
4011
|
-
|
|
4012
|
-
|
|
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() });
|
|
4013
4638
|
} catch (err) {
|
|
4014
4639
|
this.fresh = true;
|
|
4015
4640
|
const p = this.panel;
|
|
@@ -4018,7 +4643,9 @@ var UsbDevice = class {
|
|
|
4018
4643
|
this.failures++;
|
|
4019
4644
|
this.retryAt = Date.now() + Math.min(30 * this.retryMs, this.retryMs * 2 ** Math.min(this.failures, 5));
|
|
4020
4645
|
const why = err instanceof Error ? err.message : String(err);
|
|
4021
|
-
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 ?? "" });
|
|
4022
4649
|
}
|
|
4023
4650
|
}
|
|
4024
4651
|
};
|
|
@@ -4038,7 +4665,7 @@ var UsbDevice = class {
|
|
|
4038
4665
|
this.status.detected = { width: m.width, height: m.height, rotate: m.rotate };
|
|
4039
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`);
|
|
4040
4667
|
}
|
|
4041
|
-
this.say(this.describe(), true);
|
|
4668
|
+
this.say(this.describe(), true, "usbConnected", { panel: this.describe() });
|
|
4042
4669
|
}
|
|
4043
4670
|
async send(frame) {
|
|
4044
4671
|
this.latest = frame;
|
|
@@ -4108,9 +4735,9 @@ async function discoverTrcc(url2 = "http://127.0.0.1:8099", tokenFile) {
|
|
|
4108
4735
|
|
|
4109
4736
|
// packages/core/src/runtime.ts
|
|
4110
4737
|
var TICK_MS = 250;
|
|
4111
|
-
function lazyJpeg(c) {
|
|
4738
|
+
function lazyJpeg(c, turned = 0) {
|
|
4112
4739
|
let b = null;
|
|
4113
|
-
return () => b ??= c.toBuffer("image/jpeg", 88);
|
|
4740
|
+
return () => b ??= (turned ? rotateCanvas(c, (360 - turned) % 360) : c).toBuffer("image/jpeg", 88);
|
|
4114
4741
|
}
|
|
4115
4742
|
function encode(c, kind, quality) {
|
|
4116
4743
|
return kind === "jpeg" ? c.encode("jpeg", Math.max(1, Math.min(100, quality || 90))) : c.encode("png");
|
|
@@ -4248,7 +4875,8 @@ var ScreenRunner = class {
|
|
|
4248
4875
|
sourcesOf: (types2) => this.rt.hub.pick(types2),
|
|
4249
4876
|
log: this.rt.log,
|
|
4250
4877
|
demo: this.rt.demoMode,
|
|
4251
|
-
cache: this.tiles
|
|
4878
|
+
cache: this.tiles,
|
|
4879
|
+
rotate: screen.rotate
|
|
4252
4880
|
});
|
|
4253
4881
|
canvas = result.canvas;
|
|
4254
4882
|
this.animatable = result.animatable;
|
|
@@ -4259,22 +4887,23 @@ var ScreenRunner = class {
|
|
|
4259
4887
|
this.rt.paintTimes.record(t2.shown, type, t2.renderMs, now, this.rt.log);
|
|
4260
4888
|
}
|
|
4261
4889
|
} else {
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
g.fillStyle = "#000";
|
|
4265
|
-
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);
|
|
4266
4892
|
this.animatable = [];
|
|
4267
4893
|
this.nextAt = now + 6e4;
|
|
4268
4894
|
}
|
|
4269
4895
|
const sleeping = this.off || !!(screen.sleepWhenIdle && result?.idle);
|
|
4270
|
-
if (sleeping) {
|
|
4896
|
+
if (sleeping || !result) {
|
|
4271
4897
|
const g = canvas.getContext("2d");
|
|
4898
|
+
g.save();
|
|
4899
|
+
g.setTransform(1, 0, 0, 1, 0, 0);
|
|
4272
4900
|
g.fillStyle = "#000";
|
|
4273
|
-
g.fillRect(0, 0,
|
|
4901
|
+
g.fillRect(0, 0, canvas.width, canvas.height);
|
|
4902
|
+
g.restore();
|
|
4274
4903
|
}
|
|
4275
4904
|
const kind = encodeFor(screen.device, screen.jpegQuality);
|
|
4276
|
-
const out = await this.fit(
|
|
4277
|
-
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 };
|
|
4278
4907
|
this.rt.emit("frame", this.lastInfo);
|
|
4279
4908
|
if (this.last?.equals(out)) return;
|
|
4280
4909
|
this.last = out;
|
|
@@ -4414,9 +5043,10 @@ var ScreenRunner = class {
|
|
|
4414
5043
|
log: this.rt.log,
|
|
4415
5044
|
demo: this.rt.demoMode,
|
|
4416
5045
|
cache: this.tiles,
|
|
4417
|
-
animate
|
|
5046
|
+
animate,
|
|
5047
|
+
rotate: screen.rotate
|
|
4418
5048
|
});
|
|
4419
|
-
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 });
|
|
4420
5050
|
await new Promise((r) => setImmediate(r));
|
|
4421
5051
|
}
|
|
4422
5052
|
const outs = await Promise.all(sent.map((x) => x.out));
|
|
@@ -4431,7 +5061,7 @@ var ScreenRunner = class {
|
|
|
4431
5061
|
await this.device.send(outs[k]);
|
|
4432
5062
|
const snap = sent[k].snap;
|
|
4433
5063
|
if (snap) {
|
|
4434
|
-
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 };
|
|
4435
5065
|
this.rt.emit("frame", this.lastInfo);
|
|
4436
5066
|
}
|
|
4437
5067
|
if (hold && k === holdAt) {
|
|
@@ -4711,7 +5341,7 @@ function withLook(cfg, look) {
|
|
|
4711
5341
|
}
|
|
4712
5342
|
|
|
4713
5343
|
// packages/core/src/registry.ts
|
|
4714
|
-
import { existsSync as existsSync5, readdirSync as
|
|
5344
|
+
import { existsSync as existsSync5, readdirSync as readdirSync3, readFileSync as readFileSync3, statSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
4715
5345
|
import { join as join6 } from "node:path";
|
|
4716
5346
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
4717
5347
|
|
|
@@ -4731,6 +5361,8 @@ function packageMeta(pkg) {
|
|
|
4731
5361
|
const deny = os.filter((x) => x.startsWith("!")).map((x) => x.slice(1));
|
|
4732
5362
|
out.platforms = PLATFORMS.filter((p) => (!allow.length || allow.includes(p)) && !deny.includes(p));
|
|
4733
5363
|
}
|
|
5364
|
+
const langs = pkg.kiosko?.languages;
|
|
5365
|
+
if (Array.isArray(langs) && langs.length) out.languages = langs.filter((x) => typeof x === "string");
|
|
4734
5366
|
return out;
|
|
4735
5367
|
}
|
|
4736
5368
|
function incompatibility(o, env = { sdk: SDK_VERSION, platform: process.platform }) {
|
|
@@ -4741,6 +5373,17 @@ function incompatibility(o, env = { sdk: SDK_VERSION, platform: process.platform
|
|
|
4741
5373
|
var platformName = (p) => p === "darwin" ? "macOS" : p === "win32" ? "Windows" : p === "linux" ? "Linux" : p;
|
|
4742
5374
|
var pluginOf = (type) => type.split("/")[0] ?? type;
|
|
4743
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
|
+
}
|
|
4744
5387
|
function languagesOf(def) {
|
|
4745
5388
|
const out = /* @__PURE__ */ new Set();
|
|
4746
5389
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
@@ -4750,7 +5393,7 @@ function languagesOf(def) {
|
|
|
4750
5393
|
if (Array.isArray(v)) return void v.forEach((x) => walk(x));
|
|
4751
5394
|
const o = v;
|
|
4752
5395
|
const keys = Object.keys(o);
|
|
4753
|
-
if (keys.includes("en") && keys.every((k) =>
|
|
5396
|
+
if (keys.includes("en") && keys.every((k) => isLanguageTag(k) && typeof o[k] === "string")) {
|
|
4754
5397
|
for (const k of keys) out.add(k);
|
|
4755
5398
|
return;
|
|
4756
5399
|
}
|
|
@@ -4800,7 +5443,7 @@ function pluginManifest(def, o = {}) {
|
|
|
4800
5443
|
...def.icon ? { icon: def.icon } : {},
|
|
4801
5444
|
...sdk ? { sdk } : {},
|
|
4802
5445
|
platforms: def.platforms ?? meta.platforms ?? [...PLATFORMS],
|
|
4803
|
-
languages:
|
|
5446
|
+
languages: declaredLanguages(def, meta),
|
|
4804
5447
|
categories: [...new Set(widgets.map((w) => w.category ?? "info"))],
|
|
4805
5448
|
tags: [...new Set(widgets.flatMap((w) => w.tags ?? []))],
|
|
4806
5449
|
permissions: def.permissions ?? {},
|
|
@@ -5014,15 +5657,15 @@ var Registry = class {
|
|
|
5014
5657
|
}
|
|
5015
5658
|
}
|
|
5016
5659
|
const candidates = [];
|
|
5017
|
-
for (const name of
|
|
5660
|
+
for (const name of readdirSync3(dir)) {
|
|
5018
5661
|
if (name === "node_modules" || name.startsWith(".")) continue;
|
|
5019
5662
|
candidates.push(join6(dir, name));
|
|
5020
5663
|
}
|
|
5021
5664
|
const nm = join6(dir, "node_modules");
|
|
5022
5665
|
if (existsSync5(nm)) {
|
|
5023
|
-
for (const name of
|
|
5666
|
+
for (const name of readdirSync3(nm)) {
|
|
5024
5667
|
if (name.startsWith("@")) {
|
|
5025
|
-
for (const sub of
|
|
5668
|
+
for (const sub of readdirSync3(join6(nm, name))) if (sub.startsWith("kiosko-plugin-")) candidates.push(join6(nm, name, sub));
|
|
5026
5669
|
} else if (name.startsWith("kiosko-plugin-")) candidates.push(join6(nm, name));
|
|
5027
5670
|
}
|
|
5028
5671
|
}
|
|
@@ -5101,6 +5744,8 @@ var Registry = class {
|
|
|
5101
5744
|
icon: def.icon,
|
|
5102
5745
|
sdk: def.sdk ?? null,
|
|
5103
5746
|
platforms: def.platforms ?? null,
|
|
5747
|
+
/** The languages its texts come in (declared, or read from its texts). */
|
|
5748
|
+
languages: declaredLanguages(def),
|
|
5104
5749
|
permissions: def.permissions ?? {},
|
|
5105
5750
|
/** What it needs from other plugins, and whether that is here (installed and on). */
|
|
5106
5751
|
requires: (def.requires ?? []).map((type) => ({ type, plugin: pluginOf(type), ok: has(type) })),
|
|
@@ -5120,6 +5765,8 @@ var Registry = class {
|
|
|
5120
5765
|
icon: w.icon,
|
|
5121
5766
|
category: w.category ?? "info",
|
|
5122
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(" "),
|
|
5123
5770
|
size: w.size ?? {},
|
|
5124
5771
|
chrome: w.chrome ?? "card",
|
|
5125
5772
|
options: w.options ? toJsonSchema(w.options) : null,
|
|
@@ -5187,6 +5834,15 @@ function missingLanguages(text2, langs) {
|
|
|
5187
5834
|
if (typeof text2 === "string") return langs.filter((l) => l !== "en");
|
|
5188
5835
|
return langs.filter((l) => !(l in text2));
|
|
5189
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 });
|
|
5190
5846
|
function lintPlugin(def) {
|
|
5191
5847
|
const out = [];
|
|
5192
5848
|
const add = (level, where, message) => out.push({ level, where, message });
|
|
@@ -5197,10 +5853,39 @@ function lintPlugin(def) {
|
|
|
5197
5853
|
if (reaches && !def.permissions) add("warn", "plugin", "it reads data: declare `permissions` (hosts, programs, files, devices) so people know before installing");
|
|
5198
5854
|
if (!def.description) add("warn", "plugin", "a description, for the Plugins page and the store");
|
|
5199
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`);
|
|
5200
|
-
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
|
+
});
|
|
5201
5886
|
const texts = (where, ...ts) => {
|
|
5202
5887
|
for (const tx of ts) {
|
|
5203
|
-
const miss = missingLanguages(tx,
|
|
5888
|
+
const miss = missingLanguages(tx, valid);
|
|
5204
5889
|
if (miss.length) add("warn", where, `"${typeof tx === "string" ? tx : tx?.en}" has no ${miss.join(", ")} (the plugin speaks ${langs.join(", ")})`);
|
|
5205
5890
|
}
|
|
5206
5891
|
};
|
|
@@ -5215,6 +5900,15 @@ function lintPlugin(def) {
|
|
|
5215
5900
|
if (!x.description) add("warn", where, "a description, for the library and the store");
|
|
5216
5901
|
return where;
|
|
5217
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);
|
|
5218
5912
|
for (const w of def.widgets ?? []) {
|
|
5219
5913
|
const where = part("widget", w);
|
|
5220
5914
|
out.push(...lintOptions(where, w.options, "widget"));
|
|
@@ -5321,31 +6015,31 @@ function wallClock(now, timeZone) {
|
|
|
5321
6015
|
}
|
|
5322
6016
|
var clock = defineWidget({
|
|
5323
6017
|
id: "clock",
|
|
5324
|
-
name: { en: "Clock", es: "Reloj" },
|
|
5325
|
-
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" },
|
|
5326
6020
|
icon: "clock",
|
|
5327
6021
|
category: "time",
|
|
5328
6022
|
chrome: "bare",
|
|
5329
6023
|
size: { min: { w: 120, h: 60 }, preferred: { w: 320, h: 200 } },
|
|
5330
6024
|
options: t.object({
|
|
5331
|
-
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" } }),
|
|
5332
6026
|
timeFormat: t.enum(["inherit", "24h", "12h"], {
|
|
5333
|
-
label: { en: "Time format", es: "Formato de hora" },
|
|
5334
|
-
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" } }
|
|
5335
6029
|
}),
|
|
5336
|
-
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" } }),
|
|
5337
6031
|
dateFormat: t.enum(["long", "short", "numeric"], {
|
|
5338
|
-
label: { en: "Date format", es: "Formato de la fecha" },
|
|
5339
|
-
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" } },
|
|
5340
|
-
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" }
|
|
5341
6035
|
}),
|
|
5342
6036
|
timeZone: t.string({
|
|
5343
6037
|
placeholder: "America/New_York",
|
|
5344
|
-
label: { en: "Time zone", es: "Zona horaria" },
|
|
5345
|
-
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" }
|
|
5346
6040
|
}),
|
|
5347
|
-
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" } } }),
|
|
5348
|
-
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" } })
|
|
5349
6043
|
}),
|
|
5350
6044
|
redraw: "second",
|
|
5351
6045
|
render(g, { box, now, options: options2, theme, locale, fmt }) {
|
|
@@ -5374,24 +6068,24 @@ var clock = defineWidget({
|
|
|
5374
6068
|
});
|
|
5375
6069
|
var date = defineWidget({
|
|
5376
6070
|
id: "date",
|
|
5377
|
-
name: { en: "Calendar day", es: "D\xEDa del calendario" },
|
|
5378
|
-
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" },
|
|
5379
6073
|
icon: "calendar",
|
|
5380
6074
|
category: "time",
|
|
5381
6075
|
size: { min: { w: 120, h: 120 }, preferred: { w: 220, h: 300 } },
|
|
5382
6076
|
options: t.object({
|
|
5383
6077
|
weekdayColor: t.enum(["accent", "ink", "dim", "alert"], {
|
|
5384
|
-
label: { en: "Weekday colour", es: "Color del d\xEDa de la semana" },
|
|
5385
|
-
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" } },
|
|
5386
|
-
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" }
|
|
5387
6081
|
}),
|
|
5388
|
-
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" } })
|
|
5389
6083
|
}),
|
|
5390
6084
|
redraw: "minute",
|
|
5391
6085
|
render(g, { box, now, options: options2, theme, kit, locale, t: tr }) {
|
|
5392
6086
|
const d = new Date(now);
|
|
5393
6087
|
const weekday = d.toLocaleDateString(locale, { weekday: "long" });
|
|
5394
|
-
const month = d.toLocaleDateString(locale, { month: "long" });
|
|
6088
|
+
const month = d.toLocaleDateString(locale, { month: hanScript(locale) ? "short" : "long" });
|
|
5395
6089
|
const top = Math.min(box.h * 0.16, 36);
|
|
5396
6090
|
const c = theme.colors;
|
|
5397
6091
|
const weekdayColor = { accent: c.accent, ink: c.ink, dim: c.inkDim, alert: c.alert }[options2.weekdayColor];
|
|
@@ -5406,7 +6100,7 @@ var date = defineWidget({
|
|
|
5406
6100
|
const bottom = box.y + box.h - 4;
|
|
5407
6101
|
const ms = Math.min(top, box.h * 0.13);
|
|
5408
6102
|
let line = month;
|
|
5409
|
-
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)))}`;
|
|
5410
6104
|
const ls = Math.min(ms, fit2(g, line, theme.fonts.sans, box.w * 0.96, ms));
|
|
5411
6105
|
g.font = `${ls}px "${theme.fonts.sans}"`;
|
|
5412
6106
|
g.fillStyle = theme.colors.inkDim;
|
|
@@ -5421,34 +6115,37 @@ function expandHome(path) {
|
|
|
5421
6115
|
var MAX_FILE_CHARS = 2e4;
|
|
5422
6116
|
var text = defineWidget({
|
|
5423
6117
|
id: "text",
|
|
5424
|
-
name: { en: "Text note", es: "Nota de texto" },
|
|
5425
|
-
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" },
|
|
5426
6120
|
icon: "type",
|
|
5427
6121
|
category: "productivity",
|
|
5428
6122
|
size: { min: { w: 120, h: 60 }, preferred: { w: 400, h: 160 } },
|
|
5429
6123
|
options: t.object({
|
|
5430
|
-
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" } }),
|
|
5431
6125
|
file: t.string({
|
|
5432
6126
|
format: "path",
|
|
5433
6127
|
risk: "path",
|
|
5434
6128
|
placeholder: "~/status.txt",
|
|
5435
|
-
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" },
|
|
5436
6130
|
help: {
|
|
5437
6131
|
en: "Paints what a script writes there (on call, a deploy, the last backup), read again on every refresh. Empty: the text above.",
|
|
5438
|
-
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"
|
|
5439
6136
|
}
|
|
5440
6137
|
}),
|
|
5441
|
-
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" } }),
|
|
5442
6139
|
font: t.enum(["sans", "bold", "mono"], {
|
|
5443
|
-
label: { en: "Font", es: "Letra" },
|
|
5444
|
-
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" } }
|
|
5445
6142
|
}),
|
|
5446
|
-
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" } } }),
|
|
5447
6144
|
valign: t.enum(["middle", "top", "bottom"], {
|
|
5448
|
-
label: { en: "Vertical alignment", es: "Alineaci\xF3n vertical" },
|
|
5449
|
-
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" } }
|
|
5450
6147
|
}),
|
|
5451
|
-
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" } })
|
|
5452
6149
|
}),
|
|
5453
6150
|
intervalMs: 6e4,
|
|
5454
6151
|
timeoutMs: 1e4,
|
|
@@ -5485,8 +6182,8 @@ function parseItems(text2) {
|
|
|
5485
6182
|
}
|
|
5486
6183
|
var list = defineWidget({
|
|
5487
6184
|
id: "list",
|
|
5488
|
-
name: { en: "List", es: "Lista" },
|
|
5489
|
-
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" },
|
|
5490
6187
|
icon: "list",
|
|
5491
6188
|
category: "productivity",
|
|
5492
6189
|
size: { min: { w: 160, h: 80 }, preferred: { w: 360, h: 240 } },
|
|
@@ -5494,8 +6191,8 @@ var list = defineWidget({
|
|
|
5494
6191
|
items: t.string({
|
|
5495
6192
|
default: "Water the plants\nCall the bank | before 14:00\nBook the dentist | Dr. Ruiz, any morning\nBuy coffee",
|
|
5496
6193
|
multiline: true,
|
|
5497
|
-
label: { en: "Items", es: "Elementos" },
|
|
5498
|
-
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" }
|
|
5499
6196
|
}),
|
|
5500
6197
|
...listOptions({ layouts: ["one-line", "detailed"] })
|
|
5501
6198
|
}),
|
|
@@ -5503,7 +6200,7 @@ var list = defineWidget({
|
|
|
5503
6200
|
render(g, ctx) {
|
|
5504
6201
|
const { box, options: options2, theme, kit } = ctx;
|
|
5505
6202
|
const items = parseItems(options2.items);
|
|
5506
|
-
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" }));
|
|
5507
6204
|
const plan = listLayout(box, items.length, options2, {
|
|
5508
6205
|
sizes: { "one-line": { min: 18, max: 44 }, detailed: { min: 36, max: 76 } },
|
|
5509
6206
|
// Two lines only when some item has a detail and every row has room for them.
|
|
@@ -5555,10 +6252,11 @@ function placeImage(box, w, h, fit3, position) {
|
|
|
5555
6252
|
const fy = position === "top" ? 0 : position === "bottom" ? 1 : 0.5;
|
|
5556
6253
|
return { x: box.x + (box.w - dw) * fx, y: box.y + (box.h - dh) * fy, w: dw, h: dh };
|
|
5557
6254
|
}
|
|
6255
|
+
var load = (canvas, src) => canvas.loadImageScaled ? canvas.loadImageScaled(src, { width: 1920, height: 1080, fit: "cover" }) : canvas.loadImage(src);
|
|
5558
6256
|
var image = defineWidget({
|
|
5559
6257
|
id: "image",
|
|
5560
|
-
name: { en: "Picture", es: "Imagen" },
|
|
5561
|
-
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" },
|
|
5562
6260
|
icon: "image",
|
|
5563
6261
|
category: "media",
|
|
5564
6262
|
chrome: "bare",
|
|
@@ -5568,26 +6266,32 @@ var image = defineWidget({
|
|
|
5568
6266
|
format: "url",
|
|
5569
6267
|
risk: ["network", "path"],
|
|
5570
6268
|
placeholder: "https://\u2026 or /path/to/image.png",
|
|
5571
|
-
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" },
|
|
5572
6270
|
help: {
|
|
5573
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).",
|
|
5574
|
-
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"
|
|
5575
6276
|
}
|
|
5576
6277
|
}),
|
|
5577
6278
|
addTimestamp: t.boolean({
|
|
5578
|
-
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" },
|
|
5579
6280
|
help: {
|
|
5580
6281
|
en: "Appends t=<now> on every refresh, for webcams that would otherwise be served from a cache.",
|
|
5581
|
-
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"
|
|
5582
6286
|
}
|
|
5583
6287
|
}),
|
|
5584
|
-
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" } } }),
|
|
5585
6289
|
position: t.enum(["center", "top", "bottom", "left", "right"], {
|
|
5586
|
-
label: { en: "Keep in view", es: "Mantener a la vista" },
|
|
5587
|
-
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" } },
|
|
5588
|
-
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" }
|
|
5589
6293
|
}),
|
|
5590
|
-
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" } })
|
|
5591
6295
|
}),
|
|
5592
6296
|
intervalMs: 5 * 6e4,
|
|
5593
6297
|
async fetch({ options: options2, canvas, signal }) {
|
|
@@ -5595,18 +6299,18 @@ var image = defineWidget({
|
|
|
5595
6299
|
if (/^https?:/.test(options2.src)) {
|
|
5596
6300
|
const res = await fetch(imageUrl(options2.src, Date.now(), options2.addTimestamp), { signal });
|
|
5597
6301
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
5598
|
-
return { img: await canvas
|
|
6302
|
+
return { img: await load(canvas, Buffer.from(await res.arrayBuffer())) };
|
|
5599
6303
|
}
|
|
5600
6304
|
const path = (await stat(options2.src)).isDirectory() ? await nextInFolder(options2.src) : options2.src;
|
|
5601
6305
|
if (!path) throw new Error(`no pictures in ${options2.src}`);
|
|
5602
|
-
return { img: await canvas
|
|
6306
|
+
return { img: await load(canvas, path) };
|
|
5603
6307
|
},
|
|
5604
6308
|
render(g, { box, data, options: options2, theme, kit, t: tr }) {
|
|
5605
6309
|
const img = data?.img;
|
|
5606
6310
|
if (!img) {
|
|
5607
6311
|
g.fillStyle = theme.colors.surface;
|
|
5608
6312
|
g.fillRect(box.x, box.y, box.w, box.h);
|
|
5609
|
-
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" });
|
|
5610
6314
|
return;
|
|
5611
6315
|
}
|
|
5612
6316
|
const at = placeImage(box, img.width, img.height, options2.fit, options2.position);
|
|
@@ -5624,12 +6328,13 @@ var image = defineWidget({
|
|
|
5624
6328
|
});
|
|
5625
6329
|
var src_default = definePlugin({
|
|
5626
6330
|
id: "core",
|
|
5627
|
-
name: { en: "Essentials", es: "B\xE1sicos" },
|
|
5628
|
-
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"],
|
|
5629
6334
|
sdk: "^0.2.0",
|
|
5630
6335
|
// The picture widget reads the image (or folder, or URL) you give it.
|
|
5631
6336
|
permissions: { files: ["user"], network: ["user"] },
|
|
5632
|
-
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" },
|
|
5633
6338
|
author: "Kiosko",
|
|
5634
6339
|
license: "MIT",
|
|
5635
6340
|
icon: "box",
|
|
@@ -5649,7 +6354,7 @@ function resolveModule(name, dir) {
|
|
|
5649
6354
|
}
|
|
5650
6355
|
return null;
|
|
5651
6356
|
}
|
|
5652
|
-
async function
|
|
6357
|
+
async function load2(path) {
|
|
5653
6358
|
const hit = loaded.get(path);
|
|
5654
6359
|
if (hit) return hit;
|
|
5655
6360
|
const m = (await import(pathToFileURL3(path).href)).default;
|
|
@@ -5664,10 +6369,10 @@ function legacyLook(theme) {
|
|
|
5664
6369
|
};
|
|
5665
6370
|
}
|
|
5666
6371
|
var optionsSchema = t.object({
|
|
5667
|
-
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." } }),
|
|
5668
|
-
dir: t.string({ default: "~/.aimonitor/modules", format: "path", risk: "exec", label: { en: "Modules folder", es: "Carpeta de m\xF3dulos" }, advanced: true }),
|
|
5669
|
-
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." } }),
|
|
5670
|
-
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 })
|
|
5671
6376
|
});
|
|
5672
6377
|
function moduleConfig(mod, o) {
|
|
5673
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]));
|
|
@@ -5680,8 +6385,8 @@ function moduleConfig(mod, o) {
|
|
|
5680
6385
|
}
|
|
5681
6386
|
var module2 = defineWidget({
|
|
5682
6387
|
id: "module",
|
|
5683
|
-
name: { en: "aimonitor module", es: "M\xF3dulo de aimonitor" },
|
|
5684
|
-
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" },
|
|
5685
6390
|
icon: "puzzle",
|
|
5686
6391
|
category: "productivity",
|
|
5687
6392
|
size: { min: { w: 200, h: 120 }, preferred: { w: 600, h: 440 } },
|
|
@@ -5691,7 +6396,7 @@ var module2 = defineWidget({
|
|
|
5691
6396
|
if (!options2.module) throw new Error("no module set");
|
|
5692
6397
|
const path = resolveModule(options2.module, options2.dir);
|
|
5693
6398
|
if (!path) throw new Error(`module "${options2.module}" not found in ${options2.dir}`);
|
|
5694
|
-
const mod = await
|
|
6399
|
+
const mod = await load2(path);
|
|
5695
6400
|
if (options2.json.trim()) JSON.parse(options2.json);
|
|
5696
6401
|
const data = mod.fetch ? await mod.fetch({ config: moduleConfig(mod, options2), now, log, canvas }) : void 0;
|
|
5697
6402
|
return { path, data };
|
|
@@ -5701,7 +6406,7 @@ var module2 = defineWidget({
|
|
|
5701
6406
|
render(g, ctx) {
|
|
5702
6407
|
const mod = ctx.data ? loaded.get(ctx.data.path) : void 0;
|
|
5703
6408
|
if (!mod) {
|
|
5704
|
-
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 });
|
|
5705
6410
|
return;
|
|
5706
6411
|
}
|
|
5707
6412
|
const box = ctx.box;
|
|
@@ -5719,21 +6424,30 @@ var module2 = defineWidget({
|
|
|
5719
6424
|
});
|
|
5720
6425
|
var src_default2 = definePlugin({
|
|
5721
6426
|
id: "legacy",
|
|
5722
|
-
name: { en: "aimonitor compatibility", es: "Compatibilidad aimonitor" },
|
|
5723
|
-
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"],
|
|
5724
6430
|
sdk: "^0.2.0",
|
|
5725
6431
|
// Runs the aimonitor modules you point it at, and reads their folder.
|
|
5726
6432
|
permissions: { exec: ["user"], files: ["user"] },
|
|
5727
|
-
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" },
|
|
5728
6434
|
author: "Kiosko",
|
|
5729
6435
|
license: "MIT",
|
|
5730
6436
|
icon: "puzzle",
|
|
5731
6437
|
widgets: [module2]
|
|
5732
6438
|
});
|
|
5733
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
|
+
|
|
5734
6449
|
// packages/server/src/builtin.ts
|
|
5735
6450
|
var BUILTIN_PLUGINS = [src_default, src_default2];
|
|
5736
|
-
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}` }));
|
|
5737
6451
|
|
|
5738
6452
|
// packages/server/src/config-cli.ts
|
|
5739
6453
|
import { copyFileSync as copyFileSync2, existsSync as existsSync8, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync6 } from "node:fs";
|
|
@@ -5795,7 +6509,7 @@ var red = paint("31");
|
|
|
5795
6509
|
var yellow = paint("33");
|
|
5796
6510
|
var green = paint("32");
|
|
5797
6511
|
var dim = paint("2");
|
|
5798
|
-
var
|
|
6512
|
+
var plural3 = (n, w) => `${n} ${w}${n === 1 ? "" : "s"}`;
|
|
5799
6513
|
function issueLine(i) {
|
|
5800
6514
|
const ctx = i.context && !i.message.includes(i.context) && !i.path.includes(i.context) ? ` (${i.context})` : "";
|
|
5801
6515
|
return `${i.path}${ctx}: ${i.message}`;
|
|
@@ -5855,7 +6569,7 @@ async function schemaCommand(ctx, opts) {
|
|
|
5855
6569
|
mkdirSync5(dirname4(resolve2(out)), { recursive: true });
|
|
5856
6570
|
writeFileSync6(out, text2);
|
|
5857
6571
|
const count = (k) => plugins.reduce((n, p) => n + (p[k]?.length ?? 0), 0);
|
|
5858
|
-
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")}`);
|
|
5859
6573
|
const rel = relative(dirname4(resolve2(ctx.configPath)), resolve2(out));
|
|
5860
6574
|
console.error(`The published schema (official plugins) is ${CONFIG_SCHEMA_ID}. With plugins of your own, point the config at this file instead:
|
|
5861
6575
|
"$schema": ${JSON.stringify(isAbsolute2(rel) || rel.startsWith("..") ? resolve2(out) : rel)}`);
|
|
@@ -5886,7 +6600,7 @@ async function validateCommand(ctx, file, flags) {
|
|
|
5886
6600
|
console.log(`${input.name}: ${green("valid")}`);
|
|
5887
6601
|
return 0;
|
|
5888
6602
|
}
|
|
5889
|
-
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"))}` : ""}`);
|
|
5890
6604
|
if (report.errors.length) console.log(`
|
|
5891
6605
|
${bold("Errors")} (Kiosko would misread these):
|
|
5892
6606
|
${report.errors.map((i) => ` ${issueLine(i)}`).join("\n")}`);
|
|
@@ -5955,7 +6669,7 @@ async function importCommand(ctx, file, flags, opts) {
|
|
|
5955
6669
|
const { errors, warnings } = plan.report;
|
|
5956
6670
|
if (errors.length) {
|
|
5957
6671
|
console.log(`
|
|
5958
|
-
${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)`);
|
|
5959
6673
|
for (const i of errors) console.log(` ${issueLine(i)}`);
|
|
5960
6674
|
for (const i of warnings) console.log(` ${dim("warning")} ${issueLine(i)}`);
|
|
5961
6675
|
console.log(dim("\nNothing was written."));
|
|
@@ -5965,7 +6679,7 @@ ${red(plural2(errors.length, "error"))}${warnings.length ? `, ${yellow(plural2(w
|
|
|
5965
6679
|
const pages = c.screens.reduce((n, s) => n + s.pages.length, 0);
|
|
5966
6680
|
const tiles = c.screens.reduce((n, s) => n + s.pages.reduce((m, p) => m + p.tiles.length, 0), 0);
|
|
5967
6681
|
console.log(`
|
|
5968
|
-
${green("valid")}: ${
|
|
6682
|
+
${green("valid")}: ${plural3(c.screens.length, "screen")}, ${plural3(pages, "page")}, ${plural3(tiles, "tile")}${warnings.length ? `; ${yellow(plural3(warnings.length, "warning"))}` : ""}`);
|
|
5969
6683
|
for (const i of warnings) console.log(` ${dim("warning")} ${issueLine(i)}`);
|
|
5970
6684
|
console.log(`
|
|
5971
6685
|
${bold("Changes")}: ${summarizeDiff(plan.diff)}`);
|
|
@@ -6022,7 +6736,7 @@ ${green("Written")} ${path}${saved}.`);
|
|
|
6022
6736
|
if (running) console.log(dim(`The Kiosko at ${running.base} uses another config (${running.servedPath}); it was not touched.`));
|
|
6023
6737
|
else console.log(dim("No running Kiosko answered for this config: it will use the new one when it starts."));
|
|
6024
6738
|
}
|
|
6025
|
-
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).`);
|
|
6026
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.`));
|
|
6027
6741
|
return 0;
|
|
6028
6742
|
}
|
|
@@ -6045,7 +6759,7 @@ async function configCommand(argv2, ctx) {
|
|
|
6045
6759
|
|
|
6046
6760
|
// packages/server/src/plugins-cli.ts
|
|
6047
6761
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
6048
|
-
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";
|
|
6049
6763
|
import { basename, join as join11, resolve as resolve4 } from "node:path";
|
|
6050
6764
|
import { pathToFileURL as pathToFileURL4 } from "node:url";
|
|
6051
6765
|
var npmName = (s) => /^[a-z0-9][\w.-]*$/.test(s) && !s.startsWith("kiosko-plugin-") && !s.includes("/") ? `kiosko-plugin-${s}` : s;
|
|
@@ -6076,6 +6790,12 @@ async function loadPluginDir(dir, o = {}) {
|
|
|
6076
6790
|
var flagOf = (argv2, name) => argv2.includes(name);
|
|
6077
6791
|
var optOf = (argv2, name) => argv2.includes(name) ? argv2[argv2.indexOf(name) + 1] : void 0;
|
|
6078
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
|
+
}
|
|
6079
6799
|
async function check2(dir, argv2) {
|
|
6080
6800
|
const { def, pkg, entry } = await loadPluginDir(dir, { src: flagOf(argv2, "--src") });
|
|
6081
6801
|
console.log(`${def.id} v${def.version} (${entry})`);
|
|
@@ -6083,12 +6803,14 @@ async function check2(dir, argv2) {
|
|
|
6083
6803
|
const meta = packageMeta(pkg);
|
|
6084
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' });
|
|
6085
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)}` });
|
|
6086
6808
|
const why = incompatibility({ sdk: def.sdk ?? meta.sdk, platforms: def.platforms ?? meta.platforms });
|
|
6087
6809
|
if (why) issues.push({ level: "warn", where: "plugin", message: `this Kiosko can't run it: ${why}` });
|
|
6088
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}` });
|
|
6089
6811
|
const { checkPlugin: checkPlugin2 } = await Promise.resolve().then(() => (init_testing(), testing_exports));
|
|
6090
6812
|
const painted = /* @__PURE__ */ new Map();
|
|
6091
|
-
for (const p of checkPlugin2(def, { locales:
|
|
6813
|
+
for (const p of checkPlugin2(def, { locales: declaredLanguages(def, meta) })) {
|
|
6092
6814
|
const [size = "", ...look] = p.where.split(" ");
|
|
6093
6815
|
const problem = p.problem.replace(/\d+ px/, "N px").replace(/\d+ ms/, "N ms");
|
|
6094
6816
|
const key = `${p.type}|${size}|${problem}`;
|
|
@@ -6096,12 +6818,12 @@ async function check2(dir, argv2) {
|
|
|
6096
6818
|
g.looks.push(look.join(" "));
|
|
6097
6819
|
painted.set(key, g);
|
|
6098
6820
|
}
|
|
6099
|
-
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)})` : ""}` });
|
|
6100
6822
|
const errors = issues.filter((i) => i.level === "error");
|
|
6101
6823
|
for (const i of [...errors, ...issues.filter((i2) => i2.level === "warn")]) console.log(`${i.level === "error" ? "\u2717" : "!"} ${i.where}: ${i.message}`);
|
|
6102
6824
|
console.log(issues.length ? `
|
|
6103
6825
|
${errors.length} errors, ${issues.length - errors.length} warnings` : "\u2713 no problems found");
|
|
6104
|
-
return errors.length;
|
|
6826
|
+
return { errors: errors.length, warnings: issues.length - errors.length };
|
|
6105
6827
|
}
|
|
6106
6828
|
async function manifest(dir, argv2) {
|
|
6107
6829
|
const root = resolve4(dir);
|
|
@@ -6147,7 +6869,7 @@ function newPluginFiles(id) {
|
|
|
6147
6869
|
license: "MIT",
|
|
6148
6870
|
keywords: ["kiosko", "kiosko-plugin", "lcd", "widgets"],
|
|
6149
6871
|
exports: { ".": { source: "./src/index.ts", default: "./dist/index.js" } },
|
|
6150
|
-
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" },
|
|
6151
6873
|
files: ["dist", "docs", "kiosko-manifest.json", "README.md", "LICENSE"],
|
|
6152
6874
|
engines: { node: ">=22.18" },
|
|
6153
6875
|
scripts: {
|
|
@@ -6225,6 +6947,8 @@ export default definePlugin({
|
|
|
6225
6947
|
version: '0.1.0',
|
|
6226
6948
|
description: { en: '${name} for Kiosko.', es: '${name} para Kiosko.' },
|
|
6227
6949
|
sdk: '${sdk}',
|
|
6950
|
+
// The languages its texts come in (Chinese by script: 'zh-Hant', 'zh-Hans').
|
|
6951
|
+
languages: ['en', 'es'],
|
|
6228
6952
|
// What it does on the machine, shown before anyone installs it.
|
|
6229
6953
|
permissions: { network: ['user'] },
|
|
6230
6954
|
widgets: [card],
|
|
@@ -6292,8 +7016,8 @@ async function pluginsCommand(argv2, registry2) {
|
|
|
6292
7016
|
const [sub = "list", ...names] = argv2;
|
|
6293
7017
|
switch (sub) {
|
|
6294
7018
|
case "check": {
|
|
6295
|
-
const errors = await check2(positional(names)[0] ?? ".", names);
|
|
6296
|
-
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;
|
|
6297
7021
|
return;
|
|
6298
7022
|
}
|
|
6299
7023
|
case "manifest":
|
|
@@ -6304,7 +7028,7 @@ async function pluginsCommand(argv2, registry2) {
|
|
|
6304
7028
|
const [id, where] = positional(names);
|
|
6305
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)");
|
|
6306
7030
|
const dir = resolve4(where ?? `kiosko-plugin-${id}`);
|
|
6307
|
-
if (existsSync9(dir) &&
|
|
7031
|
+
if (existsSync9(dir) && readdirSync4(dir).length) throw new Error(`${dir} is not empty`);
|
|
6308
7032
|
for (const [file, body2] of Object.entries(newPluginFiles(id))) {
|
|
6309
7033
|
mkdirSync6(join11(dir, file, ".."), { recursive: true });
|
|
6310
7034
|
writeFileSync7(join11(dir, file), body2);
|
|
@@ -6391,47 +7115,76 @@ plugins folder: ${paths.plugins}`);
|
|
|
6391
7115
|
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync8 } from "node:fs";
|
|
6392
7116
|
import { join as join12 } from "node:path";
|
|
6393
7117
|
var HOME_URL = "https://kioskolcd.dev/";
|
|
6394
|
-
var DEMO_URL = "https://kioskolcd.dev/demo/";
|
|
6395
7118
|
var RELEASES_URL = "https://github.com/kiosko-lcd/kiosko/releases/latest";
|
|
6396
|
-
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
|
+
};
|
|
6397
7134
|
var esc = (s) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
6398
7135
|
var slug2 = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "page";
|
|
6399
7136
|
function buildGallery(registry2, o) {
|
|
6400
|
-
const locale = o.locale ?? "en";
|
|
6401
7137
|
const theme = themeById(o.theme);
|
|
6402
7138
|
const now = o.now ?? Date.now();
|
|
6403
|
-
const
|
|
6404
|
-
|
|
6405
|
-
const
|
|
6406
|
-
const both = (x) => (
|
|
6407
|
-
const data = { count: 0, plugins: [], pages: [] };
|
|
6408
|
-
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: [] };
|
|
6409
7144
|
let count = 0;
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
const
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
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>
|
|
6431
7181
|
<style>
|
|
6432
7182
|
:root{color-scheme:dark;--bg:#0a0d13;--panel:#121722;--line:rgba(255,255,255,.08);--text:#e7ecf4;--dim:#a3adbf}
|
|
6433
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}
|
|
6434
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}
|
|
6435
7188
|
header p{color:var(--dim);margin:6px 0 0}main{max-width:1240px;margin:auto;padding:0 24px 60px}
|
|
6436
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}
|
|
6437
7190
|
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:16px;align-items:start}
|
|
@@ -6441,21 +7194,24 @@ figcaption code{color:#22d3ee;font-size:12px}figcaption span{flex-basis:100%;col
|
|
|
6441
7194
|
a{color:#22d3ee}
|
|
6442
7195
|
p.os{margin-top:14px}p.os b{color:var(--text)}
|
|
6443
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}
|
|
6444
|
-
</style></head><body><header><p><a href="${
|
|
6445
|
-
|
|
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
|
+
}
|
|
6446
7200
|
if (o.pages) {
|
|
6447
7201
|
const sample = normalize(o.pages);
|
|
6448
7202
|
const screen = [...sample.screens].sort((a, b) => b.width / b.height - a.width / a.height)[0];
|
|
6449
7203
|
for (const page of screen?.pages.filter((p) => p.enabled !== false) ?? []) {
|
|
6450
7204
|
const name = `img/page-${slug2(page.name || page.id)}`;
|
|
6451
|
-
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 });
|
|
6452
7206
|
}
|
|
6453
|
-
for (const
|
|
6454
|
-
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 });
|
|
6455
7211
|
try {
|
|
6456
7212
|
for (const listed of data.pages) {
|
|
6457
|
-
const page =
|
|
6458
|
-
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));
|
|
6459
7215
|
}
|
|
6460
7216
|
} finally {
|
|
6461
7217
|
rt.stop();
|
|
@@ -6549,19 +7305,19 @@ function importAimonitor(old, reg, modeOverride, o = {}) {
|
|
|
6549
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 } : {} };
|
|
6550
7306
|
const grid = { cols: 24, rows: 6, gap: 10, padding: 10 };
|
|
6551
7307
|
const W = (type, options2 = {}, title) => ({ id: newId("w"), type, options: options2, ...title ? { title } : {} });
|
|
6552
|
-
const
|
|
7308
|
+
const T2 = (x, y, w, h, widgets, chrome = "auto", rotateMs = 3e4) => ({ id: newId("tile"), x, y, w, h, widgets, rotateMs, chrome });
|
|
6553
7309
|
const railOn = old.rail?.enabled !== false && old.usage?.enabled !== false;
|
|
6554
7310
|
const sysOn = old.system?.enabled !== false;
|
|
6555
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 } : {} };
|
|
6556
|
-
const dashTiles = [
|
|
6557
|
-
if (sysOn) dashTiles.push(
|
|
6558
|
-
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"));
|
|
6559
7315
|
const dashboard = { id: newId("page"), name: "Dashboard", enabled: true, durationMs: old.scene?.alternateMs ?? 10 * 6e4, when: "always", grid, gravity: "none", background: {}, tiles: dashTiles };
|
|
6560
7316
|
const cardWidgets = (old.modules ?? []).map((m) => widgetFor(m, reg, notes, modulesDir)).filter((w) => !!w);
|
|
6561
7317
|
if (railOn) cardWidgets.push(W("usage/rail", {}, "Consumo"));
|
|
6562
7318
|
const side = old.scene?.side === "izquierda" ? "left" : "right";
|
|
6563
|
-
const catsTiles = [
|
|
6564
|
-
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));
|
|
6565
7321
|
const cats = { id: newId("page"), name: "Cats", enabled: true, durationMs: old.scene?.alternateMs ?? 10 * 6e4, when: "always", grid, gravity: "none", background: {}, tiles: catsTiles };
|
|
6566
7322
|
const override = (modeOverride ?? "").trim().toLowerCase();
|
|
6567
7323
|
const mode = ["gatos", "tablero", "alternar"].includes(override) ? override : old.scene?.mode ?? "tablero";
|
|
@@ -6751,7 +7507,7 @@ function runService(action, plan) {
|
|
|
6751
7507
|
// packages/server/src/server.ts
|
|
6752
7508
|
import { existsSync as existsSync12, readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
|
|
6753
7509
|
import { createServer } from "node:http";
|
|
6754
|
-
import { createRequire as
|
|
7510
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
6755
7511
|
import { dirname as dirname6, extname, join as join15, normalize as normPath, resolve as resolve7 } from "node:path";
|
|
6756
7512
|
|
|
6757
7513
|
// packages/server/src/plugins-manage.ts
|
|
@@ -7051,12 +7807,12 @@ var MqttClient = class extends EventEmitter2 {
|
|
|
7051
7807
|
};
|
|
7052
7808
|
|
|
7053
7809
|
// packages/server/src/homeassistant.ts
|
|
7054
|
-
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" };
|
|
7055
7811
|
var NAMES = {
|
|
7056
|
-
page: { en: "Page", es: "P\xE1gina" },
|
|
7057
|
-
shown: { en: "Page shown", es: "P\xE1gina en pantalla" },
|
|
7058
|
-
display: { en: "Display", es: "Pantalla" },
|
|
7059
|
-
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" }
|
|
7060
7816
|
};
|
|
7061
7817
|
var slug3 = (s) => s.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "x";
|
|
7062
7818
|
function pageOptions(screen, auto) {
|
|
@@ -7106,7 +7862,7 @@ var HomeAssistantBridge = class {
|
|
|
7106
7862
|
return `kiosko/${this.link.nodeId}`;
|
|
7107
7863
|
}
|
|
7108
7864
|
loc(l) {
|
|
7109
|
-
return resolveLocale(this.runtime.config)
|
|
7865
|
+
return localize(l, resolveLocale(this.runtime.config));
|
|
7110
7866
|
}
|
|
7111
7867
|
/** A new config: connect, reconnect (other broker or login) or just announce again. */
|
|
7112
7868
|
apply(cfg) {
|
|
@@ -7207,7 +7963,7 @@ var HomeAssistantBridge = class {
|
|
|
7207
7963
|
});
|
|
7208
7964
|
for (const slot of screen.interludes) {
|
|
7209
7965
|
const def = this.runtime.registry.interlude(slot.type);
|
|
7210
|
-
const name = def ?
|
|
7966
|
+
const name = def ? this.loc(def.name) || slot.type : slot.type;
|
|
7211
7967
|
put("button", `${sid}_${slug3(slot.id)}`, {
|
|
7212
7968
|
name: `${this.loc(NAMES.interlude)}: ${name}`,
|
|
7213
7969
|
unique_id: id(slug3(slot.id)),
|
|
@@ -7270,7 +8026,7 @@ var HomeAssistantBridge = class {
|
|
|
7270
8026
|
};
|
|
7271
8027
|
|
|
7272
8028
|
// packages/server/src/server.ts
|
|
7273
|
-
var require3 =
|
|
8029
|
+
var require3 = createRequire3(import.meta.url);
|
|
7274
8030
|
var MIME = {
|
|
7275
8031
|
".html": "text/html; charset=utf-8",
|
|
7276
8032
|
".js": "text/javascript; charset=utf-8",
|
|
@@ -7375,7 +8131,7 @@ data: ${JSON.stringify(data)}
|
|
|
7375
8131
|
if (p === "/api/config" && m === "PUT") {
|
|
7376
8132
|
const b = await body(req);
|
|
7377
8133
|
const raw = b && typeof b === "object" && "config" in b ? b.config : b;
|
|
7378
|
-
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 });
|
|
7379
8135
|
const cfg = normalize(raw);
|
|
7380
8136
|
saveConfig(cfg, o.configPath);
|
|
7381
8137
|
rev++;
|
|
@@ -7400,7 +8156,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7400
8156
|
let mm = /^\/api\/screens\/([^/]+)\/frame\.(?:jpg|png)$/.exec(p);
|
|
7401
8157
|
if (mm && m === "GET") {
|
|
7402
8158
|
const f = runtime.lastFrame(decodeURIComponent(mm[1]));
|
|
7403
|
-
if (!f) return json(res, 404, { error: "no frame yet" });
|
|
8159
|
+
if (!f) return json(res, 404, { error: "no frame yet", code: "noFrame" });
|
|
7404
8160
|
const buf = f.image();
|
|
7405
8161
|
res.writeHead(200, { "content-type": "image/jpeg", "cache-control": "no-store", "content-length": String(buf.length), "x-kiosko-at": String(f.at) });
|
|
7406
8162
|
return void res.end(buf);
|
|
@@ -7410,7 +8166,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7410
8166
|
const cfg = normalize({ screens: [b.screen] });
|
|
7411
8167
|
const screen = cfg.screens[0];
|
|
7412
8168
|
const page = screen.pages.find((x) => x.id === b.pageId) ?? screen.pages[0];
|
|
7413
|
-
if (!page) return json(res, 400, { error: "no page" });
|
|
8169
|
+
if (!page) return json(res, 400, { error: "no page", code: "noPage" });
|
|
7414
8170
|
const r = runtime.preview(screen, page, { ...b.forceShown ? { forceShown: b.forceShown } : {}, demo: b.demo ?? true });
|
|
7415
8171
|
return png(res, r.canvas.toBuffer("image/png"), { "x-kiosko-tiles": encodeURIComponent(JSON.stringify(r.tiles)) });
|
|
7416
8172
|
}
|
|
@@ -7422,7 +8178,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7422
8178
|
const key = `${look.theme ?? runtime.config.theme}|${type}|${w}x${h}|${look.locale ?? runtime.config.locale}`;
|
|
7423
8179
|
let buf = thumbs.get(key);
|
|
7424
8180
|
if (!buf) {
|
|
7425
|
-
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" });
|
|
7426
8182
|
buf = runtime.thumbnail(type, w, h, {}, void 0, look);
|
|
7427
8183
|
thumbs.set(key, buf);
|
|
7428
8184
|
}
|
|
@@ -7475,7 +8231,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7475
8231
|
const id = decodeURIComponent(mm[1]);
|
|
7476
8232
|
try {
|
|
7477
8233
|
const r = await removePlugin(id, { registry: runtime.registry, runtime });
|
|
7478
|
-
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 } });
|
|
7479
8235
|
rev++;
|
|
7480
8236
|
send("config", { rev, by: null });
|
|
7481
8237
|
return json(res, 200, state());
|
|
@@ -7497,7 +8253,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7497
8253
|
if (mm && m === "POST") {
|
|
7498
8254
|
const id = decodeURIComponent(mm[1]);
|
|
7499
8255
|
const u = updates?.plugins.find((x) => x.id === id);
|
|
7500
|
-
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 } });
|
|
7501
8257
|
try {
|
|
7502
8258
|
const r = await installPlugin(`${u.package}@${u.version}`, { registry: runtime.registry, runtime });
|
|
7503
8259
|
if (!r.problem && updates) updates = { ...updates, plugins: updates.plugins.filter((x) => x.id !== id) };
|
|
@@ -7513,7 +8269,7 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7513
8269
|
if (mm && m === "POST") {
|
|
7514
8270
|
const id = decodeURIComponent(mm[1]);
|
|
7515
8271
|
const problem = await reloadPlugin(id, { registry: runtime.registry, runtime });
|
|
7516
|
-
if (problem) return json(res, 409, { error: problem });
|
|
8272
|
+
if (problem) return json(res, 409, { error: problem, code: "reloadFailed", params: { id, why: problem } });
|
|
7517
8273
|
rev++;
|
|
7518
8274
|
send("config", { rev, by: null });
|
|
7519
8275
|
return json(res, 200, state());
|
|
@@ -7535,11 +8291,11 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7535
8291
|
if (p === "/api/screens/export" && m === "GET") {
|
|
7536
8292
|
const id = url2.searchParams.get("id") ?? "";
|
|
7537
8293
|
const s = findScreen(runtime.config, id);
|
|
7538
|
-
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" });
|
|
7539
8295
|
res.writeHead(200, { "content-type": "application/json", "content-disposition": `attachment; filename="kiosko-${id}.json"` });
|
|
7540
8296
|
return void res.end(JSON.stringify({ kiosko: "screen", version: 1, screen: { ...s, device: { driver: "virtual" } } }, null, 2));
|
|
7541
8297
|
}
|
|
7542
|
-
return json(res, 404, { error: "not found" });
|
|
8298
|
+
return json(res, 404, { error: "not found", code: "notFound" });
|
|
7543
8299
|
}
|
|
7544
8300
|
function serveStatic(res, pathname) {
|
|
7545
8301
|
const rel = normPath(decodeURIComponent(pathname)).replace(/^([/\\])+/, "");
|
|
@@ -7590,10 +8346,10 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
7590
8346
|
function starterConfig(registry2, o = {}) {
|
|
7591
8347
|
const width = o.width ?? 1920;
|
|
7592
8348
|
const height = o.height ?? 462;
|
|
7593
|
-
const
|
|
7594
|
-
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);
|
|
7595
8351
|
const has = (t2) => !!registry2.widget(t2);
|
|
7596
|
-
const page = newPage(
|
|
8352
|
+
const page = newPage(L({ en: "Home", es: "Inicio", de: "Start", "zh-Hant": "\u9996\u9801", "zh-Hans": "\u9996\u9875" }), width, height);
|
|
7597
8353
|
page.grid = { cols: 24, rows: 6, gap: 10, padding: 10 };
|
|
7598
8354
|
page.gravity = "left";
|
|
7599
8355
|
const tiles = [];
|
|
@@ -7602,13 +8358,13 @@ function starterConfig(registry2, o = {}) {
|
|
|
7602
8358
|
if (ws.length) tiles.push(newTile(r, ws));
|
|
7603
8359
|
};
|
|
7604
8360
|
if (has("agents/sessions")) add({ x: 0, y: 0, w: 11, h: 6 }, ["agents/sessions"]);
|
|
7605
|
-
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" }));
|
|
7606
8362
|
add({ x: 11, y: 0, w: 5, h: 4 }, ["core/clock"]);
|
|
7607
8363
|
add({ x: 11, y: 4, w: 5, h: 2 }, ["weather/forecast", "mirror/compliments"]);
|
|
7608
8364
|
add({ x: 16, y: 0, w: 8, h: 6 }, ["usage/rail", "vitals/vitals", "system/health", "mirror/countdown"].filter(has).slice(0, 3));
|
|
7609
8365
|
if (!has("agents/sessions")) {
|
|
7610
8366
|
const welcome = tiles[0]?.widgets[0];
|
|
7611
|
-
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 };
|
|
7612
8368
|
}
|
|
7613
8369
|
page.tiles = tiles;
|
|
7614
8370
|
if (height > width) transposePage(page, width, height);
|
|
@@ -7623,7 +8379,7 @@ function starterConfig(registry2, o = {}) {
|
|
|
7623
8379
|
}
|
|
7624
8380
|
|
|
7625
8381
|
// packages/server/src/cli.ts
|
|
7626
|
-
var VERSION = "0.2.
|
|
8382
|
+
var VERSION = "0.2.6";
|
|
7627
8383
|
var USAGE2 = `Kiosko ${VERSION}: a widget mosaic for USB LCD panels
|
|
7628
8384
|
|
|
7629
8385
|
kiosko start [--port 7420] [--host 127.0.0.1] [--config file] [--open] [--demo]
|
|
@@ -7636,13 +8392,13 @@ var USAGE2 = `Kiosko ${VERSION}: a widget mosaic for USB LCD panels
|
|
|
7636
8392
|
kiosko usb [list] the LY panels libusb sees, with their serial numbers
|
|
7637
8393
|
kiosko usb test [--serial S] [--seconds 10] [--size 1920x462] [--rotate 180]
|
|
7638
8394
|
drive a panel with the sample screen (experimental)
|
|
7639
|
-
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]
|
|
7640
8396
|
kiosko plugins [list|add <id>\u2026|link <folder>\u2026|remove <id>\u2026]
|
|
7641
8397
|
kiosko service install|uninstall|print (start with your session)
|
|
7642
8398
|
kiosko version`;
|
|
7643
8399
|
var argv = process.argv.slice(2);
|
|
7644
8400
|
var FLAG_COMMANDS = /* @__PURE__ */ new Set(["--help", "-h", "--version", "-v"]);
|
|
7645
|
-
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";
|
|
7646
8402
|
var flag = (name) => argv.includes(name);
|
|
7647
8403
|
var opt = (name) => {
|
|
7648
8404
|
const i = argv.indexOf(name);
|
|
@@ -7698,6 +8454,13 @@ async function main() {
|
|
|
7698
8454
|
const url2 = `http://${host === "0.0.0.0" ? "127.0.0.1" : host}:${port}/`;
|
|
7699
8455
|
console.log(`Kiosko ${VERSION} \u2014 editor at ${url2}`);
|
|
7700
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}`);
|
|
7701
8464
|
if (flag("--open")) openBrowser(url2);
|
|
7702
8465
|
const stop = () => {
|
|
7703
8466
|
rt.stop();
|
|
@@ -7790,6 +8553,10 @@ async function main() {
|
|
|
7790
8553
|
console.log(`Kiosko ${VERSION} on ${process.platform}/${process.arch}, Node ${process.version}`);
|
|
7791
8554
|
console.log(`config ${path} ${exists ? error ? `INVALID: ${error}` : "ok" : "(not created yet)"}`);
|
|
7792
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}`);
|
|
7793
8560
|
for (const p of reg.problems) console.log(` \u2717 ${p.origin}: ${p.message}`);
|
|
7794
8561
|
const usb = await listUsb();
|
|
7795
8562
|
if (!usb.ok) console.log(`usb not available: ${usb.error}`);
|
|
@@ -7804,6 +8571,8 @@ async function main() {
|
|
|
7804
8571
|
case "service": {
|
|
7805
8572
|
const pass = ["--port", "--host", "--config"].flatMap((f) => opt(f) ? [f, opt(f)] : []);
|
|
7806
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;
|
|
7807
8576
|
runService(argv[1] ?? "print", servicePlan({ args: pass, env }));
|
|
7808
8577
|
return;
|
|
7809
8578
|
}
|
|
@@ -7812,7 +8581,7 @@ async function main() {
|
|
|
7812
8581
|
const reg = await registry();
|
|
7813
8582
|
const out = opt("--out") ?? "gallery";
|
|
7814
8583
|
const sample = opt("--pages");
|
|
7815
|
-
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")) } : {} });
|
|
7816
8585
|
console.log(`${n} widgets \u2192 ${out}/index.html`);
|
|
7817
8586
|
return;
|
|
7818
8587
|
}
|