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