kiosko 0.2.9 → 0.2.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kiosko",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
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",
package/screen-thread.js CHANGED
@@ -47,6 +47,12 @@ function toPx(r, grid, width, height) {
47
47
 
48
48
  // packages/core/src/config/model.ts
49
49
  var CONFIG_VERSION = 1;
50
+ function deviceRotates(d) {
51
+ return d.driver === "remote";
52
+ }
53
+ function paintTurn(s) {
54
+ return deviceRotates(s.device) ? 0 : s.rotate;
55
+ }
50
56
  var ZOOM = { min: 0.5, max: 2, step: 0.1 };
51
57
  function zoomOf(inst) {
52
58
  const z = inst.zoom;
@@ -110,7 +116,7 @@ import { homedir as homedir2, platform } from "node:os";
110
116
 
111
117
  // packages/sdk/src/plugin.ts
112
118
  var PAD_KEYS = ["up", "down", "left", "right", "a", "b", "x", "y", "l", "r", "start", "select"];
113
- var SDK_VERSION = "0.2.9";
119
+ var SDK_VERSION = "0.2.10";
114
120
  function defineWidget(w) {
115
121
  return w;
116
122
  }
@@ -1615,7 +1621,7 @@ var PROBE = "\u9AD4";
1615
1621
  var missingPixels = /* @__PURE__ */ new Map();
1616
1622
  var available = /* @__PURE__ */ new Map();
1617
1623
  var probeCanvas = null;
1618
- function pixelsOf(font, probe = PROBE) {
1624
+ function pixelsOf(font, probe2 = PROBE) {
1619
1625
  probeCanvas ??= createCanvas4(40, 40);
1620
1626
  const g = probeCanvas.getContext("2d");
1621
1627
  g.clearRect(0, 0, 40, 40);
@@ -1623,16 +1629,16 @@ function pixelsOf(font, probe = PROBE) {
1623
1629
  else g.font = font;
1624
1630
  g.fillStyle = "#000";
1625
1631
  g.textBaseline = "top";
1626
- g.fillText(probe, 4, 4);
1632
+ g.fillText(probe2, 4, 4);
1627
1633
  return Buffer.from(g.getImageData(0, 0, 40, 40).data.buffer).toString("base64");
1628
1634
  }
1629
- function hasFontFamily(family, probe = PROBE) {
1630
- const key = `${family}\0${probe}`;
1635
+ function hasFontFamily(family, probe2 = PROBE) {
1636
+ const key = `${family}\0${probe2}`;
1631
1637
  let yes = available.get(key);
1632
1638
  if (yes === void 0) {
1633
- let missing = missingPixels.get(probe);
1634
- if (missing === void 0) missingPixels.set(probe, missing = pixelsOf('28px "Kiosko Missing Font"', probe));
1635
- yes = pixelsOf(`28px "${family.replace(/"/g, "")}"`, probe) !== missing;
1639
+ let missing = missingPixels.get(probe2);
1640
+ if (missing === void 0) missingPixels.set(probe2, missing = pixelsOf('28px "Kiosko Missing Font"', probe2));
1641
+ yes = pixelsOf(`28px "${family.replace(/"/g, "")}"`, probe2) !== missing;
1636
1642
  available.set(key, yes);
1637
1643
  }
1638
1644
  return yes;
@@ -2042,10 +2048,13 @@ var DEFAULT_SNOOZE_MS = 10 * 6e4;
2042
2048
  // packages/core/src/data.ts
2043
2049
  var DEFAULT_FETCH_MS = 10 * 6e4;
2044
2050
 
2051
+ // packages/core/src/remote/link.ts
2052
+ var MAX_MSG = 1 << 20;
2053
+
2045
2054
  // packages/core/src/devices.ts
2046
2055
  function encodeFor(device, jpegQuality) {
2047
2056
  if (device.driver === "file") return device.format ?? "jpeg";
2048
- if (device.driver === "usb") return "jpeg";
2057
+ if (device.driver === "usb" || device.driver === "remote") return "jpeg";
2049
2058
  return jpegQuality > 0 ? "jpeg" : "png";
2050
2059
  }
2051
2060
 
@@ -2403,7 +2412,7 @@ function paintCard(g, w, h, look) {
2403
2412
  const chip = Math.max(9, Math.round(k2 * 0.5));
2404
2413
  const hint = Math.max(8, Math.round(k2 * 0.34));
2405
2414
  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 });
2415
+ const open2 = wrapLines(g, tx.open, bw, 3, { size: body, family: sans });
2407
2416
  const cmd = "kiosko editor";
2408
2417
  const cmdW = measureTracked(g, cmd, { size: chip, family: mono }) + chip * 1.1;
2409
2418
  const orW = measureTracked(g, tx.or, { size: body, family: sans });
@@ -2411,9 +2420,9 @@ function paintCard(g, w, h, look) {
2411
2420
  const oneLine = cmdW + body * 0.6 + orW + body * 0.6 + urlW <= bw;
2412
2421
  const hints = hint >= 10 ? wrapLines(g, tx.hint, bw, 2, { size: hint, family: sans }) : [];
2413
2422
  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);
2423
+ const height = title.length * lineH(k2) + k2 * 0.25 + open2.length * lineH(body) + body * 0.35 + (oneLine ? chip * 1.9 : chip * 1.9 * 2 + lineH(body)) + hint * 0.6 + hints.length * lineH(hint);
2415
2424
  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 };
2425
+ return { k: k2, body, chip, hint, title, open: open2, cmd, cmdW, orW, urlW, oneLine, hints, height, fits, lineH };
2417
2426
  };
2418
2427
  let k = Math.round(shape === "wide" ? h * 0.17 : shape === "tall" ? w * 0.12 : Math.min(w * 0.085, h * 0.11));
2419
2428
  let L = layout(k);
@@ -2696,7 +2705,7 @@ var ScreenRunner = class {
2696
2705
  log: this.rt.log,
2697
2706
  demo: this.rt.demoMode,
2698
2707
  cache: this.tiles,
2699
- rotate: screen.rotate
2708
+ rotate: paintTurn(screen)
2700
2709
  });
2701
2710
  canvas = result.canvas;
2702
2711
  this.animatable = result.animatable;
@@ -2707,7 +2716,8 @@ var ScreenRunner = class {
2707
2716
  this.rt.paintTime(t2.shown, type, t2.renderMs, now);
2708
2717
  }
2709
2718
  } else {
2710
- const swap = screen.rotate === 90 || screen.rotate === 270;
2719
+ const turn = paintTurn(screen);
2720
+ const swap = turn === 90 || turn === 270;
2711
2721
  canvas = CANVAS.createCanvas(swap ? screen.height : screen.width, swap ? screen.width : screen.height);
2712
2722
  this.animatable = [];
2713
2723
  this.nextAt = now + 6e4;
@@ -2723,7 +2733,7 @@ var ScreenRunner = class {
2723
2733
  }
2724
2734
  const kind = encodeFor(screen.device, screen.jpegQuality);
2725
2735
  const out = await this.fit(canvas, kind, screen.jpegQuality, screen, performance.now() - t0);
2726
- this.lastInfo = { screenId: screen.id, pageId: page?.id ?? null, at: now, image: lazyJpeg(canvas, screen.rotate), tiles: result?.tiles ?? [], interlude: null, sleeping };
2736
+ this.lastInfo = { screenId: screen.id, pageId: page?.id ?? null, at: now, image: lazyJpeg(canvas, paintTurn(screen)), tiles: result?.tiles ?? [], interlude: null, sleeping };
2727
2737
  this.rt.frame(this.lastInfo);
2728
2738
  if (this.last?.equals(out)) return;
2729
2739
  this.last = out;
@@ -2752,7 +2762,7 @@ var ScreenRunner = class {
2752
2762
  const canvas = CANVAS.createCanvas(screen.width, screen.height);
2753
2763
  paintAlert(canvas.getContext("2d"), screen.width, screen.height, shown, { intensity, fonts: this.rt.theme().fonts, minPx, sinceText, shift });
2754
2764
  const kind = encodeFor(screen.device, screen.jpegQuality || 85);
2755
- const turned = rotateCanvas(canvas, screen.rotate);
2765
+ const turned = rotateCanvas(canvas, paintTurn(screen));
2756
2766
  const out = await this.fit(turned, kind, screen.jpegQuality || 85, screen, performance.now() - t0);
2757
2767
  this.lastInfo = { screenId: screen.id, pageId: this.page?.id ?? null, at: now, image: lazyJpeg(canvas), tiles: [], interlude: null, alert: a.id, sleeping: false };
2758
2768
  this.rt.frame(this.lastInfo);
@@ -2818,7 +2828,7 @@ var ScreenRunner = class {
2818
2828
  g.save();
2819
2829
  paintBoot(g, screen.width, screen.height, ms, look);
2820
2830
  g.restore();
2821
- const out = await this.fit(rotateCanvas(canvas, screen.rotate), kind, screen.jpegQuality || 85, screen, performance.now() - t0);
2831
+ const out = await this.fit(rotateCanvas(canvas, paintTurn(screen)), kind, screen.jpegQuality || 85, screen, performance.now() - t0);
2822
2832
  await this.send(out);
2823
2833
  if (i % 4 === 0) {
2824
2834
  const snap = CANVAS.createCanvas(canvas.width, canvas.height);
@@ -2843,7 +2853,7 @@ var ScreenRunner = class {
2843
2853
  const canvas = CANVAS.createCanvas(screen.width, screen.height);
2844
2854
  paintCard(canvas.getContext("2d"), screen.width, screen.height, look);
2845
2855
  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);
2856
+ const out = await this.fit(rotateCanvas(canvas, paintTurn(screen)), kind, screen.jpegQuality || 85, screen, performance.now() - t0);
2847
2857
  this.lastInfo = { screenId: screen.id, pageId: this.page?.id ?? null, at: now, image: lazyJpeg(canvas), tiles: [], interlude: "kiosko/welcome", sleeping: false };
2848
2858
  this.rt.frame(this.lastInfo);
2849
2859
  this.last = out;
@@ -2919,7 +2929,7 @@ var ScreenRunner = class {
2919
2929
  } finally {
2920
2930
  g.restore();
2921
2931
  }
2922
- const turned = rotateCanvas(canvas, this.screen.rotate);
2932
+ const turned = rotateCanvas(canvas, paintTurn(this.screen));
2923
2933
  const out = await this.fit(turned, kind, this.screen.jpegQuality || 85, this.screen, performance.now() - t0);
2924
2934
  await this.send(out);
2925
2935
  if (i % 3 === 0) {
@@ -3017,7 +3027,7 @@ var ScreenRunner = class {
3017
3027
  demo: this.rt.demoMode,
3018
3028
  cache: this.tiles,
3019
3029
  animate,
3020
- rotate: screen.rotate
3030
+ rotate: paintTurn(screen)
3021
3031
  });
3022
3032
  sent.push({ out: this.fit(result.canvas, kind, screen.jpegQuality || 85, screen, performance.now() - t02), snap: s % 3 === 1 ? result.canvas : null });
3023
3033
  await new Promise((r) => setImmediate(r));
@@ -3034,7 +3044,7 @@ var ScreenRunner = class {
3034
3044
  await this.send(outs[k]);
3035
3045
  const snap = sent[k].snap;
3036
3046
  if (snap) {
3037
- 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 };
3047
+ this.lastInfo = { screenId: screen.id, pageId: page.id, at: Date.now(), image: lazyJpeg(snap, paintTurn(screen)), tiles: [], interlude: null, animation: items.map((x) => x.animatable.type).join(", "), sleeping: false };
3038
3048
  this.rt.frame(this.lastInfo);
3039
3049
  }
3040
3050
  if (hold && k === holdAt) {
@@ -3825,6 +3835,9 @@ async function runScreenThread(builtins = []) {
3825
3835
  // packages/core/src/store/tar.ts
3826
3836
  var MAX_TARBALL_BYTES = 20 * 1024 * 1024;
3827
3837
 
3838
+ // packages/core/src/remote/ops.ts
3839
+ var CHUNK = 16 * 1024;
3840
+
3828
3841
  // plugins/core/src/index.ts
3829
3842
  import { readdir, readFile, stat } from "node:fs/promises";
3830
3843
  import { join as join6 } from "node:path";
@@ -4189,7 +4202,7 @@ var image = defineWidget({
4189
4202
  var src_default = definePlugin({
4190
4203
  id: "core",
4191
4204
  name: { en: "Essentials", es: "B\xE1sicos", de: "Grundlagen", "zh-Hant": "\u57FA\u672C\u5DE5\u5177", "zh-Hans": "\u57FA\u7840\u7EC4\u4EF6" },
4192
- version: "0.2.9",
4205
+ version: "0.2.10",
4193
4206
  languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
4194
4207
  sdk: "^0.2.0",
4195
4208
  // The picture widget reads the image (or folder, or URL) you give it.
@@ -4285,7 +4298,7 @@ var module2 = defineWidget({
4285
4298
  var src_default2 = definePlugin({
4286
4299
  id: "legacy",
4287
4300
  name: { en: "aimonitor compatibility", es: "Compatibilidad aimonitor", de: "aimonitor-Kompatibilit\xE4t", "zh-Hant": "aimonitor \u76F8\u5BB9\u6027", "zh-Hans": "aimonitor \u517C\u5BB9" },
4288
- version: "0.2.9",
4301
+ version: "0.2.10",
4289
4302
  languages: ["en", "es", "de", "zh-Hant", "zh-Hans"],
4290
4303
  sdk: "^0.2.0",
4291
4304
  // Runs the aimonitor modules you point it at, and reads their folder.
package/sdk.js CHANGED
@@ -14,7 +14,7 @@ var CATEGORIES = [
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.9";
17
+ var SDK_VERSION = "0.2.10";
18
18
  function defineWidget(w) {
19
19
  return w;
20
20
  }