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