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 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`, `tabbed-display` |
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
- Entry points: `index.html` → `dashboard.js` (the card UI, everything but `nodeview.js`);
23
- `index-old.html` → `webcomponents.js` (everything, and the only remaining user of it);
24
- `login.html` → `login.js`, which imports only `core.js` — that is why `mqtt-login` is not in
25
- `admin.js`; `index-embedded.html` needs only `core.js` + `widgets.js` and must keep working.
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 reasoning,
32
- deferred work is L-n, and it is the place to argue with a choice rather than re-deciding it in code.
33
- `CARDS_PLAN.md` is how it was built, including the bugs found on the way. `FLASH_PLAN.md` and
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
- where a node is one wide block. Inside a card it makes everything wider than the card. Those rules
287
- read `var(--fi-chrome-font, …)`; the card page sets it to `1rem`. Anything new that is not
288
- `nodeview.js` should opt out the same way. Replace them properly when `nodeview.js` goes.
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 `webcomponents.js`. Dashboard-specific strings are added via `addVocabulary(yamlString)` in the dashboard's `<script>`.
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 `webcomponents.js` must be explicitly added in the dashboard block — do not assume the core file covers them.
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