mol_view_tree2_lib 1.0.136 → 1.0.137

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.
package/web.js CHANGED
@@ -187,6 +187,14 @@ var $;
187
187
  $.$mol_func_name_from = $mol_func_name_from;
188
188
  })($ || ($ = {}));
189
189
 
190
+ ;
191
+ "use strict";
192
+ var $;
193
+ (function ($) {
194
+ $.$mol_key_handle = Symbol.for('$mol_key_handle');
195
+ $.$mol_key_store = new WeakMap();
196
+ })($ || ($ = {}));
197
+
190
198
  ;
191
199
  "use strict";
192
200
  var $;
@@ -223,6 +231,9 @@ var $;
223
231
  static toJSON() {
224
232
  return this.toString();
225
233
  }
234
+ static [$mol_key_handle]() {
235
+ return this.toString();
236
+ }
226
237
  destructor() { }
227
238
  static destructor() { }
228
239
  [Symbol.dispose]() {
@@ -3056,46 +3067,50 @@ var $;
3056
3067
  "use strict";
3057
3068
  var $;
3058
3069
  (function ($) {
3059
- $.$mol_key_store = new WeakMap();
3060
3070
  const TypedArray = Object.getPrototypeOf(Uint8Array);
3061
3071
  function $mol_key(value) {
3062
- if (typeof value === 'bigint')
3063
- return value.toString() + 'n';
3064
- if (typeof value === 'symbol')
3065
- return value.description;
3066
- if (!value)
3067
- return JSON.stringify(value);
3068
- if (typeof value !== 'object' && typeof value !== 'function')
3069
- return JSON.stringify(value);
3070
- return JSON.stringify(value, (field, value) => {
3072
+ primitives: {
3071
3073
  if (typeof value === 'bigint')
3072
3074
  return value.toString() + 'n';
3073
3075
  if (typeof value === 'symbol')
3074
- return value.description;
3076
+ return `Symbol(${value.description})`;
3075
3077
  if (!value)
3076
- return value;
3078
+ return JSON.stringify(value);
3077
3079
  if (typeof value !== 'object' && typeof value !== 'function')
3078
- return value;
3080
+ return JSON.stringify(value);
3081
+ }
3082
+ caching: {
3083
+ let key = $mol_key_store.get(value);
3084
+ if (key)
3085
+ return key;
3086
+ }
3087
+ objects: {
3088
+ if (value instanceof TypedArray) {
3089
+ return `${value[Symbol.toStringTag]}([${[...value].map(v => $mol_key(v))}])`;
3090
+ }
3079
3091
  if (Array.isArray(value))
3080
- return value;
3081
- const proto = Reflect.getPrototypeOf(value);
3082
- if (!proto)
3083
- return value;
3084
- if (Reflect.getPrototypeOf(proto) === null)
3085
- return value;
3086
- if ('toJSON' in value)
3087
- return value;
3092
+ return `[${value.map(v => $mol_key(v))}]`;
3088
3093
  if (value instanceof RegExp)
3089
3094
  return value.toString();
3090
- if (value instanceof TypedArray)
3091
- return [...value];
3092
- let key = $.$mol_key_store.get(value);
3093
- if (key)
3094
- return key;
3095
- key = $mol_guid();
3096
- $.$mol_key_store.set(value, key);
3095
+ if (value instanceof Date)
3096
+ return `Date(${value.valueOf()})`;
3097
+ }
3098
+ structures: {
3099
+ const proto = Reflect.getPrototypeOf(value);
3100
+ if (!proto || !Reflect.getPrototypeOf(proto)) {
3101
+ return `{${Object.entries(value).map(([k, v]) => JSON.stringify(k) + ':' + $mol_key(v))}}`;
3102
+ }
3103
+ }
3104
+ handlers: {
3105
+ if ($mol_key_handle in value) {
3106
+ return value[$mol_key_handle]();
3107
+ }
3108
+ }
3109
+ containers: {
3110
+ const key = JSON.stringify('#' + $mol_guid());
3111
+ $mol_key_store.set(value, key);
3097
3112
  return key;
3098
- });
3113
+ }
3099
3114
  }
3100
3115
  $.$mol_key = $mol_key;
3101
3116
  })($ || ($ = {}));
@@ -3615,8 +3630,15 @@ var $;
3615
3630
  (this.host ?? this.task)[this.field()] = null;
3616
3631
  }
3617
3632
  else {
3618
- ;
3619
- (this.host ?? this.task)[this.field()].delete($mol_key(this.args[0]));
3633
+ const key = $mol_key(this.args[0]);
3634
+ const map = (this.host ?? this.task)[this.field()];
3635
+ if (!map.has(key))
3636
+ this.$.$mol_log3_warn({
3637
+ place: this,
3638
+ message: 'Absent key on destruction',
3639
+ hint: 'Check for $mol_key(key) is not changed',
3640
+ });
3641
+ map.delete(key);
3620
3642
  }
3621
3643
  }
3622
3644
  put(next) {