@yuneta/gobj-ui 7.23.35 → 7.23.36
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 +92 -10
- package/dist/gobj-ui.cjs.js +3296 -654
- package/dist/gobj-ui.es.js +3295 -655
- package/index.js +2 -0
- package/package.json +1 -1
- package/src/c_yui_fsm_graph.css +128 -0
- package/src/c_yui_fsm_graph.js +967 -0
- package/src/c_yui_gclass.css +508 -0
- package/src/c_yui_gclass.js +1522 -0
- package/src/c_yui_gobj_tree_js.js +11 -27
- package/src/gclass_view_model.js +421 -0
- package/src/gclass_view_model.test.js +296 -0
- package/src/yui_gclass_view.js +42 -15
package/README.md
CHANGED
|
@@ -1416,10 +1416,10 @@ let handle = open_gclass_view(host, "C_TIMER", {title_prefix: yuno_name, on_clos
|
|
|
1416
1416
|
close_gclass_view(handle);
|
|
1417
1417
|
```
|
|
1418
1418
|
|
|
1419
|
-
What a GClass IS — its attrs, its commands, the methods it implements, its
|
|
1420
|
-
— in a `
|
|
1421
|
-
|
|
1422
|
-
|
|
1419
|
+
What a GClass IS — its attrs, its commands, the methods it implements, its
|
|
1420
|
+
trace levels, its FSM — in a `C_YUI_GCLASS` window, laid out by **zones**.
|
|
1421
|
+
The framework had no such viewer: the C kernel answers `view-gclass` with
|
|
1422
|
+
exactly this document and the only thing that ever read it was a terminal.
|
|
1423
1423
|
|
|
1424
1424
|
`gclass_describe.js` builds it for a gclass of the **browser** yuno from the
|
|
1425
1425
|
gobj-js registry, in the shape `gclass2json()` answers (`id`, `gcflag`,
|
|
@@ -1428,12 +1428,94 @@ gobj-js registry, in the shape `gclass2json()` answers (`id`, `gcflag`,
|
|
|
1428
1428
|
gclass of a **backend** yuno the host passes the answer of `view-gclass` as
|
|
1429
1429
|
`opts.description` and the same window draws it.
|
|
1430
1430
|
|
|
1431
|
-
`
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
`
|
|
1431
|
+
`opts.current_state` is the state the INSTANCE the reader came from is in. The
|
|
1432
|
+
description describes the CLASS and cannot carry it, so the host supplies it —
|
|
1433
|
+
the gobj tree passes `node_data.state` — and the machine lights that column.
|
|
1434
|
+
Omitted, nothing is lit.
|
|
1435
|
+
|
|
1436
|
+
`gclass_view_available()` registers `C_YUI_GCLASS` on demand and reports
|
|
1437
|
+
whether it is there, so no app has to mount a gclass for a control it never
|
|
1438
|
+
asked for. The gobj tree still asks before drawing its `gclass` button: a
|
|
1439
|
+
registration that failed must not leave a button that opens nothing.
|
|
1440
|
+
|
|
1441
|
+
### C_YUI_GCLASS — a gclass by zones
|
|
1442
|
+
|
|
1443
|
+
```js
|
|
1444
|
+
import {register_c_yui_gclass} from "@yuneta/gobj-ui/src/c_yui_gclass.js";
|
|
1445
|
+
```
|
|
1446
|
+
|
|
1447
|
+
Attrs: `description` (the document), `gclass_name` (heads the view when the
|
|
1448
|
+
document carries no `id`), `current_state`, `view_mode` (`"zones"` | `"raw"`),
|
|
1449
|
+
`$container`. Events in: `EV_SET_DESCRIPTION {description, current_state}`,
|
|
1450
|
+
`EV_SET_VIEW_MODE {mode}`, `EV_TOGGLE_ZONE {zone}`, `EV_SEARCH {text}`,
|
|
1451
|
+
`EV_COPY_ALL`, `EV_LANGUAGE_CHANGED`, `EV_REFRESH`, `EV_SHOW`, `EV_HIDE`. It
|
|
1452
|
+
publishes nothing, so hosting it adds no declaration to a host's FSM.
|
|
1453
|
+
|
|
1454
|
+
`gclass_view_model.js` is where the document becomes the view, and it reads
|
|
1455
|
+
**both dialects of it**. The C kernel and the browser registry answer the same
|
|
1456
|
+
document in different words, and a viewer that knew only one drew half a page
|
|
1457
|
+
for the other side:
|
|
1458
|
+
|
|
1459
|
+
| key | C kernel | browser |
|
|
1460
|
+
|---|---|---|
|
|
1461
|
+
| `flag` | `"SDF_RD\|SDF_PERSIST"` | `["SDF_RD", …]` |
|
|
1462
|
+
| `type` | `"string"` | `"DTP_STRING"` |
|
|
1463
|
+
| command name | `command` | `id` |
|
|
1464
|
+
| parameter name | `parameter` | `id` |
|
|
1465
|
+
| trace levels | `info_gclass_trace` (dict) | `trace_levels` (array) |
|
|
1466
|
+
| action | the literal `"action"` | the function's name |
|
|
1467
|
+
|
|
1468
|
+
The last one is not a rename: `states2json()` cannot name an action, so a cell
|
|
1469
|
+
from a **backend** gclass says THAT there is one and never which. The viewer
|
|
1470
|
+
draws a mark rather than printing a name nobody wrote.
|
|
1471
|
+
|
|
1472
|
+
**The machine is a matrix**, rows = events and columns = states — the shape the
|
|
1473
|
+
FSM is declared in, and the one that survives 12 events against 3 states as
|
|
1474
|
+
well as 86 commands against one. Two things it says that a JSON dump cannot:
|
|
1475
|
+
|
|
1476
|
+
- **An empty cell is information.** An event with no action in a state is not
|
|
1477
|
+
ignored, it is refused with *"Event NOT DEFINED in state"*, so the empty
|
|
1478
|
+
cells are the map of what breaks. They are hatched, never blank.
|
|
1479
|
+
- **A state nothing declares a way INTO is marked.** An action may jump with
|
|
1480
|
+
`gobj_change_state()` — `C_IEVENT_CLI` reaches `ST_SESSION` that way — and no
|
|
1481
|
+
description can see inside an action. Marking it is the alternative to
|
|
1482
|
+
drawing the working half of a gclass as unreachable.
|
|
1483
|
+
|
|
1484
|
+
Events declared but handled in no state are OUTPUT events: they leave the
|
|
1485
|
+
matrix (one empty row per column says nothing) and are listed under
|
|
1486
|
+
*publishes*. The `raw` view keeps the description verbatim — it is the
|
|
1487
|
+
authoritative answer of the backend and is never thrown away.
|
|
1488
|
+
|
|
1489
|
+
### C_YUI_FSM_GRAPH — the machine, drawn
|
|
1490
|
+
|
|
1491
|
+
The machine zone's second view, switched from a pair of buttons inside the
|
|
1492
|
+
zone (the zone heading is itself a button, and a button inside a button is not
|
|
1493
|
+
a control). The matrix stays the default; the graph earns its place where the
|
|
1494
|
+
matrix is worst — many states, few events each — and in graph mode the machine
|
|
1495
|
+
takes the whole width and the other zones stack under it, because 600px of a
|
|
1496
|
+
1200px viewer is where six states stop fitting.
|
|
1497
|
+
|
|
1498
|
+
Attrs: `fsm` (the `fsm` block of the view model), `current_state`,
|
|
1499
|
+
`$container`, `canvas_id`, `wide`, `layout` (`dagre-lr` | `dagre-tb`). Events
|
|
1500
|
+
in: `EV_SET_FSM {fsm, current_state}`, `EV_CHANGE_LAYOUT {layout}`, the camera
|
|
1501
|
+
set (`EV_ZOOM_IN` / `EV_ZOOM_OUT` / `EV_ZOOM_RESET` / `EV_CENTER`),
|
|
1502
|
+
`EV_RESIZE`, `EV_THEME_CHANGED`, `EV_LANGUAGE_CHANGED`, `EV_SHOW`, `EV_HIDE`.
|
|
1503
|
+
It publishes nothing.
|
|
1504
|
+
|
|
1505
|
+
What it refuses to draw is the interesting half:
|
|
1506
|
+
|
|
1507
|
+
- **One edge per PAIR of states**, not per transition, labelled with the events
|
|
1508
|
+
that make the jump (three, then a count). G6 draws overlapping edges on top
|
|
1509
|
+
of each other, so a second edge between the same two states is invisible and
|
|
1510
|
+
nothing tells the reader it is there.
|
|
1511
|
+
- **An event a state handles without leaving is not an edge.** Ten self-loops
|
|
1512
|
+
on one card say nothing a number cannot say better, so the card carries
|
|
1513
|
+
`n events · m leave` instead.
|
|
1514
|
+
|
|
1515
|
+
It fits with `fitCenter()` then `fitView()` — the house pair; `fitView` alone
|
|
1516
|
+
leaves an html-node graph off centre — and never below `MIN_READABLE_ZOOM`
|
|
1517
|
+
(0.5), the same floor `C_G6_NODES_TREE` uses: a six-state machine fits a panel
|
|
1518
|
+
at 38%, which is the whole graph and worth nothing.
|
|
1437
1519
|
|
|
1438
1520
|
> **Mount before you start a hosted view.** `mt_create` builds the DOM;
|
|
1439
1521
|
> `mt_start` renders it, and a view that measures a canvas or observes its box
|