@synopackageland/ui 0.8.0 → 0.8.1

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 CHANGED
@@ -361,6 +361,10 @@ DSM-style application building blocks:
361
361
  `Tabs` and `SectionTabs` move a raised selection notch in 120ms. Selected labels
362
362
  are blue; main labels are bold 14px and section labels bold 13px. `Tabs` fades its
363
363
  new panel in over 160ms, with immediate selection and keyboard response.
364
+ A strip narrower than its tabs keeps one row and scrolls sideways (trackpad,
365
+ touch, Shift+wheel or keyboard focus) with no visible scrollbar; it never
366
+ scrolls vertically. In a grid or flex parent, give the strip's track or item
367
+ `min-width: 0` (`minmax(0, 1fr)`) so it can be narrower than its tabs.
364
368
  `SectionTabs` can also render content using named `panel-${value}` slots:
365
369
 
366
370
  ```vue
@@ -592,6 +596,12 @@ document, set a distinct `app.config.idPrefix` for each app.
592
596
  </ConfigProvider>
593
597
  ```
594
598
 
599
+ FilePicker sizes (`max {size}` and each file row) follow DSM: a 1024 base
600
+ with `B`, `KB`, `MB`, `GB`, `TB` labels and at most one decimal, so
601
+ `:max-size="16 * 1024 ** 3"` reads `max 16 GB`, as DSM File Station would show
602
+ it. The same rule is exported as `formatFileSize(bytes)`; use it, or the same
603
+ DSM labels, in application text that repeats a limit, rather than `GiB`/`MiB`.
604
+
595
605
  FilePicker retains browser `File[]` semantics. Built-in `locale` values are
596
606
  `en`, `zh-TW`, `zh-CN`, `ja`, `ko`, `de`, `fr`, `es`, `it`; an explicit picker
597
607
  locale overrides ConfigProvider. Its `text` accepts partial overrides of
