glimpse-sdk 0.7.0 → 0.9.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/LICENSE CHANGED
@@ -1,21 +1,28 @@
1
- MIT License
1
+ BSD 3-Clause License
2
2
 
3
- Copyright (c) 2026 Alex Oleshkevich
3
+ Copyright (c) 2026, Alex Oleshkevich
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
11
7
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
14
10
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/PROTOCOL.md ADDED
@@ -0,0 +1,536 @@
1
+ # Applet protocol
2
+
3
+ The panel is the host. An applet is a child process. They exchange UTF-8 NDJSON on the
4
+ child's stdin and stdout: one JSON object per line, separated by `\n`. The host also
5
+ accepts a trailing `\r`. Stderr is not part of the protocol; the panel logs it, at most 50
6
+ lines a second, each line up to 4 KiB.
7
+
8
+ Each line is at most 1 MiB (1,048,576 bytes), not counting the newline. A longer line is
9
+ rejected. A single JSON value nests at most 128 levels; a deeper tree is built across
10
+ commits. The operation value `op` is a closed set: an unknown `op`, or a line that is not
11
+ JSON, does not decode. A message with an unknown `t` is ignored.
12
+
13
+ The applet speaks first. The host does not send anything until it has read `hello`.
14
+
15
+ The only version is `1`, carried as `v` on both hellos.
16
+
17
+ Object keys added by a newer peer are ignored. A commit is applied as a whole batch or
18
+ not at all: if any operation in the batch is rejected, the tree does not change. The host
19
+ then stops that applet. The caps below are what the validator enforces, except the line
20
+ rate, which the host counts itself: past the cap it stops reading until the next second,
21
+ so the applet blocks on its pipe. More than 5 `hello`s within any 10 seconds stops the applet
22
+ with the reason `too many hellos`, and it restarts like any stopped applet.
23
+
24
+ ## Host to applet
25
+
26
+ Every host message is an object with a `t` tag.
27
+
28
+ ### `hello`
29
+
30
+ Sent in answer to the applet's `hello`, and again after the applet says `hello` on a
31
+ reload.
32
+
33
+ | Field | Type | Meaning |
34
+ | --- | --- | --- |
35
+ | `v` | number | `1` |
36
+ | `name` | string | This instance's name |
37
+ | `state` | string | Absolute path to the applet's persistent state directory, owned by the applet and mode 0700 |
38
+ | `options` | object | The instance's options, a JSON object |
39
+ | `placement` | placement | Where this instance is drawn |
40
+
41
+ ### `options`
42
+
43
+ Sent when the instance's options change. The process is not restarted.
44
+
45
+ | Field | Type |
46
+ | --- | --- |
47
+ | `options` | object |
48
+
49
+ ### `placement`
50
+
51
+ Sent when the bar's placement changes and the process stays up.
52
+
53
+ | Field | Type |
54
+ | --- | --- |
55
+ | `placement` | placement |
56
+
57
+ A placement object:
58
+
59
+ | Field | Type | Values |
60
+ | --- | --- | --- |
61
+ | `output` | string or `null` | Connector name, such as `"DP-2"`. `null` when the bar has none |
62
+ | `position` | string | `top`, `bottom`, `left`, `right` — which edge the bar sits on |
63
+ | `orientation` | string | `horizontal`, `vertical` — how the bar lays out |
64
+ | `zone` | string | `left`, `center`, `right` |
65
+ | `size` | number | The bar's thickness, in logical pixels |
66
+
67
+ ### `event`
68
+
69
+ A subscribed handler fired.
70
+
71
+ | Field | Type | Meaning |
72
+ | --- | --- | --- |
73
+ | `id` | number | The element id |
74
+ | `name` | string | The handler name, below |
75
+ | `args` | array | The handler's arguments, in order. `[]` when it takes none |
76
+ | `seq` | number or `null` | A number on `onChange` and `onToggle`, otherwise `null` |
77
+
78
+ `seq` is always present. It is a number only for `onChange` and `onToggle`. The applet copies that
79
+ number onto the next `set` of the same element when the set confirms the edited value.
80
+ A `set` with no `seq` is a deliberate replacement and is stored as sent. The host keeps
81
+ a newer local edit on screen when a later `set` of `value` carries an older `seq`; the
82
+ stored tree still records that set.
83
+
84
+ | Handler | Elements | `args` |
85
+ | --- | --- | --- |
86
+ | `onPress` | indicator | `[button]` — pointer button code: `1` left, `2` middle, `3` right, otherwise the code as reported |
87
+ | `onScroll` | indicator | `[dx, dy]` — scroll deltas, numbers |
88
+ | `onActivate` | row | `[]` |
89
+ | `onToggle` | switchrow, switch | `[active]` — boolean. `seq` is a number |
90
+ | `onChange` | fader, scale | `[value]` — number. `seq` is a number |
91
+ | `onMute` | fader | `[]` |
92
+ | `onChange` | entry | `[value]` — string. `seq` is a number |
93
+ | `onSubmit` | entry | `[value]` — string |
94
+ | `onClick` | button | `[]` |
95
+
96
+ A handler prop on an element is a boolean. `"onPress": true` subscribes. A missing or
97
+ `false` handler does not.
98
+
99
+ ### `popover`
100
+
101
+ | Field | Type | Meaning |
102
+ | --- | --- | --- |
103
+ | `open` | boolean | Whether this instance's popover is showing |
104
+
105
+ ## Applet to host
106
+
107
+ Every applet message is an object with a `t` tag.
108
+
109
+ ### `hello`
110
+
111
+ | Field | Type |
112
+ | --- | --- |
113
+ | `v` | number, `1` |
114
+
115
+ The first message on stdout. The host answers with its own `hello`. A later `hello` from
116
+ the same process starts a new generation and an empty tree.
117
+
118
+ ### `commit`
119
+
120
+ | Field | Type |
121
+ | --- | --- |
122
+ | `ops` | array of operations |
123
+
124
+ Operations are applied in order to a copy of the tree. Ids, cycles, the parent table,
125
+ the node cap and the child cap are checked before the copy replaces the live tree.
126
+
127
+ ### `notify`
128
+
129
+ | Field | Type | Default |
130
+ | --- | --- | --- |
131
+ | `summary` | string | required |
132
+ | `body` | string | `""` |
133
+ | `icon` | string or absent | absent |
134
+ | `urgency` | `low`, `normal`, `critical` | `normal` |
135
+
136
+ `copy`, `open-uri`, `session` and `close-popover` are honored only within two seconds of
137
+ a press, click, activation or submit. `copy`, `open-uri` and `session` each use up that
138
+ gesture; `close-popover` does not. A scroll is not a gesture.
139
+
140
+ ### `copy`
141
+
142
+ | Field | Type |
143
+ | --- | --- |
144
+ | `text` | string |
145
+
146
+ ### `open-uri`
147
+
148
+ | Field | Type |
149
+ | --- | --- |
150
+ | `uri` | string |
151
+
152
+ Only `http`, `https` and `mailto` URIs of at most 2,048 bytes are opened; any other is
153
+ dropped.
154
+
155
+ ### `session`
156
+
157
+ | Field | Type |
158
+ | --- | --- |
159
+ | `action` | `lock`, `suspend`, `hibernate`, `log-out`, `reboot`, `power-off` |
160
+
161
+ ### `close-popover`
162
+
163
+ No fields. `{"t":"close-popover"}`.
164
+
165
+ ## Operations
166
+
167
+ An operation is an object with an `op` tag. Ids are integers the applet chooses. `0` is
168
+ the root and is never an element id. An id is unique for as long as its element exists.
169
+
170
+ `before` is required. `null` appends. A number is the sibling to insert in front of, and
171
+ that sibling must already be a child of `parent`.
172
+
173
+ ### `insert`
174
+
175
+ ```json
176
+ {"op":"insert","parent":0,"before":null,"node":{"id":1,"type":"indicator","props":{},"children":[]}}
177
+ ```
178
+
179
+ | Field | Type |
180
+ | --- | --- |
181
+ | `parent` | number |
182
+ | `before` | number or `null` |
183
+ | `node` | element, with nested `children` |
184
+
185
+ `node` is `{id, type, props, children}`. `props` defaults to `{}` and `children` to
186
+ `[]`. The whole subtree is new ids. Text of a `label`, `button` or `progress` is the
187
+ `text` prop, not a child node. The same is true of an indicator's label.
188
+
189
+ ### `move`
190
+
191
+ ```json
192
+ {"op":"move","parent":2,"id":5,"before":3}
193
+ ```
194
+
195
+ Takes `id` off its current parent and inserts it under `parent`, before `before`.
196
+ A move under `id` itself, or under one of its descendants, is a cycle and rejects the
197
+ batch. Reordering is a move whose `parent` is already the parent.
198
+
199
+ ### `remove`
200
+
201
+ ```json
202
+ {"op":"remove","parent":1,"id":7}
203
+ ```
204
+
205
+ `id` must be a child of `parent`. The element and every descendant are deleted.
206
+
207
+ ### `set`
208
+
209
+ ```json
210
+ {"op":"set","id":3,"props":{"title":"Sequenced"},"seq":4}
211
+ ```
212
+
213
+ | Field | Type | Default |
214
+ | --- | --- | --- |
215
+ | `id` | number | required |
216
+ | `props` | object | required |
217
+ | `seq` | number or absent | absent |
218
+
219
+ `props` is a merge, not a replacement. A value of `null` deletes that key. Any other
220
+ key keeps its previous value. After the merge the element is derived again. The element
221
+ type does not change. When `seq` is present it is stored on the element; when it is
222
+ absent the stored seq is cleared.
223
+
224
+ A key the element does not take, or whose value has the wrong type, is dropped and not
225
+ stored, and the other keys still apply. A number that is not finite is the same kind of
226
+ drop. JSON itself cannot carry `NaN` or infinity; a non-finite number is still
227
+ rejected if one is presented to the decoder.
228
+
229
+ ## Parent table
230
+
231
+ The root holds `indicator` and `popover` elements. The panel shows the first `popover`,
232
+ and in it the first `hero` and the first `footer`.
233
+
234
+ | Parent | Children |
235
+ | --- | --- |
236
+ | root | `indicator`, `popover` |
237
+ | `popover` | `hero`, `footer`, and any body element |
238
+ | `section` | body elements except `section` |
239
+ | `box` | body elements except `section` |
240
+ | `footer` | `button`, `row`, `label`, `box` |
241
+ | anything else | nothing |
242
+
243
+ Body elements are `section`, `row`, `switchrow`, `fader`, `entry`, `placeholder`, `box`,
244
+ `label`, `image`, `button`, `switch`, `scale`, `spinner`, `progress`, `separator` and
245
+ `unsupported`.
246
+
247
+ An unknown `type` is `unsupported`. Its name is the type string after text cleaning,
248
+ capped at 64 characters. Markup in that name is kept literal.
249
+
250
+ A child on a leaf is rejected, as are a `section` inside a `section` or a `box` and any
251
+ pair the table does not list.
252
+
253
+ ## Elements
254
+
255
+ `type` is one of the lowercase names below. Props use camelCase. Every element takes
256
+ `className`, one class from this list, or the key is dropped:
257
+
258
+ `dim-label`, `caption`, `heading`, `title-1`, `title-2`, `title-3`, `title-4`,
259
+ `numeric`, `accent`, `success`, `warning`, `error`, `flat`, `pill`, `circular`.
260
+
261
+ There is no applet CSS.
262
+
263
+ Unless a row below says otherwise:
264
+
265
+ - Strings that are labels, titles, tooltips, subtitles, descriptions, counts or
266
+ placeholders go through text cleaning and a cap of 256 characters. Cleaning drops
267
+ control characters and bidi overrides, folds whitespace, trims, and appends `…` when
268
+ the cap cuts the string. An empty result removes the prop.
269
+ - `icon` and `overlay` must match `^[A-Za-z0-9_.-]+$`. Anything else is dropped.
270
+ - Booleans default to `false`, except `sensitive`, which defaults to `true`.
271
+ - A missing object defaults each prop as the tables say.
272
+
273
+ ### `indicator`
274
+
275
+ Only under the root. No children.
276
+
277
+ | Prop | Type | Notes |
278
+ | --- | --- | --- |
279
+ | `icon` | string | Icon name |
280
+ | `text` | string | Chip label |
281
+ | `tooltip` | string | |
282
+ | `badge` | string | Cleaned and capped at 8 characters |
283
+ | `overlay` | string | Icon name |
284
+ | `dot` | string | Stored as a string, capped at 256 characters, not parsed and not whitespace-folded. The panel reads it as a color |
285
+ | `severity` | `info`, `warning`, `error` | |
286
+ | `attention` | boolean | |
287
+ | `notice` | boolean | |
288
+ | `className` | class | |
289
+ | `onPress` | boolean | |
290
+ | `onScroll` | boolean | |
291
+
292
+ ### `popover`
293
+
294
+ Under the root.
295
+
296
+ | Prop | Type |
297
+ | --- | --- |
298
+ | `className` | class |
299
+
300
+ Children follow the parent table. The order of `children` is the order on screen.
301
+
302
+ ### `hero`
303
+
304
+ Only under `popover`. No children.
305
+
306
+ | Prop | Type |
307
+ | --- | --- |
308
+ | `icon` | string |
309
+ | `title` | string |
310
+ | `subtitle` | string |
311
+ | `className` | class |
312
+
313
+ ### `section`
314
+
315
+ A body element. It holds body elements except another `section`.
316
+
317
+ | Prop | Type |
318
+ | --- | --- |
319
+ | `title` | string |
320
+ | `count` | string |
321
+ | `className` | class |
322
+
323
+ ### `row`
324
+
325
+ A leaf.
326
+
327
+ | Prop | Type | Notes |
328
+ | --- | --- | --- |
329
+ | `icon` | string | |
330
+ | `title` | string | |
331
+ | `subtitle` | string | |
332
+ | `value` | string | |
333
+ | `selected` | boolean or absent | Present, either way, means the row can be selected |
334
+ | `busy` | boolean | |
335
+ | `className` | class | |
336
+ | `onActivate` | boolean | `false` or absent means the row does not activate |
337
+
338
+ ### `switchrow`
339
+
340
+ A leaf.
341
+
342
+ | Prop | Type |
343
+ | --- | --- |
344
+ | `icon` | string |
345
+ | `title` | string |
346
+ | `subtitle` | string |
347
+ | `active` | boolean |
348
+ | `busy` | boolean |
349
+ | `className` | class |
350
+ | `onToggle` | boolean |
351
+
352
+ ### `fader`
353
+
354
+ A leaf. `onMute: false` means the mute control is not shown.
355
+
356
+ | Prop | Type | Default |
357
+ | --- | --- | --- |
358
+ | `icon` | string | absent |
359
+ | `value` | number | `0` |
360
+ | `maximum` | number | `100`. Raised to `floor` when it would be lower |
361
+ | `floor` | number | `0`. Raised to `0` when negative |
362
+ | `muted` | boolean | `false` |
363
+ | `className` | class | |
364
+ | `onChange` | boolean | |
365
+ | `onMute` | boolean | |
366
+
367
+ ### `entry`
368
+
369
+ A leaf. `value` is not text-cleaned. Control characters and bidi overrides are stripped
370
+ in place, the rest is kept, including leading and trailing spaces, and the result is
371
+ capped at 4096 characters with no ellipsis.
372
+
373
+ | Prop | Type | Default |
374
+ | --- | --- | --- |
375
+ | `placeholder` | string | absent. This one is text-cleaned |
376
+ | `value` | string | `""` |
377
+ | `className` | class | |
378
+ | `onChange` | boolean | |
379
+ | `onSubmit` | boolean | |
380
+
381
+ ### `placeholder`
382
+
383
+ A leaf.
384
+
385
+ | Prop | Type |
386
+ | --- | --- |
387
+ | `icon` | string |
388
+ | `title` | string |
389
+ | `description` | string |
390
+ | `className` | class |
391
+
392
+ ### `footer`
393
+
394
+ Only under `popover`. Holds `button`, `row`, `label` and `box`.
395
+
396
+ | Prop | Type |
397
+ | --- | --- |
398
+ | `className` | class |
399
+
400
+ ### `box`
401
+
402
+ A body element. Holds body elements except `section`.
403
+
404
+ | Prop | Type | Default |
405
+ | --- | --- | --- |
406
+ | `orientation` | `horizontal`, `vertical` | `horizontal` |
407
+ | `spacing` | number | `0`, clamped to `0`–`24` |
408
+ | `homogeneous` | boolean | `false` |
409
+ | `halign`, `valign` | `fill`, `start`, `end`, `center`, `baseline` | absent, so the widget's own align is left alone |
410
+ | `hexpand`, `vexpand` | boolean | `false` |
411
+ | `className` | class | |
412
+
413
+ ### `label`
414
+
415
+ A leaf. The words are the `text` prop, plain text, never markup.
416
+
417
+ | Prop | Type | Default |
418
+ | --- | --- | --- |
419
+ | `text` | string | absent |
420
+ | `wrap` | boolean | `false` |
421
+ | `xalign` | number | absent. When set, clamped to `0`–`1` |
422
+ | `ellipsize` | `none`, `start`, `middle`, `end` | absent |
423
+ | `lines` | number | `0`, meaning no extra line limit. Rounded and clamped to `0`–`8` |
424
+ | `className` | class | |
425
+
426
+ ### `image`
427
+
428
+ A leaf. `icon` is a themed name, never a path.
429
+ When set, `tooltip` also provides the accessible name.
430
+
431
+ | Prop | Type | Default |
432
+ | --- | --- | --- |
433
+ | `icon` | string | absent |
434
+ | `tooltip` | string | absent |
435
+ | `pixelSize` | number | absent. When set, rounded and clamped to `8`–`64` |
436
+ | `className` | class | |
437
+
438
+ ### `button`
439
+
440
+ A leaf. The label is the `text` prop.
441
+ For an icon-only button, `tooltip` also provides the accessible name.
442
+
443
+ | Prop | Type | Default |
444
+ | --- | --- | --- |
445
+ | `text` | string | absent |
446
+ | `icon` | string | absent |
447
+ | `tooltip` | string | absent |
448
+ | `sensitive` | boolean | `true` |
449
+ | `className` | class | |
450
+ | `onClick` | boolean | |
451
+
452
+ ### `switch`
453
+
454
+ A leaf.
455
+
456
+ | Prop | Type | Default |
457
+ | --- | --- | --- |
458
+ | `active` | boolean | `false` |
459
+ | `sensitive` | boolean | `true` |
460
+ | `className` | class | |
461
+ | `onToggle` | boolean | |
462
+
463
+ ### `scale`
464
+
465
+ A leaf. `min` must be less than `max`. When a set breaks that, both return to `0` and
466
+ `1` and `value` is clamped into the range. `value` is also clamped when the range is
467
+ already valid.
468
+
469
+ | Prop | Type | Default |
470
+ | --- | --- | --- |
471
+ | `value` | number | `0` |
472
+ | `min` | number | `0` |
473
+ | `max` | number | `1` |
474
+ | `step` | number | `0`. A negative step becomes `0` |
475
+ | `sensitive` | boolean | `true` |
476
+ | `className` | class | |
477
+ | `onChange` | boolean | |
478
+
479
+ ### `spinner`
480
+
481
+ A leaf. No props besides `className`.
482
+
483
+ ### `progress`
484
+
485
+ A leaf. The caption is the `text` prop.
486
+
487
+ | Prop | Type | Default |
488
+ | --- | --- | --- |
489
+ | `fraction` | number | `0`, clamped to `0`–`1` |
490
+ | `text` | string | absent |
491
+ | `className` | class | |
492
+
493
+ ### `separator`
494
+
495
+ A leaf.
496
+
497
+ | Prop | Type | Default |
498
+ | --- | --- | --- |
499
+ | `orientation` | `horizontal`, `vertical` | `horizontal` |
500
+ | `className` | class | |
501
+
502
+ ### `unsupported`
503
+
504
+ Any other `type`. No children. The name shown is the cleaned type string. Its props are
505
+ not stored.
506
+
507
+ ## Caps
508
+
509
+ | Cap | Value | Who enforces it |
510
+ | --- | --- | --- |
511
+ | Line length | 1,048,576 bytes | The host, while framing |
512
+ | JSON nesting | 128 levels in one value | The decoder |
513
+ | Nodes | 300, counting the root | The commit |
514
+ | Children of one parent | 200 | The commit |
515
+ | Operations per commit | 1,200 | The commit |
516
+ | Lines read | 120 per second; more are delayed, not rejected | The host, not the tree |
517
+ | Text | 256 characters | The commit, via cleaning |
518
+ | Element name | 64 characters | The commit, via cleaning |
519
+ | `badge` | 8 characters | The commit, via cleaning |
520
+ | `entry.value` | 4,096 characters | The commit, without trimming |
521
+ | `dot` | 256 characters | The commit, without cleaning |
522
+
523
+ ## Rejection
524
+
525
+ A batch is rejected, and the previous tree kept, when it:
526
+
527
+ - names an id that is not in the tree, or reuses one
528
+ - moves an element under itself or under a descendant
529
+ - puts a child where the parent table does not allow it
530
+ - carries more than 1,200 operations
531
+ - would hold more than 300 nodes once the whole batch is applied
532
+ - would give one parent more than 200 children once the whole batch is applied
533
+ - tries to `set`, `move` or `remove` the root
534
+
535
+ `before` that is not a child of `parent` is the same kind of rejection. A line that does
536
+ not decode never reaches this list.