kiosko 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/cli.js +925 -277
- package/kit.js +64 -7
- package/package.json +1 -1
- package/sdk.js +204 -37
- package/web/assets/app.js +3 -3
- package/web/assets/styles.css +1 -1
package/kit.js
CHANGED
|
@@ -30,14 +30,50 @@ function widthOf(ctx, font, ch) {
|
|
|
30
30
|
function clearTextCache() {
|
|
31
31
|
widths.clear();
|
|
32
32
|
}
|
|
33
|
+
var CJK = /[\u1100-\u11ff\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\uff00-\uffef]/;
|
|
34
|
+
function hasCjk(text) {
|
|
35
|
+
return CJK.test(text);
|
|
36
|
+
}
|
|
37
|
+
function trackingOf(text, o) {
|
|
38
|
+
return o.tracking && hasCjk(text) ? 0 : o.tracking ?? 0;
|
|
39
|
+
}
|
|
40
|
+
var minCjkPx = 0;
|
|
41
|
+
var enlarged = Infinity;
|
|
42
|
+
function setMinCjkPx(px) {
|
|
43
|
+
if (px !== minCjkPx) widths.clear();
|
|
44
|
+
minCjkPx = Math.max(0, px);
|
|
45
|
+
}
|
|
46
|
+
function takeCjkEnlarged() {
|
|
47
|
+
const v = enlarged;
|
|
48
|
+
enlarged = Infinity;
|
|
49
|
+
return Number.isFinite(v) ? Math.round(v) : null;
|
|
50
|
+
}
|
|
51
|
+
function scaleOf(ctx) {
|
|
52
|
+
const t = ctx.getTransform?.();
|
|
53
|
+
return t ? Math.hypot(t.a, t.b) || 1 : 1;
|
|
54
|
+
}
|
|
33
55
|
function glyphs(ctx, text, o) {
|
|
34
56
|
const family = o.family ?? defaultFamily;
|
|
35
|
-
const
|
|
57
|
+
const cjk = hasCjk(text);
|
|
58
|
+
const small = o.smallCaps === true && !cjk;
|
|
36
59
|
const capSize = o.size * (o.capRatio ?? 0.76);
|
|
37
60
|
const out = [];
|
|
38
61
|
const font = `${o.size}px "${family}"`;
|
|
39
62
|
const capFont = `${capSize}px "${family}"`;
|
|
63
|
+
let cjkSize = o.size;
|
|
64
|
+
if (cjk && minCjkPx > 0) {
|
|
65
|
+
const scale = scaleOf(ctx);
|
|
66
|
+
if (o.size * scale < minCjkPx - 0.5) {
|
|
67
|
+
cjkSize = minCjkPx / scale;
|
|
68
|
+
enlarged = Math.min(enlarged, o.size * scale);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const cjkFont = `${cjkSize}px "${family}"`;
|
|
40
72
|
for (const ch of text) {
|
|
73
|
+
if (cjkSize !== o.size && CJK.test(ch)) {
|
|
74
|
+
out.push({ ch, size: cjkSize, width: widthOf(ctx, cjkFont, ch) });
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
41
77
|
const isLower = small && ch !== ch.toUpperCase() && ch === ch.toLowerCase();
|
|
42
78
|
const size = isLower ? capSize : o.size;
|
|
43
79
|
const draw = small ? ch.toUpperCase() : ch;
|
|
@@ -50,11 +86,11 @@ function advance(gs, tracking) {
|
|
|
50
86
|
return gs.reduce((a, g) => a + g.width, 0) + tracking * (gs.length - 1);
|
|
51
87
|
}
|
|
52
88
|
function measureTracked(ctx, text, o) {
|
|
53
|
-
return advance(glyphs(ctx, text, o), o
|
|
89
|
+
return advance(glyphs(ctx, text, o), trackingOf(text, o));
|
|
54
90
|
}
|
|
55
91
|
function drawTracked(ctx, text, x, y, o) {
|
|
56
92
|
const family = o.family ?? defaultFamily;
|
|
57
|
-
const tracking = o
|
|
93
|
+
const tracking = trackingOf(text, o);
|
|
58
94
|
const gs = glyphs(ctx, text, o);
|
|
59
95
|
const total = advance(gs, tracking);
|
|
60
96
|
let cursor = o.align === "right" ? x - total : o.align === "center" ? x - total / 2 : x;
|
|
@@ -92,17 +128,35 @@ function fitSize(ctx, text, maxWidth, o, minSize) {
|
|
|
92
128
|
function drawClipped(ctx, text, x, y, maxWidth, o) {
|
|
93
129
|
return drawTracked(ctx, truncate(ctx, text, maxWidth, o), x, y, o);
|
|
94
130
|
}
|
|
131
|
+
var 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,.;:?!)]}%"]);
|
|
132
|
+
var NO_END = /* @__PURE__ */ new Set([..."\uFF08\u300C\u300E\u3010\u300A\u3008\u3014\uFF5B\u3016\u3018\u301A\u2018\u201C([{$"]);
|
|
133
|
+
var isSpace = (c) => /\s/.test(c);
|
|
95
134
|
function fitPrefix(ctx, text, maxWidth, o) {
|
|
96
135
|
if (measureTracked(ctx, text, o) <= maxWidth) return text.length;
|
|
136
|
+
const chars = [...text];
|
|
97
137
|
let lo = 1;
|
|
98
|
-
let hi =
|
|
138
|
+
let hi = chars.length;
|
|
99
139
|
while (lo < hi) {
|
|
100
140
|
const mid = Math.ceil((lo + hi) / 2);
|
|
101
|
-
if (measureTracked(ctx,
|
|
141
|
+
if (measureTracked(ctx, chars.slice(0, mid).join(""), o) <= maxWidth) lo = mid;
|
|
102
142
|
else hi = mid - 1;
|
|
103
143
|
}
|
|
104
|
-
const
|
|
105
|
-
|
|
144
|
+
const cjk = hasCjk(text);
|
|
145
|
+
const fits = (i) => !NO_START.has(chars[i]) && !NO_END.has(chars[i - 1]);
|
|
146
|
+
let cut = 0;
|
|
147
|
+
for (let i = lo; i >= 1; i--) {
|
|
148
|
+
const before = chars[i - 1];
|
|
149
|
+
const after = chars[i];
|
|
150
|
+
if ((isSpace(before) || isSpace(after) || CJK.test(before) || CJK.test(after)) && fits(i)) {
|
|
151
|
+
cut = i;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!cut || cjk && cut < lo * 0.6) {
|
|
156
|
+
cut = lo;
|
|
157
|
+
while (cut > 1 && !fits(cut)) cut--;
|
|
158
|
+
}
|
|
159
|
+
return chars.slice(0, cut).join("").length;
|
|
106
160
|
}
|
|
107
161
|
function wrapLines(ctx, text, maxWidth, maxLines, o) {
|
|
108
162
|
const clean = text.replace(/\s+/g, " ").trim();
|
|
@@ -407,6 +461,7 @@ export {
|
|
|
407
461
|
drawWeatherIcon,
|
|
408
462
|
ellipse,
|
|
409
463
|
fitSize,
|
|
464
|
+
hasCjk,
|
|
410
465
|
hashString,
|
|
411
466
|
hex,
|
|
412
467
|
linear,
|
|
@@ -417,8 +472,10 @@ export {
|
|
|
417
472
|
registerFontFiles,
|
|
418
473
|
rng,
|
|
419
474
|
setDefaultFamily,
|
|
475
|
+
setMinCjkPx,
|
|
420
476
|
smooth,
|
|
421
477
|
sparkBars,
|
|
478
|
+
takeCjkEnlarged,
|
|
422
479
|
truncate,
|
|
423
480
|
wrapLines
|
|
424
481
|
};
|
package/package.json
CHANGED
package/sdk.js
CHANGED
|
@@ -2,17 +2,17 @@ import { createRequire as __kioskoRequire } from 'node:module'; const require =
|
|
|
2
2
|
|
|
3
3
|
// packages/sdk/src/plugin.ts
|
|
4
4
|
var CATEGORIES = [
|
|
5
|
-
{ id: "agents", label: { en: "AI agents", es: "Agentes IA" } },
|
|
6
|
-
{ id: "system", label: { en: "System", es: "Sistema" } },
|
|
7
|
-
{ id: "time", label: { en: "Time & calendar", es: "Tiempo y agenda" } },
|
|
8
|
-
{ id: "productivity", label: { en: "Productivity", es: "Productividad" } },
|
|
9
|
-
{ id: "dev", label: { en: "Development", es: "Desarrollo" } },
|
|
10
|
-
{ id: "info", label: { en: "News & world", es: "Noticias y mundo" } },
|
|
11
|
-
{ id: "media", label: { en: "Media", es: "Multimedia" } },
|
|
12
|
-
{ id: "scene", label: { en: "Scenes", es: "Escenas" } },
|
|
13
|
-
{ id: "fun", label: { en: "Fun", es: "Diversi\xF3n" } }
|
|
5
|
+
{ id: "agents", label: { en: "AI agents", es: "Agentes IA", de: "KI-Agenten", "zh-Hant": "AI \u4EE3\u7406", "zh-Hans": "AI \u667A\u80FD\u4F53" } },
|
|
6
|
+
{ id: "system", label: { en: "System", es: "Sistema", de: "System", "zh-Hant": "\u7CFB\u7D71", "zh-Hans": "\u7CFB\u7EDF" } },
|
|
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
|
+
{ id: "productivity", label: { en: "Productivity", es: "Productividad", de: "Produktivit\xE4t", "zh-Hant": "\u751F\u7522\u529B", "zh-Hans": "\u6548\u7387" } },
|
|
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": "\u65B0\u805E\u8207\u4E16\u754C", "zh-Hans": "\u65B0\u95FB\u4E0E\u4E16\u754C" } },
|
|
11
|
+
{ id: "media", label: { en: "Media", es: "Multimedia", de: "Medien", "zh-Hant": "\u591A\u5A92\u9AD4", "zh-Hans": "\u591A\u5A92\u4F53" } },
|
|
12
|
+
{ id: "scene", label: { en: "Scenes", es: "Escenas", de: "Szenen", "zh-Hant": "\u5834\u666F", "zh-Hans": "\u573A\u666F" } },
|
|
13
|
+
{ id: "fun", label: { en: "Fun", es: "Diversi\xF3n", de: "Spa\xDF", "zh-Hant": "\u8DA3\u5473", "zh-Hans": "\u8DA3\u5473" } }
|
|
14
14
|
];
|
|
15
|
-
var SDK_VERSION = "0.2.
|
|
15
|
+
var SDK_VERSION = "0.2.6";
|
|
16
16
|
function defineWidget(w) {
|
|
17
17
|
return w;
|
|
18
18
|
}
|
|
@@ -27,11 +27,98 @@ function definePlugin(p) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// packages/sdk/src/i18n.ts
|
|
30
|
+
var ALIASES = { iw: "he", in: "id", ji: "yi", tl: "fil", no: "nb", cmn: "zh" };
|
|
31
|
+
var READS = { yue: "zh", nn: "nb" };
|
|
32
|
+
function parseLocale(tag) {
|
|
33
|
+
if (!tag) return null;
|
|
34
|
+
let t2 = tag.trim();
|
|
35
|
+
const latin2 = /@latin\b/i.test(t2);
|
|
36
|
+
t2 = t2.replace(/[.@].*$/, "").replace(/_/g, "-");
|
|
37
|
+
if (!t2 || t2 === "C" || t2 === "POSIX") return null;
|
|
38
|
+
try {
|
|
39
|
+
let l = new Intl.Locale(Intl.getCanonicalLocales(t2)[0]);
|
|
40
|
+
const alias = ALIASES[l.language];
|
|
41
|
+
if (alias) l = new Intl.Locale(alias, { ...l.script ? { script: l.script } : {}, ...l.region ? { region: l.region } : {} });
|
|
42
|
+
if (latin2 && !l.script) l = new Intl.Locale(l.language, { script: "Latn", ...l.region ? { region: l.region } : {} });
|
|
43
|
+
return l;
|
|
44
|
+
} catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var 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"]);
|
|
49
|
+
var PT_PT = /* @__PURE__ */ new Set(["PT", "AO", "MZ", "CV", "GW", "ST", "TL", "MO", "GQ", "LU", "CH"]);
|
|
50
|
+
function pickLocale(available, locale) {
|
|
51
|
+
if (!locale || !available.length) return void 0;
|
|
52
|
+
const exact = available.find((k) => k.toLowerCase() === locale.replace(/_/g, "-").toLowerCase());
|
|
53
|
+
if (exact) return exact;
|
|
54
|
+
const want = parseLocale(locale);
|
|
55
|
+
if (!want) return void 0;
|
|
56
|
+
const w = want.maximize();
|
|
57
|
+
const lang = READS[w.language] ?? w.language;
|
|
58
|
+
const fits = available.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);
|
|
59
|
+
if (!fits.length) return void 0;
|
|
60
|
+
const same = (a, b) => a.baseName === b.baseName;
|
|
61
|
+
const byTag = fits.find((c) => same(c.l, want));
|
|
62
|
+
if (byTag) return byTag.k;
|
|
63
|
+
if (w.region) {
|
|
64
|
+
const byRegion = fits.find((c) => c.m.region === w.region && c.l.region);
|
|
65
|
+
if (byRegion) return byRegion.k;
|
|
66
|
+
const usual = (r) => lang === "es" && LATAM.has(w.region) ? ["419", "MX"].includes(r) : lang === "pt" && PT_PT.has(w.region) ? r === "PT" : false;
|
|
67
|
+
const variant = fits.find((c) => c.l.region && usual(c.l.region));
|
|
68
|
+
if (variant) return variant.k;
|
|
69
|
+
}
|
|
70
|
+
const plain = [...fits].sort((a, b) => a.l.baseName.split("-").length - b.l.baseName.split("-").length);
|
|
71
|
+
return plain[0].k;
|
|
72
|
+
}
|
|
73
|
+
function plural(n, forms, locale = "en") {
|
|
74
|
+
const key = pickLocale(Object.keys(forms), locale) ?? (forms.en ? "en" : Object.keys(forms)[0]);
|
|
75
|
+
const f = forms[key];
|
|
76
|
+
let rule = "other";
|
|
77
|
+
try {
|
|
78
|
+
rule = new Intl.PluralRules(key).select(n);
|
|
79
|
+
} catch {
|
|
80
|
+
}
|
|
81
|
+
const text = f[rule] ?? f.other;
|
|
82
|
+
let num = String(n);
|
|
83
|
+
try {
|
|
84
|
+
num = new Intl.NumberFormat(key).format(n);
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
return text.replaceAll("{n}", num);
|
|
88
|
+
}
|
|
30
89
|
function localize(text, locale = "en") {
|
|
31
90
|
if (text === void 0) return "";
|
|
32
91
|
if (typeof text === "string") return text;
|
|
33
|
-
const
|
|
34
|
-
return
|
|
92
|
+
const key = pickLocale(Object.keys(text), locale);
|
|
93
|
+
return (key ? text[key] : void 0) ?? text.en ?? Object.values(text).find((v) => typeof v === "string") ?? "";
|
|
94
|
+
}
|
|
95
|
+
function hanScript(locale) {
|
|
96
|
+
const l = parseLocale(locale || "en");
|
|
97
|
+
if (!l) return null;
|
|
98
|
+
const full = l.maximize();
|
|
99
|
+
switch (READS[full.language] ?? full.language) {
|
|
100
|
+
case "zh":
|
|
101
|
+
if (full.script === "Hant") return full.region === "HK" || full.region === "MO" ? "Hant-HK" : "Hant";
|
|
102
|
+
return "Hans";
|
|
103
|
+
case "ja":
|
|
104
|
+
return "Jpan";
|
|
105
|
+
case "ko":
|
|
106
|
+
return "Kore";
|
|
107
|
+
default:
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
var PluginError = class extends Error {
|
|
112
|
+
text;
|
|
113
|
+
constructor(text, options) {
|
|
114
|
+
super(localize(text, "en"), options);
|
|
115
|
+
this.name = "PluginError";
|
|
116
|
+
this.text = text;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function errorMessage(err, locale = "en") {
|
|
120
|
+
if (err instanceof Error && "text" in err && err.text !== void 0) return localize(err.text, locale);
|
|
121
|
+
return err instanceof Error ? err.message : String(err);
|
|
35
122
|
}
|
|
36
123
|
|
|
37
124
|
// packages/sdk/src/schema.ts
|
|
@@ -64,7 +151,10 @@ var t = {
|
|
|
64
151
|
};
|
|
65
152
|
var FILTER_HELP = {
|
|
66
153
|
en: "Empty: all. Names or patterns, comma-separated: * matches anything, a leading ! leaves out (web, acme/*, !*-old).",
|
|
67
|
-
es: "Vac\xEDo: todos. Nombres o patrones separados por comas: * vale por cualquier cosa y un ! delante excluye (web, acme/*, !*-old)."
|
|
154
|
+
es: "Vac\xEDo: todos. Nombres o patrones separados por comas: * vale por cualquier cosa y un ! delante excluye (web, acme/*, !*-old).",
|
|
155
|
+
de: "Leer: alle. Namen oder Muster, durch Kommas getrennt: * steht f\xFCr alles, ein ! davor schlie\xDFt aus (web, acme/*, !*-old).",
|
|
156
|
+
"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",
|
|
157
|
+
"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"
|
|
68
158
|
};
|
|
69
159
|
function clone(v) {
|
|
70
160
|
return v === void 0 ? v : JSON.parse(JSON.stringify(v));
|
|
@@ -213,14 +303,67 @@ function themeById(id) {
|
|
|
213
303
|
return THEMES.find((t2) => t2.id === id) ?? DEFAULT_THEME;
|
|
214
304
|
}
|
|
215
305
|
|
|
306
|
+
// packages/sdk/src/languages.ts
|
|
307
|
+
var MAINLAND_CHINA = {
|
|
308
|
+
without: ["agents", "cats", "usage"],
|
|
309
|
+
first: ["llm", "gpu"],
|
|
310
|
+
instead: { "agents/summary": "llm/status", "agents/sessions": "llm/models", "usage/rail": "gpu/cards", "cats/room": "gpu/history" }
|
|
311
|
+
};
|
|
312
|
+
var LANGUAGES = [
|
|
313
|
+
{ id: "en", name: "English", panel: "en", ogLocale: "en_US", hreflang: ["en", "x-default"], dir: "ltr" },
|
|
314
|
+
{ id: "es", name: "Espa\xF1ol", panel: "es", ogLocale: "es_ES", hreflang: ["es"], dir: "ltr" },
|
|
315
|
+
{ id: "de", name: "Deutsch", panel: "de", ogLocale: "de_DE", hreflang: ["de"], dir: "ltr" },
|
|
316
|
+
{ id: "zh-Hant", name: "\u7E41\u9AD4\u4E2D\u6587", panel: "zh-TW", ogLocale: "zh_TW", hreflang: ["zh-Hant", "zh-TW", "zh-HK"], dir: "ltr" },
|
|
317
|
+
{ id: "zh-Hans", name: "\u7B80\u4F53\u4E2D\u6587", panel: "zh-CN", ogLocale: "zh_CN", hreflang: ["zh-Hans", "zh-CN"], dir: "ltr", plugins: MAINLAND_CHINA }
|
|
318
|
+
];
|
|
319
|
+
var LANGUAGE_IDS = LANGUAGES.map((l) => l.id);
|
|
320
|
+
function languageById(id) {
|
|
321
|
+
return LANGUAGES.find((l) => l.id === id);
|
|
322
|
+
}
|
|
323
|
+
|
|
216
324
|
// packages/sdk/src/format.ts
|
|
217
325
|
var TIME_FORMATS = ["auto", "24h", "12h"];
|
|
326
|
+
var latin = (wk, yr) => ({
|
|
327
|
+
s: (n) => `${n} s`,
|
|
328
|
+
min: (n) => `${n} min`,
|
|
329
|
+
h: (n) => `${n} h`,
|
|
330
|
+
d: (n) => `${n} d`,
|
|
331
|
+
wk: (n) => `${n} ${wk}`,
|
|
332
|
+
yr: (n) => `${n} ${yr(n)}`,
|
|
333
|
+
hm: (h, m) => `${h} h ${pad2(m)}`,
|
|
334
|
+
dh: (d, h) => `${d} d ${h} h`
|
|
335
|
+
});
|
|
336
|
+
var german = {
|
|
337
|
+
s: (n) => `${n} s`,
|
|
338
|
+
min: (n) => `${n} Min.`,
|
|
339
|
+
h: (n) => `${n} Std.`,
|
|
340
|
+
d: (n) => `${n} T.`,
|
|
341
|
+
wk: (n) => `${n} Wo.`,
|
|
342
|
+
yr: (n) => `${n} J.`,
|
|
343
|
+
hm: (h, m) => `${h}:${pad2(m)} h`,
|
|
344
|
+
dh: (d, h) => `${d} T. ${h} Std.`
|
|
345
|
+
};
|
|
346
|
+
var chinese = (u) => ({
|
|
347
|
+
s: (n) => `${n} \u79D2`,
|
|
348
|
+
min: (n) => `${n} ${u.min}`,
|
|
349
|
+
h: (n) => `${n} ${u.h}`,
|
|
350
|
+
d: (n) => `${n} \u5929`,
|
|
351
|
+
wk: (n) => `${n} ${u.wk}`,
|
|
352
|
+
yr: (n) => `${n} \u5E74`,
|
|
353
|
+
// No leading zero in Chinese: 1 小時 5 分.
|
|
354
|
+
hm: (h, m) => `${h} ${u.h} ${m} \u5206`,
|
|
355
|
+
dh: (d, h) => `${d} \u5929 ${h} ${u.h}`
|
|
356
|
+
});
|
|
218
357
|
var WORDS = {
|
|
219
|
-
en: { now: "now", justNow: "just now", ago: (v) => `${v} ago`,
|
|
220
|
-
es: { now: "ahora", justNow: "ahora mismo", ago: (v) => `hace ${v}`,
|
|
358
|
+
en: { now: "now", justNow: "just now", ago: (v) => `${v} ago`, am: "AM", pm: "PM", ...latin("wk", () => "yr") },
|
|
359
|
+
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") },
|
|
360
|
+
de: { now: "jetzt", justNow: "gerade eben", ago: (v) => `vor ${v}`, am: "AM", pm: "PM", ...german },
|
|
361
|
+
"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" }) },
|
|
362
|
+
"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" }) }
|
|
221
363
|
};
|
|
222
|
-
var
|
|
223
|
-
var
|
|
364
|
+
var FORMAT_LANGUAGES = Object.keys(WORDS);
|
|
365
|
+
var LANGS = Object.keys(WORDS);
|
|
366
|
+
var wordsFor = (locale) => WORDS[pickLocale(LANGS, locale) ?? "en"] ?? WORDS.en;
|
|
224
367
|
var pad2 = (n) => String(n).padStart(2, "0");
|
|
225
368
|
var cycles = /* @__PURE__ */ new Map();
|
|
226
369
|
function usesHour12(locale, timeFormat = "auto") {
|
|
@@ -245,7 +388,7 @@ function toMs(at) {
|
|
|
245
388
|
function createFormatters(o) {
|
|
246
389
|
const w = wordsFor(o.locale);
|
|
247
390
|
const hour12 = usesHour12(o.locale, o.timeFormat);
|
|
248
|
-
|
|
391
|
+
const fmt = {
|
|
249
392
|
hour12,
|
|
250
393
|
time(at, opts = {}) {
|
|
251
394
|
const d = new Date(toMs(at));
|
|
@@ -253,7 +396,15 @@ function createFormatters(o) {
|
|
|
253
396
|
const rest = `:${pad2(d.getMinutes())}${opts.seconds ? `:${pad2(d.getSeconds())}` : ""}`;
|
|
254
397
|
if (!hour12) return `${pad2(h)}${rest}`;
|
|
255
398
|
const base2 = `${h % 12 || 12}${rest}`;
|
|
256
|
-
|
|
399
|
+
if (opts.ampm === false) return base2;
|
|
400
|
+
const mark = h < 12 ? w.am : w.pm;
|
|
401
|
+
return w.ampmFirst ? `${mark} ${base2}` : `${base2} ${mark}`;
|
|
402
|
+
},
|
|
403
|
+
range(from, to, opts = {}) {
|
|
404
|
+
const a = new Date(toMs(from));
|
|
405
|
+
const b = new Date(toMs(to));
|
|
406
|
+
if (!hour12 || a.getHours() < 12 !== b.getHours() < 12) return `${fmt.time(a, opts)}\u2013${fmt.time(b, opts)}`;
|
|
407
|
+
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)}`;
|
|
257
408
|
},
|
|
258
409
|
ago(at, opts = {}) {
|
|
259
410
|
const suffix = opts.suffix !== false;
|
|
@@ -262,20 +413,21 @@ function createFormatters(o) {
|
|
|
262
413
|
if (!Number.isFinite(min) || min < 1) return suffix ? w.justNow : w.now;
|
|
263
414
|
const h = Math.floor(min / 60);
|
|
264
415
|
const d = Math.floor(h / 24);
|
|
265
|
-
const v = min < 60 ?
|
|
266
|
-
return suffix ? w.ago(v) : v;
|
|
416
|
+
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)];
|
|
417
|
+
return suffix ? w.ago(v, n) : v;
|
|
267
418
|
},
|
|
268
419
|
duration(ms, opts = {}) {
|
|
269
420
|
const round = opts.round === "up" ? Math.ceil : opts.round === "nearest" ? Math.round : Math.floor;
|
|
270
421
|
const safe = Number.isFinite(ms) ? Math.max(0, ms) : 0;
|
|
271
|
-
if (opts.seconds && safe < 6e4) return
|
|
422
|
+
if (opts.seconds && safe < 6e4) return w.s(round(safe / 1e3));
|
|
272
423
|
const min = round(safe / 6e4);
|
|
273
|
-
if (min < 60) return
|
|
424
|
+
if (min < 60) return w.min(min);
|
|
274
425
|
const h = Math.floor(min / 60);
|
|
275
|
-
if (h < 24) return opts.compact && min % 60 === 0 ?
|
|
276
|
-
return opts.compact && h % 24 === 0 ?
|
|
426
|
+
if (h < 24) return opts.compact && min % 60 === 0 ? w.h(h) : w.hm(h, min % 60);
|
|
427
|
+
return opts.compact && h % 24 === 0 ? w.d(h / 24) : w.dh(Math.floor(h / 24), h % 24);
|
|
277
428
|
}
|
|
278
429
|
};
|
|
430
|
+
return fmt;
|
|
279
431
|
}
|
|
280
432
|
|
|
281
433
|
// packages/sdk/src/workday.ts
|
|
@@ -310,18 +462,21 @@ function weeklyHours(w) {
|
|
|
310
462
|
|
|
311
463
|
// packages/sdk/src/list.ts
|
|
312
464
|
var LAYOUT_LABELS = {
|
|
313
|
-
auto: { en: "Automatic", es: "Autom\xE1tico" },
|
|
314
|
-
"one-line": { en: "One line", es: "Una l\xEDnea" },
|
|
315
|
-
detailed: { en: "Detailed", es: "Detallado" }
|
|
465
|
+
auto: { en: "Automatic", es: "Autom\xE1tico", de: "Automatisch", "zh-Hant": "\u81EA\u52D5", "zh-Hans": "\u81EA\u52A8" },
|
|
466
|
+
"one-line": { en: "One line", es: "Una l\xEDnea", de: "Eine Zeile", "zh-Hant": "\u55AE\u884C", "zh-Hans": "\u5355\u884C" },
|
|
467
|
+
detailed: { en: "Detailed", es: "Detallado", de: "Ausf\xFChrlich", "zh-Hant": "\u8A73\u7D30", "zh-Hans": "\u8BE6\u7EC6" }
|
|
316
468
|
};
|
|
317
469
|
var rowsField = (def) => t.integer({
|
|
318
470
|
default: def,
|
|
319
471
|
min: 0,
|
|
320
472
|
max: 30,
|
|
321
|
-
label: { en: "Rows", es: "Filas" },
|
|
473
|
+
label: { en: "Rows", es: "Filas", de: "Zeilen", "zh-Hant": "\u5217\u6578", "zh-Hans": "\u884C\u6570" },
|
|
322
474
|
help: {
|
|
323
475
|
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".',
|
|
324
|
-
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."
|
|
476
|
+
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.",
|
|
477
|
+
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.",
|
|
478
|
+
"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",
|
|
479
|
+
"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"
|
|
325
480
|
}
|
|
326
481
|
});
|
|
327
482
|
function listOptions(o = {}) {
|
|
@@ -332,9 +487,9 @@ function listOptions(o = {}) {
|
|
|
332
487
|
rows,
|
|
333
488
|
layout: t.enum(values, {
|
|
334
489
|
default: o.layout ?? "auto",
|
|
335
|
-
label: { en: "Row layout", es: "Formato de fila" },
|
|
490
|
+
label: { en: "Row layout", es: "Formato de fila", de: "Zeilenlayout", "zh-Hant": "\u5217\u7248\u9762", "zh-Hans": "\u884C\u5E03\u5C40" },
|
|
336
491
|
labels: Object.fromEntries(values.map((v) => [v, LAYOUT_LABELS[v]])),
|
|
337
|
-
help: { en: "Automatic: the widget picks by the tile's shape.", es: "Autom\xE1tico: el widget elige seg\xFAn la forma de la tesela." }
|
|
492
|
+
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" }
|
|
338
493
|
})
|
|
339
494
|
};
|
|
340
495
|
}
|
|
@@ -380,7 +535,7 @@ function listLayout(box, count, options, spec) {
|
|
|
380
535
|
return { layout, rowH, rows, shown, hidden: n - shown, more, ...text(rowH) };
|
|
381
536
|
}
|
|
382
537
|
function moreLabel(n, tr) {
|
|
383
|
-
return tr({ en: `+${n} more`, es: `+${n} m\xE1s` });
|
|
538
|
+
return tr({ en: `+${n} more`, es: `+${n} m\xE1s`, de: `+${n} weitere`, "zh-Hant": `\u9084\u6709 ${n} \u500B`, "zh-Hans": `\u8FD8\u6709 ${n} \u4E2A` });
|
|
384
539
|
}
|
|
385
540
|
function drawMore(g, ctx, plan, o = {}) {
|
|
386
541
|
const m = plan.more;
|
|
@@ -437,6 +592,8 @@ function createBaseContext(o) {
|
|
|
437
592
|
now: o.now,
|
|
438
593
|
locale,
|
|
439
594
|
t: (text) => localize(text, locale),
|
|
595
|
+
plural: (n, forms) => plural(n, forms, locale),
|
|
596
|
+
pickLanguage: (available) => pickLocale(available, locale) ?? (available.includes("en") ? "en" : available[0] ?? "en"),
|
|
440
597
|
fmt: createFormatters({ locale, timeFormat: o.timeFormat ?? "auto", now: o.now }),
|
|
441
598
|
log: o.log ?? (() => void 0),
|
|
442
599
|
dataDir: o.dataDir ?? "",
|
|
@@ -456,11 +613,11 @@ function locationOptions() {
|
|
|
456
613
|
step: 1e-4,
|
|
457
614
|
unit: "\xB0",
|
|
458
615
|
advanced: true,
|
|
459
|
-
label: { en: "Latitude", es: "Latitud" },
|
|
460
|
-
help: { en: "Leave latitude and longitude at 0 to use the place in Settings.", es: "Con latitud y longitud a 0 se usa el lugar de los ajustes." }
|
|
616
|
+
label: { en: "Latitude", es: "Latitud", de: "Breitengrad", "zh-Hant": "\u7DEF\u5EA6", "zh-Hans": "\u7EAC\u5EA6" },
|
|
617
|
+
help: { en: "Leave latitude and longitude at 0 to use the place in Settings.", es: "Con latitud y longitud a 0 se usa el lugar de los ajustes.", de: "Breiten- und L\xE4ngengrad auf 0 lassen, um den Ort aus den Einstellungen zu verwenden.", "zh-Hant": "\u7DEF\u5EA6\u548C\u7D93\u5EA6\u4FDD\u6301 0 \u5373\u4F7F\u7528\u8A2D\u5B9A\u4E2D\u7684\u5730\u9EDE\u3002", "zh-Hans": "\u7EAC\u5EA6\u548C\u7ECF\u5EA6\u4FDD\u6301\u4E3A 0 \u65F6\u4F7F\u7528\u8BBE\u7F6E\u4E2D\u7684\u5730\u70B9\u3002" }
|
|
461
618
|
}),
|
|
462
|
-
longitude: t.number({ default: 0, min: -180, max: 180, step: 1e-4, unit: "\xB0", advanced: true, label: { en: "Longitude", es: "Longitud" } }),
|
|
463
|
-
placeName: t.string({ advanced: true, placeholder: "Madrid", label: { en: "Place name", es: "Nombre del lugar" }, help: { en: "Empty: the one in Settings.", es: "Vac\xEDo: el de los ajustes." } })
|
|
619
|
+
longitude: t.number({ default: 0, min: -180, max: 180, step: 1e-4, unit: "\xB0", advanced: true, label: { en: "Longitude", es: "Longitud", de: "L\xE4ngengrad", "zh-Hant": "\u7D93\u5EA6", "zh-Hans": "\u7ECF\u5EA6" } }),
|
|
620
|
+
placeName: t.string({ advanced: true, placeholder: "Madrid", label: { en: "Place name", es: "Nombre del lugar", de: "Ortsname", "zh-Hant": "\u5730\u9EDE\u540D\u7A31", "zh-Hans": "\u5730\u70B9\u540D\u79F0" }, help: { en: "Empty: the one in Settings.", es: "Vac\xEDo: el de los ajustes.", de: "Leer: der aus den Einstellungen.", "zh-Hant": "\u7559\u7A7A\uFF1A\u4F7F\u7528\u8A2D\u5B9A\u4E2D\u7684\u5730\u9EDE\u3002", "zh-Hans": "\u7559\u7A7A\uFF1A\u4F7F\u7528\u8BBE\u7F6E\u4E2D\u7684\u5730\u70B9\u3002" } })
|
|
464
621
|
};
|
|
465
622
|
}
|
|
466
623
|
function placeOf(own, user) {
|
|
@@ -688,7 +845,11 @@ export {
|
|
|
688
845
|
DEFAULT_WORKDAY,
|
|
689
846
|
FILTER_HELP,
|
|
690
847
|
FONT_FAMILIES,
|
|
848
|
+
FORMAT_LANGUAGES,
|
|
691
849
|
HttpError,
|
|
850
|
+
LANGUAGES,
|
|
851
|
+
LANGUAGE_IDS,
|
|
852
|
+
PluginError,
|
|
692
853
|
SDK_VERSION,
|
|
693
854
|
SECRET_NOTE,
|
|
694
855
|
THEMES,
|
|
@@ -706,9 +867,12 @@ export {
|
|
|
706
867
|
defineWidget,
|
|
707
868
|
drawEmpty,
|
|
708
869
|
drawMore,
|
|
870
|
+
errorMessage,
|
|
709
871
|
expandPath,
|
|
710
872
|
filterPatterns,
|
|
873
|
+
hanScript,
|
|
711
874
|
isWorkingAt,
|
|
875
|
+
languageById,
|
|
712
876
|
listLayout,
|
|
713
877
|
listOptions,
|
|
714
878
|
localize,
|
|
@@ -717,8 +881,11 @@ export {
|
|
|
717
881
|
minutesOf,
|
|
718
882
|
moreHeight,
|
|
719
883
|
moreLabel,
|
|
884
|
+
parseLocale,
|
|
720
885
|
parseVersion,
|
|
886
|
+
pickLocale,
|
|
721
887
|
placeOf,
|
|
888
|
+
plural,
|
|
722
889
|
retryAtOf,
|
|
723
890
|
risksOf,
|
|
724
891
|
satisfies,
|