package/dist/cli.js CHANGED
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import { readFile as S, mkdtemp as E, mkdir as M, writeFile as D, rm as R } from "node:fs/promises";
3
- import { createServer as F } from "node:http";
4
- import { tmpdir as H } from "node:os";
5
- import { join as g, win32 as U, posix as j } from "node:path";
6
- import { spawn as I } from "node:child_process";
7
- import { existsSync as f } from "node:fs";
8
- import { setTimeout as L } from "node:timers/promises";
9
- import { synoJsonAiPrompt as T, synoJsonSchema as W, describeSynoJsonComponent as _, closestSynoJsonComponent as V, listSynoJsonComponents as B, validateSynoJsonSpec as G } from "./json.js";
10
- const K = [
2
+ import { readFile as b, mkdtemp as M, mkdir as D, writeFile as R, rm as F } from "node:fs/promises";
3
+ import { createServer as H } from "node:http";
4
+ import { tmpdir as U } from "node:os";
5
+ import { join as f, win32 as I, posix as C } from "node:path";
6
+ import { spawn as L } from "node:child_process";
7
+ import { existsSync as y } from "node:fs";
8
+ import { setTimeout as T } from "node:timers/promises";
9
+ import { synoJsonAiPrompt as W, synoJsonSchema as _, describeSynoJsonComponent as V, closestSynoJsonComponent as B, listSynoJsonComponents as G, validateSynoJsonSpec as K } from "./json.js";
10
+ const X = [
11
11
  "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
12
12
  "/Applications/Chromium.app/Contents/MacOS/Chromium"
13
- ], X = ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"], z = ["ProgramFiles", "ProgramFiles(x86)", "LOCALAPPDATA"];
14
- function Q(e = process.env, t = process.platform, n = f) {
15
- return e.CHROME ? e.CHROME : (t === "darwin" ? K : t === "win32" ? z.flatMap((r) => e[r] ? [U.join(e[r], "Google", "Chrome", "Application", "chrome.exe")] : []) : (e.PATH ?? "").split(j.delimiter).filter(Boolean).flatMap((r) => X.map((o) => j.join(r, o)))).find(n);
13
+ ], z = ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"], Q = ["ProgramFiles", "ProgramFiles(x86)", "LOCALAPPDATA"];
14
+ function Y(e = process.env, t = process.platform, n = y) {
15
+ return e.CHROME ? e.CHROME : (t === "darwin" ? X : t === "win32" ? Q.flatMap((r) => e[r] ? [I.join(e[r], "Google", "Chrome", "Application", "chrome.exe")] : []) : (e.PATH ?? "").split(C.delimiter).filter(Boolean).flatMap((r) => z.map((o) => C.join(r, o)))).find(n);
16
16
  }
17
- function Y(e, t = process.env) {
17
+ function Z(e, t = process.env, { scrollbars: n = !1 } = {}) {
18
18
  return [
19
19
  "--headless=new",
20
20
  "--disable-gpu",
21
- "--hide-scrollbars",
21
+ ...n ? [] : ["--hide-scrollbars"],
22
22
  "--no-first-run",
23
23
  // Repaint whole tiles: partial raster redraws only the invalidated rect, and
24
24
  // the anti-aliased edges it touches can come out one colour level apart, so
@@ -32,59 +32,59 @@ function Y(e, t = process.env) {
32
32
  "about:blank"
33
33
  ];
34
34
  }
35
- async function Z(e) {
36
- const t = Q();
37
- if (!t) throw new Error("Chrome or Chromium was not found; set CHROME to its executable path.");
38
- const n = I(t, Y(e), { stdio: ["ignore", "ignore", "pipe"] });
39
- let s, r = "";
40
- n.once("error", (a) => {
41
- s = a;
42
- }), n.stderr.on("data", (a) => {
43
- r = (r + a).slice(-4e3);
35
+ async function q(e, t = {}) {
36
+ const n = Y();
37
+ if (!n) throw new Error("Chrome or Chromium was not found; set CHROME to its executable path.");
38
+ const s = L(n, Z(e, process.env, t), { stdio: ["ignore", "ignore", "pipe"] });
39
+ let r, o = "";
40
+ s.once("error", (a) => {
41
+ r = a;
42
+ }), s.stderr.on("data", (a) => {
43
+ o = (o + a).slice(-4e3);
44
44
  });
45
- const o = g(e, "DevToolsActivePort");
46
- for (let a = 0; a < 100 && !f(o) && !s && n.exitCode === null; a++) await L(100);
47
- if (!f(o))
48
- throw n.kill(), new Error(`Chrome failed to start: ${s?.message ?? (r || "no debugging port within 10 seconds")}`);
49
- const [i] = (await S(o, "utf8")).split(`
50
- `), c = await (await fetch(`http://127.0.0.1:${i}/json/new?about:blank`, { method: "PUT" })).json(), d = new WebSocket(c.webSocketDebuggerUrl);
45
+ const i = f(e, "DevToolsActivePort");
46
+ for (let a = 0; a < 100 && !y(i) && !r && s.exitCode === null; a++) await T(100);
47
+ if (!y(i))
48
+ throw s.kill(), new Error(`Chrome failed to start: ${r?.message ?? (o || "no debugging port within 10 seconds")}`);
49
+ const [c] = (await b(i, "utf8")).split(`
50
+ `), l = await (await fetch(`http://127.0.0.1:${c}/json/new?about:blank`, { method: "PUT" })).json(), d = new WebSocket(l.webSocketDebuggerUrl);
51
51
  await new Promise((a, u) => {
52
52
  d.onopen = a, d.onerror = u;
53
53
  });
54
- let l = 1;
55
- const m = /* @__PURE__ */ new Map();
54
+ let m = 1;
55
+ const w = /* @__PURE__ */ new Map();
56
56
  d.onmessage = (a) => {
57
57
  const u = JSON.parse(String(a.data));
58
- m.get(u.id)?.(u), m.delete(u.id);
58
+ w.get(u.id)?.(u), w.delete(u.id);
59
59
  };
60
- const b = (a, u = {}) => new Promise((A, P) => {
61
- const O = l++;
62
- m.set(O, (w) => w.error ? P(new Error(w.error.message)) : A(w.result)), d.send(JSON.stringify({ id: O, method: a, params: u }));
60
+ const O = (a, u = {}) => new Promise((P, E) => {
61
+ const j = m++;
62
+ w.set(j, (g) => g.error ? E(new Error(g.error.message)) : P(g.result)), d.send(JSON.stringify({ id: j, method: a, params: u }));
63
63
  });
64
- await b("Emulation.setDeviceMetricsOverride", { width: 1100, height: 720, deviceScaleFactor: 1, mobile: !1 });
65
- const N = new Promise((a) => n.once("exit", a));
66
- return { send: b, close: () => (d.close(), n.kill(), N) };
64
+ await O("Emulation.setDeviceMetricsOverride", { width: 1100, height: 720, deviceScaleFactor: 1, mobile: !1 });
65
+ const A = new Promise((a) => s.once("exit", a));
66
+ return { send: O, close: () => (d.close(), s.kill(), A) };
67
67
  }
68
- const q = `<!doctype html>
68
+ const ee = `<!doctype html>
69
69
  <html><head><meta charset="utf-8"><link rel="stylesheet" href="/theme.css">
70
70
  <style>html, body, #app { margin: 0; height: 100%; }</style></head>
71
71
  <body><div id="app"></div><script type="module" src="/preview.js"><\/script></body></html>`;
72
- function ee(e, t) {
72
+ function te(e, t) {
73
73
  const n = {
74
74
  "/theme.css": [new URL("theme.css", e), "text/css"],
75
75
  "/preview.js": [new URL("json-preview/preview.js", e), "text/javascript"]
76
- }, s = F(async (r, o) => {
76
+ }, s = H(async (r, o) => {
77
77
  const i = new URL(r.url ?? "/", "http://localhost").pathname;
78
78
  try {
79
- const [c, d] = i === "/" ? [q, "text/html"] : i === "/config.json" ? [t, "application/json"] : [await S(n[i][0]), n[i][1]];
80
- o.writeHead(200, { "content-type": d }).end(c);
79
+ const [c, l] = i === "/" ? [ee, "text/html"] : i === "/config.json" ? [t, "application/json"] : [await b(n[i][0]), n[i][1]];
80
+ o.writeHead(200, { "content-type": l }).end(c);
81
81
  } catch {
82
82
  o.writeHead(404).end();
83
83
  }
84
84
  });
85
85
  return new Promise((r) => s.listen(0, "127.0.0.1", () => r(s)));
86
86
  }
87
- async function te(e, t) {
87
+ async function ne(e, t) {
88
88
  await e.send("Page.navigate", { url: t });
89
89
  const { result: n, exceptionDetails: s } = await e.send(
90
90
  "Runtime.evaluate",
@@ -103,21 +103,21 @@ async function te(e, t) {
103
103
  if (s) throw new Error(`Rendering failed: ${s.exception?.description ?? "unknown error"}`);
104
104
  return n.value;
105
105
  }
106
- function ne(e) {
106
+ function se(e) {
107
107
  return async (t) => {
108
- const n = await ee(e, JSON.stringify({ spec: t.spec, state: t.state, messages: t.messages })), s = `http://127.0.0.1:${n.address().port}/`, r = await E(g(H(), "syno-pkg-land-ui-render-"));
108
+ const n = await te(e, JSON.stringify({ spec: t.spec, state: t.state, messages: t.messages })), s = `http://127.0.0.1:${n.address().port}/`, r = await M(f(U(), "syno-pkg-land-ui-render-"));
109
109
  let o;
110
110
  try {
111
- o = await Z(r), await M(t.out, { recursive: !0 });
111
+ o = await q(r), await D(t.out, { recursive: !0 });
112
112
  const i = [];
113
113
  for (const c of t.widths) {
114
114
  await o.send("Emulation.setDeviceMetricsOverride", { width: c, height: t.height, deviceScaleFactor: 1, mobile: !1 });
115
- const d = await te(o, `${s}?width=${c}`), { data: l } = await o.send("Page.captureScreenshot", { format: "png" }), m = g(t.out, `${t.name}-${c}.png`);
116
- await D(m, Buffer.from(l, "base64")), i.push({ width: c, screenshot: m, issues: d });
115
+ const l = await ne(o, `${s}?width=${c}`), { data: d } = await o.send("Page.captureScreenshot", { format: "png" }), m = f(t.out, `${t.name}-${c}.png`);
116
+ await R(m, Buffer.from(d, "base64")), i.push({ width: c, screenshot: m, issues: l });
117
117
  }
118
118
  return i;
119
119
  } finally {
120
- await o?.close(), n.close(), await R(r, { recursive: !0, force: !0, maxRetries: 12, retryDelay: 250 });
120
+ await o?.close(), n.close(), await F(r, { recursive: !0, force: !0, maxRetries: 12, retryDelay: 250 });
121
121
  }
122
122
  };
123
123
  }
@@ -140,8 +140,8 @@ Commands:
140
140
  --widths 390,640,960,1350 Viewport widths: phone, narrow window, DSM window, wide
141
141
  --height <px> Viewport height (default 800)
142
142
  --state, --messages As for validate; messages also back $computed t()
143
- `, se = /* @__PURE__ */ new Set(["actions", "functions", "state", "messages", "out", "widths", "height", "wide"]);
144
- function re(e) {
143
+ `, re = /* @__PURE__ */ new Set(["actions", "functions", "state", "messages", "out", "widths", "height", "wide"]);
144
+ function oe(e) {
145
145
  const t = [], n = {};
146
146
  for (let s = 0; s < e.length; s++) {
147
147
  const r = e[s];
@@ -150,19 +150,19 @@ function re(e) {
150
150
  continue;
151
151
  }
152
152
  const [o, i] = r.slice(2).split("=", 2);
153
- n[o] = i ?? (se.has(o) && e[s + 1] !== void 0 ? e[++s] : !0);
153
+ n[o] = i ?? (re.has(o) && e[s + 1] !== void 0 ? e[++s] : !0);
154
154
  }
155
155
  return { positional: t, flags: n };
156
156
  }
157
- const y = (e) => typeof e == "string" ? e.split(",").map((t) => t.trim()).filter(Boolean) : void 0;
158
- function oe(e) {
157
+ const v = (e) => typeof e == "string" ? e.split(",").map((t) => t.trim()).filter(Boolean) : void 0;
158
+ function ie(e) {
159
159
  return ` ${e.severity} ${e.code} ${e.path || "/"}: ${e.message}${e.hint ? `
160
160
  hint: ${e.hint}` : ""}
161
161
  `;
162
162
  }
163
163
  class h extends Error {
164
164
  }
165
- async function C(e, t) {
165
+ async function k(e, t) {
166
166
  try {
167
167
  return await e.readFile(t);
168
168
  } catch (n) {
@@ -170,61 +170,61 @@ async function C(e, t) {
170
170
  }
171
171
  }
172
172
  async function $(e, t) {
173
- const n = await C(e, t);
173
+ const n = await k(e, t);
174
174
  try {
175
175
  return JSON.parse(n);
176
176
  } catch (s) {
177
177
  throw new h(`${t} is not valid JSON: ${s instanceof Error ? s.message : String(s)}`);
178
178
  }
179
179
  }
180
- async function k(e, t, n) {
181
- const s = await C(e, t);
180
+ async function x(e, t, n) {
181
+ const s = await k(e, t);
182
182
  let r;
183
183
  try {
184
184
  r = JSON.parse(s);
185
185
  } catch (o) {
186
186
  return { valid: !1, errors: [{ severity: "error", code: "invalid_json", path: "", message: o instanceof Error ? o.message : String(o), hint: "Return a single JSON object without comments or trailing commas." }], warnings: [] };
187
187
  }
188
- return G(r, n);
188
+ return K(r, n);
189
189
  }
190
- async function x(e, t) {
190
+ async function J(e, t) {
191
191
  return {
192
- actions: y(t.actions),
193
- functions: y(t.functions),
192
+ actions: v(t.actions),
193
+ functions: v(t.functions),
194
194
  state: typeof t.state == "string" ? await $(e, t.state) : void 0,
195
195
  messages: typeof t.messages == "string" ? await $(e, t.messages) : void 0
196
196
  };
197
197
  }
198
- const J = (e, t) => e.errors.length > 0 || !!t.strict && e.warnings.length > 0;
199
- function v(e) {
198
+ const N = (e, t) => e.errors.length > 0 || !!t.strict && e.warnings.length > 0;
199
+ function S(e) {
200
200
  return e.errors.length || e.warnings.length ? `${e.file}: ${e.errors.length} error(s), ${e.warnings.length} warning(s)
201
- ${[...e.errors, ...e.warnings].map(oe).join("")}` : `${e.file}: OK
201
+ ${[...e.errors, ...e.warnings].map(ie).join("")}` : `${e.file}: OK
202
202
  `;
203
203
  }
204
- async function ie(e, { positional: t, flags: n }) {
204
+ async function ae(e, { positional: t, flags: n }) {
205
205
  if (!t.length)
206
206
  return e.stderr(p), 2;
207
- const s = await x(e, n), r = [];
208
- for (const o of t) r.push({ file: o, ...await k(e, o, s) });
207
+ const s = await J(e, n), r = [];
208
+ for (const o of t) r.push({ file: o, ...await x(e, o, s) });
209
209
  return e.stdout(n.json ? JSON.stringify(r, null, 2) + `
210
- ` : r.map(v).join("")), r.some((o) => J(o, n)) ? 1 : 0;
210
+ ` : r.map(S).join("")), r.some((o) => N(o, n)) ? 1 : 0;
211
211
  }
212
- const ae = [390, 640, 960, 1350];
213
- async function ce(e, { positional: [t], flags: n }) {
212
+ const ce = [390, 640, 960, 1350];
213
+ async function de(e, { positional: [t], flags: n }) {
214
214
  if (!t)
215
215
  return e.stderr(p), 2;
216
216
  if (!e.render)
217
217
  return e.stderr(`render needs a local Chrome or Chromium (set CHROME to its path) and Node 22 or newer.
218
218
  `), 2;
219
- const s = await x(e, n), r = { file: t, ...await k(e, t, s) };
220
- if (J(r, n))
219
+ const s = await J(e, n), r = { file: t, ...await x(e, t, s) };
220
+ if (N(r, n))
221
221
  return e.stdout(n.json ? JSON.stringify({ file: t, validation: r, renders: [] }, null, 2) + `
222
- ` : v(r)), 1;
222
+ ` : S(r)), 1;
223
223
  const o = await e.render({
224
224
  spec: await $(e, t),
225
225
  state: s.state,
226
226
  messages: s.messages,
227
- widths: y(n.widths)?.map(Number) ?? ae,
227
+ widths: v(n.widths)?.map(Number) ?? ce,
228
228
  height: typeof n.height == "string" ? Number(n.height) : 800,
229
229
  out: typeof n.out == "string" ? n.out : "syno-pkg-land-ui-render",
230
230
  name: t.split(/[\\/]/).pop().replace(/\.json$/i, "")
@@ -234,58 +234,58 @@ async function ce(e, { positional: [t], flags: n }) {
234
234
  if (n.json) e.stdout(JSON.stringify({ file: t, validation: r, renders: o }, null, 2) + `
235
235
  `);
236
236
  else {
237
- e.stdout(r.warnings.length ? v(r) : "");
238
- for (const { width: i, screenshot: c, issues: d } of o)
239
- e.stdout(`${t} @${i}px: ${d.length ? `${d.length} layout issue(s)` : "OK"} ${c}
240
- ` + d.map((l) => ` ${l.kind} ${l.key ?? "(outside the spec)"}: ${l.detail}
237
+ e.stdout(r.warnings.length ? S(r) : "");
238
+ for (const { width: i, screenshot: c, issues: l } of o)
239
+ e.stdout(`${t} @${i}px: ${l.length ? `${l.length} layout issue(s)` : "OK"} ${c}
240
+ ` + l.map((d) => ` ${d.kind} ${d.key ?? "(outside the spec)"}: ${d.detail}
241
241
  `).join(""));
242
242
  }
243
243
  return o.some((i) => i.issues.length) ? 1 : 0;
244
244
  }
245
- async function de(e, t) {
245
+ async function le(e, t) {
246
246
  try {
247
- return await le(re(e), t);
247
+ return await ue(oe(e), t);
248
248
  } catch (n) {
249
249
  if (!(n instanceof h)) throw n;
250
250
  return t.stderr(`${n.message}
251
251
  `), 2;
252
252
  }
253
253
  }
254
- async function le(e, t) {
254
+ async function ue(e, t) {
255
255
  if (e.flags.help === !0)
256
256
  return t.stdout(p), 0;
257
257
  const [n, ...s] = e.positional, r = e.flags.json === !0;
258
258
  switch (n) {
259
259
  case "catalog": {
260
- const o = B();
260
+ const o = G();
261
261
  return t.stdout(r ? JSON.stringify({ components: o }, null, 2) + `
262
262
  ` : o.map((i) => `${i.name}${i.required.length ? ` (${i.required.join(", ")})` : ""}: ${i.description}
263
263
  `).join("")), 0;
264
264
  }
265
265
  case "describe": {
266
- const o = s[0] ?? "", i = _(o);
266
+ const o = s[0] ?? "", i = V(o);
267
267
  if (!i) {
268
- const c = V(o);
268
+ const c = B(o);
269
269
  return t.stderr(`Unknown component ${JSON.stringify(o)}.${c ? ` Did you mean "${c}"?` : ""} Run "syno-pkg-land-ui catalog".
270
270
  `), 2;
271
271
  }
272
272
  return t.stdout(r ? JSON.stringify(i, null, 2) + `
273
- ` : ue(i)), 0;
273
+ ` : me(i)), 0;
274
274
  }
275
275
  case "schema":
276
- return t.stdout(JSON.stringify(W(), null, 2) + `
276
+ return t.stdout(JSON.stringify(_(), null, 2) + `
277
277
  `), 0;
278
278
  case "prompt":
279
- return t.stdout(T()), 0;
279
+ return t.stdout(W()), 0;
280
280
  case "validate":
281
- return ie(t, { positional: s, flags: e.flags });
281
+ return ae(t, { positional: s, flags: e.flags });
282
282
  case "render":
283
- return ce(t, { positional: s, flags: e.flags });
283
+ return de(t, { positional: s, flags: e.flags });
284
284
  default:
285
285
  return t.stderr(p), 2;
286
286
  }
287
287
  }
288
- function ue(e) {
288
+ function me(e) {
289
289
  const t = Object.entries(e.props).map(([n, s]) => ` ${n}${s.required ? "" : "?"}: ${JSON.stringify(s.schema)}
290
290
  `).join("");
291
291
  return `${e.name}: ${e.description}
@@ -296,10 +296,10 @@ events: ${e.events.join(", ") || "(none)"}
296
296
  example: ${JSON.stringify(e.example)}
297
297
  `;
298
298
  }
299
- process.exitCode = await de(process.argv.slice(2), {
299
+ process.exitCode = await le(process.argv.slice(2), {
300
300
  stdout: (e) => process.stdout.write(e),
301
301
  stderr: (e) => process.stderr.write(e),
302
- readFile: (e) => S(e, "utf8"),
302
+ readFile: (e) => b(e, "utf8"),
303
303
  // The DevTools connection uses the WebSocket global of Node 22 and newer.
304
- render: typeof WebSocket == "function" ? ne(import.meta.url) : void 0
304
+ render: typeof WebSocket == "function" ? se(import.meta.url) : void 0
305
305
  });
package/dist/index.d.ts CHANGED
@@ -94,6 +94,7 @@ export { default as FormActions } from './components/composite/form-actions/Form
94
94
  export { default as RepeatRows } from './components/composite/repeat-rows/RepeatRows.vue';
95
95
  export { default as RepeatRow } from './components/composite/repeat-rows/RepeatRow.vue';
96
96
  export { default as FieldCell } from './components/composite/repeat-rows/FieldCell.vue';
97
+ export { formatFileSize } from './lib/fileSize';
97
98
  export { resolveFieldWidth } from './lib/fieldWidth';
98
99
  export type { FieldWidth } from './lib/fieldWidth';
99
100
  export { default as SettingsSection } from './components/composite/settings-section/SettingsSection.vue';