frugal-iot-client 1.3.15 → 2.0.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/CLAUDE.md +27 -15
- package/admin.js +308 -161
- package/cards.js +27 -8
- package/core.js +346 -117
- package/dashboard_example.html +8 -4
- package/{CARDS_UX.md → docs/CARDS_UX.md} +33 -0
- package/frugaliot.css +25 -67
- package/graph.js +85 -42
- package/index-embedded.html +6 -4
- package/index.html +2 -3
- package/package.json +1 -1
- package/test/cards.test.js +67 -1
- package/test/cardui.test.js +20 -0
- package/test/datatree.test.js +103 -0
- package/test/fixtures/config.json +574 -55
- package/test/graph.test.js +69 -0
- package/test/grid.test.js +4 -0
- package/test/mock.html +4 -5
- package/test/mock.js +19 -13
- package/test/modules.test.js +1 -2
- package/test/page.test.js +56 -5
- package/test/permissions.test.js +34 -4
- package/test/smoke.test.js +15 -9
- package/test/snapshots/card-control-wired-back.txt +5 -5
- package/test/snapshots/card-control-wired-front.txt +6 -3
- package/test/snapshots/control-wired.txt +11 -11
- package/test/snapshots/default-front.txt +8 -8
- package/test/snapshots/mixed-sensors.txt +7 -7
- package/test/snapshots/one-device.txt +6 -6
- package/test/snapshots/unknown-module.txt +3 -3
- package/index-old.html +0 -37
- package/index-project.html +0 -27
- package/nodeview.js +0 -433
- package/test/oldui.test.js +0 -40
- package/test/snapshots/no-readings.txt +0 -54
- package/webcomponents.js +0 -20
- /package/{CARDS_PLAN.md → docs/CARDS_PLAN.md} +0 -0
- /package/{FLASH_PLAN.md → docs/FLASH_PLAN.md} +0 -0
package/CLAUDE.md
CHANGED
|
@@ -14,24 +14,32 @@ it loadable on its own, and it is maintained by reaching the display elements **
|
|
|
14
14
|
| `widgets.js` | core | `mqtt-bar`, `mqtt-text`, `mqtt-toggle`, `mqtt-gauge`, `mqtt-slider`, `mqtt-color`, `mqtt-choosetopic` — all shadow DOM |
|
|
15
15
|
| `graph.js` | core, widgets | `mqtt-graph`, `mqtt-graphdataset` — pulls Chart.js |
|
|
16
16
|
| `cards.js` | core | the card UI: `mqtt-devicecard`, `mqtt-devicegrid`, `mqtt-projectback`, `mqtt-dashboard`, the layout store |
|
|
17
|
-
| `nodeview.js` | core, widgets | the old node/group UI — **retires with `index-old.html`**; nothing new belongs here |
|
|
18
17
|
| `flash.js` | core | `mqtt-flash` — pulls esptool-js |
|
|
19
|
-
| `admin.js` | core | `mqtt-admin
|
|
18
|
+
| `admin.js` | core | `mqtt-admin` — one admin section, rendered per card by `cards.js` |
|
|
20
19
|
| `login.js` | core | `mqtt-login` — sign in, register, forgot/reset password; light DOM |
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
Every page loads the modules it needs; there is no file that loads everything.
|
|
22
|
+
|
|
23
|
+
| Page | Loads |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `index.html` | `dashboard.js` — the card UI |
|
|
26
|
+
| `login.html` | `login.js`, which imports only `core.js` — that is why `mqtt-login` is not in `admin.js` |
|
|
27
|
+
| `index-embedded.html`, `dashboard_example.html` | `core.js` + `widgets.js` + `graph.js` |
|
|
28
|
+
|
|
29
|
+
Retired with the pre-cards UI: `index-old.html`, `index-project.html`, `nodeview.js` and
|
|
30
|
+
`webcomponents.js` (the shim that loaded everything), `mqtt-admin`'s tab strip, and the wrapper's
|
|
31
|
+
`headless` attribute — the data tree is all it builds now. `mqtt-admin` renders one section, chosen
|
|
32
|
+
by its `section` attribute; the cards on a project's back make one per card.
|
|
26
33
|
|
|
27
34
|
Dashboards (e.g. `dashboard_example.html`) are thin HTML pages importing selectively.
|
|
28
35
|
|
|
29
36
|
## Design documents
|
|
30
37
|
|
|
31
|
-
`CARDS_UX.md` is the design for the card UI — every decision is numbered (D-n) with its
|
|
32
|
-
deferred work is L-n, and it is the place to argue with a choice rather than re-deciding
|
|
33
|
-
`CARDS_PLAN.md` is how it was built, including the bugs found on the way.
|
|
34
|
-
`HEADLESS_PLAN.md` cover their own areas.
|
|
38
|
+
`docs/CARDS_UX.md` is the design for the card UI — every decision is numbered (D-n) with its
|
|
39
|
+
reasoning, deferred work is L-n, and it is the place to argue with a choice rather than re-deciding
|
|
40
|
+
it in code. `docs/CARDS_PLAN.md` is how it was built, including the bugs found on the way.
|
|
41
|
+
`docs/FLASH_PLAN.md` and `HEADLESS_PLAN.md` cover their own areas. Comments throughout the code cite
|
|
42
|
+
these by bare filename (`see CARDS_UX.md 4.7`); they all live in `docs/` except `HEADLESS_PLAN.md`.
|
|
35
43
|
|
|
36
44
|
## Code style
|
|
37
45
|
|
|
@@ -40,6 +48,10 @@ deferred work is L-n, and it is the place to argue with a choice rather than re-
|
|
|
40
48
|
- **Comments**: explain WHY, not WHAT. One short line is enough; do not restate what the code clearly shows. No multi-line docstrings.
|
|
41
49
|
- Good: `// topicSetPath throws when this.node is null — guard before calling`
|
|
42
50
|
- Bad: `// Check if topic starts with the set path`
|
|
51
|
+
- **A comment says what is true now, not what used to break.** When fixing a bug, state the
|
|
52
|
+
constraint that still holds; the diagnosis — what it threw, where, why one deployment differed —
|
|
53
|
+
belongs in the pull request or the chat, not in the source, where it buries the one line that
|
|
54
|
+
still matters.
|
|
43
55
|
- **No trailing summaries** — do not add a comment block or prose after a method explaining what it does.
|
|
44
56
|
- **Getters**: prefer `get foo()` over plain property access whenever a value is derived or retrieved by traversing connected objects (e.g. `this.node.project`, `this.parentElement`, `this.mt.node.groups[this.group]`). Getters make the dependency chain explicit and let callers read `thing.project` naturally.
|
|
45
57
|
- **Dashboard functionality**: prefer adding reusable behaviour to the shared modules over implementing it inside a custom dashboard file. If a dashboard needs to traverse the topic tree, compute a list, or fire an event, that logic belongs on the relevant class as a getter or method.
|
|
@@ -283,9 +295,9 @@ Each of these cost real time. They are not obvious from reading the code.
|
|
|
283
295
|
`innerHTML`, `action`) as properties. **Any other function is silently put in `el.state`** and
|
|
284
296
|
never wired up: `el({onpointerdown: fn})` does nothing at all. Use `addEventListener`.
|
|
285
297
|
- **`@media (max-width: 1001px)` in `frugaliot.css`** inflates fonts and icons for the node/group UI,
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
298
|
+
which is now retired — so these rules have no page they were drawn for. The card page opts out by
|
|
299
|
+
setting `--fi-chrome-font: 1rem`, which the rules read. They still reach the login page and the
|
|
300
|
+
embedded examples, so removing them is a visual change to those and wants looking at on a phone.
|
|
289
301
|
- **`:host-context(details[open]) div { display: block }`** near the top of `frugaliot.css` has
|
|
290
302
|
specificity (0,2,2) and overrides most rules for any div in a shadow root inside an open
|
|
291
303
|
`<details>` — which is every widget in the old UI.
|
|
@@ -340,9 +352,9 @@ regress unnoticed; regenerate deliberately with `npm run test:update` and read t
|
|
|
340
352
|
|
|
341
353
|
## Internationalisation
|
|
342
354
|
|
|
343
|
-
The master language table is `const languages` in `
|
|
355
|
+
The master language table is `const languages` in `core.js`. Dashboard-specific strings are added via `addVocabulary(yamlString)` in the dashboard's `<script>`.
|
|
344
356
|
|
|
345
|
-
Every `addVocabulary` block must include **all four** language sections (EN, FR, HI, ID). Strings absent from `
|
|
357
|
+
Every `addVocabulary` block must include **all four** language sections (EN, FR, HI, ID). Strings absent from `core.js` must be explicitly added in the dashboard block — do not assume the core file covers them.
|
|
346
358
|
|
|
347
359
|
### How a string gets translated
|
|
348
360
|
|