@yuneta/gobj-ui 7.23.171 β 7.23.172
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/dist/gobj-ui.cjs.js +126 -347
- package/dist/gobj-ui.es.js +127 -348
- package/package.json +3 -3
- package/src/yui_dev.js +152 -363
- package/src/dev_machine_trace.js +0 -116
- package/src/dev_machine_trace.test.js +0 -123
package/src/dev_machine_trace.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/***********************************************************************
|
|
2
|
-
* dev_machine_trace.js
|
|
3
|
-
*
|
|
4
|
-
* Reading a MACHINE trace line back.
|
|
5
|
-
*
|
|
6
|
-
* The developer window mirrors the runtime's log, and the
|
|
7
|
-
* `machine` trace is most of what lands there once it is on.
|
|
8
|
-
* Those lines arrive as text, so to the window they were just
|
|
9
|
-
* "a debug log" -- which is why its `Periodic` filter could
|
|
10
|
-
* not touch them: the filter works on a signature, and every
|
|
11
|
-
* mirrored log carried the same one (`log:debug`).
|
|
12
|
-
*
|
|
13
|
-
* This gives a machine line back its EVENT, which is the only
|
|
14
|
-
* thing that says whether it is noise. Both formats gobj-js
|
|
15
|
-
* emits (`gobj_set_trace_machine_format`):
|
|
16
|
-
*
|
|
17
|
-
* 0 verbose "π mach(C_TIMER^t), st: ST_IDLE, ev: EV_TIMEOUT, ac: β¦"
|
|
18
|
-
* "<- mach(C_TIMER^t), st: ST_IDLE, ev: EV_TIMEOUT, ret: 0"
|
|
19
|
-
* 1 compact "π EV_TIMEOUT C_TIMER^t ST_IDLE from C_TIMER^t"
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) 2026, ArtGins.
|
|
22
|
-
* All Rights Reserved.
|
|
23
|
-
***********************************************************************/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/* The verbose format names itself; the compact one does not. */
|
|
27
|
-
const MACHINE_MARK_RE = /\bmach\(/;
|
|
28
|
-
|
|
29
|
-
/* Verbose: the event is the `ev:` field. */
|
|
30
|
-
const EVENT_FIELD_RE = /\bev:\s*([A-Za-z0-9_]+)/;
|
|
31
|
-
|
|
32
|
-
/* Compact: the event is the first token, behind the emoji. Anchored,
|
|
33
|
-
* so a line that merely MENTIONS an event ("subscribed to EV_X") is
|
|
34
|
-
* not mistaken for a transition. */
|
|
35
|
-
const EVENT_HEAD_RE = /^\s*\S{0,4}\s*(EV_[A-Za-z0-9_]+)(?=\s|$)/;
|
|
36
|
-
|
|
37
|
-
/* What "recurring" means by name. The count-based half of the filter
|
|
38
|
-
* lives in the window, which is the only thing that can count. */
|
|
39
|
-
const PERIODIC_EVENT_RE = /PERIODIC|TIMEOUT|HEARTBEAT|PING|POLL/i;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/************************************************************
|
|
43
|
-
* The event of a machine trace line, or "" when the line is
|
|
44
|
-
* not one.
|
|
45
|
-
*
|
|
46
|
-
* "" is also the answer for a machine line that carries no
|
|
47
|
-
* event -- a state change ("new st(β¦), prev st(β¦)") -- and
|
|
48
|
-
* that is right: what it reports is not repetitive.
|
|
49
|
-
************************************************************/
|
|
50
|
-
function machine_event_of(text)
|
|
51
|
-
{
|
|
52
|
-
if(typeof text !== "string" || text.length === 0) {
|
|
53
|
-
return "";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if(MACHINE_MARK_RE.test(text)) {
|
|
57
|
-
let m = EVENT_FIELD_RE.exec(text);
|
|
58
|
-
return m? m[1]: "";
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let m = EVENT_HEAD_RE.exec(text);
|
|
62
|
-
return m? m[1]: "";
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/************************************************************
|
|
66
|
-
* Is this event one of the ones that arrive by themselves,
|
|
67
|
-
* for ever, and say nothing about what the app is doing?
|
|
68
|
-
************************************************************/
|
|
69
|
-
function is_periodic_event(event_name)
|
|
70
|
-
{
|
|
71
|
-
if(!event_name) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
return PERIODIC_EVENT_RE.test(event_name);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/************************************************************
|
|
78
|
-
* The signature of a mirrored log line: what the window
|
|
79
|
-
* counts it under and what its filters match on.
|
|
80
|
-
*
|
|
81
|
-
* A machine line is signed by its EVENT, so a hundred
|
|
82
|
-
* EV_TIMEOUTs are one recurring thing rather than a hundred
|
|
83
|
-
* anonymous debug lines. Everything else is signed by its
|
|
84
|
-
* level, as before.
|
|
85
|
-
************************************************************/
|
|
86
|
-
function log_signature(level, text)
|
|
87
|
-
{
|
|
88
|
-
let event = machine_event_of(text);
|
|
89
|
-
if(event) {
|
|
90
|
-
return "mach:" + event;
|
|
91
|
-
}
|
|
92
|
-
return "log:" + (level || "debug");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/************************************************************
|
|
96
|
-
* May the periodic filter hide this log line?
|
|
97
|
-
*
|
|
98
|
-
* Only a machine transition, and only below warning level.
|
|
99
|
-
* An ERROR that names EV_TIMEOUT -- "Event NOT DEFINED in
|
|
100
|
-
* state", which is exactly the loud one the framework wants
|
|
101
|
-
* seen -- must never disappear because of the word in it.
|
|
102
|
-
************************************************************/
|
|
103
|
-
function log_is_periodic(level, text)
|
|
104
|
-
{
|
|
105
|
-
if(level === "error" || level === "warning") {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
return is_periodic_event(machine_event_of(text));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export {
|
|
112
|
-
machine_event_of,
|
|
113
|
-
is_periodic_event,
|
|
114
|
-
log_signature,
|
|
115
|
-
log_is_periodic,
|
|
116
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {describe, it, expect} from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
machine_event_of,
|
|
4
|
-
is_periodic_event,
|
|
5
|
-
log_signature,
|
|
6
|
-
log_is_periodic,
|
|
7
|
-
} from "./dev_machine_trace.js";
|
|
8
|
-
|
|
9
|
-
/* Real lines, copied from the developer window. */
|
|
10
|
-
const VERBOSE_IN =
|
|
11
|
-
"π mach(C_TIMER^demo_yuno), st: ST_IDLE, ev: EV_TIMEOUT, ac: fi(), from(C_TIMER^demo_yuno)";
|
|
12
|
-
const VERBOSE_RET =
|
|
13
|
-
"<- mach(C_YUNO^demo_yuno), st: ST_IDLE, ev: EV_TIMEOUT_PERIODIC, ret: 0";
|
|
14
|
-
const VERBOSE_WORK =
|
|
15
|
-
"π mach(C_YUI_SHELL^shell), st: ST_IDLE, ev: EV_ROUTE_CHANGED, ac: ac_route(), from(C_YUI_NAV^nav)";
|
|
16
|
-
const COMPACT =
|
|
17
|
-
"π EV_TIMEOUT C_TIMER^demo_yuno ST_IDLE from C_TIMER^demo_yuno";
|
|
18
|
-
const STATE_CHANGE =
|
|
19
|
-
"ππ mach(C_TCP^conn), new st(ST_CONNECTED), prev st(ST_WAIT_CONNECTED)";
|
|
20
|
-
const NOT_DEFINED =
|
|
21
|
-
"π mach(C_X^x), st: ST_IDLE, ev: EV_TIMEOUT, ππERROR Event NOT DEFINED in stateππ, from(C_TIMER^t)";
|
|
22
|
-
|
|
23
|
-
/* The other four shapes the SIMPLER format emits (gobj-js 7.13.7 gave them
|
|
24
|
-
* their format-1 branch; before that they leaked `mach(β¦)` into it). */
|
|
25
|
-
const SIMPLE_PUBLISH = "ππ EV_STATE_CHANGED C_PROT_MQTT^input-2 ST_WAIT_FRAME_HEADER";
|
|
26
|
-
const SIMPLE_FORWARD = "ππ EV_TX_READY (EV_TX_READY) C_PROT_TCP4H^output-0";
|
|
27
|
-
const SIMPLE_INJECT = "π EV_ON_MESSAGE C_GATE^gate ST_IDLE";
|
|
28
|
-
const SIMPLE_NESTED = " π EV_ON_MESSAGE C_IOGATE^output-iogate-0 ST_IDLE from C_CHANNEL^output-0";
|
|
29
|
-
|
|
30
|
-
describe("the simpler format's other shapes", () => {
|
|
31
|
-
it("reads the event out of a publish, a forward and an injection", () => {
|
|
32
|
-
expect(machine_event_of(SIMPLE_PUBLISH)).toBe("EV_STATE_CHANGED");
|
|
33
|
-
expect(machine_event_of(SIMPLE_FORWARD)).toBe("EV_TX_READY");
|
|
34
|
-
expect(machine_event_of(SIMPLE_INJECT)).toBe("EV_ON_MESSAGE");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("the leading INDENTATION does not hide the event", () => {
|
|
38
|
-
expect(machine_event_of(SIMPLE_NESTED)).toBe("EV_ON_MESSAGE");
|
|
39
|
-
expect(log_is_periodic("debug", SIMPLE_NESTED)).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("a periodic one is still recognised in every shape", () => {
|
|
43
|
-
expect(log_is_periodic("debug", "ππ EV_TIMEOUT C_TIMER^t ST_IDLE")).toBe(true);
|
|
44
|
-
expect(log_is_periodic("debug", " π EV_TIMEOUT_PERIODIC C_YUNO^y ST_IDLE")).toBe(true);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe("machine_event_of", () => {
|
|
49
|
-
it("reads the event out of the verbose format, both lines of it", () => {
|
|
50
|
-
expect(machine_event_of(VERBOSE_IN)).toBe("EV_TIMEOUT");
|
|
51
|
-
expect(machine_event_of(VERBOSE_RET)).toBe("EV_TIMEOUT_PERIODIC");
|
|
52
|
-
expect(machine_event_of(VERBOSE_WORK)).toBe("EV_ROUTE_CHANGED");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("reads it out of the compact format, where it leads the line", () => {
|
|
56
|
-
expect(machine_event_of(COMPACT)).toBe("EV_TIMEOUT");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("a state change carries no event, and says so", () => {
|
|
60
|
-
expect(machine_event_of(STATE_CHANGE)).toBe("");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("a line that merely MENTIONS an event is not a transition", () => {
|
|
64
|
-
expect(machine_event_of("subscribed to EV_TIMEOUT of C_TIMER^t")).toBe("");
|
|
65
|
-
expect(machine_event_of("cannot send EV_ON_OPEN")).toBe("");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("is safe on anything that is not a line", () => {
|
|
69
|
-
expect(machine_event_of("")).toBe("");
|
|
70
|
-
expect(machine_event_of(null)).toBe("");
|
|
71
|
-
expect(machine_event_of(undefined)).toBe("");
|
|
72
|
-
expect(machine_event_of(42)).toBe("");
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
describe("is_periodic_event", () => {
|
|
77
|
-
it("names the events that arrive by themselves for ever", () => {
|
|
78
|
-
expect(is_periodic_event("EV_TIMEOUT")).toBe(true);
|
|
79
|
-
expect(is_periodic_event("EV_TIMEOUT_PERIODIC")).toBe(true);
|
|
80
|
-
expect(is_periodic_event("EV_HEARTBEAT")).toBe(true);
|
|
81
|
-
expect(is_periodic_event("EV_PING")).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("leaves the ones a user caused alone", () => {
|
|
85
|
-
expect(is_periodic_event("EV_ROUTE_CHANGED")).toBe(false);
|
|
86
|
-
expect(is_periodic_event("EV_ON_MESSAGE")).toBe(false);
|
|
87
|
-
expect(is_periodic_event("")).toBe(false);
|
|
88
|
-
expect(is_periodic_event(null)).toBe(false);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe("log_signature", () => {
|
|
93
|
-
it("signs a machine line by its EVENT, so a hundred of them are one thing", () => {
|
|
94
|
-
expect(log_signature("debug", VERBOSE_IN)).toBe("mach:EV_TIMEOUT");
|
|
95
|
-
expect(log_signature("debug", VERBOSE_RET)).toBe("mach:EV_TIMEOUT_PERIODIC");
|
|
96
|
-
expect(log_signature("debug", COMPACT)).toBe("mach:EV_TIMEOUT");
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("signs everything else by its level, as before", () => {
|
|
100
|
-
expect(log_signature("error", "connect failed")).toBe("log:error");
|
|
101
|
-
expect(log_signature("debug", "hello")).toBe("log:debug");
|
|
102
|
-
expect(log_signature("", "hello")).toBe("log:debug");
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe("log_is_periodic", () => {
|
|
107
|
-
it("hides the timer traffic the filter is for", () => {
|
|
108
|
-
expect(log_is_periodic("debug", VERBOSE_IN)).toBe(true);
|
|
109
|
-
expect(log_is_periodic("debug", VERBOSE_RET)).toBe(true);
|
|
110
|
-
expect(log_is_periodic("debug", COMPACT)).toBe(true);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("NEVER hides an error or a warning that names a timeout", () => {
|
|
114
|
-
expect(log_is_periodic("error", NOT_DEFINED)).toBe(false);
|
|
115
|
-
expect(log_is_periodic("warning", VERBOSE_RET)).toBe(false);
|
|
116
|
-
expect(log_is_periodic("error", "connection timeout")).toBe(false);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("leaves a transition somebody caused alone", () => {
|
|
120
|
-
expect(log_is_periodic("debug", VERBOSE_WORK)).toBe(false);
|
|
121
|
-
expect(log_is_periodic("debug", "just a log line")).toBe(false);
|
|
122
|
-
});
|
|
123
|
-
});
|