@navbytes/vee 0.3.0 → 0.5.0

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
@@ -48,6 +48,10 @@ The examples in this repository import `../vee.ts` because they sit next to the
48
48
  SDK here. Copying one out means running `vee sdk ts` beside it and changing that
49
49
  import to `./vee.ts`.
50
50
 
51
+ For a new plugin, prefer `JSONMenu` over `Menu` — see
52
+ [`examples/json-demo.ts`](examples/json-demo.ts) and the
53
+ [JSON output format](https://vee.navbytes.io/guide/json-output/) docs.
54
+
51
55
  ## Layout
52
56
 
53
57
  ```
package/dist/vee.d.ts CHANGED
@@ -1,4 +1,13 @@
1
1
  export type Color = string;
2
+ /**
3
+ * One presentation of a plugin's menu, in the vocabulary `visibleOn` takes:
4
+ * the menu-bar dropdown, the transient search panel, a detached window, and
5
+ * terminal listings (`vee search`).
6
+ *
7
+ * There is deliberately no `"widget"`: menu rows never reach the widget, which
8
+ * a plugin targets whole with `<vee.surface>`.
9
+ */
10
+ export type Surface = "menu" | "search" | "window" | "cli";
2
11
  export interface ItemOptions {
3
12
  color?: Color;
4
13
  size?: number;
@@ -16,7 +25,11 @@ export interface ItemOptions {
16
25
  params?: string[];
17
26
  terminal?: boolean;
18
27
  refresh?: boolean;
19
- /** Show this line in the dropdown only, never in the menu bar. */
28
+ /**
29
+ * Show this line in the dropdown only, never in the menu bar. On a dropdown
30
+ * row `dropdown: false` is the older spelling of "on no surface at all";
31
+ * `visibleOn` says the same thing precisely, and wins when both are set.
32
+ */
20
33
  dropdown?: boolean;
21
34
  alternate?: boolean;
22
35
  disabled?: boolean;
@@ -64,6 +77,19 @@ export interface ItemOptions {
64
77
  * share the same in-row geometry. Omitted, the accessory sits trailing.
65
78
  */
66
79
  accessory?: "leading" | "trailing";
80
+ /**
81
+ * The surfaces this row exists on → `visibleon=menu,window`. Omitted, the row
82
+ * exists on all of them — targeting only ever subtracts, and it takes the
83
+ * row's whole subtree with it.
84
+ */
85
+ visibleOn?: Surface[];
86
+ /**
87
+ * `false` keeps the row out of every filter query's reach — the search panel,
88
+ * a window's filter field, and `vee search` — while leaving it visible and
89
+ * clickable in an idle listing. A separate axis from `visibleOn`: where a row
90
+ * exists and whether a query can reach it are different questions.
91
+ */
92
+ searchable?: boolean;
67
93
  /** Inline data series → `sparkline=1,2,3`. */
68
94
  sparkline?: number[];
69
95
  /**
@@ -173,6 +199,19 @@ export interface WidgetCardItem {
173
199
  value?: string;
174
200
  symbol?: string;
175
201
  tint?: Color;
202
+ /**
203
+ * Makes this `list`/`board` row a tap target that opens a URL.
204
+ * Scheme-filtered by Vee on parse, exactly like an `href` action's; a blocked
205
+ * URL drops the tap and leaves the row inert, keeping its data.
206
+ */
207
+ url?: string;
208
+ /**
209
+ * Makes this row a tap target that runs a named macOS Shortcut. A row
210
+ * declaring both opens its `url` — the same href-before-shortcut precedence
211
+ * the menu applies. There is deliberately no `shell`: a widget row must not
212
+ * run an arbitrary command without the menu's context.
213
+ */
214
+ shortcut?: string;
176
215
  }
177
216
  export interface WidgetCardAction {
178
217
  kind: WidgetActionKind;
@@ -237,7 +276,9 @@ export interface NodeStyle {
237
276
  /** Grow to fill available width (the only, bounded, width control). */
238
277
  fill?: boolean;
239
278
  }
240
- export type NodeType = "vstack" | "hstack" | "zstack" | "grid" | "text" | "image" | "gauge" | "sparkline" | "spacer" | "divider";
279
+ export type NodeType = "vstack" | "hstack" | "zstack" | "grid" | "text" | "image" | "gauge" | "sparkline" | "chart" | "spacer" | "divider";
280
+ /** The three share-chart shapes, spelled as they are on a menu row. */
281
+ export type ChartNodeKind = "pie" | "donut" | "stackedbar";
241
282
  export interface WidgetNode {
242
283
  type: NodeType;
243
284
  text?: string;
@@ -245,10 +286,16 @@ export interface WidgetNode {
245
286
  symbol?: string;
246
287
  /** `0…1` fill, for a `gauge` node. */
247
288
  value?: number;
248
- /** Series, for a `sparkline` node. */
289
+ /** Series, for a `sparkline` node, or segment magnitudes for a `chart` one. */
249
290
  values?: number[];
250
291
  /** `"linear"` (default) or `"circular"`, for a `gauge` node. */
251
292
  gaugeStyle?: "linear" | "circular";
293
+ /** The shape, for a `chart` node. Unknown kinds drop the leaf. */
294
+ kind?: ChartNodeKind;
295
+ /** Per-segment names, for a `chart` node. May be shorter than `values`. */
296
+ labels?: string[];
297
+ /** Per-segment colors, for a `chart` node. Recolors a prefix; unset segments take the palette. */
298
+ colors?: Color[];
252
299
  /** Cross-axis alignment, for a container. */
253
300
  align?: string;
254
301
  /** Inter-child spacing, for a container. */
@@ -312,6 +359,17 @@ export declare const Node: {
312
359
  } & LeafOpts) => WidgetNode;
313
360
  /** A dependency-free line chart from `values`. */
314
361
  Sparkline: (values: number[], opts?: LeafOpts) => WidgetNode;
362
+ /**
363
+ * A share chart — the same `pie`/`donut`/`stackedbar` a menu row draws, from
364
+ * one series of non-negative values read as shares of a whole. `labels` and
365
+ * `colors` are positional against `values` and may be shorter; an unset
366
+ * segment takes its slot in Vee's eight-color categorical palette. A series
367
+ * longer than eight is folded (not truncated) into a trailing `Other`.
368
+ */
369
+ Chart: (kind: ChartNodeKind, values: number[], opts?: {
370
+ labels?: string[];
371
+ colors?: Color[];
372
+ } & LeafOpts) => WidgetNode;
315
373
  /** Flexible empty space. */
316
374
  Spacer: (opts?: {
317
375
  minLength?: number;
@@ -353,6 +411,10 @@ export interface JSONItemOptions {
353
411
  tooltip?: string;
354
412
  header?: boolean;
355
413
  accessory?: "leading" | "trailing";
414
+ /** The surfaces this item exists on; absent = all of them. */
415
+ visibleOn?: Surface[];
416
+ /** `false` keeps the item out of every filter query, but still browsable. */
417
+ searchable?: boolean;
356
418
  sparkline?: number[];
357
419
  /** Sparkline width in points; `"full"` stretches it to the row's width. */
358
420
  /** @deprecated Use `accessoryWidth`. */
package/dist/vee.js CHANGED
@@ -75,6 +75,9 @@ function encode(options) {
75
75
  push("shortcut", options.shortcut);
76
76
  push("header", options.header);
77
77
  push("accessory", options.accessory);
78
+ if (options.visibleOn !== undefined)
79
+ push("visibleon", options.visibleOn.join(","));
80
+ push("searchable", options.searchable);
78
81
  if (options.sparkline !== undefined)
79
82
  push("sparkline", options.sparkline.map(String).join(","));
80
83
  push("sparklinecolor", options.sparklineColor);
@@ -205,6 +208,9 @@ function orderNode(n) {
205
208
  put("value", n.value);
206
209
  put("values", n.values);
207
210
  put("gauge_style", n.gaugeStyle);
211
+ put("kind", n.kind);
212
+ put("labels", n.labels);
213
+ put("colors", n.colors);
208
214
  put("align", n.align);
209
215
  put("spacing", n.spacing);
210
216
  put("columns", n.columns);
@@ -261,6 +267,14 @@ export const Node = {
261
267
  Gauge: (value, opts = {}) => ({ type: "gauge", value, ...opts }),
262
268
  /** A dependency-free line chart from `values`. */
263
269
  Sparkline: (values, opts = {}) => ({ type: "sparkline", values, ...opts }),
270
+ /**
271
+ * A share chart — the same `pie`/`donut`/`stackedbar` a menu row draws, from
272
+ * one series of non-negative values read as shares of a whole. `labels` and
273
+ * `colors` are positional against `values` and may be shorter; an unset
274
+ * segment takes its slot in Vee's eight-color categorical palette. A series
275
+ * longer than eight is folded (not truncated) into a trailing `Other`.
276
+ */
277
+ Chart: (kind, values, opts = {}) => ({ type: "chart", kind, values, ...opts }),
264
278
  /** Flexible empty space. */
265
279
  Spacer: (opts = {}) => ({ type: "spacer", ...opts }),
266
280
  /** A hairline divider. */
@@ -290,6 +304,7 @@ export function Board(options) {
290
304
  const JSON_ITEM_KEYS = [
291
305
  "text", "separator", "color", "size", "href", "shell", "params", "terminal",
292
306
  "refresh", "sfimage", "disabled", "checked", "tooltip", "header", "accessory",
307
+ "visibleOn", "searchable",
293
308
  "sparkline", "sparklineWidth", "sparklineHeight", "sparklineColor",
294
309
  "accessoryWidth", "accessoryHeight",
295
310
  "toggle", "slider", "progress", "progressTrackColor", "progressWidth",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navbytes/vee",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "Typed builders for authoring Vee plugins — the xbar/SwiftBar text protocol, the structured-JSON menu format, and widget cards.",
6
6
  "keywords": [