@yuneta/gobj-js 7.9.6 → 7.9.10

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 CHANGED
@@ -598,6 +598,44 @@ a GUI route framework output — **including the automata/FSM trace, which arriv
598
598
  as `debug`** — into its own monitor window while keeping the browser console
599
599
  clean (gobj-ui's dev-window "Output" selector does exactly this).
600
600
 
601
+ ### Tracing: the `machine` trace, and the levels around it
602
+
603
+ The FSM is where things happen, so the trace of the FSM **is** the execution
604
+ log. The level model is the C kernel's — same names, same bits — so a level
605
+ means one thing on both sides and a habit learned on a node transfers here.
606
+
607
+ ```javascript
608
+ gobj_set_global_trace("machine", true) // everything
609
+ gobj_set_gclass_trace("C_MY_VIEW", "machine", true)
610
+ gobj_set_gobj_trace(gobj, "ev_kw", true) // + the kw of each event
611
+ gobj_set_gobj_no_trace(noisy, "machine", true) // veto, by the SOURCE gobj
612
+
613
+ gobj_global_trace_level() // the mask in force
614
+ gobj_trace_level(gobj) // global | gclass | gobj, combined
615
+ gobj_repr_global_trace_levels() // [{name, bit, description, set}]
616
+ gobj_set_deep_trace(1) // everything, everywhere
617
+ gobj_set_trace_machine_format(1) // 1 = one compact line per transition
618
+ ```
619
+
620
+ Levels: `machine`, `create_delete`, `create_delete2`, `subscriptions`,
621
+ `start_stop`, `ev_kw`, `authzs`, `states`, `gbuffers`, `timer`, `fs`,
622
+ `liburing`, `timer_periodic`, `liburing_timer`, `commands`. The ones that only
623
+ exist on a node keep their bit rather than being dropped — removing them would
624
+ shift every bit above and break that alignment.
625
+
626
+ A gobj's effective level is the **union** of global, gclass and gobj.
627
+ `timer` / `timer_periodic` light up for their own event only. And the veto is
628
+ asked of the **source**, so one noisy sender can be silenced without turning
629
+ the destination off.
630
+
631
+ The trace arrives as `debug`, so **`set_log_callback()` is how you read it** —
632
+ that is how a dev panel shows the machine inside the app, and how
633
+ `doc.yuneta.io/navigation` feeds the panel under each of its demos.
634
+
635
+ > The yuno attrs `tracing` / `trace_timer` / `trace_creation` /
636
+ > `trace_start_stop` predate this and still work (gobj-ui's dev panel writes
637
+ > them); they fold in as one more source of bits.
638
+
601
639
  ### i18n: `refresh_language` and the `data-i18n-*` family
602
640
 
603
641
  The runtime does not translate anything itself — the **app** owns the
@@ -644,6 +644,18 @@ function gobj_set_gobj_trace(gobj, level, set) {
644
644
  else gobj.trace_level &= ~bitmask;
645
645
  return 0;
646
646
  }
647
+ function gobj_set_gclass_no_trace(gclass, level, set) {
648
+ const gclass_ = is_string(gclass) ? gclass_find_by_name(gclass) : gclass;
649
+ if (!gclass_) {
650
+ log_error(`gobj_set_gclass_no_trace: gclass NOT FOUND: ${gclass}`);
651
+ return -1;
652
+ }
653
+ const bitmask = trace_bitmask(level, "gobj_set_gclass_no_trace");
654
+ if (!bitmask) return -1;
655
+ if (set) gclass_.no_trace_level |= bitmask;
656
+ else gclass_.no_trace_level &= ~bitmask;
657
+ return 0;
658
+ }
647
659
  function gobj_set_gobj_no_trace(gobj, level, set) {
648
660
  if (!gobj) {
649
661
  log_error(`gobj_set_gobj_no_trace: gobj NULL`);
@@ -5381,10 +5393,22 @@ function create_template_record(template, kw) {
5381
5393
  * c_timer.js
5382
5394
  *
5383
5395
  * GClass Timer
5384
- * High-level, feed timers from periodic time of yuno
5385
- * IN SECONDS! although the parameter is in milliseconds (msec)
5396
+ * High-level timer, fed by the browser's own timer service
5386
5397
  *
5387
- * Copyright (c) 2025, ArtGins.
5398
+ * Don't use gobj_start()/gobj_stop(), USE set_timeout..(), clear_timeout()
5399
+ *
5400
+ * The CONTRACT is the C one (see c_timer.h), and it is the whole
5401
+ * public surface: set_timeout() arms, clear_timeout() disarms, and
5402
+ * a one-shot is done once it fires. Whether the gobj is running is
5403
+ * an INTERNAL matter of this gclass -- nobody asking for a timeout
5404
+ * has to know it exists, and no caller should have to pair a
5405
+ * set_timeout() with a gobj_start() to make it work.
5406
+ *
5407
+ * What feeds the timer is the only thing that differs from C, and
5408
+ * it is deliberately invisible from outside: there the gobj rides
5409
+ * the yuno's one-second heartbeat, here it is a native setTimeout().
5410
+ *
5411
+ * Copyright (c) 2025-2026, ArtGins.
5388
5412
  * All Rights Reserved.
5389
5413
  ****************************************************************************/
5390
5414
  /***************************************************************
@@ -5437,6 +5461,9 @@ function mt_writing$2(gobj, path) {
5437
5461
  if (priv.msec > 0) priv.timer_id = setTimeout(function() {
5438
5462
  gobj_send_event(gobj, "EV_TIMEOUT", {}, gobj);
5439
5463
  }, priv.msec);
5464
+ if (priv.msec > 0) {
5465
+ if (!gobj_is_running(gobj)) gobj_start(gobj);
5466
+ } else if (gobj_is_running(gobj)) gobj_stop(gobj);
5440
5467
  break;
5441
5468
  }
5442
5469
  }
@@ -5466,11 +5493,15 @@ function mt_destroy$2(gobj) {}
5466
5493
  function ac_timeout$1(gobj, event, kw, src) {
5467
5494
  let priv = gobj.priv;
5468
5495
  let ev = priv.periodic ? "EV_TIMEOUT_PERIODIC" : "EV_TIMEOUT";
5469
- if (gobj_is_pure_child(gobj)) gobj_send_event(gobj_parent(gobj), ev, {}, gobj);
5470
- else gobj_publish_event(gobj, ev, {});
5471
- if (priv.periodic) priv.timer_id = setTimeout(function() {
5496
+ if (priv.periodic && priv.msec > 0) priv.timer_id = setTimeout(function() {
5472
5497
  gobj_send_event(gobj, "EV_TIMEOUT", {}, gobj);
5473
5498
  }, priv.msec);
5499
+ else priv.timer_id = -1;
5500
+ if (gobj_is_pure_child(gobj)) gobj_send_event(gobj_parent(gobj), ev, {}, gobj);
5501
+ else gobj_publish_event(gobj, ev, {});
5502
+ if (!priv.periodic && priv.timer_id === -1) {
5503
+ if (gobj_is_running(gobj)) gobj_stop(gobj);
5504
+ }
5474
5505
  return 0;
5475
5506
  }
5476
5507
  /***************************
@@ -6596,6 +6627,7 @@ exports.gobj_send_event = gobj_send_event;
6596
6627
  exports.gobj_services = gobj_services;
6597
6628
  exports.gobj_set_bottom_gobj = gobj_set_bottom_gobj;
6598
6629
  exports.gobj_set_deep_trace = gobj_set_deep_trace;
6630
+ exports.gobj_set_gclass_no_trace = gobj_set_gclass_no_trace;
6599
6631
  exports.gobj_set_gclass_trace = gobj_set_gclass_trace;
6600
6632
  exports.gobj_set_global_no_trace = gobj_set_global_no_trace;
6601
6633
  exports.gobj_set_global_trace = gobj_set_global_trace;