@yuneta/gobj-js 7.26.0 → 7.26.2

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.
@@ -896,17 +896,20 @@ var gobjJs = (function(exports) {
896
896
  break;
897
897
  case data_type_t.DTP_JSON:
898
898
  jn_value2 = jn_value_;
899
- if (is_string(jn_value_)) try {
900
- jn_value2 = JSON.parse(jn_value_);
901
- } catch (error) {
902
- jn_value2 = jn_value_;
899
+ if (is_string(jn_value_)) {
900
+ const t = jn_value_.trim();
901
+ if (t.startsWith("{") || t.startsWith("[")) try {
902
+ jn_value2 = JSON.parse(t);
903
+ } catch (error) {
904
+ jn_value2 = jn_value_;
905
+ }
903
906
  }
904
907
  break;
905
908
  case data_type_t.DTP_POINTER: jn_value2 = jn_value_;
906
909
  }
907
910
  if (jn_value2 === void 0) log_error(`${gobj_short_name(gobj)}: attr undefined: ${it.name}`);
908
911
  sdata[it.name] = jn_value2;
909
- if (is_object(gobj.priv) && gobj.priv.hasOwnProperty(it.name)) gobj.priv[it.name] = jn_value2;
912
+ if (is_object(gobj.priv) && Object.prototype.hasOwnProperty.call(gobj.priv, it.name)) gobj.priv[it.name] = jn_value2;
910
913
  if (gobj.obflag & obflag_t.obflag_created && !(gobj.obflag & obflag_t.obflag_destroyed)) {
911
914
  if (gobj.gclass.gmt.mt_writing) gobj.gclass.gmt.mt_writing(gobj, it.name);
912
915
  }
@@ -2109,7 +2112,7 @@ var gobjJs = (function(exports) {
2109
2112
  function gobj_read_attr(gobj, name, src) {
2110
2113
  let jn_attrs = gobj.jn_attrs;
2111
2114
  if (name in jn_attrs) {
2112
- if (jn_attrs.hasOwnProperty(name)) {
2115
+ if (Object.prototype.hasOwnProperty.call(jn_attrs, name)) {
2113
2116
  let value = jn_attrs[name];
2114
2117
  if (gobj.gclass.gmt.mt_reading) return gobj.gclass.gmt.mt_reading(gobj, name, value);
2115
2118
  return value;
@@ -2215,9 +2218,9 @@ var gobjJs = (function(exports) {
2215
2218
  if (ss.length <= 1) {
2216
2219
  let key = path;
2217
2220
  if (key in jn_attrs) {
2218
- if (jn_attrs.hasOwnProperty(key)) {
2221
+ if (Object.prototype.hasOwnProperty.call(jn_attrs, key)) {
2219
2222
  jn_attrs[key] = value;
2220
- if (is_object(gobj.priv) && gobj.priv.hasOwnProperty(key)) gobj.priv[key] = value;
2223
+ if (is_object(gobj.priv) && Object.prototype.hasOwnProperty.call(gobj.priv, key)) gobj.priv[key] = value;
2221
2224
  if (gobj.obflag & obflag_t.obflag_created && !(gobj.obflag & obflag_t.obflag_destroyed)) {
2222
2225
  if (gobj.gclass.gmt.mt_writing) gobj.gclass.gmt.mt_writing(gobj, key);
2223
2226
  }
@@ -2238,9 +2241,9 @@ var gobjJs = (function(exports) {
2238
2241
  }
2239
2242
  let jn_attrs = gobj.jn_attrs;
2240
2243
  if (key in jn_attrs) {
2241
- if (jn_attrs.hasOwnProperty(key)) {
2244
+ if (Object.prototype.hasOwnProperty.call(jn_attrs, key)) {
2242
2245
  jn_attrs[key] = value;
2243
- if (is_object(gobj.priv) && gobj.priv.hasOwnProperty(key)) gobj.priv[key] = value;
2246
+ if (is_object(gobj.priv) && Object.prototype.hasOwnProperty.call(gobj.priv, key)) gobj.priv[key] = value;
2244
2247
  if (gobj.obflag & obflag_t.obflag_created && !(gobj.obflag & obflag_t.obflag_destroyed)) {
2245
2248
  if (gobj.gclass.gmt.mt_writing) gobj.gclass.gmt.mt_writing(gobj, key);
2246
2249
  }
@@ -2267,7 +2270,7 @@ var gobjJs = (function(exports) {
2267
2270
  if (exclude_flag && it.flag & exclude_flag) continue;
2268
2271
  if (include_flag === -1 || it.flag & include_flag) {
2269
2272
  set_default(gobj, gobj.jn_attrs, it);
2270
- if (is_object(gobj.priv) && gobj.priv.hasOwnProperty(it.name)) gobj.priv[it.name] = gobj.jn_attrs[it.name];
2273
+ if (is_object(gobj.priv) && Object.prototype.hasOwnProperty.call(gobj.priv, it.name)) gobj.priv[it.name] = gobj.jn_attrs[it.name];
2271
2274
  if (gobj.gclass.gmt.mt_writing) gobj.gclass.gmt.mt_writing(gobj, it.name);
2272
2275
  }
2273
2276
  }
@@ -2301,7 +2304,7 @@ var gobjJs = (function(exports) {
2301
2304
  let hs = gobj_hsdata2(gobj, name, false);
2302
2305
  if (hs) {
2303
2306
  hs[name] = parseBoolean(value);
2304
- if (is_object(gobj.priv) && gobj.priv.hasOwnProperty(name)) gobj.priv[name] = hs[name];
2307
+ if (is_object(gobj.priv) && Object.prototype.hasOwnProperty.call(gobj.priv, name)) gobj.priv[name] = hs[name];
2305
2308
  if (gobj.obflag & obflag_t.obflag_created && !(gobj.obflag & obflag_t.obflag_destroyed)) {
2306
2309
  if (gobj.gclass.gmt.mt_writing) gobj.gclass.gmt.mt_writing(gobj, name);
2307
2310
  }
@@ -2317,7 +2320,7 @@ var gobjJs = (function(exports) {
2317
2320
  let hs = gobj_hsdata2(gobj, name, false);
2318
2321
  if (hs) {
2319
2322
  hs[name] = parseInt(value);
2320
- if (is_object(gobj.priv) && gobj.priv.hasOwnProperty(name)) gobj.priv[name] = hs[name];
2323
+ if (is_object(gobj.priv) && Object.prototype.hasOwnProperty.call(gobj.priv, name)) gobj.priv[name] = hs[name];
2321
2324
  if (gobj.obflag & obflag_t.obflag_created && !(gobj.obflag & obflag_t.obflag_destroyed)) {
2322
2325
  if (gobj.gclass.gmt.mt_writing) gobj.gclass.gmt.mt_writing(gobj, name);
2323
2326
  }
@@ -2333,7 +2336,7 @@ var gobjJs = (function(exports) {
2333
2336
  let hs = gobj_hsdata2(gobj, name, false);
2334
2337
  if (hs) {
2335
2338
  hs[name] = String(value);
2336
- if (is_object(gobj.priv) && gobj.priv.hasOwnProperty(name)) gobj.priv[name] = hs[name];
2339
+ if (is_object(gobj.priv) && Object.prototype.hasOwnProperty.call(gobj.priv, name)) gobj.priv[name] = hs[name];
2337
2340
  if (gobj.obflag & obflag_t.obflag_created && !(gobj.obflag & obflag_t.obflag_destroyed)) {
2338
2341
  if (gobj.gclass.gmt.mt_writing) gobj.gclass.gmt.mt_writing(gobj, name);
2339
2342
  }
@@ -2600,7 +2603,7 @@ var gobjJs = (function(exports) {
2600
2603
  } catch (e) {
2601
2604
  __inside__--;
2602
2605
  if (!(e && e.__gobj_logged__)) {
2603
- log_error(`${gobj_short_name(dst)}: action of ${event} in ${dst.current_state.state_name} THREW: ${e && e.stack ? e.stack : e}`);
2606
+ log_error(`${gobj_short_name(dst)}: action of ${event} in ${state.state_name} THREW: ${e && e.stack ? e.stack : e}`);
2604
2607
  try {
2605
2608
  e.__gobj_logged__ = true;
2606
2609
  } catch (e2) {}
@@ -2721,8 +2724,8 @@ var gobjJs = (function(exports) {
2721
2724
  kw,
2722
2725
  renamed_event: ""
2723
2726
  };
2724
- let kw_match = Object.assign({}, kw);
2725
- let config_match = Object.assign({}, __config__);
2727
+ let kw_match = json_object_update({}, kw);
2728
+ let config_match = json_object_update({}, __config__);
2726
2729
  kw_match.__config__ = config_match;
2727
2730
  let renamed_event = "";
2728
2731
  let rename = config_match.__rename_event_name__;
@@ -2730,7 +2733,7 @@ var gobjJs = (function(exports) {
2730
2733
  if (event_type) {
2731
2734
  renamed_event = event_type.event_name;
2732
2735
  delete config_match.__rename_event_name__;
2733
- if (event && json_size(kw_match.__global__) > 0) kw_match.__global__ = Object.assign({}, kw_match.__global__, { __original_event_name__: event });
2736
+ if (event && json_size(kw_match.__global__) > 0) kw_match.__global__ = json_object_update(json_object_update({}, kw_match.__global__), { __original_event_name__: event });
2734
2737
  }
2735
2738
  delete config_match.__hard_subscription__;
2736
2739
  delete config_match.__own_event__;
@@ -3106,7 +3109,7 @@ var gobjJs = (function(exports) {
3106
3109
  }
3107
3110
  }
3108
3111
  let kw2publish = kw;
3109
- if (json_size(__local__) > 0 || json_size(__global__) > 0) kw2publish = Object.assign({}, kw);
3112
+ if (json_size(__local__) > 0 || json_size(__global__) > 0) kw2publish = json_object_update({}, kw);
3110
3113
  if (json_size(__local__) > 0) kw_pop(kw2publish, __local__);
3111
3114
  if (__config__) {}
3112
3115
  if (json_size(__global__) > 0) json_object_update(kw2publish, json_deep_copy(__global__));
@@ -3608,7 +3611,7 @@ var gobjJs = (function(exports) {
3608
3611
  if ((is_secret_name(key.slice(-128)) || value_is_secret && key === "value") && value !== void 0 && value !== null && value !== "") shown = "********";
3609
3612
  else shown = _json_mask_secrets(value, memo, depth + 1, budget);
3610
3613
  if (shown !== value) changed = true;
3611
- result[key] = shown;
3614
+ set_own_key(result, key, shown);
3612
3615
  }
3613
3616
  if (truncated) result["<more>"] = MASK_TOO_LARGE;
3614
3617
  }
@@ -3643,10 +3646,7 @@ var gobjJs = (function(exports) {
3643
3646
  ************************************************************/
3644
3647
  function duplicate_objects(...sourceObjects) {
3645
3648
  const result = {};
3646
- for (const obj of sourceObjects) {
3647
- const clonedObj = structuredClone(obj);
3648
- Object.assign(result, clonedObj);
3649
- }
3649
+ for (const obj of sourceObjects) json_object_update(result, structuredClone(obj));
3650
3650
  return result;
3651
3651
  }
3652
3652
  /************************************************************
@@ -3680,7 +3680,7 @@ var gobjJs = (function(exports) {
3680
3680
  ************************************************************/
3681
3681
  function json_object_update(destination, source) {
3682
3682
  if (!source) return destination;
3683
- for (let property of Object.keys(source)) destination[property] = source[property];
3683
+ for (let property of Object.keys(source)) set_own_key(destination, property, source[property]);
3684
3684
  return destination;
3685
3685
  }
3686
3686
  /************************************************************
@@ -3689,7 +3689,7 @@ var gobjJs = (function(exports) {
3689
3689
  ************************************************************/
3690
3690
  function json_object_update_existing(destination, source) {
3691
3691
  if (!source) return destination;
3692
- for (let property in source) if (source.hasOwnProperty(property) && destination.hasOwnProperty(property)) destination[property] = source[property];
3692
+ for (let property in source) if (Object.prototype.hasOwnProperty.call(source, property) && Object.prototype.hasOwnProperty.call(destination, property)) set_own_key(destination, property, source[property]);
3693
3693
  return destination;
3694
3694
  }
3695
3695
  /************************************************************
@@ -3698,32 +3698,32 @@ var gobjJs = (function(exports) {
3698
3698
  ************************************************************/
3699
3699
  function json_object_update_missing(destination, source) {
3700
3700
  if (!source) return destination;
3701
- for (let property in source) if (source.hasOwnProperty(property) && !destination.hasOwnProperty(property)) destination[property] = source[property];
3701
+ for (let property in source) if (Object.prototype.hasOwnProperty.call(source, property) && !Object.prototype.hasOwnProperty.call(destination, property)) set_own_key(destination, property, source[property]);
3702
3702
  return destination;
3703
3703
  }
3704
3704
  /************************************************************
3705
3705
  * Simulate jansson function
3706
3706
  ************************************************************/
3707
3707
  function json_object_get(o, key) {
3708
- if (o && o.hasOwnProperty(key)) return o[key];
3708
+ if (o && Object.prototype.hasOwnProperty.call(o, key)) return o[key];
3709
3709
  }
3710
3710
  /************************************************************
3711
3711
  * Simulate jansson function
3712
3712
  ************************************************************/
3713
3713
  function json_object_del(o, k) {
3714
- if (o && o.hasOwnProperty(k)) delete o[k];
3714
+ if (o && Object.prototype.hasOwnProperty.call(o, k)) delete o[k];
3715
3715
  }
3716
3716
  /************************************************************
3717
3717
  * Simulate jansson function
3718
3718
  ************************************************************/
3719
3719
  function json_object_set(o, k, v) {
3720
- o[k] = v;
3720
+ set_own_key(o, k, v);
3721
3721
  }
3722
3722
  /************************************************************
3723
3723
  * Simulate jansson function
3724
3724
  ************************************************************/
3725
3725
  function json_object_set_new(o, k, v) {
3726
- o[k] = v;
3726
+ set_own_key(o, k, v);
3727
3727
  }
3728
3728
  /************************************************************
3729
3729
  * Simulate jansson function
@@ -3967,22 +3967,20 @@ var gobjJs = (function(exports) {
3967
3967
  ************************************************************/
3968
3968
  function kw_has_key(kw, key) {
3969
3969
  if (key in kw) {
3970
- if (kw.hasOwnProperty(key)) return true;
3970
+ if (Object.prototype.hasOwnProperty.call(kw, key)) return true;
3971
3971
  }
3972
3972
  return false;
3973
3973
  }
3974
3974
  /************************************************************
3975
3975
  * A key that reaches the prototype chain instead of the data:
3976
- * "__proto__", "constructor" or "prototype" when the object
3977
- * does not hold it as its OWN key. A walk through one of them
3976
+ * any key the object does not hold as its OWN key. A walk through one of them
3978
3977
  * read, or WROTE, Object.prototype: the flat id
3979
3978
  * "__proto__`polluted" set a key on every object of the page.
3980
3979
  * In C they are keys like any other, so here too: read them
3981
3980
  * only as own keys, and write "__proto__" as an own key.
3982
3981
  ************************************************************/
3983
3982
  function is_prototype_segment(obj, key) {
3984
- if (key === "__proto__" || key === "constructor" || key === "prototype") return !Object.prototype.hasOwnProperty.call(obj, key);
3985
- return false;
3983
+ return !Object.prototype.hasOwnProperty.call(obj, key);
3986
3984
  }
3987
3985
  function set_own_key(obj, key, value) {
3988
3986
  if (key === "__proto__") Object.defineProperty(obj, key, {
@@ -4021,6 +4019,13 @@ var gobjJs = (function(exports) {
4021
4019
  let ss = path.split("`");
4022
4020
  let len = ss.length;
4023
4021
  for (let i = 0; i < len; i++) {
4022
+ if (is_array(kw)) {
4023
+ if (!/^[0-9]+$/.test(ss[i])) {
4024
+ if (verbose) log_error(`${prefix}path not found: '${path}'`);
4025
+ return;
4026
+ }
4027
+ ss[i] = String(Number(ss[i]));
4028
+ }
4024
4029
  if (is_prototype_segment(kw, ss[i])) {
4025
4030
  if (verbose) log_error(`${prefix}path not found: '${path}'`);
4026
4031
  return;
@@ -4438,7 +4443,7 @@ var gobjJs = (function(exports) {
4438
4443
  log_error("subdict is not an object");
4439
4444
  return -1;
4440
4445
  }
4441
- subdict[key] = value;
4446
+ set_own_key(subdict, key, value);
4442
4447
  return 0;
4443
4448
  }
4444
4449
  /***************************************************************************
@@ -4565,14 +4570,14 @@ var gobjJs = (function(exports) {
4565
4570
  let kw_clone = {};
4566
4571
  if (is_string(keys) && !empty_string(keys)) {
4567
4572
  let key = keys;
4568
- if (kw.hasOwnProperty(key)) kw_clone[key] = kw[key];
4573
+ if (Object.prototype.hasOwnProperty.call(kw, key)) set_own_key(kw_clone, key, kw[key]);
4569
4574
  else if (verbose) log_error(`${gobj_short_name(gobj)}: key not found: ${key}`);
4570
4575
  } else if (is_object(keys) && json_object_size(keys) > 0) {
4571
- for (let key of Object.keys(keys)) if (kw.hasOwnProperty(key)) kw_clone[key] = kw[key];
4576
+ for (let key of Object.keys(keys)) if (Object.prototype.hasOwnProperty.call(kw, key)) set_own_key(kw_clone, key, kw[key]);
4572
4577
  else if (verbose) log_error(`${gobj_short_name(gobj)}: key not found: ${key}`);
4573
4578
  } else if (is_array(keys) && json_array_size(keys) > 0) for (let j = 0; j < keys.length; j++) {
4574
4579
  let key = keys[j];
4575
- if (kw.hasOwnProperty(key)) kw_clone[key] = kw[key];
4580
+ if (Object.prototype.hasOwnProperty.call(kw, key)) set_own_key(kw_clone, key, kw[key]);
4576
4581
  else if (verbose) log_error(`${gobj_short_name(gobj)}: key not found: ${key}`);
4577
4582
  }
4578
4583
  else return kw;
@@ -4594,14 +4599,14 @@ var gobjJs = (function(exports) {
4594
4599
  json_object_update(kw_clone, kw);
4595
4600
  if (is_string(keys) && !empty_string(keys)) {
4596
4601
  let key = keys;
4597
- if (kw.hasOwnProperty(key)) json_object_del(kw_clone, key);
4602
+ if (Object.prototype.hasOwnProperty.call(kw, key)) json_object_del(kw_clone, key);
4598
4603
  else if (verbose) log_error(`${gobj_short_name(gobj)}: key not found: ${key}`);
4599
4604
  } else if (is_object(keys) && json_object_size(keys) > 0) {
4600
- for (let key of Object.keys(keys)) if (kw.hasOwnProperty(key)) json_object_del(kw_clone, key);
4605
+ for (let key of Object.keys(keys)) if (Object.prototype.hasOwnProperty.call(kw, key)) json_object_del(kw_clone, key);
4601
4606
  else if (verbose) log_error(`${gobj_short_name(gobj)}: key not found: ${key}`);
4602
4607
  } else if (is_array(keys) && json_array_size(keys) > 0) for (let j = 0; j < keys.length; j++) {
4603
4608
  let key = keys[j];
4604
- if (kw.hasOwnProperty(key)) json_object_del(kw_clone, key);
4609
+ if (Object.prototype.hasOwnProperty.call(kw, key)) json_object_del(kw_clone, key);
4605
4610
  else if (verbose) log_error(`${gobj_short_name(gobj)}: key not found: ${key}`);
4606
4611
  }
4607
4612
  else return {};
@@ -4746,7 +4751,7 @@ var gobjJs = (function(exports) {
4746
4751
  else if (is_array(kw)) for (let i = 0; i < kw.length; i++) {
4747
4752
  let kv = kw[i];
4748
4753
  let id = kw_get_str(gobj, kv, "id", "", kw_flag_t.KW_REQUIRED);
4749
- if (!empty_string(id)) new_dict[id] = kv;
4754
+ if (!empty_string(id)) set_own_key(new_dict, id, kv);
4750
4755
  }
4751
4756
  else log_error(`${gobj_short_name(gobj)} kwid_new_dict: data type unknown`);
4752
4757
  return new_dict;
@@ -4832,7 +4837,7 @@ var gobjJs = (function(exports) {
4832
4837
  let new_ids = [];
4833
4838
  if (is_string(ids)) new_ids.push(ids);
4834
4839
  else if (is_object(ids)) {
4835
- for (let id in ids) if (ids.hasOwnProperty(id)) new_ids.push(id);
4840
+ for (let id in ids) if (Object.prototype.hasOwnProperty.call(ids, id)) new_ids.push(id);
4836
4841
  } else if (is_array(ids)) ids.forEach(function(item) {
4837
4842
  if (is_string(item)) {
4838
4843
  if (!empty_string(item)) new_ids.push(item);
@@ -5085,7 +5090,7 @@ var gobjJs = (function(exports) {
5085
5090
  function _traverse_dict(obj, callback, full_path) {
5086
5091
  if (full_path === void 0 || !is_string(full_path)) full_path = "";
5087
5092
  for (let key of Object.keys(obj)) {
5088
- if (!obj.hasOwnProperty(key)) continue;
5093
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
5089
5094
  let sufix = (full_path.length ? "`" : "") + key;
5090
5095
  full_path += sufix;
5091
5096
  callback.apply(this, [
@@ -5192,11 +5197,11 @@ var gobjJs = (function(exports) {
5192
5197
  }
5193
5198
  if (ids.length === 0 && v) {
5194
5199
  if (is_array(v)) v.push(kw);
5195
- else if (v["id"] === kw["id"]) Object.assign(v, kw);
5200
+ else if (v["id"] === kw["id"]) json_object_update(v, kw);
5196
5201
  else {
5197
5202
  let v_ = kw_get_dict_value(null, v, jdb.hook, [], 1);
5198
5203
  let v__ = _jdb_get(v_, jdb.hook, kw["id"], false);
5199
- if (v__) Object.assign(v__, kw);
5204
+ if (v__) json_object_update(v__, kw);
5200
5205
  else v_.push(kw);
5201
5206
  }
5202
5207
  }
@@ -5563,6 +5568,10 @@ var gobjJs = (function(exports) {
5563
5568
  * as a bare string, or "<img src=x onerror=...>" runs.
5564
5569
  * Pass it as a Text node, which is always text:
5565
5570
  * ['span', {}, document.createTextNode(value)]
5571
+ * In a LIST of children a node (element, svg, Text) is
5572
+ * appended as it is and a string is always text -- but a
5573
+ * list whose first item is a string is read as ONE
5574
+ * description (the string is its tag).
5566
5575
  * if attrs['i18n'] is not empty then (or 'data-i18n' or 'data_i18next')
5567
5576
  * it will be overridden with the translation
5568
5577
  * content = translate(attrs['i18n']));
@@ -5615,8 +5624,11 @@ var gobjJs = (function(exports) {
5615
5624
  } else if (is_array(content)) {
5616
5625
  if (content.length > 0) {
5617
5626
  if (is_string(content[0])) el.appendChild(createElement2(content, translate_fn));
5618
- else for (let child of content) if (Array.isArray(child) && child.length > 0) el.appendChild(createElement2(child, translate_fn));
5619
- else if (child instanceof HTMLElement) el.appendChild(child);
5627
+ else for (let child of content) if (Array.isArray(child)) {
5628
+ if (child.length > 0) el.appendChild(createElement2(child, translate_fn));
5629
+ } else if (child instanceof Node) el.appendChild(child);
5630
+ else if (is_string(child)) el.appendChild(document.createTextNode(child));
5631
+ else if (child !== null && child !== void 0 && child !== false) log_error(`createElement2: child ignored, type ${typeof child}`);
5620
5632
  }
5621
5633
  } else if (content instanceof HTMLElement || content instanceof Text || content instanceof SVGElement) el.appendChild(content);
5622
5634
  else if (content != null) {
@@ -5966,7 +5978,7 @@ var gobjJs = (function(exports) {
5966
5978
  return;
5967
5979
  }
5968
5980
  if (depth === 0) return;
5969
- flat[path] = value;
5981
+ set_own_key(flat, path, value);
5970
5982
  };
5971
5983
  if (jn === void 0 || jn === null) return flat;
5972
5984
  walk(jn, "", 0);
@@ -6049,12 +6061,12 @@ var gobjJs = (function(exports) {
6049
6061
  removed: {},
6050
6062
  changed: {}
6051
6063
  };
6052
- for (const key of Object.keys(a)) if (!Object.prototype.hasOwnProperty.call(b, key)) diff.removed[key] = a[key];
6053
- else if (!flat_value_equal(a[key], b[key])) diff.changed[key] = {
6064
+ for (const key of Object.keys(a)) if (!Object.prototype.hasOwnProperty.call(b, key)) set_own_key(diff.removed, key, a[key]);
6065
+ else if (!flat_value_equal(a[key], b[key])) set_own_key(diff.changed, key, {
6054
6066
  from: a[key],
6055
6067
  to: b[key]
6056
- };
6057
- for (const key of Object.keys(b)) if (!Object.prototype.hasOwnProperty.call(a, key)) diff.added[key] = b[key];
6068
+ });
6069
+ for (const key of Object.keys(b)) if (!Object.prototype.hasOwnProperty.call(a, key)) set_own_key(diff.added, key, b[key]);
6058
6070
  return diff;
6059
6071
  }
6060
6072
  /************************************************************
@@ -6068,11 +6080,11 @@ var gobjJs = (function(exports) {
6068
6080
  if (flat === null || typeof flat !== "object" || Array.isArray(flat)) throw new Error("flat_apply: a flat json is an object of id -> value");
6069
6081
  if (diff === null || typeof diff !== "object") throw new Error("flat_apply: a diff is the object flat_diff() answers");
6070
6082
  for (const key of Object.keys(diff.removed || {})) delete flat[key];
6071
- for (const key of Object.keys(diff.added || {})) flat[key] = diff.added[key];
6083
+ for (const key of Object.keys(diff.added || {})) set_own_key(flat, key, diff.added[key]);
6072
6084
  for (const key of Object.keys(diff.changed || {})) {
6073
6085
  const change = diff.changed[key];
6074
6086
  if (!change || !Object.prototype.hasOwnProperty.call(change, "to")) throw new Error(`flat_apply: changed '${key}' without a 'to'`);
6075
- flat[key] = change.to;
6087
+ set_own_key(flat, key, change.to);
6076
6088
  }
6077
6089
  return flat;
6078
6090
  }
@@ -7162,7 +7174,7 @@ var gobjJs = (function(exports) {
7162
7174
  window.console.error(`Not in session`);
7163
7175
  return -1;
7164
7176
  }
7165
- kw = Object.assign({}, is_object(kw) ? kw : {});
7177
+ kw = json_object_update({}, is_object(kw) ? kw : {});
7166
7178
  if (is_object(kw["__md_iev__"])) kw["__md_iev__"] = json_deep_copy(kw["__md_iev__"]);
7167
7179
  if (msg_iev_get_stack(gobj, kw, IEVENT_STACK_ID)) {} else {
7168
7180
  let jn_ievent_id = build_cli_ievent_request(gobj, gobj_name(src), kw_get_str(gobj, kw, "__service__", 0, 0));
@@ -7214,18 +7226,25 @@ var gobjJs = (function(exports) {
7214
7226
  if (gobj.priv.websocket) log_error(`Websocket ALREADY setup`);
7215
7227
  const url = gobj_read_str_attr(gobj, "url");
7216
7228
  log_debug(`====> Starting WebSocket to '${url}' (${gobj_short_name(gobj)})`);
7229
+ const ws_seq = ++gobj.priv.ws_seq;
7217
7230
  let websocket;
7218
7231
  try {
7219
7232
  websocket = new WebSocket(url);
7220
7233
  } catch (e) {
7221
7234
  log_error(`${gobj_short_name(gobj)}: Cannot open WebSocket to '${url}', Error: ${e.message}`);
7235
+ gobj_post_event(gobj, "EV_ON_CLOSE", {
7236
+ url,
7237
+ ws_seq,
7238
+ code: 1006,
7239
+ reason: e.message,
7240
+ was_clean: false
7241
+ }, gobj);
7222
7242
  return null;
7223
7243
  }
7224
7244
  if (!websocket) {
7225
7245
  log_error(`${gobj_short_name(gobj)}: Failed to initialize WebSocket.`);
7226
7246
  return null;
7227
7247
  }
7228
- const ws_seq = ++gobj.priv.ws_seq;
7229
7248
  websocket.onopen = () => {
7230
7249
  if (ws_seq !== gobj.priv.ws_seq || gobj_is_destroying(gobj)) return;
7231
7250
  gobj_send_event(gobj, "EV_ON_OPEN", {
@@ -7478,6 +7497,7 @@ var gobjJs = (function(exports) {
7478
7497
  function ac_on_close(gobj, event, kw, src) {
7479
7498
  let priv = gobj.priv;
7480
7499
  let url = kw.url;
7500
+ if (kw.ws_seq !== void 0 && kw.ws_seq !== priv.ws_seq) return 0;
7481
7501
  set_remote_log_functions();
7482
7502
  log_warning(`${gobj_short_name(gobj)}: WebSocket closed ${url} (Code: ${kw.code}, Reason: "${kw.reason}", Clean: ${kw.was_clean})`);
7483
7503
  if (priv.websocket) {
@@ -7495,7 +7515,7 @@ var gobjJs = (function(exports) {
7495
7515
  remote_yuno_role: priv.remote_yuno_role,
7496
7516
  remote_yuno_service: priv.remote_yuno_service
7497
7517
  });
7498
- } else {
7518
+ } else if (!gobj_is_running(gobj)) {} else {
7499
7519
  log_warning(`${gobj_short_name(gobj)}: EV_ON_OPEN_ERROR cannot open ${url} (Code: ${kw.code}, Reason: "${kw.reason}", Clean: ${kw.was_clean})`);
7500
7520
  gobj_publish_event(gobj, "EV_ON_OPEN_ERROR", {
7501
7521
  url,