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/node.d.ts +6 -1
- package/node.d.ts.map +1 -1
- package/node.deps.json +1 -1
- package/node.js +53 -31
- package/node.js.map +1 -1
- package/node.mjs +53 -31
- package/node.test.js +68 -40
- package/node.test.js.map +1 -1
- package/package.json +3 -2
- package/web.d.ts +6 -1
- package/web.d.ts.map +1 -1
- package/web.deps.json +1 -1
- package/web.js +53 -31
- package/web.js.map +1 -1
- package/web.mjs +53 -31
- package/web.test.js +15 -9
- package/web.test.js.map +1 -1
package/web.mjs
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
|
-
|
|
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
|
|
3091
|
-
return
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
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()]
|
|
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) {
|
package/web.test.js
CHANGED
|
@@ -3417,9 +3417,9 @@ var $;
|
|
|
3417
3417
|
$mol_assert_equal($mol_key({ foo: [false] }), '{"foo":[false]}');
|
|
3418
3418
|
},
|
|
3419
3419
|
'Uint8Array'() {
|
|
3420
|
-
$mol_assert_equal($mol_key(new Uint8Array([1, 2])), '[1,2]');
|
|
3421
|
-
$mol_assert_equal($mol_key([new Uint8Array([1, 2])]), '[[1,2]]');
|
|
3422
|
-
$mol_assert_equal($mol_key({ foo: new Uint8Array([1, 2]) }), '{"foo":[1,2]}');
|
|
3420
|
+
$mol_assert_equal($mol_key(new Uint8Array([1, 2])), 'Uint8Array([1,2])');
|
|
3421
|
+
$mol_assert_equal($mol_key([new Uint8Array([1, 2])]), '[Uint8Array([1,2])]');
|
|
3422
|
+
$mol_assert_equal($mol_key({ foo: new Uint8Array([1, 2]) }), '{"foo":Uint8Array([1,2])}');
|
|
3423
3423
|
},
|
|
3424
3424
|
'Function'() {
|
|
3425
3425
|
const func = () => { };
|
|
@@ -3439,6 +3439,12 @@ var $;
|
|
|
3439
3439
|
$mol_assert_unique($mol_key(foo), $mol_key($mol_jsx("div", null, "bar")));
|
|
3440
3440
|
},
|
|
3441
3441
|
'Custom JSON representation'() {
|
|
3442
|
+
class User {
|
|
3443
|
+
toJSON() { return 'jin'; }
|
|
3444
|
+
}
|
|
3445
|
+
$mol_assert_unique([$mol_key(new User)], [$mol_key(new User)]);
|
|
3446
|
+
},
|
|
3447
|
+
'Custom key handler'() {
|
|
3442
3448
|
class User {
|
|
3443
3449
|
name;
|
|
3444
3450
|
age;
|
|
@@ -3446,15 +3452,15 @@ var $;
|
|
|
3446
3452
|
this.name = name;
|
|
3447
3453
|
this.age = age;
|
|
3448
3454
|
}
|
|
3449
|
-
|
|
3455
|
+
[$mol_key_handle]() { return `User(${JSON.stringify(this.name)})`; }
|
|
3450
3456
|
}
|
|
3451
|
-
$mol_assert_equal($mol_key(new User('jin', 18)), '
|
|
3457
|
+
$mol_assert_equal($mol_key([new User('jin', 16)]), $mol_key([new User('jin', 18)]), '[User("jin")]');
|
|
3452
3458
|
},
|
|
3453
3459
|
'Special native classes'() {
|
|
3454
|
-
$mol_assert_equal($mol_key(new Date('xyz')), '
|
|
3455
|
-
$mol_assert_equal($mol_key(new Date(
|
|
3456
|
-
$mol_assert_equal($mol_key(/./), '
|
|
3457
|
-
$mol_assert_equal($mol_key(/\./gimsu), '
|
|
3460
|
+
$mol_assert_equal($mol_key(new Date('xyz')), 'Date(NaN)');
|
|
3461
|
+
$mol_assert_equal($mol_key(new Date(12345)), 'Date(12345)');
|
|
3462
|
+
$mol_assert_equal($mol_key(/./), '/./');
|
|
3463
|
+
$mol_assert_equal($mol_key(/\./gimsu), '/\\./gimsu');
|
|
3458
3464
|
},
|
|
3459
3465
|
});
|
|
3460
3466
|
})($ || ($ = {}));
|