kiosko 0.2.7 → 0.2.8
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 +2 -1
- package/cli.js +164 -91
- package/package.json +7 -1
- package/screen-thread.js +27 -10
- package/sdk.js +28 -5
- package/web/assets/app.js +3 -3
- package/web/assets/styles.css +1 -1
package/cli.js
CHANGED
|
@@ -1139,8 +1139,8 @@ var init_testing = __esm({
|
|
|
1139
1139
|
|
|
1140
1140
|
// packages/server/src/cli.ts
|
|
1141
1141
|
import { spawn } from "node:child_process";
|
|
1142
|
-
import { existsSync as existsSync15, readFileSync as
|
|
1143
|
-
import { dirname as dirname8, join as
|
|
1142
|
+
import { existsSync as existsSync15, readFileSync as readFileSync10, writeFileSync as writeFileSync12 } from "node:fs";
|
|
1143
|
+
import { dirname as dirname8, join as join18 } from "node:path";
|
|
1144
1144
|
|
|
1145
1145
|
// packages/core/src/config/model.ts
|
|
1146
1146
|
init_workday();
|
|
@@ -1367,14 +1367,14 @@ var CATEGORIES = [
|
|
|
1367
1367
|
{ 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" } },
|
|
1368
1368
|
{ id: "productivity", label: { en: "Productivity", es: "Productividad", de: "Produktivit\xE4t", "zh-Hant": "\u751F\u7522\u529B", "zh-Hans": "\u6548\u7387" } },
|
|
1369
1369
|
{ id: "dev", label: { en: "Development", es: "Desarrollo", de: "Entwicklung", "zh-Hant": "\u958B\u767C", "zh-Hans": "\u5F00\u53D1" } },
|
|
1370
|
-
{ id: "info", label: { en: "News & world", es: "Noticias y mundo", de: "Nachrichten & Welt", "zh-Hant": "\
|
|
1370
|
+
{ 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" } },
|
|
1371
1371
|
{ id: "media", label: { en: "Media", es: "Multimedia", de: "Medien", "zh-Hant": "\u591A\u5A92\u9AD4", "zh-Hans": "\u591A\u5A92\u4F53" } },
|
|
1372
1372
|
{ id: "scene", label: { en: "Scenes", es: "Escenas", de: "Szenen", "zh-Hant": "\u5834\u666F", "zh-Hans": "\u573A\u666F" } },
|
|
1373
1373
|
{ id: "fun", label: { en: "Fun", es: "Diversi\xF3n", de: "Spa\xDF", "zh-Hant": "\u8DA3\u5473", "zh-Hans": "\u8DA3\u5473" } }
|
|
1374
1374
|
];
|
|
1375
1375
|
var ALERT_LEVELS = ["info", "warn", "critical"];
|
|
1376
1376
|
var PAD_KEYS = ["up", "down", "left", "right", "a", "b", "x", "y", "l", "r", "start", "select"];
|
|
1377
|
-
var SDK_VERSION = "0.2.
|
|
1377
|
+
var SDK_VERSION = "0.2.8";
|
|
1378
1378
|
function defineWidget(w) {
|
|
1379
1379
|
return w;
|
|
1380
1380
|
}
|
|
@@ -1389,9 +1389,9 @@ init_i18n();
|
|
|
1389
1389
|
|
|
1390
1390
|
// packages/sdk/src/languages.ts
|
|
1391
1391
|
var MAINLAND_CHINA = {
|
|
1392
|
-
without: [
|
|
1393
|
-
first: ["llm", "gpu"],
|
|
1394
|
-
instead: { "
|
|
1392
|
+
without: [],
|
|
1393
|
+
first: ["llm", "gpu", "usage"],
|
|
1394
|
+
instead: { "usage/rail": "usage/balance", "usage/blocks": "usage/agents" }
|
|
1395
1395
|
};
|
|
1396
1396
|
var LANGUAGES = [
|
|
1397
1397
|
{ id: "en", name: "English", panel: "en", ogLocale: "en_US", hreflang: ["en", "x-default"], dir: "ltr" },
|
|
@@ -7303,7 +7303,22 @@ function lintPlugin(def) {
|
|
|
7303
7303
|
}
|
|
7304
7304
|
|
|
7305
7305
|
// packages/core/src/plugin-updates.ts
|
|
7306
|
+
import { readFileSync as readFileSync4 } from "node:fs";
|
|
7307
|
+
import { homedir as homedir3 } from "node:os";
|
|
7308
|
+
import { join as join7 } from "node:path";
|
|
7306
7309
|
var REGISTRY = "https://registry.npmjs.org";
|
|
7310
|
+
function npmRegistry(env = process.env, home = homedir3()) {
|
|
7311
|
+
const fromEnv = env.npm_config_registry ?? env.NPM_CONFIG_REGISTRY;
|
|
7312
|
+
if (fromEnv?.trim()) return fromEnv.trim().replace(/\/+$/, "");
|
|
7313
|
+
try {
|
|
7314
|
+
const rc = readFileSync4(env.npm_config_userconfig ?? env.NPM_CONFIG_USERCONFIG ?? join7(home, ".npmrc"), "utf8");
|
|
7315
|
+
const line = rc.split(/\r?\n/).map((l) => l.trim()).find((l) => /^registry\s*=/.test(l));
|
|
7316
|
+
const url2 = line?.slice(line.indexOf("=") + 1).trim().replace(/^["']|["']$/g, "");
|
|
7317
|
+
if (url2 && /^https?:\/\//.test(url2)) return url2.replace(/\/+$/, "");
|
|
7318
|
+
} catch {
|
|
7319
|
+
}
|
|
7320
|
+
return REGISTRY;
|
|
7321
|
+
}
|
|
7307
7322
|
var releases = (p) => Object.keys(p.versions ?? {}).filter((v) => {
|
|
7308
7323
|
const x = parseVersion(v);
|
|
7309
7324
|
return !!x && !x[3];
|
|
@@ -7319,7 +7334,7 @@ function pickUpdate(installed2, p, env) {
|
|
|
7319
7334
|
async function checkUpdates(plugins, o = {}) {
|
|
7320
7335
|
const http = o.http ?? createHttp({ agent: "kiosko-updates" });
|
|
7321
7336
|
const env = { sdk: o.sdk ?? SDK_VERSION, platform: o.platform ?? process.platform };
|
|
7322
|
-
const base3 = o.registry ??
|
|
7337
|
+
const base3 = o.registry ?? npmRegistry();
|
|
7323
7338
|
const headers2 = { Accept: "application/vnd.npm.install-v1+json" };
|
|
7324
7339
|
const errors = [];
|
|
7325
7340
|
const read = async (pkg) => {
|
|
@@ -7369,7 +7384,7 @@ var MAX_TARBALL_BYTES = 20 * 1024 * 1024;
|
|
|
7369
7384
|
|
|
7370
7385
|
// plugins/core/src/index.ts
|
|
7371
7386
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
7372
|
-
import { join as
|
|
7387
|
+
import { join as join8 } from "node:path";
|
|
7373
7388
|
function fit2(g, text3, family, w, h, max = 400) {
|
|
7374
7389
|
let size = Math.min(max, h);
|
|
7375
7390
|
g.font = `${size}px "${family}"`;
|
|
@@ -7431,17 +7446,34 @@ var clock = defineWidget({
|
|
|
7431
7446
|
const at = wallClock(now, options2.timeZone);
|
|
7432
7447
|
const clock2 = options2.timeFormat === "inherit" ? fmt : createFormatters({ locale, timeFormat: options2.timeFormat, now });
|
|
7433
7448
|
const text3 = clock2.time(at, { seconds: options2.showSeconds, ampm: false });
|
|
7449
|
+
const full = clock2.hour12 ? clock2.time(at, { seconds: options2.showSeconds }) : text3;
|
|
7450
|
+
const mark = full === text3 ? "" : full.replace(text3, "").trim();
|
|
7451
|
+
const markFirst = !!mark && full.startsWith(mark);
|
|
7434
7452
|
const dateText = options2.showDate ? new Date(at).toLocaleDateString(locale, DATE_FORMATS[options2.dateFormat]) : "";
|
|
7435
7453
|
const dateH = options2.showDate ? Math.min(box.h * 0.2, 40) : 0;
|
|
7436
|
-
const size = fit2(g, text3, theme.fonts.monoBold, box.w * 0.96, (box.h - dateH * 1.3) * 0.95);
|
|
7454
|
+
const size = fit2(g, text3, theme.fonts.monoBold, box.w * (mark ? 0.76 : 0.96), (box.h - dateH * 1.3) * 0.95);
|
|
7437
7455
|
const color2 = options2.color === "accent" ? theme.colors.accent : options2.color === "dim" ? theme.colors.inkDim : theme.colors.ink;
|
|
7438
|
-
const x = options2.align === "left" ? box.x : options2.align === "right" ? box.x + box.w : box.x + box.w / 2;
|
|
7439
7456
|
const block = size * 0.78 + (dateH ? dateH * 1.4 : 0);
|
|
7440
7457
|
const base3 = box.y + (box.h - block) / 2 + size * 0.78;
|
|
7441
|
-
g.
|
|
7458
|
+
g.font = `${size}px "${theme.fonts.monoBold}"`;
|
|
7459
|
+
const digitsW = g.measureText(text3).width;
|
|
7460
|
+
const markSize = Math.max(8, Math.round(size * 0.26));
|
|
7461
|
+
g.font = `${markSize}px "${theme.fonts.sansBold}"`;
|
|
7462
|
+
const markW = mark ? g.measureText(mark).width + size * 0.08 : 0;
|
|
7463
|
+
const total = digitsW + markW;
|
|
7464
|
+
const left = options2.align === "left" ? box.x : options2.align === "right" ? box.x + box.w - total : box.x + (box.w - total) / 2;
|
|
7465
|
+
const digitsX = markFirst ? left + markW : left;
|
|
7466
|
+
g.textAlign = "left";
|
|
7442
7467
|
g.fillStyle = color2;
|
|
7443
7468
|
g.font = `${size}px "${theme.fonts.monoBold}"`;
|
|
7444
|
-
g.fillText(text3,
|
|
7469
|
+
g.fillText(text3, digitsX, base3);
|
|
7470
|
+
if (mark) {
|
|
7471
|
+
g.fillStyle = theme.colors.inkDim;
|
|
7472
|
+
g.font = `${markSize}px "${theme.fonts.sansBold}"`;
|
|
7473
|
+
g.fillText(mark, markFirst ? left : left + digitsW + size * 0.08, base3 - size * 0.78 + markSize * 0.92);
|
|
7474
|
+
}
|
|
7475
|
+
const x = options2.align === "left" ? box.x : options2.align === "right" ? box.x + box.w : box.x + box.w / 2;
|
|
7476
|
+
g.textAlign = options2.align;
|
|
7445
7477
|
if (dateH) {
|
|
7446
7478
|
const ds = Math.min(dateH, fit2(g, dateText, theme.fonts.sans, box.w * 0.96, dateH));
|
|
7447
7479
|
g.font = `${ds}px "${theme.fonts.sans}"`;
|
|
@@ -7621,7 +7653,7 @@ async function nextInFolder(dir) {
|
|
|
7621
7653
|
if (!files.length) return null;
|
|
7622
7654
|
const i = ((turns.get(dir) ?? -1) + 1) % files.length;
|
|
7623
7655
|
turns.set(dir, i);
|
|
7624
|
-
return
|
|
7656
|
+
return join8(dir, files[i]);
|
|
7625
7657
|
}
|
|
7626
7658
|
function imageUrl(src, now, addTimestamp = false) {
|
|
7627
7659
|
const filled = src.replace(/\{now\}/g, String(now)).replace(/\{unix\}/g, String(Math.floor(now / 1e3)));
|
|
@@ -7714,7 +7746,7 @@ var image = defineWidget({
|
|
|
7714
7746
|
var src_default = definePlugin({
|
|
7715
7747
|
id: "core",
|
|
7716
7748
|
name: { en: "Essentials", es: "B\xE1sicos", de: "Grundlagen", "zh-Hant": "\u57FA\u672C\u5DE5\u5177", "zh-Hans": "\u57FA\u7840\u7EC4\u4EF6" },
|
|
7717
|
-
version: "0.2.
|
|
7749
|
+
version: "0.2.8",
|
|
7718
7750
|
languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
|
|
7719
7751
|
sdk: "^0.2.0",
|
|
7720
7752
|
// The picture widget reads the image (or folder, or URL) you give it.
|
|
@@ -7728,13 +7760,13 @@ var src_default = definePlugin({
|
|
|
7728
7760
|
|
|
7729
7761
|
// plugins/legacy/src/index.ts
|
|
7730
7762
|
import { existsSync as existsSync7, statSync as statSync2 } from "node:fs";
|
|
7731
|
-
import { isAbsolute, join as
|
|
7763
|
+
import { isAbsolute, join as join9 } from "node:path";
|
|
7732
7764
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
7733
7765
|
var loaded = /* @__PURE__ */ new Map();
|
|
7734
7766
|
function resolveModule(name, dir) {
|
|
7735
7767
|
const expanded = expandPath(name);
|
|
7736
|
-
const base3 = isAbsolute(expanded) ? expanded :
|
|
7737
|
-
for (const p of [base3, `${base3}.mjs`, `${base3}.js`,
|
|
7768
|
+
const base3 = isAbsolute(expanded) ? expanded : join9(expandPath(dir), expanded);
|
|
7769
|
+
for (const p of [base3, `${base3}.mjs`, `${base3}.js`, join9(base3, "index.mjs"), join9(base3, "index.js")]) {
|
|
7738
7770
|
if (existsSync7(p) && statSync2(p).isFile()) return p;
|
|
7739
7771
|
}
|
|
7740
7772
|
return null;
|
|
@@ -7810,7 +7842,7 @@ var module2 = defineWidget({
|
|
|
7810
7842
|
var src_default2 = definePlugin({
|
|
7811
7843
|
id: "legacy",
|
|
7812
7844
|
name: { en: "aimonitor compatibility", es: "Compatibilidad aimonitor", de: "aimonitor-Kompatibilit\xE4t", "zh-Hant": "aimonitor \u76F8\u5BB9\u6027", "zh-Hans": "aimonitor \u517C\u5BB9" },
|
|
7813
|
-
version: "0.2.
|
|
7845
|
+
version: "0.2.8",
|
|
7814
7846
|
languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
|
|
7815
7847
|
sdk: "^0.2.0",
|
|
7816
7848
|
// Runs the aimonitor modules you point it at, and reads their folder.
|
|
@@ -7835,13 +7867,13 @@ var BUNDLED_PLUGINS = OFFICIAL_PLUGINS.filter((o) => o.bundled);
|
|
|
7835
7867
|
var BUILTIN_PLUGINS = [src_default, src_default2];
|
|
7836
7868
|
|
|
7837
7869
|
// packages/server/src/config-cli.ts
|
|
7838
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as
|
|
7870
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync6 } from "node:fs";
|
|
7839
7871
|
import { tmpdir } from "node:os";
|
|
7840
|
-
import { dirname as dirname4, isAbsolute as isAbsolute2, join as
|
|
7872
|
+
import { dirname as dirname4, isAbsolute as isAbsolute2, join as join11, relative, resolve as resolve2 } from "node:path";
|
|
7841
7873
|
|
|
7842
7874
|
// packages/server/src/preview.ts
|
|
7843
7875
|
import { existsSync as existsSync8, mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "node:fs";
|
|
7844
|
-
import { dirname as dirname3, join as
|
|
7876
|
+
import { dirname as dirname3, join as join10 } from "node:path";
|
|
7845
7877
|
function writePreview(rt, screen, page, out, o = {}) {
|
|
7846
7878
|
const r = rt.preview(screen, page, { demo: o.demo ?? true });
|
|
7847
7879
|
if (!existsSync8(dirname3(out))) mkdirSync4(dirname3(out), { recursive: true });
|
|
@@ -7859,7 +7891,7 @@ function renderPreviews(registry2, cfg, dir) {
|
|
|
7859
7891
|
try {
|
|
7860
7892
|
safe2.screens.forEach(
|
|
7861
7893
|
(s, si) => s.pages.forEach((p, pi) => {
|
|
7862
|
-
const file =
|
|
7894
|
+
const file = join10(dir, `${si + 1}-${slug(s.name || s.id)}--${pi + 1}-${slug(p.name || p.id)}.png`);
|
|
7863
7895
|
const problems = writePreview(rt, s, p, file);
|
|
7864
7896
|
out.push({ screen: s.name || s.id, page: p.name || p.id, file, size: `${s.width}\xD7${s.height}`, problems });
|
|
7865
7897
|
})
|
|
@@ -7917,7 +7949,7 @@ function readConfigText(text3) {
|
|
|
7917
7949
|
function readInput(file) {
|
|
7918
7950
|
const name = file === "-" ? "(stdin)" : file;
|
|
7919
7951
|
if (file !== "-" && !existsSync9(file)) return { error: `not found: ${file}`, notes: [], name };
|
|
7920
|
-
return { ...readConfigText(
|
|
7952
|
+
return { ...readConfigText(readFileSync5(file === "-" ? 0 : file, "utf8")), name };
|
|
7921
7953
|
}
|
|
7922
7954
|
var pluginDefs = (r) => r.list().map((p) => p.def);
|
|
7923
7955
|
async function findRunning(cfg, configPath, o) {
|
|
@@ -8074,7 +8106,7 @@ ${bold("Changes")}: ${summarizeDiff(plan.diff)}`);
|
|
|
8074
8106
|
}
|
|
8075
8107
|
if (plan.carried.length) console.log(dim(` kept from your current config (the file leaves them out): ${plan.carried.join(", ")}`));
|
|
8076
8108
|
if (!flags.has("--no-preview")) {
|
|
8077
|
-
const dir = opts.get("--preview") ||
|
|
8109
|
+
const dir = opts.get("--preview") || join11(tmpdir(), `kiosko-import-${stamp()}`);
|
|
8078
8110
|
try {
|
|
8079
8111
|
const files = renderPreviews(reg, c, dir);
|
|
8080
8112
|
console.log(`
|
|
@@ -8142,16 +8174,48 @@ async function configCommand(argv2, ctx) {
|
|
|
8142
8174
|
}
|
|
8143
8175
|
}
|
|
8144
8176
|
|
|
8177
|
+
// packages/server/src/editor-cli.ts
|
|
8178
|
+
function editorUrl(server, over = {}) {
|
|
8179
|
+
let host = over.host ?? server.host;
|
|
8180
|
+
if (host === "0.0.0.0" || host === "") host = "127.0.0.1";
|
|
8181
|
+
if (host === "::") host = "::1";
|
|
8182
|
+
const port = Number(over.port ?? server.port);
|
|
8183
|
+
return `http://${host.includes(":") ? `[${host}]` : host}:${port}/`;
|
|
8184
|
+
}
|
|
8185
|
+
async function runningAt(url2, timeoutMs = 1500) {
|
|
8186
|
+
try {
|
|
8187
|
+
const res = await fetch(new URL("api/state", url2), { signal: AbortSignal.timeout(timeoutMs) });
|
|
8188
|
+
if (!res.ok) return null;
|
|
8189
|
+
const body2 = await res.json();
|
|
8190
|
+
return typeof body2.version === "string" ? body2.version : null;
|
|
8191
|
+
} catch {
|
|
8192
|
+
return null;
|
|
8193
|
+
}
|
|
8194
|
+
}
|
|
8195
|
+
async function editorCommand({ server, flags, open, log }) {
|
|
8196
|
+
const url2 = editorUrl(server, flags);
|
|
8197
|
+
const version = await runningAt(url2);
|
|
8198
|
+
if (!version) {
|
|
8199
|
+
log(`Kiosko isn't running at ${url2}`);
|
|
8200
|
+
log(" start it: kiosko start --open");
|
|
8201
|
+
log(" or with your session, always: kiosko service install");
|
|
8202
|
+
return 1;
|
|
8203
|
+
}
|
|
8204
|
+
log(`Kiosko ${version} \u2014 editor at ${url2}`);
|
|
8205
|
+
if (!flags.print) open(url2);
|
|
8206
|
+
return 0;
|
|
8207
|
+
}
|
|
8208
|
+
|
|
8145
8209
|
// packages/server/src/plugins-cli.ts
|
|
8146
8210
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
8147
|
-
import { existsSync as existsSync10, lstatSync, mkdirSync as mkdirSync6, readdirSync as readdirSync4, readFileSync as
|
|
8148
|
-
import { basename, join as
|
|
8211
|
+
import { existsSync as existsSync10, lstatSync, mkdirSync as mkdirSync6, readdirSync as readdirSync4, readFileSync as readFileSync6, rmSync, symlinkSync, watch, writeFileSync as writeFileSync7 } from "node:fs";
|
|
8212
|
+
import { basename, join as join12, resolve as resolve4 } from "node:path";
|
|
8149
8213
|
import { pathToFileURL as pathToFileURL4 } from "node:url";
|
|
8150
8214
|
var npmName = (s) => /^[a-z0-9][\w.-]*$/.test(s) && !s.startsWith("kiosko-plugin-") && !s.includes("/") ? `kiosko-plugin-${s}` : s;
|
|
8151
8215
|
function ensureFolder() {
|
|
8152
8216
|
const dir = paths.plugins;
|
|
8153
8217
|
mkdirSync6(dir, { recursive: true });
|
|
8154
|
-
const pkg =
|
|
8218
|
+
const pkg = join12(dir, "package.json");
|
|
8155
8219
|
if (!existsSync10(pkg)) writeFileSync7(pkg, `${JSON.stringify({ name: "kiosko-user-plugins", private: true, type: "module" }, null, 2)}
|
|
8156
8220
|
`);
|
|
8157
8221
|
return dir;
|
|
@@ -8161,10 +8225,10 @@ function npm(args, cwd) {
|
|
|
8161
8225
|
}
|
|
8162
8226
|
async function loadPluginDir(dir, o = {}) {
|
|
8163
8227
|
const root = resolve4(dir);
|
|
8164
|
-
const pkgPath =
|
|
8165
|
-
const pkg = existsSync10(pkgPath) ? JSON.parse(
|
|
8166
|
-
const built = [pkg.kiosko?.plugin, pkg.main, "index.mjs", "index.js"].filter((x) => typeof x === "string").map((x) =>
|
|
8167
|
-
const src =
|
|
8228
|
+
const pkgPath = join12(root, "package.json");
|
|
8229
|
+
const pkg = existsSync10(pkgPath) ? JSON.parse(readFileSync6(pkgPath, "utf8")) : {};
|
|
8230
|
+
const built = [pkg.kiosko?.plugin, pkg.main, "index.mjs", "index.js"].filter((x) => typeof x === "string").map((x) => join12(root, x)).find(existsSync10);
|
|
8231
|
+
const src = join12(root, "src", "index.ts");
|
|
8168
8232
|
const entry = (o.src || !built) && existsSync10(src) ? src : built;
|
|
8169
8233
|
if (!entry) throw new Error(`no plugin in ${root}: no package.json "kiosko.plugin", index.js or src/index.ts`);
|
|
8170
8234
|
installSdkResolver();
|
|
@@ -8213,8 +8277,8 @@ ${errors.length} errors, ${issues.length - errors.length} warnings` : "\u2713 no
|
|
|
8213
8277
|
async function manifest(dir, argv2) {
|
|
8214
8278
|
const root = resolve4(dir);
|
|
8215
8279
|
const { def, pkg } = await loadPluginDir(root, { src: flagOf(argv2, "--src") });
|
|
8216
|
-
const screenshots = Object.fromEntries((def.widgets ?? []).map((w) => [w.id, `docs/${w.id}.png`]).filter(([, f]) => existsSync10(
|
|
8217
|
-
const out = optOf(argv2, "--out") ??
|
|
8280
|
+
const screenshots = Object.fromEntries((def.widgets ?? []).map((w) => [w.id, `docs/${w.id}.png`]).filter(([, f]) => existsSync10(join12(root, f))));
|
|
8281
|
+
const out = optOf(argv2, "--out") ?? join12(root, "kiosko-manifest.json");
|
|
8218
8282
|
writeFileSync7(out, `${JSON.stringify(pluginManifest(def, { pkg, screenshots }), null, 2)}
|
|
8219
8283
|
`);
|
|
8220
8284
|
console.log(out);
|
|
@@ -8453,8 +8517,8 @@ async function pluginsCommand(argv2, registry2) {
|
|
|
8453
8517
|
const dir = resolve4(where ?? `kiosko-plugin-${id}`);
|
|
8454
8518
|
if (existsSync10(dir) && readdirSync4(dir).length) throw new Error(`${dir} is not empty`);
|
|
8455
8519
|
for (const [file, body2] of Object.entries(newPluginFiles(id))) {
|
|
8456
|
-
mkdirSync6(
|
|
8457
|
-
writeFileSync7(
|
|
8520
|
+
mkdirSync6(join12(dir, file, ".."), { recursive: true });
|
|
8521
|
+
writeFileSync7(join12(dir, file), body2);
|
|
8458
8522
|
}
|
|
8459
8523
|
console.log(`${dir}
|
|
8460
8524
|
|
|
@@ -8486,12 +8550,12 @@ plugins folder: ${paths.plugins}`);
|
|
|
8486
8550
|
const dir = ensureFolder();
|
|
8487
8551
|
for (const n of names) {
|
|
8488
8552
|
const src = resolve4(n);
|
|
8489
|
-
const pkgPath =
|
|
8553
|
+
const pkgPath = join12(src, "package.json");
|
|
8490
8554
|
if (!existsSync10(pkgPath)) throw new Error(`${src} has no package.json`);
|
|
8491
|
-
const pkg = JSON.parse(
|
|
8555
|
+
const pkg = JSON.parse(readFileSync6(pkgPath, "utf8"));
|
|
8492
8556
|
const entry = pkg.kiosko?.plugin;
|
|
8493
|
-
if (entry && !existsSync10(
|
|
8494
|
-
const target =
|
|
8557
|
+
if (entry && !existsSync10(join12(src, entry))) console.warn(`warning: ${entry} doesn't exist yet in ${src} (run its build)`);
|
|
8558
|
+
const target = join12(dir, pkg.kiosko?.id ?? basename(src).replace(/^kiosko-plugin-/, ""));
|
|
8495
8559
|
const existing = (() => {
|
|
8496
8560
|
try {
|
|
8497
8561
|
return lstatSync(target);
|
|
@@ -8512,7 +8576,7 @@ plugins folder: ${paths.plugins}`);
|
|
|
8512
8576
|
const dir = ensureFolder();
|
|
8513
8577
|
for (const n of names) {
|
|
8514
8578
|
const id = n.replace(/^kiosko-plugin-/, "");
|
|
8515
|
-
const link =
|
|
8579
|
+
const link = join12(dir, id);
|
|
8516
8580
|
const st = (() => {
|
|
8517
8581
|
try {
|
|
8518
8582
|
return lstatSync(link);
|
|
@@ -8536,7 +8600,7 @@ plugins folder: ${paths.plugins}`);
|
|
|
8536
8600
|
|
|
8537
8601
|
// packages/server/src/gallery.ts
|
|
8538
8602
|
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync8 } from "node:fs";
|
|
8539
|
-
import { join as
|
|
8603
|
+
import { join as join13 } from "node:path";
|
|
8540
8604
|
var HOME_URL = "https://kioskolcd.dev/";
|
|
8541
8605
|
var RELEASES_URL = "https://github.com/kiosko-lcd/kiosko/releases/latest";
|
|
8542
8606
|
var MADRID = { latitude: 40.4168, longitude: -3.7038, name: "Madrid" };
|
|
@@ -8567,7 +8631,7 @@ function buildGallery(registry2, o) {
|
|
|
8567
8631
|
let count = 0;
|
|
8568
8632
|
const pluginsOf = registry2.list().filter(({ def, enabled }) => enabled && def.widgets?.length);
|
|
8569
8633
|
for (const lang of langs) {
|
|
8570
|
-
mkdirSync7(
|
|
8634
|
+
mkdirSync7(join13(o.out, "img", folder(lang.id)), { recursive: true });
|
|
8571
8635
|
const cfg = normalize({ locale: lang.locale, theme: theme.id, location: SAMPLE_PLACES[lang.id] ?? MADRID });
|
|
8572
8636
|
const L = (x) => localize(x, lang.locale);
|
|
8573
8637
|
const up = folder(lang.id) ? "../" : "";
|
|
@@ -8583,7 +8647,7 @@ function buildGallery(registry2, o) {
|
|
|
8583
8647
|
const height = Math.min(720, pref.h);
|
|
8584
8648
|
const file = `img/${folder(lang.id)}${def.id}-${w.id}.png`;
|
|
8585
8649
|
const r = composeWidget({ cfg, registry: registry2, theme, type: `${def.id}/${w.id}`, width, height, now, ...w.chrome === "bare" ? {} : { title: L(w.name) } });
|
|
8586
|
-
writeFileSync8(
|
|
8650
|
+
writeFileSync8(join13(o.out, file), r.canvas.toBuffer("image/png"));
|
|
8587
8651
|
let shot = listed.widgets.find((x) => x.type === `${def.id}/${w.id}`);
|
|
8588
8652
|
if (!shot) {
|
|
8589
8653
|
count++;
|
|
@@ -8596,10 +8660,10 @@ function buildGallery(registry2, o) {
|
|
|
8596
8660
|
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>`);
|
|
8597
8661
|
}
|
|
8598
8662
|
const home = `${HOME_URL}${folder(lang.id)}`;
|
|
8599
|
-
const usb =
|
|
8600
|
-
mkdirSync7(
|
|
8663
|
+
const usb = lang.id.startsWith("zh") ? `${HOME_URL}${lang.id}/docs/usb/` : "https://github.com/kiosko-lcd/kiosko/blob/main/docs/usb.md";
|
|
8664
|
+
mkdirSync7(join13(o.out, folder(lang.id)), { recursive: true });
|
|
8601
8665
|
writeFileSync8(
|
|
8602
|
-
|
|
8666
|
+
join13(o.out, folder(lang.id), "index.html"),
|
|
8603
8667
|
`<!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>
|
|
8604
8668
|
<style>
|
|
8605
8669
|
:root{color-scheme:dark;--bg:#0a0d13;--panel:#121722;--line:rgba(255,255,255,.08);--text:#e7ecf4;--dim:#a3adbf}
|
|
@@ -8634,7 +8698,7 @@ a.try{display:inline-block;margin-top:10px;padding:8px 14px;border-radius:10px;b
|
|
|
8634
8698
|
try {
|
|
8635
8699
|
for (const listed of data.pages) {
|
|
8636
8700
|
const page = shown.pages.find((p) => p.id === listed.id);
|
|
8637
|
-
writeFileSync8(
|
|
8701
|
+
writeFileSync8(join13(o.out, listed.file[l.id]), rt.preview(shown, page, { now, demo: true }).canvas.toBuffer("image/jpeg", 88));
|
|
8638
8702
|
}
|
|
8639
8703
|
} finally {
|
|
8640
8704
|
rt.stop();
|
|
@@ -8642,7 +8706,7 @@ a.try{display:inline-block;margin-top:10px;padding:8px 14px;border-radius:10px;b
|
|
|
8642
8706
|
}
|
|
8643
8707
|
}
|
|
8644
8708
|
data.count = count;
|
|
8645
|
-
writeFileSync8(
|
|
8709
|
+
writeFileSync8(join13(o.out, "gallery.json"), `${JSON.stringify(data)}
|
|
8646
8710
|
`);
|
|
8647
8711
|
return count;
|
|
8648
8712
|
}
|
|
@@ -8810,8 +8874,8 @@ function importAimonitor(old, reg, modeOverride, o = {}) {
|
|
|
8810
8874
|
// packages/server/src/service.ts
|
|
8811
8875
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
8812
8876
|
import { existsSync as existsSync11, mkdirSync as mkdirSync8, rmSync as rmSync2, writeFileSync as writeFileSync9 } from "node:fs";
|
|
8813
|
-
import { homedir as
|
|
8814
|
-
import { dirname as dirname5, join as
|
|
8877
|
+
import { homedir as homedir4, platform as platform2 } from "node:os";
|
|
8878
|
+
import { dirname as dirname5, join as join14, resolve as resolve5, win32 as win322 } from "node:path";
|
|
8815
8879
|
import { fileURLToPath } from "node:url";
|
|
8816
8880
|
var xml = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
8817
8881
|
function servicePlan(o = {}) {
|
|
@@ -8821,10 +8885,10 @@ function servicePlan(o = {}) {
|
|
|
8821
8885
|
const args = [...nodeArgs, cli, "start", ...o.args ?? []];
|
|
8822
8886
|
const os = o.os ?? platform2();
|
|
8823
8887
|
const sep2 = os === "win32" ? ";" : ":";
|
|
8824
|
-
const path = [dirname5(node),
|
|
8888
|
+
const path = [dirname5(node), join14(homedir4(), ".local", "bin"), ...os === "darwin" ? ["/opt/homebrew/bin"] : [], "/usr/local/bin", "/usr/bin", "/bin"].join(sep2);
|
|
8825
8889
|
const env = { ...os === "win32" ? {} : { PATH: path }, ...o.env ?? {} };
|
|
8826
8890
|
if (os === "darwin") {
|
|
8827
|
-
const file2 =
|
|
8891
|
+
const file2 = join14(homedir4(), "Library", "LaunchAgents", "dev.kiosko.plist");
|
|
8828
8892
|
const content2 = `<?xml version="1.0" encoding="UTF-8"?>
|
|
8829
8893
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
8830
8894
|
<plist version="1.0">
|
|
@@ -8841,8 +8905,8 @@ ${Object.entries(env).map(([k, v]) => ` <key>${xml(k)}</key><string>${xml(v)}
|
|
|
8841
8905
|
<key>RunAtLoad</key><true/>
|
|
8842
8906
|
<key>KeepAlive</key><true/>
|
|
8843
8907
|
<key>ProcessType</key><string>Background</string>
|
|
8844
|
-
<key>StandardOutPath</key><string>${xml(
|
|
8845
|
-
<key>StandardErrorPath</key><string>${xml(
|
|
8908
|
+
<key>StandardOutPath</key><string>${xml(join14(homedir4(), "Library", "Logs", "kiosko.log"))}</string>
|
|
8909
|
+
<key>StandardErrorPath</key><string>${xml(join14(homedir4(), "Library", "Logs", "kiosko.log"))}</string>
|
|
8846
8910
|
</dict>
|
|
8847
8911
|
</plist>
|
|
8848
8912
|
`;
|
|
@@ -8870,7 +8934,7 @@ CreateObject("WScript.Shell").Run ${vbs(`cmd.exe /d /s /c "${inner}"`)}, 0, Fals
|
|
|
8870
8934
|
disable: [["schtasks", "/End", "/TN", "Kiosko"], stopProcesses(cli), ["schtasks", "/Delete", "/F", "/TN", "Kiosko"]]
|
|
8871
8935
|
};
|
|
8872
8936
|
}
|
|
8873
|
-
const file =
|
|
8937
|
+
const file = join14(process.env.XDG_CONFIG_HOME ?? join14(homedir4(), ".config"), "systemd", "user", "kiosko.service");
|
|
8874
8938
|
const q3 = (a) => /[\s"\\]/.test(a) ? `"${a.replace(/(["\\])/g, "\\$1")}"` : a;
|
|
8875
8939
|
const content = `[Unit]
|
|
8876
8940
|
Description=Kiosko: widgets for USB LCD panels
|
|
@@ -8928,20 +8992,20 @@ function runService(action, plan) {
|
|
|
8928
8992
|
}
|
|
8929
8993
|
|
|
8930
8994
|
// packages/server/src/server.ts
|
|
8931
|
-
import { existsSync as existsSync14, readFileSync as
|
|
8995
|
+
import { existsSync as existsSync14, readFileSync as readFileSync9, statSync as statSync3 } from "node:fs";
|
|
8932
8996
|
import { createServer } from "node:http";
|
|
8933
8997
|
import { createRequire as createRequire3 } from "node:module";
|
|
8934
|
-
import { dirname as dirname7, extname, join as
|
|
8998
|
+
import { dirname as dirname7, extname, join as join17, normalize as normPath, resolve as resolve7 } from "node:path";
|
|
8935
8999
|
|
|
8936
9000
|
// packages/server/src/plugins-manage.ts
|
|
8937
9001
|
import { execFile } from "node:child_process";
|
|
8938
|
-
import { existsSync as existsSync12, lstatSync as lstatSync2, mkdirSync as mkdirSync9, readFileSync as
|
|
8939
|
-
import { join as
|
|
9002
|
+
import { existsSync as existsSync12, lstatSync as lstatSync2, mkdirSync as mkdirSync9, readFileSync as readFileSync7, rmSync as rmSync3, writeFileSync as writeFileSync10 } from "node:fs";
|
|
9003
|
+
import { join as join15, relative as relative2, resolve as resolve6, sep } from "node:path";
|
|
8940
9004
|
var NPM_NAME = /^(@[a-z0-9][\w.-]*\/)?[a-z0-9][\w.-]*(@[\w.^~<>=*-]+)?$/i;
|
|
8941
9005
|
var packageName = (spec) => spec.startsWith("@") ? `@${spec.slice(1).split("@")[0]}` : spec.split("@")[0];
|
|
8942
9006
|
function ensureFolder2(dir) {
|
|
8943
9007
|
mkdirSync9(dir, { recursive: true });
|
|
8944
|
-
const pkg =
|
|
9008
|
+
const pkg = join15(dir, "package.json");
|
|
8945
9009
|
if (!existsSync12(pkg)) writeFileSync10(pkg, `${JSON.stringify({ name: "kiosko-user-plugins", private: true, type: "module" }, null, 2)}
|
|
8946
9010
|
`);
|
|
8947
9011
|
}
|
|
@@ -8954,7 +9018,7 @@ var realNpm = (args, cwd) => new Promise((ok, fail) => {
|
|
|
8954
9018
|
});
|
|
8955
9019
|
function installedIntegrity(dir, name) {
|
|
8956
9020
|
try {
|
|
8957
|
-
const lock = JSON.parse(
|
|
9021
|
+
const lock = JSON.parse(readFileSync7(join15(dir, "node_modules", ".package-lock.json"), "utf8"));
|
|
8958
9022
|
return lock.packages?.[`node_modules/${name}`]?.integrity;
|
|
8959
9023
|
} catch {
|
|
8960
9024
|
return void 0;
|
|
@@ -8966,8 +9030,8 @@ async function installPlugin(spec, o) {
|
|
|
8966
9030
|
ensureFolder2(dir);
|
|
8967
9031
|
const npm2 = o.npm ?? realNpm;
|
|
8968
9032
|
const r = o.registry;
|
|
8969
|
-
const folder =
|
|
8970
|
-
const readPkg = () => existsSync12(
|
|
9033
|
+
const folder = join15(dir, "node_modules", packageName(spec));
|
|
9034
|
+
const readPkg = () => existsSync12(join15(folder, "package.json")) ? JSON.parse(readFileSync7(join15(folder, "package.json"), "utf8")) : null;
|
|
8971
9035
|
const beforePkg = readPkg();
|
|
8972
9036
|
const beforeId = beforePkg ? packageMeta(beforePkg).id : void 0;
|
|
8973
9037
|
const output = await npm2(["install", "--no-audit", "--no-fund", "--ignore-scripts", "--save-exact", spec], dir);
|
|
@@ -9023,7 +9087,7 @@ async function removePlugin(id, o) {
|
|
|
9023
9087
|
const name = parts[1].startsWith("@") ? `${parts[1]}/${parts[2]}` : parts[1];
|
|
9024
9088
|
await (o.npm ?? realNpm)(["uninstall", "--no-audit", "--no-fund", name], dir);
|
|
9025
9089
|
} else {
|
|
9026
|
-
const top =
|
|
9090
|
+
const top = join15(dir, parts[0]);
|
|
9027
9091
|
if (!lstatSync2(top).isSymbolicLink()) return { removed: false, reason: `${top} is a folder you put there: delete it yourself if you mean it` };
|
|
9028
9092
|
rmSync3(top);
|
|
9029
9093
|
}
|
|
@@ -9038,17 +9102,17 @@ async function reloadPlugin(id, o) {
|
|
|
9038
9102
|
}
|
|
9039
9103
|
|
|
9040
9104
|
// packages/server/src/store.ts
|
|
9041
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as
|
|
9042
|
-
import { dirname as dirname6, join as
|
|
9105
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as readFileSync8, renameSync as renameSync4, writeFileSync as writeFileSync11 } from "node:fs";
|
|
9106
|
+
import { dirname as dirname6, join as join16 } from "node:path";
|
|
9043
9107
|
var STORE_URL = "https://kioskolcd.dev/store/v1/";
|
|
9044
9108
|
function shipped(...candidates) {
|
|
9045
9109
|
for (const c of candidates) if (existsSync13(c)) return c;
|
|
9046
9110
|
return null;
|
|
9047
9111
|
}
|
|
9048
9112
|
function snapshotIndex() {
|
|
9049
|
-
const file = shipped(
|
|
9113
|
+
const file = shipped(join16(import.meta.dirname, "../assets/store-index.json"), join16(import.meta.dirname, "assets/store-index.json"));
|
|
9050
9114
|
try {
|
|
9051
|
-
return file ? JSON.parse(
|
|
9115
|
+
return file ? JSON.parse(readFileSync8(file, "utf8")) : null;
|
|
9052
9116
|
} catch {
|
|
9053
9117
|
return null;
|
|
9054
9118
|
}
|
|
@@ -9056,8 +9120,8 @@ function snapshotIndex() {
|
|
|
9056
9120
|
var schema;
|
|
9057
9121
|
function indexSchema() {
|
|
9058
9122
|
if (schema !== void 0) return schema;
|
|
9059
|
-
const file = shipped(
|
|
9060
|
-
schema = file ? JSON.parse(
|
|
9123
|
+
const file = shipped(join16(import.meta.dirname, "../../core/schema/store-index.json"), join16(import.meta.dirname, "assets/store-index.schema.json"));
|
|
9124
|
+
schema = file ? JSON.parse(readFileSync8(file, "utf8")) : null;
|
|
9061
9125
|
return schema;
|
|
9062
9126
|
}
|
|
9063
9127
|
function indexProblem(x) {
|
|
@@ -9085,11 +9149,11 @@ var StoreCatalog = class {
|
|
|
9085
9149
|
} else if (snap) this.state = { index: snap, from: "snapshot", fetchedAt: null, error: null };
|
|
9086
9150
|
}
|
|
9087
9151
|
get file() {
|
|
9088
|
-
return
|
|
9152
|
+
return join16(this.o.cacheDir, "index.json");
|
|
9089
9153
|
}
|
|
9090
9154
|
readCache() {
|
|
9091
9155
|
try {
|
|
9092
|
-
const c = JSON.parse(
|
|
9156
|
+
const c = JSON.parse(readFileSync8(this.file, "utf8"));
|
|
9093
9157
|
return indexProblem(c.index) ? null : c;
|
|
9094
9158
|
} catch {
|
|
9095
9159
|
return null;
|
|
@@ -9628,10 +9692,10 @@ var MIME = {
|
|
|
9628
9692
|
".ico": "image/x-icon"
|
|
9629
9693
|
};
|
|
9630
9694
|
function webRoot() {
|
|
9631
|
-
const bundled =
|
|
9632
|
-
if (existsSync14(
|
|
9695
|
+
const bundled = join17(import.meta.dirname, "web");
|
|
9696
|
+
if (existsSync14(join17(bundled, "index.html"))) return bundled;
|
|
9633
9697
|
try {
|
|
9634
|
-
return
|
|
9698
|
+
return join17(dirname7(require3.resolve("@kiosko/web/package.json")), "dist");
|
|
9635
9699
|
} catch {
|
|
9636
9700
|
return resolve7(import.meta.dirname, "../../web/dist");
|
|
9637
9701
|
}
|
|
@@ -9673,7 +9737,7 @@ function startServer(o) {
|
|
|
9673
9737
|
const checking = o.checkUpdates ?? (!runtime.demoMode && process.env.KIOSKO_NO_UPDATE_CHECK !== "1");
|
|
9674
9738
|
const updateTimers = checking ? [setTimeout(() => void refreshUpdates().catch(() => void 0), 2e4), setInterval(() => void refreshUpdates().catch(() => void 0), 24 * 36e5)] : [];
|
|
9675
9739
|
for (const t2 of updateTimers) t2.unref?.();
|
|
9676
|
-
const store = o.store ?? new StoreCatalog({ cacheDir:
|
|
9740
|
+
const store = o.store ?? new StoreCatalog({ cacheDir: join17(paths.home, "store") });
|
|
9677
9741
|
const storeTimers = checking ? [setTimeout(() => void store.refresh(), 15e3), setInterval(() => void store.refresh(), 24 * 36e5)] : [];
|
|
9678
9742
|
for (const t2 of storeTimers) t2.unref?.();
|
|
9679
9743
|
const installFromStore = async (p, version) => {
|
|
@@ -9997,16 +10061,16 @@ data: ${JSON.stringify({ version: o.version })}
|
|
|
9997
10061
|
}
|
|
9998
10062
|
function serveStatic(res, pathname) {
|
|
9999
10063
|
const rel = normPath(decodeURIComponent(pathname)).replace(/^([/\\])+/, "");
|
|
10000
|
-
let file =
|
|
10064
|
+
let file = join17(root, rel || "index.html");
|
|
10001
10065
|
if (!file.startsWith(root)) return void json(res, 400, { error: "bad path" });
|
|
10002
|
-
if (!existsSync14(file) || statSync3(file).isDirectory()) file =
|
|
10066
|
+
if (!existsSync14(file) || statSync3(file).isDirectory()) file = join17(root, "index.html");
|
|
10003
10067
|
if (!existsSync14(file)) {
|
|
10004
10068
|
res.writeHead(500, { "content-type": "text/plain" });
|
|
10005
10069
|
return void res.end("The editor is not built. Run `npm run web:build`.");
|
|
10006
10070
|
}
|
|
10007
10071
|
const ext = extname(file);
|
|
10008
10072
|
res.writeHead(200, { "content-type": MIME[ext] ?? "application/octet-stream", "cache-control": ext === ".html" ? "no-cache" : "max-age=300" });
|
|
10009
|
-
res.end(
|
|
10073
|
+
res.end(readFileSync9(file));
|
|
10010
10074
|
}
|
|
10011
10075
|
const server = createServer((req, res) => {
|
|
10012
10076
|
const host = req.headers.host ?? "";
|
|
@@ -10051,7 +10115,9 @@ function starterConfig(registry2, o = {}) {
|
|
|
10051
10115
|
const height = o.height ?? 462;
|
|
10052
10116
|
const L = (t2) => localize(t2, o.locale ?? "en");
|
|
10053
10117
|
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);
|
|
10054
|
-
const
|
|
10118
|
+
const market = languageById(pickLocale(LANGUAGE_IDS, o.locale ?? "en") ?? "en")?.plugins;
|
|
10119
|
+
const offered = (t2) => !market?.without.includes(t2.split("/")[0]) && !market?.instead[t2];
|
|
10120
|
+
const has = (t2) => offered(t2) && !!registry2.widget(t2);
|
|
10055
10121
|
const page = newPage(L({ en: "Home", es: "Inicio", de: "Start", "zh-Hant": "\u9996\u9801", "zh-Hans": "\u9996\u9875" }), width, height);
|
|
10056
10122
|
page.grid = { cols: 24, rows: 6, gap: 10, padding: 10 };
|
|
10057
10123
|
page.gravity = "left";
|
|
@@ -10060,14 +10126,15 @@ function starterConfig(registry2, o = {}) {
|
|
|
10060
10126
|
const ws = types2.filter(has).map((t2) => newWidget(t2, {}, title));
|
|
10061
10127
|
if (ws.length) tiles.push(newTile(r, ws));
|
|
10062
10128
|
};
|
|
10063
|
-
|
|
10129
|
+
const lead = "agents/sessions";
|
|
10130
|
+
if (has(lead)) add({ x: 0, y: 0, w: 11, h: 6 }, [lead]);
|
|
10064
10131
|
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" }));
|
|
10065
10132
|
add({ x: 11, y: 0, w: 5, h: 4 }, ["core/clock"]);
|
|
10066
10133
|
add({ x: 11, y: 4, w: 5, h: 2 }, ["weather/forecast", "mirror/compliments"]);
|
|
10067
10134
|
add({ x: 16, y: 0, w: 8, h: 6 }, ["usage/rail", "vitals/vitals", "system/health", "mirror/countdown"].filter(has).slice(0, 3));
|
|
10068
|
-
if (!has(
|
|
10135
|
+
if (!has(lead)) {
|
|
10069
10136
|
const welcome = tiles[0]?.widgets[0];
|
|
10070
|
-
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\
|
|
10137
|
+
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\n\u6253\u9020\u4F60\u7684\u9762\u677F\u3002", "zh-Hans": "\u4F60\u597D\u3002\n\u4ECE\u7EC4\u4EF6\u5E93\u62D6\u52A8\u5C0F\u7EC4\u4EF6\uFF0C\n\u5E03\u7F6E\u4F60\u7684\u526F\u5C4F\u3002" }), maxSize: 54 };
|
|
10071
10138
|
}
|
|
10072
10139
|
page.tiles = tiles;
|
|
10073
10140
|
if (height > width) transposePage(page, width, height);
|
|
@@ -10077,15 +10144,16 @@ function starterConfig(registry2, o = {}) {
|
|
|
10077
10144
|
page.grid = grid;
|
|
10078
10145
|
}
|
|
10079
10146
|
screen.pages = [page];
|
|
10080
|
-
screen.interludes = registry2.interlude("agents/runner") ? [{ id: "interlude-runner", type: "agents/runner", enabled: false, everyMs: 15 * 6e4, maxSeconds: 30, options: {} }] : [];
|
|
10147
|
+
screen.interludes = offered("agents/runner") && registry2.interlude("agents/runner") ? [{ id: "interlude-runner", type: "agents/runner", enabled: false, everyMs: 15 * 6e4, maxSeconds: 30, options: {} }] : [];
|
|
10081
10148
|
return normalize({ screens: [screen], locale: "auto" });
|
|
10082
10149
|
}
|
|
10083
10150
|
|
|
10084
10151
|
// packages/server/src/cli.ts
|
|
10085
|
-
var VERSION = "0.2.
|
|
10152
|
+
var VERSION = "0.2.8";
|
|
10086
10153
|
var USAGE2 = `Kiosko ${VERSION}: a widget mosaic for USB LCD panels
|
|
10087
10154
|
|
|
10088
10155
|
kiosko start [--port 7420] [--host 127.0.0.1] [--config file] [--open] [--demo]
|
|
10156
|
+
kiosko editor [--print] open the editor of the Kiosko running here
|
|
10089
10157
|
kiosko render [--screen id|name] [--page id|name] [--out frame.png] [--live]
|
|
10090
10158
|
kiosko import-aimonitor [--from ~/.aimonitor/config.json] [--with-secrets] [--write]
|
|
10091
10159
|
kiosko config schema [--out file] JSON Schema of config.json, with your plugins
|
|
@@ -10177,6 +10245,11 @@ async function main() {
|
|
|
10177
10245
|
process.on("SIGTERM", stop);
|
|
10178
10246
|
return;
|
|
10179
10247
|
}
|
|
10248
|
+
case "editor": {
|
|
10249
|
+
const { config: cfg } = loadConfig(path);
|
|
10250
|
+
process.exitCode = await editorCommand({ server: cfg.server, flags: { host: opt("--host"), port: opt("--port"), print: flag("--print") }, open: openBrowser, log: (l) => console.log(l) });
|
|
10251
|
+
return;
|
|
10252
|
+
}
|
|
10180
10253
|
case "render": {
|
|
10181
10254
|
process.env.KIOSKO_QUIET ??= "1";
|
|
10182
10255
|
const reg = await registry();
|
|
@@ -10209,13 +10282,13 @@ async function main() {
|
|
|
10209
10282
|
process.exit(1);
|
|
10210
10283
|
}
|
|
10211
10284
|
const reg = await registry();
|
|
10212
|
-
const modePath =
|
|
10213
|
-
const modeOverride = existsSync15(modePath) ?
|
|
10214
|
-
const { config: imported, notes } = importAimonitor(JSON.parse(
|
|
10285
|
+
const modePath = join18(dirname8(from), "modo");
|
|
10286
|
+
const modeOverride = existsSync15(modePath) ? readFileSync10(modePath, "utf8") : null;
|
|
10287
|
+
const { config: imported, notes } = importAimonitor(JSON.parse(readFileSync10(from, "utf8")), reg, modeOverride, { withSecrets: flag("--with-secrets") });
|
|
10215
10288
|
if (modeOverride) notes.push(`mode from ${modePath}: ${modeOverride.trim()}`);
|
|
10216
10289
|
for (const n of notes) console.log(`- ${n}`);
|
|
10217
10290
|
if (flag("--write")) {
|
|
10218
|
-
if (existsSync15(path)) writeFileSync12(`${path}.bak`,
|
|
10291
|
+
if (existsSync15(path)) writeFileSync12(`${path}.bak`, readFileSync10(path));
|
|
10219
10292
|
saveConfig(imported, path);
|
|
10220
10293
|
console.log(`written ${path}${existsSync15(`${path}.bak`) ? ` (previous one in ${path}.bak)` : ""}`);
|
|
10221
10294
|
} else {
|
|
@@ -10287,7 +10360,7 @@ async function main() {
|
|
|
10287
10360
|
const reg = await registry();
|
|
10288
10361
|
const out = opt("--out") ?? "gallery";
|
|
10289
10362
|
const sample = opt("--pages");
|
|
10290
|
-
const n = buildGallery(reg, { out, locale: opt("--locale") ?? "en", languages: flag("--all-languages"), theme: opt("--theme") ?? "midnight", ...sample ? { pages: JSON.parse(
|
|
10363
|
+
const n = buildGallery(reg, { out, locale: opt("--locale") ?? "en", languages: flag("--all-languages"), theme: opt("--theme") ?? "midnight", ...sample ? { pages: JSON.parse(readFileSync10(sample, "utf8")) } : {} });
|
|
10291
10364
|
console.log(`${n} widgets \u2192 ${out}/index.html`);
|
|
10292
10365
|
return;
|
|
10293
10366
|
}
|