@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.
@@ -647,6 +647,18 @@
647
647
  else gobj.trace_level &= ~bitmask;
648
648
  return 0;
649
649
  }
650
+ function gobj_set_gclass_no_trace(gclass, level, set) {
651
+ const gclass_ = is_string(gclass) ? gclass_find_by_name(gclass) : gclass;
652
+ if (!gclass_) {
653
+ log_error(`gobj_set_gclass_no_trace: gclass NOT FOUND: ${gclass}`);
654
+ return -1;
655
+ }
656
+ const bitmask = trace_bitmask(level, "gobj_set_gclass_no_trace");
657
+ if (!bitmask) return -1;
658
+ if (set) gclass_.no_trace_level |= bitmask;
659
+ else gclass_.no_trace_level &= ~bitmask;
660
+ return 0;
661
+ }
650
662
  function gobj_set_gobj_no_trace(gobj, level, set) {
651
663
  if (!gobj) {
652
664
  log_error(`gobj_set_gobj_no_trace: gobj NULL`);
@@ -5384,10 +5396,22 @@
5384
5396
  * c_timer.js
5385
5397
  *
5386
5398
  * GClass Timer
5387
- * High-level, feed timers from periodic time of yuno
5388
- * IN SECONDS! although the parameter is in milliseconds (msec)
5399
+ * High-level timer, fed by the browser's own timer service
5389
5400
  *
5390
- * Copyright (c) 2025, ArtGins.
5401
+ * Don't use gobj_start()/gobj_stop(), USE set_timeout..(), clear_timeout()
5402
+ *
5403
+ * The CONTRACT is the C one (see c_timer.h), and it is the whole
5404
+ * public surface: set_timeout() arms, clear_timeout() disarms, and
5405
+ * a one-shot is done once it fires. Whether the gobj is running is
5406
+ * an INTERNAL matter of this gclass -- nobody asking for a timeout
5407
+ * has to know it exists, and no caller should have to pair a
5408
+ * set_timeout() with a gobj_start() to make it work.
5409
+ *
5410
+ * What feeds the timer is the only thing that differs from C, and
5411
+ * it is deliberately invisible from outside: there the gobj rides
5412
+ * the yuno's one-second heartbeat, here it is a native setTimeout().
5413
+ *
5414
+ * Copyright (c) 2025-2026, ArtGins.
5391
5415
  * All Rights Reserved.
5392
5416
  ****************************************************************************/
5393
5417
  /***************************************************************
@@ -5440,6 +5464,9 @@
5440
5464
  if (priv.msec > 0) priv.timer_id = setTimeout(function() {
5441
5465
  gobj_send_event(gobj, "EV_TIMEOUT", {}, gobj);
5442
5466
  }, priv.msec);
5467
+ if (priv.msec > 0) {
5468
+ if (!gobj_is_running(gobj)) gobj_start(gobj);
5469
+ } else if (gobj_is_running(gobj)) gobj_stop(gobj);
5443
5470
  break;
5444
5471
  }
5445
5472
  }
@@ -5469,11 +5496,15 @@
5469
5496
  function ac_timeout$1(gobj, event, kw, src) {
5470
5497
  let priv = gobj.priv;
5471
5498
  let ev = priv.periodic ? "EV_TIMEOUT_PERIODIC" : "EV_TIMEOUT";
5472
- if (gobj_is_pure_child(gobj)) gobj_send_event(gobj_parent(gobj), ev, {}, gobj);
5473
- else gobj_publish_event(gobj, ev, {});
5474
- if (priv.periodic) priv.timer_id = setTimeout(function() {
5499
+ if (priv.periodic && priv.msec > 0) priv.timer_id = setTimeout(function() {
5475
5500
  gobj_send_event(gobj, "EV_TIMEOUT", {}, gobj);
5476
5501
  }, priv.msec);
5502
+ else priv.timer_id = -1;
5503
+ if (gobj_is_pure_child(gobj)) gobj_send_event(gobj_parent(gobj), ev, {}, gobj);
5504
+ else gobj_publish_event(gobj, ev, {});
5505
+ if (!priv.periodic && priv.timer_id === -1) {
5506
+ if (gobj_is_running(gobj)) gobj_stop(gobj);
5507
+ }
5477
5508
  return 0;
5478
5509
  }
5479
5510
  /***************************
@@ -6599,6 +6630,7 @@
6599
6630
  exports.gobj_services = gobj_services;
6600
6631
  exports.gobj_set_bottom_gobj = gobj_set_bottom_gobj;
6601
6632
  exports.gobj_set_deep_trace = gobj_set_deep_trace;
6633
+ exports.gobj_set_gclass_no_trace = gobj_set_gclass_no_trace;
6602
6634
  exports.gobj_set_gclass_trace = gobj_set_gclass_trace;
6603
6635
  exports.gobj_set_global_no_trace = gobj_set_global_no_trace;
6604
6636
  exports.gobj_set_global_trace = gobj_set_global_trace;