kiosko 0.2.7 → 0.2.9
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 +45 -3
- package/cli.js +1374 -190
- package/package.json +7 -1
- package/screen-thread.js +387 -11
- package/sdk.js +28 -5
- package/web/assets/app.js +69 -3
- package/web/assets/styles.css +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kiosko",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "A widget mosaic for small always-on USB LCD panels (Thermalright Trofeo Vision and friends), with a visual editor and plugins.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,6 +36,12 @@
|
|
|
36
36
|
"type": "git",
|
|
37
37
|
"url": "git+https://github.com/kiosko-lcd/kiosko.git"
|
|
38
38
|
},
|
|
39
|
+
"homepage": "https://kioskolcd.dev",
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/kiosko-lcd/kiosko/issues",
|
|
42
|
+
"email": "info@kioskolcd.dev"
|
|
43
|
+
},
|
|
44
|
+
"author": "Loksly <info@kioskolcd.dev> (https://kioskolcd.dev)",
|
|
39
45
|
"dependencies": {
|
|
40
46
|
"@napi-rs/canvas": "^1.1.0",
|
|
41
47
|
"dejavu-fonts-ttf": "^2.37.3"
|
package/screen-thread.js
CHANGED
|
@@ -54,6 +54,10 @@ function zoomOf(inst) {
|
|
|
54
54
|
return Math.round(Math.min(ZOOM.max, Math.max(ZOOM.min, z)) * 100) / 100;
|
|
55
55
|
}
|
|
56
56
|
var READING_CM = { near: 40, normal: 60, far: 90 };
|
|
57
|
+
var STARTER_NAMES = {
|
|
58
|
+
screen: { en: "My panel", es: "Mi panel", de: "Mein Panel", "zh-Hant": "\u6211\u7684\u9762\u677F", "zh-Hans": "\u6211\u7684\u5C4F\u5E55" },
|
|
59
|
+
page: { en: "Home", es: "Inicio", de: "Start", "zh-Hant": "\u9996\u9801", "zh-Hans": "\u9996\u9875" }
|
|
60
|
+
};
|
|
57
61
|
var DEFAULT_CONFIG = {
|
|
58
62
|
version: CONFIG_VERSION,
|
|
59
63
|
locale: "auto",
|
|
@@ -106,7 +110,7 @@ import { homedir as homedir2, platform } from "node:os";
|
|
|
106
110
|
|
|
107
111
|
// packages/sdk/src/plugin.ts
|
|
108
112
|
var PAD_KEYS = ["up", "down", "left", "right", "a", "b", "x", "y", "l", "r", "start", "select"];
|
|
109
|
-
var SDK_VERSION = "0.2.
|
|
113
|
+
var SDK_VERSION = "0.2.9";
|
|
110
114
|
function defineWidget(w) {
|
|
111
115
|
return w;
|
|
112
116
|
}
|
|
@@ -377,9 +381,9 @@ function themeById(id) {
|
|
|
377
381
|
|
|
378
382
|
// packages/sdk/src/languages.ts
|
|
379
383
|
var MAINLAND_CHINA = {
|
|
380
|
-
without: [
|
|
381
|
-
first: ["llm", "gpu"],
|
|
382
|
-
instead: { "
|
|
384
|
+
without: [],
|
|
385
|
+
first: ["llm", "gpu", "usage"],
|
|
386
|
+
instead: { "usage/rail": "usage/balance", "usage/blocks": "usage/agents" }
|
|
383
387
|
};
|
|
384
388
|
var LANGUAGES = [
|
|
385
389
|
{ id: "en", name: "English", panel: "en", ogLocale: "en_US", hreflang: ["en", "x-default"], dir: "ltr" },
|
|
@@ -805,6 +809,20 @@ function sourceOptionsField(def) {
|
|
|
805
809
|
return merged.get(def) ?? void 0;
|
|
806
810
|
}
|
|
807
811
|
|
|
812
|
+
// packages/core/src/config/starter.ts
|
|
813
|
+
var STARTER_TYPES = /* @__PURE__ */ new Set(["agents/sessions", "core/text", "core/clock", "core/date", "weather/forecast", "mirror/compliments", "usage/rail", "vitals/vitals", "system/health", "mirror/countdown"]);
|
|
814
|
+
function looksLikeStarter(c) {
|
|
815
|
+
if (c.screens.length !== 1) return false;
|
|
816
|
+
const s = c.screens[0];
|
|
817
|
+
const named = (name, names) => Object.values(names).includes(name);
|
|
818
|
+
if (s.device.driver !== "virtual" || !named(s.name, STARTER_NAMES.screen) || s.pages.length !== 1) return false;
|
|
819
|
+
const p = s.pages[0];
|
|
820
|
+
return named(p.name, STARTER_NAMES.page) && p.tiles.length <= 4 && p.tiles.every((t2) => t2.widgets.every((w) => STARTER_TYPES.has(w.type)));
|
|
821
|
+
}
|
|
822
|
+
function offersSetup(c) {
|
|
823
|
+
return c.setup === "pending" || !c.setup && (c.screens.length === 0 || looksLikeStarter(c));
|
|
824
|
+
}
|
|
825
|
+
|
|
808
826
|
// packages/core/src/layout/stack.ts
|
|
809
827
|
function pickInStack(entries, now, rotateMs) {
|
|
810
828
|
const urgent = entries.find((e) => e.visible && e.urgent);
|
|
@@ -2213,6 +2231,245 @@ function paintAlert(g, w, h, shown, o) {
|
|
|
2213
2231
|
g.restore();
|
|
2214
2232
|
}
|
|
2215
2233
|
|
|
2234
|
+
// packages/core/src/welcome.ts
|
|
2235
|
+
var BOOT_MS = 2400;
|
|
2236
|
+
var BOOT_WINDOW_MS = 6e4;
|
|
2237
|
+
var CARD_EVERY_MS = 10 * 6e4;
|
|
2238
|
+
var CARD_MS = 15e3;
|
|
2239
|
+
var FIRST_CARD_MS = 3e4;
|
|
2240
|
+
var BOOT_FPS = 15;
|
|
2241
|
+
function welcomeDue(cfg, s) {
|
|
2242
|
+
const pending2 = offersSetup(cfg);
|
|
2243
|
+
if (!s.booted) {
|
|
2244
|
+
if (s.sinceStartMs < BOOT_WINDOW_MS && (cfg.bootAnimation !== false || pending2)) return "boot";
|
|
2245
|
+
return pending2 ? "card" : null;
|
|
2246
|
+
}
|
|
2247
|
+
if (!pending2) return null;
|
|
2248
|
+
const slot = Math.floor(s.now / CARD_EVERY_MS);
|
|
2249
|
+
return slot !== s.cardSlot && s.now - slot * CARD_EVERY_MS < 6e4 ? "card" : null;
|
|
2250
|
+
}
|
|
2251
|
+
var TEXTS = {
|
|
2252
|
+
running: { en: "Kiosko is running", es: "Kiosko est\xE1 en marcha", de: "Kiosko l\xE4uft", "zh-Hant": "Kiosko \u5DF2\u5728\u57F7\u884C", "zh-Hans": "Kiosko \u5DF2\u5728\u8FD0\u884C" },
|
|
2253
|
+
open: { en: "Open the editor to set up this panel:", es: "Abre el editor para configurar este panel:", de: "\xD6ffne den Editor, um dieses Panel einzurichten:", "zh-Hant": "\u958B\u555F\u7DE8\u8F2F\u5668\u4F86\u8A2D\u5B9A\u9019\u584A\u9762\u677F\uFF1A", "zh-Hans": "\u6253\u5F00\u7F16\u8F91\u5668\u6765\u8BBE\u7F6E\u8FD9\u5757\u526F\u5C4F\uFF1A" },
|
|
2254
|
+
or: { en: "or go to", es: "o entra en", de: "oder \xF6ffne", "zh-Hant": "\u6216\u524D\u5F80", "zh-Hans": "\u6216\u8BBF\u95EE" },
|
|
2255
|
+
hint: { en: "This card goes away once the setup is done.", es: "Esta tarjeta se va cuando termines la configuraci\xF3n.", de: "Diese Karte verschwindet, sobald die Einrichtung fertig ist.", "zh-Hant": "\u5B8C\u6210\u8A2D\u5B9A\u5F8C\uFF0C\u9019\u5F35\u5361\u7247\u5C31\u6703\u6D88\u5931\u3002", "zh-Hans": "\u5B8C\u6210\u8BBE\u7F6E\u540E\uFF0C\u8FD9\u5F20\u5361\u7247\u5C31\u4F1A\u6D88\u5931\u3002" }
|
|
2256
|
+
};
|
|
2257
|
+
function welcomeTexts(locale) {
|
|
2258
|
+
return Object.fromEntries(Object.entries(TEXTS).map(([k, v]) => [k, localize(v, locale)]));
|
|
2259
|
+
}
|
|
2260
|
+
function editorUrl(cfg) {
|
|
2261
|
+
const host = !cfg.server.host || cfg.server.host === "0.0.0.0" || cfg.server.host === "::" ? "127.0.0.1" : cfg.server.host;
|
|
2262
|
+
return `http://${host.includes(":") ? `[${host}]` : host}:${cfg.server.port}`;
|
|
2263
|
+
}
|
|
2264
|
+
function cardUrl(listening, cfg) {
|
|
2265
|
+
return listening ?? editorUrl(cfg);
|
|
2266
|
+
}
|
|
2267
|
+
var clamp01 = (x) => Math.max(0, Math.min(1, x));
|
|
2268
|
+
var easeOut = (x) => 1 - (1 - clamp01(x)) ** 3;
|
|
2269
|
+
var easeBack = (x) => {
|
|
2270
|
+
const t2 = clamp01(x) - 1;
|
|
2271
|
+
return 1 + 2.2 * t2 ** 3 + 1.2 * t2 ** 2;
|
|
2272
|
+
};
|
|
2273
|
+
var TILES = [
|
|
2274
|
+
{ x: 6, y: 6, w: 30, h: 22, grad: true, alpha: 1 },
|
|
2275
|
+
{ x: 40, y: 6, w: 18, h: 22, grad: false, tone: 1, alpha: 0.55 },
|
|
2276
|
+
{ x: 6, y: 32, w: 18, h: 26, grad: false, tone: 0, alpha: 0.55 },
|
|
2277
|
+
{ x: 28, y: 32, w: 30, h: 26, grad: true, alpha: 0.85 }
|
|
2278
|
+
];
|
|
2279
|
+
function brand(theme) {
|
|
2280
|
+
return [theme.colors.accent, theme.colors.info];
|
|
2281
|
+
}
|
|
2282
|
+
function paintMark(g, x, y, size, theme, t2 = 1, glint = -1) {
|
|
2283
|
+
const k = size / 64;
|
|
2284
|
+
const [c1, c2] = brand(theme);
|
|
2285
|
+
TILES.forEach((tile, i) => {
|
|
2286
|
+
const p = clamp01((t2 - i * 0.12) / 0.52);
|
|
2287
|
+
if (p <= 0) return;
|
|
2288
|
+
const s = 0.55 + 0.45 * easeBack(p);
|
|
2289
|
+
const cx = x + (tile.x + tile.w / 2) * k;
|
|
2290
|
+
const cy = y + (tile.y + tile.h / 2) * k;
|
|
2291
|
+
const dx = (tile.x + tile.w / 2 - 32) * k * 0.6 * (1 - easeOut(p));
|
|
2292
|
+
const dy = (tile.y + tile.h / 2 - 32) * k * 0.6 * (1 - easeOut(p));
|
|
2293
|
+
const w = tile.w * k * s;
|
|
2294
|
+
const h = tile.h * k * s;
|
|
2295
|
+
g.save();
|
|
2296
|
+
g.globalAlpha = tile.alpha * easeOut(p);
|
|
2297
|
+
if (tile.grad) {
|
|
2298
|
+
const gr = g.createLinearGradient(x, y, x + size, y + size);
|
|
2299
|
+
gr.addColorStop(0, c1);
|
|
2300
|
+
gr.addColorStop(1, c2);
|
|
2301
|
+
g.fillStyle = gr;
|
|
2302
|
+
} else g.fillStyle = "tone" in tile && tile.tone ? c2 : c1;
|
|
2303
|
+
g.beginPath();
|
|
2304
|
+
g.roundRect(cx + dx - w / 2, cy + dy - h / 2, w, h, 5 * k * s);
|
|
2305
|
+
g.fill();
|
|
2306
|
+
g.restore();
|
|
2307
|
+
});
|
|
2308
|
+
if (glint >= 0 && glint <= 1) {
|
|
2309
|
+
g.save();
|
|
2310
|
+
g.beginPath();
|
|
2311
|
+
for (const tile of TILES) g.roundRect(x + tile.x * k, y + tile.y * k, tile.w * k, tile.h * k, 5 * k);
|
|
2312
|
+
g.clip();
|
|
2313
|
+
const bx = x - size * 0.6 + glint * size * 2.2;
|
|
2314
|
+
const gr = g.createLinearGradient(bx, y, bx + size * 0.5, y + size);
|
|
2315
|
+
gr.addColorStop(0, "rgba(255,255,255,0)");
|
|
2316
|
+
gr.addColorStop(0.5, "rgba(255,255,255,0.45)");
|
|
2317
|
+
gr.addColorStop(1, "rgba(255,255,255,0)");
|
|
2318
|
+
g.fillStyle = gr;
|
|
2319
|
+
g.fillRect(x, y, size, size);
|
|
2320
|
+
g.restore();
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
function paintBackground(g, w, h, theme, cx, cy, glow) {
|
|
2324
|
+
g.fillStyle = theme.colors.bg;
|
|
2325
|
+
g.fillRect(0, 0, w, h);
|
|
2326
|
+
if (glow <= 0) return;
|
|
2327
|
+
const r = Math.max(w, h) * 0.55;
|
|
2328
|
+
const gr = g.createRadialGradient(cx, cy, 0, cx, cy, r);
|
|
2329
|
+
const [c1] = brand(theme);
|
|
2330
|
+
gr.addColorStop(0, css(hex(c1), 0.16 * glow));
|
|
2331
|
+
gr.addColorStop(1, css(hex(c1), 0));
|
|
2332
|
+
g.fillStyle = gr;
|
|
2333
|
+
g.fillRect(0, 0, w, h);
|
|
2334
|
+
}
|
|
2335
|
+
function shapeOf(w, h) {
|
|
2336
|
+
const r = w / h;
|
|
2337
|
+
return r >= 1.6 ? "wide" : r <= 0.7 ? "tall" : "square";
|
|
2338
|
+
}
|
|
2339
|
+
function paintBoot(g, w, h, ms, look) {
|
|
2340
|
+
const { theme } = look;
|
|
2341
|
+
const shape = shapeOf(w, h);
|
|
2342
|
+
const bold = theme.fonts.sansBold;
|
|
2343
|
+
const word = "Kiosko";
|
|
2344
|
+
const mark = shape === "wide" ? Math.round(h * 0.5) : Math.round(Math.min(w * (shape === "tall" ? 0.62 : 0.42), h * 0.42));
|
|
2345
|
+
let size = Math.round(mark * (shape === "wide" ? 0.62 : 0.4));
|
|
2346
|
+
size = fitSize(g, word, shape === "wide" ? w * 0.5 : w * 0.86, { size, family: bold }, 10);
|
|
2347
|
+
const wordW = measureTracked(g, word, { size, family: bold });
|
|
2348
|
+
const gap = Math.round(mark * 0.22);
|
|
2349
|
+
const groupW = shape === "wide" ? mark + gap + wordW : Math.max(mark, wordW);
|
|
2350
|
+
const groupH = shape === "wide" ? mark : mark + gap + size;
|
|
2351
|
+
const gx = Math.round((w - groupW) / 2);
|
|
2352
|
+
const gy = Math.round((h - groupH) / 2);
|
|
2353
|
+
const mx = shape === "wide" ? gx : Math.round((w - mark) / 2);
|
|
2354
|
+
const fade = 1 - clamp01((ms - (BOOT_MS - 380)) / 380);
|
|
2355
|
+
paintBackground(g, w, h, theme, mx + mark / 2, gy + mark / 2, easeOut(ms / 900) * fade);
|
|
2356
|
+
g.save();
|
|
2357
|
+
g.globalAlpha = fade;
|
|
2358
|
+
paintMark(g, mx, gy, mark, theme, ms / 1e3, (ms - 1350) / 650);
|
|
2359
|
+
const p = easeOut((ms - 650) / 700);
|
|
2360
|
+
if (p > 0) {
|
|
2361
|
+
const wx = shape === "wide" ? gx + mark + gap : Math.round((w - wordW) / 2);
|
|
2362
|
+
const base2 = shape === "wide" ? gy + mark / 2 + size * 0.36 : gy + mark + gap + size * 0.82;
|
|
2363
|
+
g.save();
|
|
2364
|
+
g.beginPath();
|
|
2365
|
+
if (shape === "wide") g.rect(wx - 2, 0, (wordW + 4) * p, h);
|
|
2366
|
+
else g.rect(0, 0, w, h);
|
|
2367
|
+
g.clip();
|
|
2368
|
+
g.globalAlpha = fade * (shape === "wide" ? 1 : p);
|
|
2369
|
+
drawTracked(g, word, wx, base2 + (1 - p) * size * 0.25, { size, family: bold, color: theme.colors.ink });
|
|
2370
|
+
g.restore();
|
|
2371
|
+
const u = easeOut((ms - 1150) / 600);
|
|
2372
|
+
if (u > 0) {
|
|
2373
|
+
const [c1, c2] = brand(theme);
|
|
2374
|
+
const gr = g.createLinearGradient(wx, 0, wx + wordW, 0);
|
|
2375
|
+
gr.addColorStop(0, c1);
|
|
2376
|
+
gr.addColorStop(1, c2);
|
|
2377
|
+
g.fillStyle = gr;
|
|
2378
|
+
const uh = Math.max(2, Math.round(size * 0.07));
|
|
2379
|
+
g.beginPath();
|
|
2380
|
+
g.roundRect(wx, base2 + size * 0.16, wordW * u, uh, uh / 2);
|
|
2381
|
+
g.fill();
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
g.restore();
|
|
2385
|
+
}
|
|
2386
|
+
function paintCard(g, w, h, look) {
|
|
2387
|
+
const { theme } = look;
|
|
2388
|
+
const tx = welcomeTexts(look.locale);
|
|
2389
|
+
const shape = shapeOf(w, h);
|
|
2390
|
+
const pad = Math.round(Math.min(w, h) * 0.08);
|
|
2391
|
+
const mark = shape === "wide" ? Math.round(h * 0.42) : shape === "tall" ? Math.round(w * 0.5) : Math.round(Math.min(w * 0.3, h * 0.28));
|
|
2392
|
+
const gap = Math.round(pad * 0.8);
|
|
2393
|
+
const mx = shape === "wide" ? pad + Math.round(mark * 0.1) : Math.round((w - mark) / 2);
|
|
2394
|
+
const bx = shape === "wide" ? mx + mark + Math.round(mark * 0.35) : pad;
|
|
2395
|
+
const bw = w - bx - pad;
|
|
2396
|
+
const bh = shape === "wide" ? h - 2 * pad : h - 2 * pad - mark - gap;
|
|
2397
|
+
const bold = theme.fonts.sansBold;
|
|
2398
|
+
const sans = theme.fonts.sans;
|
|
2399
|
+
const mono = theme.fonts.monoBold;
|
|
2400
|
+
const center = shape !== "wide";
|
|
2401
|
+
const layout = (k2) => {
|
|
2402
|
+
const body = Math.max(9, Math.round(k2 * 0.5));
|
|
2403
|
+
const chip = Math.max(9, Math.round(k2 * 0.5));
|
|
2404
|
+
const hint = Math.max(8, Math.round(k2 * 0.34));
|
|
2405
|
+
const title = wrapLines(g, tx.running, bw, 2, { size: k2, family: bold });
|
|
2406
|
+
const open = wrapLines(g, tx.open, bw, 3, { size: body, family: sans });
|
|
2407
|
+
const cmd = "kiosko editor";
|
|
2408
|
+
const cmdW = measureTracked(g, cmd, { size: chip, family: mono }) + chip * 1.1;
|
|
2409
|
+
const orW = measureTracked(g, tx.or, { size: body, family: sans });
|
|
2410
|
+
const urlW = measureTracked(g, look.url, { size: chip, family: mono });
|
|
2411
|
+
const oneLine = cmdW + body * 0.6 + orW + body * 0.6 + urlW <= bw;
|
|
2412
|
+
const hints = hint >= 10 ? wrapLines(g, tx.hint, bw, 2, { size: hint, family: sans }) : [];
|
|
2413
|
+
const lineH = (s) => Math.round(s * 1.3);
|
|
2414
|
+
const height = title.length * lineH(k2) + k2 * 0.25 + open.length * lineH(body) + body * 0.35 + (oneLine ? chip * 1.9 : chip * 1.9 * 2 + lineH(body)) + hint * 0.6 + hints.length * lineH(hint);
|
|
2415
|
+
const fits = urlW <= bw && cmdW <= bw && title.length === 1;
|
|
2416
|
+
return { k: k2, body, chip, hint, title, open, cmd, cmdW, orW, urlW, oneLine, hints, height, fits, lineH };
|
|
2417
|
+
};
|
|
2418
|
+
let k = Math.round(shape === "wide" ? h * 0.17 : shape === "tall" ? w * 0.12 : Math.min(w * 0.085, h * 0.11));
|
|
2419
|
+
let L = layout(k);
|
|
2420
|
+
while (k > 12 && (L.height > bh || !L.fits)) L = layout(--k);
|
|
2421
|
+
const my = shape === "wide" ? Math.round((h - mark) / 2) : Math.max(pad, Math.round((h - mark - gap - L.height) / 2));
|
|
2422
|
+
paintBackground(g, w, h, theme, mx + mark / 2, my + mark / 2, 1);
|
|
2423
|
+
paintMark(g, mx, my, mark, theme);
|
|
2424
|
+
let y = shape === "wide" ? pad + Math.max(0, Math.round((bh - L.height) / 2)) : my + mark + gap;
|
|
2425
|
+
const ax = center ? w / 2 : bx;
|
|
2426
|
+
const align = center ? "center" : "left";
|
|
2427
|
+
for (const line of L.title) {
|
|
2428
|
+
drawTracked(g, line, ax, y + L.k * 0.95, { size: L.k, family: bold, color: theme.colors.ink, align });
|
|
2429
|
+
y += L.lineH(L.k);
|
|
2430
|
+
}
|
|
2431
|
+
y += L.k * 0.25;
|
|
2432
|
+
for (const line of L.open) {
|
|
2433
|
+
drawTracked(g, line, ax, y + L.body * 0.95, { size: L.body, family: sans, color: theme.colors.inkDim, align });
|
|
2434
|
+
y += L.lineH(L.body);
|
|
2435
|
+
}
|
|
2436
|
+
y += L.body * 0.35;
|
|
2437
|
+
const chipH = Math.round(L.chip * 1.6);
|
|
2438
|
+
const drawChip = (x, text2, cw) => {
|
|
2439
|
+
g.fillStyle = theme.colors.surface;
|
|
2440
|
+
g.strokeStyle = theme.colors.surfaceEdge;
|
|
2441
|
+
g.lineWidth = 1;
|
|
2442
|
+
g.beginPath();
|
|
2443
|
+
g.roundRect(x, y, cw, chipH, chipH / 3);
|
|
2444
|
+
g.fill();
|
|
2445
|
+
g.stroke();
|
|
2446
|
+
drawTracked(g, text2, x + cw / 2, y + chipH / 2 + L.chip * 0.36, { size: L.chip, family: mono, color: theme.colors.ink, align: "center" });
|
|
2447
|
+
};
|
|
2448
|
+
const drawUrl = (x) => drawTracked(g, look.url, x, y + chipH / 2 + L.chip * 0.36, { size: L.chip, family: mono, color: theme.colors.accent });
|
|
2449
|
+
if (L.oneLine) {
|
|
2450
|
+
const total = L.cmdW + L.body * 0.6 + L.orW + L.body * 0.6 + L.urlW;
|
|
2451
|
+
let x = center ? Math.round((w - total) / 2) : bx;
|
|
2452
|
+
drawChip(x, L.cmd, L.cmdW);
|
|
2453
|
+
x += L.cmdW + L.body * 0.6;
|
|
2454
|
+
drawTracked(g, tx.or, x, y + chipH / 2 + L.body * 0.36, { size: L.body, family: sans, color: theme.colors.inkDim });
|
|
2455
|
+
x += L.orW + L.body * 0.6;
|
|
2456
|
+
drawUrl(x);
|
|
2457
|
+
y += L.chip * 1.9;
|
|
2458
|
+
} else {
|
|
2459
|
+
drawChip(center ? Math.round((w - L.cmdW) / 2) : bx, L.cmd, L.cmdW);
|
|
2460
|
+
y += L.chip * 1.9;
|
|
2461
|
+
drawTracked(g, tx.or, ax, y + L.body * 0.95, { size: L.body, family: sans, color: theme.colors.inkDim, align });
|
|
2462
|
+
y += L.lineH(L.body);
|
|
2463
|
+
drawUrl(center ? Math.round((w - L.urlW) / 2) : bx);
|
|
2464
|
+
y += L.chip * 1.9;
|
|
2465
|
+
}
|
|
2466
|
+
y += L.hint * 0.6;
|
|
2467
|
+
for (const line of L.hints) {
|
|
2468
|
+
drawTracked(g, line, ax, y + L.hint * 0.95, { size: L.hint, family: sans, color: theme.colors.inkFaint, align });
|
|
2469
|
+
y += L.lineH(L.hint);
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2216
2473
|
// packages/core/src/frame-stats.ts
|
|
2217
2474
|
var FPS_WINDOW_MS = 5e3;
|
|
2218
2475
|
var round = (ms) => Math.round(ms * 10) / 10;
|
|
@@ -2305,6 +2562,12 @@ var ScreenRunner = class {
|
|
|
2305
2562
|
alertKey = null;
|
|
2306
2563
|
/** Real fps, paint and encode times (see frame-stats.ts). */
|
|
2307
2564
|
stats = new FrameStats();
|
|
2565
|
+
/** The start went by (the boot animation played, or wasn't due). */
|
|
2566
|
+
booted = false;
|
|
2567
|
+
/** The first run's card: the last slot it was shown in, and until when it stays. */
|
|
2568
|
+
cardSlot = -1;
|
|
2569
|
+
cardUntil = 0;
|
|
2570
|
+
cardKey = null;
|
|
2308
2571
|
screen;
|
|
2309
2572
|
rt;
|
|
2310
2573
|
/** `device`: one already open for this screen (handed over by a thread that stopped). */
|
|
@@ -2387,6 +2650,7 @@ var ScreenRunner = class {
|
|
|
2387
2650
|
const play = this.wantedPlay;
|
|
2388
2651
|
this.wanted = null;
|
|
2389
2652
|
this.wantedPlay = false;
|
|
2653
|
+
if (!this.off && !asked && await this.maybeWelcome(now)) return;
|
|
2390
2654
|
if (!this.off && await this.maybeInterlude(now, asked ?? void 0, play)) return;
|
|
2391
2655
|
const page = this.currentPage(now);
|
|
2392
2656
|
if (page?.id !== this.page?.id) {
|
|
@@ -2496,6 +2760,95 @@ var ScreenRunner = class {
|
|
|
2496
2760
|
this.last = out;
|
|
2497
2761
|
await this.send(out);
|
|
2498
2762
|
}
|
|
2763
|
+
/**
|
|
2764
|
+
* The boot animation and the first run's card (welcome.ts), before
|
|
2765
|
+
* anything else but an alert. True while one has the screen.
|
|
2766
|
+
*/
|
|
2767
|
+
async maybeWelcome(now) {
|
|
2768
|
+
if (!this.rt.welcome || this.rt.demoMode) return false;
|
|
2769
|
+
const cfg = this.rt.config;
|
|
2770
|
+
if (this.cardUntil) {
|
|
2771
|
+
if (now < this.cardUntil && offersSetup(cfg)) {
|
|
2772
|
+
await this.paintWelcomeCard(now);
|
|
2773
|
+
return true;
|
|
2774
|
+
}
|
|
2775
|
+
this.cardUntil = 0;
|
|
2776
|
+
this.cardKey = null;
|
|
2777
|
+
this.last = null;
|
|
2778
|
+
this.dirty = true;
|
|
2779
|
+
return false;
|
|
2780
|
+
}
|
|
2781
|
+
const due = welcomeDue(cfg, { sinceStartMs: now - this.rt.startedAt, now, booted: this.booted, cardSlot: this.cardSlot });
|
|
2782
|
+
const first = !this.booted;
|
|
2783
|
+
this.booted = true;
|
|
2784
|
+
if (!due) return false;
|
|
2785
|
+
if (due === "boot") {
|
|
2786
|
+
await this.playBoot();
|
|
2787
|
+
if (!offersSetup(cfg)) {
|
|
2788
|
+
this.last = null;
|
|
2789
|
+
this.dirty = true;
|
|
2790
|
+
return true;
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
this.cardSlot = Math.floor(Date.now() / CARD_EVERY_MS);
|
|
2794
|
+
this.cardUntil = Date.now() + (first ? FIRST_CARD_MS : CARD_MS);
|
|
2795
|
+
await this.paintWelcomeCard(Date.now());
|
|
2796
|
+
return true;
|
|
2797
|
+
}
|
|
2798
|
+
welcomeLook() {
|
|
2799
|
+
const cfg = this.rt.config;
|
|
2800
|
+
return { theme: this.rt.theme(), locale: resolveLocale(cfg), url: cardUrl(this.rt.editorUrl, cfg) };
|
|
2801
|
+
}
|
|
2802
|
+
/** The boot animation, at the screen's fps (at most BOOT_FPS): a slower panel plays fewer frames, never longer. */
|
|
2803
|
+
async playBoot() {
|
|
2804
|
+
const { screen } = this;
|
|
2805
|
+
const look = this.welcomeLook();
|
|
2806
|
+
registerFonts();
|
|
2807
|
+
setFontLocale(look.locale);
|
|
2808
|
+
const fps = Math.max(1, Math.min(BOOT_FPS, screen.maxFps));
|
|
2809
|
+
const frames = Math.max(1, Math.round(BOOT_MS / 1e3 * fps));
|
|
2810
|
+
const kind = encodeFor(screen.device, screen.jpegQuality || 85);
|
|
2811
|
+
const canvas = CANVAS.createCanvas(screen.width, screen.height);
|
|
2812
|
+
const g = canvas.getContext("2d");
|
|
2813
|
+
const start = Date.now();
|
|
2814
|
+
for (let i = 0; i < frames && !this.alert && !this.closed; i++) {
|
|
2815
|
+
const ms = Math.min(BOOT_MS, Date.now() - start);
|
|
2816
|
+
if (ms >= BOOT_MS) break;
|
|
2817
|
+
const t0 = performance.now();
|
|
2818
|
+
g.save();
|
|
2819
|
+
paintBoot(g, screen.width, screen.height, ms, look);
|
|
2820
|
+
g.restore();
|
|
2821
|
+
const out = await this.fit(rotateCanvas(canvas, screen.rotate), kind, screen.jpegQuality || 85, screen, performance.now() - t0);
|
|
2822
|
+
await this.send(out);
|
|
2823
|
+
if (i % 4 === 0) {
|
|
2824
|
+
const snap = CANVAS.createCanvas(canvas.width, canvas.height);
|
|
2825
|
+
snap.getContext("2d").drawImage(canvas, 0, 0);
|
|
2826
|
+
this.lastInfo = { screenId: screen.id, pageId: this.page?.id ?? null, at: Date.now(), image: lazyJpeg(snap), tiles: [], interlude: "kiosko/boot", sleeping: false };
|
|
2827
|
+
this.rt.frame(this.lastInfo);
|
|
2828
|
+
}
|
|
2829
|
+
const wait = start + (i + 1) * 1e3 / fps - Date.now();
|
|
2830
|
+
await new Promise((r) => wait > 0 ? setTimeout(r, wait) : setImmediate(r));
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2833
|
+
/** The first run's card: a still frame, sent again only when it changes (the theme, the language, the address). */
|
|
2834
|
+
async paintWelcomeCard(now) {
|
|
2835
|
+
const { screen } = this;
|
|
2836
|
+
const look = this.welcomeLook();
|
|
2837
|
+
const key = JSON.stringify([look.theme.id, look.locale, look.url, screen.width, screen.height, screen.rotate]);
|
|
2838
|
+
if (key === this.cardKey) return;
|
|
2839
|
+
this.cardKey = key;
|
|
2840
|
+
const t0 = performance.now();
|
|
2841
|
+
registerFonts();
|
|
2842
|
+
setFontLocale(look.locale);
|
|
2843
|
+
const canvas = CANVAS.createCanvas(screen.width, screen.height);
|
|
2844
|
+
paintCard(canvas.getContext("2d"), screen.width, screen.height, look);
|
|
2845
|
+
const kind = encodeFor(screen.device, screen.jpegQuality || 85);
|
|
2846
|
+
const out = await this.fit(rotateCanvas(canvas, screen.rotate), kind, screen.jpegQuality || 85, screen, performance.now() - t0);
|
|
2847
|
+
this.lastInfo = { screenId: screen.id, pageId: this.page?.id ?? null, at: now, image: lazyJpeg(canvas), tiles: [], interlude: "kiosko/welcome", sleeping: false };
|
|
2848
|
+
this.rt.frame(this.lastInfo);
|
|
2849
|
+
this.last = out;
|
|
2850
|
+
await this.send(out);
|
|
2851
|
+
}
|
|
2499
2852
|
/**
|
|
2500
2853
|
* Plays an interlude if one is due. Returns true while it played (no normal paint this tick).
|
|
2501
2854
|
* `play`: someone plays it from the Play page (an interlude with `input`): it gets their
|
|
@@ -3281,6 +3634,9 @@ var Host = class {
|
|
|
3281
3634
|
demoMode;
|
|
3282
3635
|
maxConcurrent;
|
|
3283
3636
|
playIdleMs;
|
|
3637
|
+
welcome;
|
|
3638
|
+
startedAt;
|
|
3639
|
+
editorUrl;
|
|
3284
3640
|
rnd = Math.random;
|
|
3285
3641
|
data = /* @__PURE__ */ new Map();
|
|
3286
3642
|
sources = /* @__PURE__ */ new Map();
|
|
@@ -3297,6 +3653,9 @@ var Host = class {
|
|
|
3297
3653
|
this.demoMode = init.demo;
|
|
3298
3654
|
this.maxConcurrent = init.maxConcurrent;
|
|
3299
3655
|
this.playIdleMs = init.playIdleMs;
|
|
3656
|
+
this.welcome = init.welcome;
|
|
3657
|
+
this.startedAt = init.startedAt;
|
|
3658
|
+
this.editorUrl = init.editorUrl;
|
|
3300
3659
|
this.post = post;
|
|
3301
3660
|
this.device = new RelayDevice(post);
|
|
3302
3661
|
}
|
|
@@ -3530,17 +3889,34 @@ var clock = defineWidget({
|
|
|
3530
3889
|
const at = wallClock(now, options.timeZone);
|
|
3531
3890
|
const clock2 = options.timeFormat === "inherit" ? fmt : createFormatters({ locale, timeFormat: options.timeFormat, now });
|
|
3532
3891
|
const text2 = clock2.time(at, { seconds: options.showSeconds, ampm: false });
|
|
3892
|
+
const full = clock2.hour12 ? clock2.time(at, { seconds: options.showSeconds }) : text2;
|
|
3893
|
+
const mark = full === text2 ? "" : full.replace(text2, "").trim();
|
|
3894
|
+
const markFirst = !!mark && full.startsWith(mark);
|
|
3533
3895
|
const dateText = options.showDate ? new Date(at).toLocaleDateString(locale, DATE_FORMATS[options.dateFormat]) : "";
|
|
3534
3896
|
const dateH = options.showDate ? Math.min(box.h * 0.2, 40) : 0;
|
|
3535
|
-
const size = fit(g, text2, theme.fonts.monoBold, box.w * 0.96, (box.h - dateH * 1.3) * 0.95);
|
|
3897
|
+
const size = fit(g, text2, theme.fonts.monoBold, box.w * (mark ? 0.76 : 0.96), (box.h - dateH * 1.3) * 0.95);
|
|
3536
3898
|
const color = options.color === "accent" ? theme.colors.accent : options.color === "dim" ? theme.colors.inkDim : theme.colors.ink;
|
|
3537
|
-
const x = options.align === "left" ? box.x : options.align === "right" ? box.x + box.w : box.x + box.w / 2;
|
|
3538
3899
|
const block = size * 0.78 + (dateH ? dateH * 1.4 : 0);
|
|
3539
3900
|
const base2 = box.y + (box.h - block) / 2 + size * 0.78;
|
|
3540
|
-
g.
|
|
3901
|
+
g.font = `${size}px "${theme.fonts.monoBold}"`;
|
|
3902
|
+
const digitsW = g.measureText(text2).width;
|
|
3903
|
+
const markSize = Math.max(8, Math.round(size * 0.26));
|
|
3904
|
+
g.font = `${markSize}px "${theme.fonts.sansBold}"`;
|
|
3905
|
+
const markW = mark ? g.measureText(mark).width + size * 0.08 : 0;
|
|
3906
|
+
const total = digitsW + markW;
|
|
3907
|
+
const left = options.align === "left" ? box.x : options.align === "right" ? box.x + box.w - total : box.x + (box.w - total) / 2;
|
|
3908
|
+
const digitsX = markFirst ? left + markW : left;
|
|
3909
|
+
g.textAlign = "left";
|
|
3541
3910
|
g.fillStyle = color;
|
|
3542
3911
|
g.font = `${size}px "${theme.fonts.monoBold}"`;
|
|
3543
|
-
g.fillText(text2,
|
|
3912
|
+
g.fillText(text2, digitsX, base2);
|
|
3913
|
+
if (mark) {
|
|
3914
|
+
g.fillStyle = theme.colors.inkDim;
|
|
3915
|
+
g.font = `${markSize}px "${theme.fonts.sansBold}"`;
|
|
3916
|
+
g.fillText(mark, markFirst ? left : left + digitsW + size * 0.08, base2 - size * 0.78 + markSize * 0.92);
|
|
3917
|
+
}
|
|
3918
|
+
const x = options.align === "left" ? box.x : options.align === "right" ? box.x + box.w : box.x + box.w / 2;
|
|
3919
|
+
g.textAlign = options.align;
|
|
3544
3920
|
if (dateH) {
|
|
3545
3921
|
const ds = Math.min(dateH, fit(g, dateText, theme.fonts.sans, box.w * 0.96, dateH));
|
|
3546
3922
|
g.font = `${ds}px "${theme.fonts.sans}"`;
|
|
@@ -3813,7 +4189,7 @@ var image = defineWidget({
|
|
|
3813
4189
|
var src_default = definePlugin({
|
|
3814
4190
|
id: "core",
|
|
3815
4191
|
name: { en: "Essentials", es: "B\xE1sicos", de: "Grundlagen", "zh-Hant": "\u57FA\u672C\u5DE5\u5177", "zh-Hans": "\u57FA\u7840\u7EC4\u4EF6" },
|
|
3816
|
-
version: "0.2.
|
|
4192
|
+
version: "0.2.9",
|
|
3817
4193
|
languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
|
|
3818
4194
|
sdk: "^0.2.0",
|
|
3819
4195
|
// The picture widget reads the image (or folder, or URL) you give it.
|
|
@@ -3909,7 +4285,7 @@ var module2 = defineWidget({
|
|
|
3909
4285
|
var src_default2 = definePlugin({
|
|
3910
4286
|
id: "legacy",
|
|
3911
4287
|
name: { en: "aimonitor compatibility", es: "Compatibilidad aimonitor", de: "aimonitor-Kompatibilit\xE4t", "zh-Hant": "aimonitor \u76F8\u5BB9\u6027", "zh-Hans": "aimonitor \u517C\u5BB9" },
|
|
3912
|
-
version: "0.2.
|
|
4288
|
+
version: "0.2.9",
|
|
3913
4289
|
languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
|
|
3914
4290
|
sdk: "^0.2.0",
|
|
3915
4291
|
// Runs the aimonitor modules you point it at, and reads their folder.
|
|
@@ -3923,7 +4299,7 @@ var src_default2 = definePlugin({
|
|
|
3923
4299
|
|
|
3924
4300
|
// packages/server/src/official.ts
|
|
3925
4301
|
var BUNDLED_PLUGIN_IDS = ["agents", "cats", "system", "vitals", "usage", "weather", "calendar", "news", "mirror", "gitlab", "github", "calls", "timesheet", "llm", "gpu", "homeassistant"];
|
|
3926
|
-
var OPTIONAL_PLUGIN_IDS = ["doom", "video", "fractals", "gaming", "logs", "hazards"];
|
|
4302
|
+
var OPTIONAL_PLUGIN_IDS = ["doom", "video", "fractals", "gaming", "logs", "hazards", "batteries"];
|
|
3927
4303
|
var OFFICIAL_PLUGINS = [
|
|
3928
4304
|
...BUNDLED_PLUGIN_IDS.map((id) => ({ id, npm: `kiosko-plugin-${id}`, bundled: true })),
|
|
3929
4305
|
...OPTIONAL_PLUGIN_IDS.map((id) => ({ id, npm: `kiosko-plugin-${id}`, bundled: false }))
|
package/sdk.js
CHANGED
|
@@ -7,14 +7,14 @@ var CATEGORIES = [
|
|
|
7
7
|
{ 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" } },
|
|
8
8
|
{ id: "productivity", label: { en: "Productivity", es: "Productividad", de: "Produktivit\xE4t", "zh-Hant": "\u751F\u7522\u529B", "zh-Hans": "\u6548\u7387" } },
|
|
9
9
|
{ id: "dev", label: { en: "Development", es: "Desarrollo", de: "Entwicklung", "zh-Hant": "\u958B\u767C", "zh-Hans": "\u5F00\u53D1" } },
|
|
10
|
-
{ id: "info", label: { en: "News & world", es: "Noticias y mundo", de: "Nachrichten & Welt", "zh-Hant": "\
|
|
10
|
+
{ id: "info", label: { en: "News & world", es: "Noticias y mundo", de: "Nachrichten & Welt", "zh-Hant": "\u8CC7\u8A0A\u8207\u751F\u6D3B", "zh-Hans": "\u8D44\u8BAF\u4E0E\u751F\u6D3B" } },
|
|
11
11
|
{ id: "media", label: { en: "Media", es: "Multimedia", de: "Medien", "zh-Hant": "\u591A\u5A92\u9AD4", "zh-Hans": "\u591A\u5A92\u4F53" } },
|
|
12
12
|
{ id: "scene", label: { en: "Scenes", es: "Escenas", de: "Szenen", "zh-Hant": "\u5834\u666F", "zh-Hans": "\u573A\u666F" } },
|
|
13
13
|
{ id: "fun", label: { en: "Fun", es: "Diversi\xF3n", de: "Spa\xDF", "zh-Hant": "\u8DA3\u5473", "zh-Hans": "\u8DA3\u5473" } }
|
|
14
14
|
];
|
|
15
15
|
var ALERT_LEVELS = ["info", "warn", "critical"];
|
|
16
16
|
var PAD_KEYS = ["up", "down", "left", "right", "a", "b", "x", "y", "l", "r", "start", "select"];
|
|
17
|
-
var SDK_VERSION = "0.2.
|
|
17
|
+
var SDK_VERSION = "0.2.9";
|
|
18
18
|
function defineWidget(w) {
|
|
19
19
|
return w;
|
|
20
20
|
}
|
|
@@ -307,9 +307,9 @@ function themeById(id) {
|
|
|
307
307
|
|
|
308
308
|
// packages/sdk/src/languages.ts
|
|
309
309
|
var MAINLAND_CHINA = {
|
|
310
|
-
without: [
|
|
311
|
-
first: ["llm", "gpu"],
|
|
312
|
-
instead: { "
|
|
310
|
+
without: [],
|
|
311
|
+
first: ["llm", "gpu", "usage"],
|
|
312
|
+
instead: { "usage/rail": "usage/balance", "usage/blocks": "usage/agents" }
|
|
313
313
|
};
|
|
314
314
|
var LANGUAGES = [
|
|
315
315
|
{ id: "en", name: "English", panel: "en", ogLocale: "en_US", hreflang: ["en", "x-default"], dir: "ltr" },
|
|
@@ -322,6 +322,27 @@ var LANGUAGE_IDS = LANGUAGES.map((l) => l.id);
|
|
|
322
322
|
function languageById(id) {
|
|
323
323
|
return LANGUAGES.find((l) => l.id === id);
|
|
324
324
|
}
|
|
325
|
+
var REGION_NAMES = {
|
|
326
|
+
"zh-Hans": { TW: "\u4E2D\u56FD\u53F0\u6E7E", HK: "\u4E2D\u56FD\u9999\u6E2F", MO: "\u4E2D\u56FD\u6FB3\u95E8" },
|
|
327
|
+
"zh-Hant": { HK: "\u9999\u6E2F", MO: "\u6FB3\u9580" }
|
|
328
|
+
};
|
|
329
|
+
function regionName(code, lang) {
|
|
330
|
+
const own = REGION_NAMES[lang]?.[code.toUpperCase()];
|
|
331
|
+
if (own) return own;
|
|
332
|
+
try {
|
|
333
|
+
return new Intl.DisplayNames([lang], { type: "region" }).of(code) ?? code;
|
|
334
|
+
} catch {
|
|
335
|
+
return code;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function listIn(items, lang) {
|
|
339
|
+
if (/^zh\b/.test(lang)) return items.join("\u3001");
|
|
340
|
+
try {
|
|
341
|
+
return new Intl.ListFormat(lang, { type: "conjunction" }).format(items);
|
|
342
|
+
} catch {
|
|
343
|
+
return items.join(", ");
|
|
344
|
+
}
|
|
345
|
+
}
|
|
325
346
|
|
|
326
347
|
// packages/sdk/src/format.ts
|
|
327
348
|
var TIME_FORMATS = ["auto", "24h", "12h"];
|
|
@@ -877,6 +898,7 @@ export {
|
|
|
877
898
|
hanScript,
|
|
878
899
|
isWorkingAt,
|
|
879
900
|
languageById,
|
|
901
|
+
listIn,
|
|
880
902
|
listLayout,
|
|
881
903
|
listOptions,
|
|
882
904
|
localize,
|
|
@@ -890,6 +912,7 @@ export {
|
|
|
890
912
|
pickLocale,
|
|
891
913
|
placeOf,
|
|
892
914
|
plural,
|
|
915
|
+
regionName,
|
|
893
916
|
retryAtOf,
|
|
894
917
|
risksOf,
|
|
895
918
|
satisfies,
|