@yuneta/gobj-js 7.2.1 → 7.3.3

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.
@@ -240,7 +240,7 @@ var sdata_flag_t = Object.freeze({
240
240
  SDF_VOLATIL: 32,
241
241
  SDF_RESOURCE: 64,
242
242
  SDF_PKEY: 128,
243
- SDF_FUTURE1: 256,
243
+ SDF_DEPRECATED: 256,
244
244
  SDF_FUTURE2: 512,
245
245
  SDF_WILD_CMD: 1024,
246
246
  SDF_STATS: 2048,
@@ -512,7 +512,8 @@ function json2item(gobj, sdata, it, jn_value_) {
512
512
  let jn_value2;
513
513
  switch (it.type) {
514
514
  case data_type_t.DTP_STRING:
515
- if (is_string(jn_value_)) jn_value2 = String(jn_value_);
515
+ if (jn_value_ === null || jn_value_ === void 0) jn_value2 = "";
516
+ else if (is_string(jn_value_)) jn_value2 = String(jn_value_);
516
517
  else {
517
518
  let s = JSON.stringify(jn_value_);
518
519
  if (s) jn_value2 = String(s);
@@ -987,6 +988,7 @@ function json2sdata(hsdata, kw, flag, not_found_cb, gobj) {
987
988
  continue;
988
989
  }
989
990
  if (!(flag === -1 || it.flag & flag)) continue;
991
+ if (it.flag & sdata_flag_t.SDF_DEPRECATED) log_warning(`${gobj_short_name(gobj)}: Deprecated attribute used in gobj creation: ${key}`);
990
992
  ret += json2item(gobj, hsdata, it, jn_value);
991
993
  }
992
994
  return ret;
@@ -4388,8 +4390,10 @@ function createElement2(description, translate_fn) {
4388
4390
  el.style.cssText = styleString;
4389
4391
  } else if (attr === "style") el.style.cssText = attrs[attr];
4390
4392
  else if (attr === "i18n" || attr === "data-i18n" || attr === "data_i18next" || attr === "data-i18next") {
4391
- data_i18next = attrs[attr];
4392
- el.setAttribute("data-i18n", data_i18next);
4393
+ if (attrs[attr] !== null && attrs[attr] !== void 0) {
4394
+ data_i18next = attrs[attr];
4395
+ el.setAttribute("data-i18n", data_i18next);
4396
+ }
4393
4397
  } else el.setAttribute(attr, attrs[attr]);
4394
4398
  if (is_string(content)) {
4395
4399
  content = content.trim();
@@ -4462,6 +4466,14 @@ function refresh_language(element, t) {
4462
4466
  break;
4463
4467
  }
4464
4468
  });
4469
+ element.querySelectorAll("[data-i18n-title]").forEach(function(elem) {
4470
+ let value = elem.getAttribute("data-i18n-title");
4471
+ if (value) elem.setAttribute("title", t(value));
4472
+ });
4473
+ element.querySelectorAll("[data-i18n-aria-label]").forEach(function(elem) {
4474
+ let value = elem.getAttribute("data-i18n-aria-label");
4475
+ if (value) elem.setAttribute("aria-label", t(value));
4476
+ });
4465
4477
  }
4466
4478
  /************************************************************
4467
4479
  * Example Usage
@@ -5842,6 +5854,17 @@ function ac_on_close(gobj, event, kw, src) {
5842
5854
  remote_yuno_role: priv.remote_yuno_role,
5843
5855
  remote_yuno_service: priv.remote_yuno_service
5844
5856
  });
5857
+ } else {
5858
+ log_warning(`${gobj_short_name(gobj)}: EV_ON_OPEN_ERROR cannot open ${url} (Code: ${e.code}, Reason: "${e.reason}", Clean: ${e.wasClean})`);
5859
+ gobj_publish_event(gobj, "EV_ON_OPEN_ERROR", {
5860
+ url,
5861
+ remote_yuno_name: priv.remote_yuno_name,
5862
+ remote_yuno_role: priv.remote_yuno_role,
5863
+ remote_yuno_service: priv.remote_yuno_service,
5864
+ code: e.code,
5865
+ reason: e.reason,
5866
+ was_clean: e.wasClean
5867
+ });
5845
5868
  }
5846
5869
  if (gobj_is_running(gobj)) set_timeout(priv.gobj_timer, gobj_read_integer_attr(gobj, "timeout_retry"));
5847
5870
  return 0;
@@ -6072,6 +6095,7 @@ function create_gclass(gclass_name) {
6072
6095
  ["EV_MT_COMMAND", event_flag_t.EVF_PUBLIC_EVENT],
6073
6096
  ["EV_ON_OPEN", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
6074
6097
  ["EV_ON_CLOSE", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
6098
+ ["EV_ON_OPEN_ERROR", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
6075
6099
  ["EV_TIMEOUT", 0],
6076
6100
  [null, 0]
6077
6101
  ], states, gmt, 0, attrs_table, PRIVATE_DATA, 0, 0, 0, gclass_flag_t.gcflag_no_check_output_events);